2014-04-30 15:42:35 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2014 Vincent Petry <pvince81@owncloud.com>
|
|
|
|
*
|
|
|
|
* This file is licensed under the Affero General Public License version 3
|
|
|
|
* or later.
|
|
|
|
*
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
(function() {
|
|
|
|
|
|
|
|
/**
|
2014-06-23 21:56:10 +00:00
|
|
|
* @class OCA.Sharing.FileList
|
|
|
|
* @augments OCA.Files.FileList
|
2014-04-30 15:42:35 +00:00
|
|
|
*
|
2014-06-23 21:56:10 +00:00
|
|
|
* @classdesc Sharing file list.
|
2014-04-30 15:42:35 +00:00
|
|
|
* Contains both "shared with others" and "shared with you" modes.
|
2014-06-23 21:56:10 +00:00
|
|
|
*
|
|
|
|
* @param $el container element with existing markup for the #controls
|
|
|
|
* and a table
|
|
|
|
* @param [options] map of options, see other parameters
|
|
|
|
* @param {boolean} [options.sharedWithUser] true to return files shared with
|
|
|
|
* the current user, false to return files that the user shared with others.
|
|
|
|
* Defaults to false.
|
|
|
|
* @param {boolean} [options.linksOnly] true to return only link shares
|
2014-04-30 15:42:35 +00:00
|
|
|
*/
|
|
|
|
var FileList = function($el, options) {
|
|
|
|
this.initialize($el, options);
|
|
|
|
};
|
2014-06-23 21:56:10 +00:00
|
|
|
FileList.prototype = _.extend({}, OCA.Files.FileList.prototype,
|
|
|
|
/** @lends OCA.Sharing.FileList.prototype */ {
|
2014-04-30 15:42:35 +00:00
|
|
|
appName: 'Shares',
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether the list shows the files shared with the user (true) or
|
|
|
|
* the files that the user shared with others (false).
|
|
|
|
*/
|
|
|
|
_sharedWithUser: false,
|
2014-06-04 09:10:11 +00:00
|
|
|
_linksOnly: false,
|
2014-08-15 14:52:41 +00:00
|
|
|
_clientSideSort: true,
|
2014-12-11 16:36:14 +00:00
|
|
|
_allowSelection: false,
|
2014-08-15 14:52:41 +00:00
|
|
|
|
2014-06-23 21:56:10 +00:00
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
*/
|
2014-04-30 15:42:35 +00:00
|
|
|
initialize: function($el, options) {
|
|
|
|
OCA.Files.FileList.prototype.initialize.apply(this, arguments);
|
|
|
|
if (this.initialized) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-06-04 09:10:11 +00:00
|
|
|
// TODO: consolidate both options
|
2014-04-30 15:42:35 +00:00
|
|
|
if (options && options.sharedWithUser) {
|
|
|
|
this._sharedWithUser = true;
|
|
|
|
}
|
2014-06-04 09:10:11 +00:00
|
|
|
if (options && options.linksOnly) {
|
|
|
|
this._linksOnly = true;
|
|
|
|
}
|
2014-04-30 15:42:35 +00:00
|
|
|
},
|
|
|
|
|
2014-06-03 09:04:57 +00:00
|
|
|
_renderRow: function() {
|
|
|
|
// HACK: needed to call the overridden _renderRow
|
|
|
|
// this is because at the time this class is created
|
|
|
|
// the overriding hasn't been done yet...
|
|
|
|
return OCA.Files.FileList.prototype._renderRow.apply(this, arguments);
|
|
|
|
},
|
|
|
|
|
2014-04-30 15:42:35 +00:00
|
|
|
_createRow: function(fileData) {
|
|
|
|
// TODO: hook earlier and render the whole row here
|
|
|
|
var $tr = OCA.Files.FileList.prototype._createRow.apply(this, arguments);
|
|
|
|
$tr.find('.filesize').remove();
|
2014-05-28 14:53:42 +00:00
|
|
|
$tr.find('td.date').before($tr.children('td:first'));
|
2014-04-30 15:42:35 +00:00
|
|
|
$tr.find('td.filename input:checkbox').remove();
|
2014-05-19 13:20:44 +00:00
|
|
|
$tr.attr('data-share-id', _.pluck(fileData.shares, 'id').join(','));
|
2014-05-26 10:59:44 +00:00
|
|
|
if (this._sharedWithUser) {
|
2014-06-02 16:52:31 +00:00
|
|
|
$tr.attr('data-share-owner', fileData.shareOwner);
|
2014-07-28 20:04:13 +00:00
|
|
|
$tr.attr('data-mounttype', 'shared-root');
|
|
|
|
var permission = parseInt($tr.attr('data-permissions')) | OC.PERMISSION_DELETE;
|
|
|
|
$tr.attr('data-permissions', permission);
|
2014-05-26 10:59:44 +00:00
|
|
|
}
|
2015-09-30 16:20:55 +00:00
|
|
|
|
|
|
|
// add row with expiration date for link only shares - influenced by _createRow of filelist
|
|
|
|
if (this._linksOnly) {
|
2016-03-16 17:28:45 +00:00
|
|
|
var expirationTimestamp = 0;
|
2016-11-10 08:13:25 +00:00
|
|
|
if(fileData.shares && fileData.shares[0].expiration !== null) {
|
2016-03-16 17:28:45 +00:00
|
|
|
expirationTimestamp = moment(fileData.shares[0].expiration).valueOf();
|
|
|
|
}
|
2015-09-30 16:20:55 +00:00
|
|
|
$tr.attr('data-expiration', expirationTimestamp);
|
|
|
|
|
|
|
|
// date column (1000 milliseconds to seconds, 60 seconds, 60 minutes, 24 hours)
|
|
|
|
// difference in days multiplied by 5 - brightest shade for expiry dates in more than 32 days (160/5)
|
|
|
|
var modifiedColor = Math.round((expirationTimestamp - (new Date()).getTime()) / 1000 / 60 / 60 / 24 * 5);
|
|
|
|
// ensure that the brightest color is still readable
|
2015-10-02 06:45:07 +00:00
|
|
|
if (modifiedColor >= 160) {
|
2015-09-30 16:20:55 +00:00
|
|
|
modifiedColor = 160;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (expirationTimestamp > 0) {
|
|
|
|
formatted = OC.Util.formatDate(expirationTimestamp);
|
|
|
|
text = OC.Util.relativeModifiedDate(expirationTimestamp);
|
|
|
|
} else {
|
|
|
|
formatted = t('files_sharing', 'No expiration date set');
|
2016-07-07 07:54:32 +00:00
|
|
|
text = '';
|
2015-10-02 06:45:07 +00:00
|
|
|
modifiedColor = 160;
|
2015-09-30 16:20:55 +00:00
|
|
|
}
|
|
|
|
td = $('<td></td>').attr({"class": "date"});
|
|
|
|
td.append($('<span></span>').attr({
|
|
|
|
"class": "modified",
|
|
|
|
"title": formatted,
|
|
|
|
"style": 'color:rgb(' + modifiedColor + ',' + modifiedColor + ',' + modifiedColor + ')'
|
|
|
|
}).text(text)
|
|
|
|
.tooltip({placement: 'top'})
|
|
|
|
);
|
|
|
|
|
|
|
|
$tr.append(td);
|
|
|
|
}
|
2014-04-30 15:42:35 +00:00
|
|
|
return $tr;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set whether the list should contain outgoing shares
|
|
|
|
* or incoming shares.
|
|
|
|
*
|
|
|
|
* @param state true for incoming shares, false otherwise
|
|
|
|
*/
|
|
|
|
setSharedWithUser: function(state) {
|
|
|
|
this._sharedWithUser = !!state;
|
|
|
|
},
|
|
|
|
|
2014-05-19 13:20:44 +00:00
|
|
|
updateEmptyContent: function() {
|
|
|
|
var dir = this.getCurrentDirectory();
|
|
|
|
if (dir === '/') {
|
|
|
|
// root has special permissions
|
|
|
|
this.$el.find('#emptycontent').toggleClass('hidden', !this.isEmpty);
|
|
|
|
this.$el.find('#filestable thead th').toggleClass('hidden', this.isEmpty);
|
2016-04-01 07:07:04 +00:00
|
|
|
|
|
|
|
// hide expiration date header for non link only shares
|
|
|
|
if (!this._linksOnly) {
|
|
|
|
this.$el.find('th.column-expiration').addClass('hidden');
|
|
|
|
}
|
2014-05-19 13:20:44 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
OCA.Files.FileList.prototype.updateEmptyContent.apply(this, arguments);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
getDirectoryPermissions: function() {
|
2015-10-29 16:56:54 +00:00
|
|
|
return OC.PERMISSION_READ | OC.PERMISSION_DELETE;
|
2014-05-21 10:54:34 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
updateStorageStatistics: function() {
|
|
|
|
// no op because it doesn't have
|
|
|
|
// storage info like free space / used space
|
2014-05-19 13:20:44 +00:00
|
|
|
},
|
|
|
|
|
2017-11-23 16:51:56 +00:00
|
|
|
updateRow: function($tr, fileInfo, options) {
|
|
|
|
if(!fileInfo instanceof OCA.Sharing.SharedFileInfo) {
|
|
|
|
// recycle SharedFileInfo values if something tries to overwrite it
|
|
|
|
var oldModel = this.getModelForFile($tr);
|
|
|
|
|
|
|
|
if(_.isUndefined(fileInfo.recipientData) && oldModel.recipientData) {
|
|
|
|
fileInfo.recipientData = oldModel.recipientData;
|
|
|
|
}
|
|
|
|
if(_.isUndefined(fileInfo.recipients) && oldModel.recipientData) {
|
|
|
|
fileInfo.recipientData = oldModel.recipientData;
|
|
|
|
}
|
|
|
|
if(_.isUndefined(fileInfo.shares) && oldModel.shares) {
|
|
|
|
fileInfo.shares = oldModel.shares;
|
|
|
|
}
|
|
|
|
if(_.isUndefined(fileInfo.shareOwner) && oldModel.shareOwner) {
|
|
|
|
fileInfo.shareOwner = oldModel.shareOwner;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
OCA.Files.FileList.prototype._createRow.updateRow(this, arguments);
|
|
|
|
},
|
|
|
|
|
2014-04-30 15:42:35 +00:00
|
|
|
reload: function() {
|
|
|
|
this.showMask();
|
|
|
|
if (this._reloadCall) {
|
|
|
|
this._reloadCall.abort();
|
|
|
|
}
|
2015-10-01 10:26:59 +00:00
|
|
|
|
2015-10-27 10:51:54 +00:00
|
|
|
// there is only root
|
|
|
|
this._setCurrentDir('/', false);
|
|
|
|
|
2015-10-01 10:26:59 +00:00
|
|
|
var promises = [];
|
|
|
|
var shares = $.ajax({
|
2014-04-30 15:42:35 +00:00
|
|
|
url: OC.linkToOCS('apps/files_sharing/api/v1') + 'shares',
|
|
|
|
/* jshint camelcase: false */
|
|
|
|
data: {
|
|
|
|
format: 'json',
|
2016-11-10 08:13:25 +00:00
|
|
|
shared_with_me: !!this._sharedWithUser,
|
|
|
|
include_tags: true
|
2014-04-30 15:42:35 +00:00
|
|
|
},
|
|
|
|
type: 'GET',
|
|
|
|
beforeSend: function(xhr) {
|
|
|
|
xhr.setRequestHeader('OCS-APIREQUEST', 'true');
|
2015-10-01 10:26:59 +00:00
|
|
|
},
|
2014-04-30 15:42:35 +00:00
|
|
|
});
|
2015-10-01 10:26:59 +00:00
|
|
|
promises.push(shares);
|
|
|
|
|
|
|
|
if (!!this._sharedWithUser) {
|
|
|
|
var remoteShares = $.ajax({
|
|
|
|
url: OC.linkToOCS('apps/files_sharing/api/v1') + 'remote_shares',
|
|
|
|
/* jshint camelcase: false */
|
|
|
|
data: {
|
2016-11-10 08:13:25 +00:00
|
|
|
format: 'json',
|
|
|
|
include_tags: true
|
2015-10-01 10:26:59 +00:00
|
|
|
},
|
|
|
|
type: 'GET',
|
|
|
|
beforeSend: function(xhr) {
|
|
|
|
xhr.setRequestHeader('OCS-APIREQUEST', 'true');
|
|
|
|
},
|
|
|
|
});
|
|
|
|
promises.push(remoteShares);
|
2015-10-01 15:20:47 +00:00
|
|
|
} else {
|
|
|
|
//Push empty promise so callback gets called the same way
|
|
|
|
promises.push($.Deferred().resolve());
|
2015-10-01 10:26:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this._reloadCall = $.when.apply($, promises);
|
2014-07-04 09:45:36 +00:00
|
|
|
var callBack = this.reloadCallback.bind(this);
|
|
|
|
return this._reloadCall.then(callBack, callBack);
|
2014-04-30 15:42:35 +00:00
|
|
|
},
|
|
|
|
|
2015-10-01 10:26:59 +00:00
|
|
|
reloadCallback: function(shares, remoteShares) {
|
2014-04-30 15:42:35 +00:00
|
|
|
delete this._reloadCall;
|
|
|
|
this.hideMask();
|
|
|
|
|
|
|
|
this.$el.find('#headerSharedWith').text(
|
|
|
|
t('files_sharing', this._sharedWithUser ? 'Shared by' : 'Shared with')
|
|
|
|
);
|
2015-10-01 10:26:59 +00:00
|
|
|
|
|
|
|
var files = [];
|
|
|
|
|
|
|
|
if (shares[0].ocs && shares[0].ocs.data) {
|
|
|
|
files = files.concat(this._makeFilesFromShares(shares[0].ocs.data));
|
2014-04-30 15:42:35 +00:00
|
|
|
}
|
2015-10-01 10:26:59 +00:00
|
|
|
|
2015-10-01 15:20:47 +00:00
|
|
|
if (remoteShares && remoteShares[0].ocs && remoteShares[0].ocs.data) {
|
2015-10-01 10:26:59 +00:00
|
|
|
files = files.concat(this._makeFilesFromRemoteShares(remoteShares[0].ocs.data));
|
2014-04-30 15:42:35 +00:00
|
|
|
}
|
2015-10-01 10:26:59 +00:00
|
|
|
|
|
|
|
this.setFiles(files);
|
2015-10-27 10:51:54 +00:00
|
|
|
return true;
|
2015-10-01 10:26:59 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
_makeFilesFromRemoteShares: function(data) {
|
|
|
|
var files = data;
|
|
|
|
|
|
|
|
files = _.chain(files)
|
|
|
|
// convert share data to file data
|
|
|
|
.map(function(share) {
|
|
|
|
var file = {
|
2015-10-01 14:04:22 +00:00
|
|
|
shareOwner: share.owner + '@' + share.remote.replace(/.*?:\/\//g, ""),
|
|
|
|
name: OC.basename(share.mountpoint),
|
2015-10-01 15:20:47 +00:00
|
|
|
mtime: share.mtime * 1000,
|
2015-10-01 14:04:22 +00:00
|
|
|
mimetype: share.mimetype,
|
|
|
|
type: share.type,
|
|
|
|
id: share.file_id,
|
2015-10-01 15:20:47 +00:00
|
|
|
path: OC.dirname(share.mountpoint),
|
2016-11-10 08:13:25 +00:00
|
|
|
permissions: share.permissions,
|
|
|
|
tags: share.tags || []
|
2015-10-01 10:26:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
file.shares = [{
|
|
|
|
id: share.id,
|
2015-10-01 14:04:22 +00:00
|
|
|
type: OC.Share.SHARE_TYPE_REMOTE
|
2015-10-01 10:26:59 +00:00
|
|
|
}];
|
|
|
|
return file;
|
|
|
|
})
|
|
|
|
.value();
|
|
|
|
return files;
|
2014-04-30 15:42:35 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts the OCS API share response data to a file info
|
|
|
|
* list
|
2014-06-23 21:56:10 +00:00
|
|
|
* @param {Array} data OCS API share array
|
|
|
|
* @return {Array.<OCA.Sharing.SharedFileInfo>} array of shared file info
|
2014-04-30 15:42:35 +00:00
|
|
|
*/
|
|
|
|
_makeFilesFromShares: function(data) {
|
2014-06-04 09:10:11 +00:00
|
|
|
/* jshint camelcase: false */
|
2014-04-30 15:42:35 +00:00
|
|
|
var self = this;
|
2014-06-04 09:10:11 +00:00
|
|
|
var files = data;
|
|
|
|
|
|
|
|
if (this._linksOnly) {
|
|
|
|
files = _.filter(data, function(share) {
|
|
|
|
return share.share_type === OC.Share.SHARE_TYPE_LINK;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-04-30 15:42:35 +00:00
|
|
|
// OCS API uses non-camelcased names
|
2014-06-04 09:10:11 +00:00
|
|
|
files = _.chain(files)
|
2014-05-21 10:54:34 +00:00
|
|
|
// convert share data to file data
|
2014-05-15 17:51:15 +00:00
|
|
|
.map(function(share) {
|
2015-07-13 15:38:13 +00:00
|
|
|
// TODO: use OC.Files.FileInfo
|
2014-05-15 17:51:15 +00:00
|
|
|
var file = {
|
|
|
|
id: share.file_source,
|
2015-07-02 14:59:59 +00:00
|
|
|
icon: OC.MimeType.getIconUrl(share.mimetype),
|
2016-11-10 08:13:25 +00:00
|
|
|
mimetype: share.mimetype,
|
|
|
|
tags: share.tags || []
|
2014-05-15 17:51:15 +00:00
|
|
|
};
|
|
|
|
if (share.item_type === 'folder') {
|
|
|
|
file.type = 'dir';
|
2014-05-21 10:54:34 +00:00
|
|
|
file.mimetype = 'httpd/unix-directory';
|
2014-05-15 17:51:15 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
file.type = 'file';
|
|
|
|
}
|
|
|
|
file.share = {
|
|
|
|
id: share.id,
|
|
|
|
type: share.share_type,
|
2014-05-21 10:54:34 +00:00
|
|
|
target: share.share_with,
|
|
|
|
stime: share.stime * 1000,
|
2015-09-30 16:20:55 +00:00
|
|
|
expiration: share.expiration,
|
2014-05-15 17:51:15 +00:00
|
|
|
};
|
|
|
|
if (self._sharedWithUser) {
|
2014-06-02 16:52:31 +00:00
|
|
|
file.shareOwner = share.displayname_owner;
|
2017-11-19 15:38:04 +00:00
|
|
|
file.shareOwnerId = share.uid_owner;
|
2014-05-15 17:51:15 +00:00
|
|
|
file.name = OC.basename(share.file_target);
|
|
|
|
file.path = OC.dirname(share.file_target);
|
2014-05-19 16:33:43 +00:00
|
|
|
file.permissions = share.permissions;
|
2014-08-27 09:28:31 +00:00
|
|
|
if (file.path) {
|
|
|
|
file.extraData = share.file_target;
|
|
|
|
}
|
2014-05-15 17:51:15 +00:00
|
|
|
}
|
|
|
|
else {
|
2014-07-07 14:33:23 +00:00
|
|
|
if (share.share_type !== OC.Share.SHARE_TYPE_LINK) {
|
|
|
|
file.share.targetDisplayName = share.share_with_displayname;
|
2017-11-19 15:37:37 +00:00
|
|
|
file.share.targetShareWithId = share.share_with;
|
2014-07-07 14:33:23 +00:00
|
|
|
}
|
2014-05-15 17:51:15 +00:00
|
|
|
file.name = OC.basename(share.path);
|
|
|
|
file.path = OC.dirname(share.path);
|
2015-10-29 16:56:54 +00:00
|
|
|
file.permissions = OC.PERMISSION_ALL;
|
2014-08-27 09:28:31 +00:00
|
|
|
if (file.path) {
|
|
|
|
file.extraData = share.path;
|
|
|
|
}
|
2014-05-15 17:51:15 +00:00
|
|
|
}
|
|
|
|
return file;
|
|
|
|
})
|
|
|
|
// Group all files and have a "shares" array with
|
|
|
|
// the share info for each file.
|
|
|
|
//
|
|
|
|
// This uses a hash memo to cumulate share information
|
|
|
|
// inside the same file object (by file id).
|
|
|
|
.reduce(function(memo, file) {
|
|
|
|
var data = memo[file.id];
|
2014-05-28 16:39:29 +00:00
|
|
|
var recipient = file.share.targetDisplayName;
|
2017-11-19 15:37:37 +00:00
|
|
|
var recipientId = file.share.targetShareWithId;
|
2014-05-15 17:51:15 +00:00
|
|
|
if (!data) {
|
|
|
|
data = memo[file.id] = file;
|
|
|
|
data.shares = [file.share];
|
2014-05-21 10:54:34 +00:00
|
|
|
// using a hash to make them unique,
|
|
|
|
// this is only a list to be displayed
|
2014-05-28 16:39:29 +00:00
|
|
|
data.recipients = {};
|
2017-11-19 15:37:37 +00:00
|
|
|
data.recipientData = {};
|
2016-03-02 17:25:31 +00:00
|
|
|
// share types
|
|
|
|
data.shareTypes = {};
|
2014-05-21 10:54:34 +00:00
|
|
|
// counter is cheaper than calling _.keys().length
|
2014-05-28 16:39:29 +00:00
|
|
|
data.recipientsCount = 0;
|
2014-05-21 10:54:34 +00:00
|
|
|
data.mtime = file.share.stime;
|
2014-05-15 17:51:15 +00:00
|
|
|
}
|
|
|
|
else {
|
2014-05-21 10:54:34 +00:00
|
|
|
// always take the most recent stime
|
|
|
|
if (file.share.stime > data.mtime) {
|
|
|
|
data.mtime = file.share.stime;
|
|
|
|
}
|
2014-05-15 17:51:15 +00:00
|
|
|
data.shares.push(file.share);
|
|
|
|
}
|
2014-05-21 10:54:34 +00:00
|
|
|
|
2014-06-02 13:59:06 +00:00
|
|
|
if (recipient) {
|
2014-05-21 10:54:34 +00:00
|
|
|
// limit counterparts for output
|
2014-06-02 13:59:06 +00:00
|
|
|
if (data.recipientsCount < 4) {
|
2014-05-28 16:39:29 +00:00
|
|
|
// only store the first ones, they will be the only ones
|
|
|
|
// displayed
|
|
|
|
data.recipients[recipient] = true;
|
2017-11-21 10:29:42 +00:00
|
|
|
data.recipientData[data.recipientsCount] = {
|
|
|
|
'shareWith': recipientId,
|
|
|
|
'shareWithDisplayName': recipient
|
|
|
|
};
|
2014-05-28 16:39:29 +00:00
|
|
|
}
|
|
|
|
data.recipientsCount++;
|
2014-05-15 17:51:15 +00:00
|
|
|
}
|
2014-05-21 10:54:34 +00:00
|
|
|
|
2016-03-02 17:25:31 +00:00
|
|
|
data.shareTypes[file.share.type] = true;
|
|
|
|
|
2014-05-15 17:51:15 +00:00
|
|
|
delete file.share;
|
|
|
|
return memo;
|
|
|
|
}, {})
|
|
|
|
// Retrieve only the values of the returned hash
|
|
|
|
.values()
|
2014-05-21 10:54:34 +00:00
|
|
|
// Clean up
|
|
|
|
.each(function(data) {
|
2014-05-28 16:39:29 +00:00
|
|
|
// convert the recipients map to a flat
|
2014-05-21 10:54:34 +00:00
|
|
|
// array of sorted names
|
2014-07-10 15:25:46 +00:00
|
|
|
data.mountType = 'shared';
|
2014-05-28 16:39:29 +00:00
|
|
|
delete data.recipientsCount;
|
2016-03-02 17:25:31 +00:00
|
|
|
if (self._sharedWithUser) {
|
|
|
|
// only for outgoing shres
|
|
|
|
delete data.shareTypes;
|
|
|
|
} else {
|
|
|
|
data.shareTypes = _.keys(data.shareTypes);
|
|
|
|
}
|
2014-05-21 10:54:34 +00:00
|
|
|
})
|
2014-05-15 17:51:15 +00:00
|
|
|
// Finish the chain by getting the result
|
|
|
|
.value();
|
|
|
|
|
2014-07-07 14:49:32 +00:00
|
|
|
// Sort by expected sort comparator
|
|
|
|
return files.sort(this._sortComparator);
|
2017-04-11 07:33:27 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
_onUrlChanged: function(e) {
|
|
|
|
if (e && _.isString(e.dir)) {
|
|
|
|
this.changeDirectory(e.dir, false, true);
|
|
|
|
}
|
2014-04-30 15:42:35 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-06-23 21:56:10 +00:00
|
|
|
/**
|
|
|
|
* Share info attributes.
|
|
|
|
*
|
|
|
|
* @typedef {Object} OCA.Sharing.ShareInfo
|
|
|
|
*
|
|
|
|
* @property {int} id share ID
|
|
|
|
* @property {int} type share type
|
|
|
|
* @property {String} target share target, either user name or group name
|
|
|
|
* @property {int} stime share timestamp in milliseconds
|
|
|
|
* @property {String} [targetDisplayName] display name of the recipient
|
|
|
|
* (only when shared with others)
|
2017-11-21 11:45:57 +00:00
|
|
|
* @property {String} [targetShareWithId] id of the recipient
|
2014-06-23 21:56:10 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2017-11-21 11:45:57 +00:00
|
|
|
/**
|
|
|
|
* Recipient attributes
|
|
|
|
*
|
|
|
|
* @typedef {Object} OCA.Sharing.RecipientInfo
|
|
|
|
* @property {String} shareWith the id of the recipient
|
|
|
|
* @property {String} shareWithDisplayName the display name of the recipient
|
|
|
|
*/
|
|
|
|
|
2014-06-23 21:56:10 +00:00
|
|
|
/**
|
|
|
|
* Shared file info attributes.
|
|
|
|
*
|
|
|
|
* @typedef {OCA.Files.FileInfo} OCA.Sharing.SharedFileInfo
|
|
|
|
*
|
|
|
|
* @property {Array.<OCA.Sharing.ShareInfo>} shares array of shares for
|
|
|
|
* this file
|
|
|
|
* @property {int} mtime most recent share time (if multiple shares)
|
|
|
|
* @property {String} shareOwner name of the share owner
|
|
|
|
* @property {Array.<String>} recipients name of the first 4 recipients
|
|
|
|
* (this is mostly for display purposes)
|
2017-11-21 11:45:57 +00:00
|
|
|
* @property {Object.<OCA.Sharing.RecipientInfo>} recipientData (as object for easier
|
|
|
|
* passing to HTML data attributes with jQuery)
|
2014-06-23 21:56:10 +00:00
|
|
|
*/
|
|
|
|
|
2014-04-30 15:42:35 +00:00
|
|
|
OCA.Sharing.FileList = FileList;
|
|
|
|
})();
|