diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2015-10-01 12:26:59 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2015-10-02 12:45:47 +0200 |
commit | eeafccb3a65498e83071e71d5954bf4a856a1caa (patch) | |
tree | fa02571e524e7750b2f1d6d505e71608e271d6c5 /apps/files_sharing/js | |
parent | 4fb2ef3bacf2ae8eeac0b5bebecd98b90cca5511 (diff) | |
download | nextcloud-server-eeafccb3a65498e83071e71d5954bf4a856a1caa.tar.gz nextcloud-server-eeafccb3a65498e83071e71d5954bf4a856a1caa.zip |
Start to show remote shares in shared with you section
Diffstat (limited to 'apps/files_sharing/js')
-rw-r--r-- | apps/files_sharing/js/sharedfilelist.js | 65 |
1 files changed, 59 insertions, 6 deletions
diff --git a/apps/files_sharing/js/sharedfilelist.js b/apps/files_sharing/js/sharedfilelist.js index 98dbd4c6702..7912944ac18 100644 --- a/apps/files_sharing/js/sharedfilelist.js +++ b/apps/files_sharing/js/sharedfilelist.js @@ -122,7 +122,9 @@ if (this._reloadCall) { this._reloadCall.abort(); } - this._reloadCall = $.ajax({ + + var promises = []; + var shares = $.ajax({ url: OC.linkToOCS('apps/files_sharing/api/v1') + 'shares', /* jshint camelcase: false */ data: { @@ -132,25 +134,76 @@ type: 'GET', beforeSend: function(xhr) { xhr.setRequestHeader('OCS-APIREQUEST', 'true'); - } + }, }); + promises.push(shares); + + if (!!this._sharedWithUser) { + var remoteShares = $.ajax({ + url: OC.linkToOCS('apps/files_sharing/api/v1') + 'remote_shares', + /* jshint camelcase: false */ + data: { + format: 'json' + }, + type: 'GET', + beforeSend: function(xhr) { + xhr.setRequestHeader('OCS-APIREQUEST', 'true'); + }, + }); + promises.push(remoteShares); + } + + this._reloadCall = $.when.apply($, promises); var callBack = this.reloadCallback.bind(this); return this._reloadCall.then(callBack, callBack); }, - reloadCallback: function(result) { + reloadCallback: function(shares, remoteShares) { delete this._reloadCall; this.hideMask(); this.$el.find('#headerSharedWith').text( t('files_sharing', this._sharedWithUser ? 'Shared by' : 'Shared with') ); - if (result.ocs && result.ocs.data) { - this.setFiles(this._makeFilesFromShares(result.ocs.data)); + + var files = []; + + if (shares[0].ocs && shares[0].ocs.data) { + files = files.concat(this._makeFilesFromShares(shares[0].ocs.data)); + } else { + // TODO: error handling } - else { + + if (remoteShares[0].ocs && remoteShares[0].ocs.data) { + files = files.concat(this._makeFilesFromRemoteShares(remoteShares[0].ocs.data)); + } else { // TODO: error handling } + + this.setFiles(files); + }, + + _makeFilesFromRemoteShares: function(data) { + var self = this; + var files = data; + + files = _.chain(files) + // convert share data to file data + .map(function(share) { + var file = { + shareOwner: share.owner + '@' + share.remote, + name: share.name + }; + + file.shares = [{ + id: share.id, + type: OC.Share.SHARE_TYPE_REMOTE, + target: share.mountpoint + }]; + return file; + }) + .value(); + return files; }, /** |