summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2018-07-13 11:45:50 +0200
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2018-07-13 12:24:12 +0200
commit34368cc031a069cf16dfd770d59b8f4912c2ba68 (patch)
treeb2822d035c54dbefc81b5dba7ab7a6059791944d /apps/files_sharing
parente1a2bb9d69bf1aeba6362672c6b161bb96ad8a48 (diff)
downloadnextcloud-server-34368cc031a069cf16dfd770d59b8f4912c2ba68.tar.gz
nextcloud-server-34368cc031a069cf16dfd770d59b8f4912c2ba68.zip
Fixed sharing coding style and display - Added all shares overview
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> Fixed if condition Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/files_sharing')
-rw-r--r--apps/files_sharing/js/sharedfilelist.js183
1 files changed, 71 insertions, 112 deletions
diff --git a/apps/files_sharing/js/sharedfilelist.js b/apps/files_sharing/js/sharedfilelist.js
index e89a061e992..914bfd6ae15 100644
--- a/apps/files_sharing/js/sharedfilelist.js
+++ b/apps/files_sharing/js/sharedfilelist.js
@@ -195,120 +195,70 @@
// there is only root
this._setCurrentDir('/', false);
- if (!this._isOverview) {
- if (this._showDeleted) {
- var shares = $.ajax({
- url: OC.linkToOCS('apps/files_sharing/api/v1', 2) + 'deletedshares',
- /* jshint camelcase: false */
- data: {
- format: 'json',
- include_tags: true
- },
- type: 'GET',
- beforeSend: function (xhr) {
- xhr.setRequestHeader('OCS-APIREQUEST', 'true');
- },
- });
- } else {
- var shares = $.ajax({
- url: OC.linkToOCS('apps/files_sharing/api/v1') + 'shares',
- /* jshint camelcase: false */
- data: {
- format: 'json',
- shared_with_me: !!this._sharedWithUser,
- include_tags: true
- },
- type: 'GET',
- beforeSend: function (xhr) {
- xhr.setRequestHeader('OCS-APIREQUEST', 'true');
- },
- });
- }
- var promises = [];
- 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',
- include_tags: true
- },
- type: 'GET',
- beforeSend: function (xhr) {
- xhr.setRequestHeader('OCS-APIREQUEST', 'true');
- },
- });
- promises.push(remoteShares);
- } else {
- //Push empty promise so callback gets called the same way
- promises.push($.Deferred().resolve());
- }
-
- this._reloadCall = $.when.apply($, promises);
- var callBack = this.reloadCallback.bind(this);
- return this._reloadCall.then(callBack, callBack);
+ var promises = [];
+
+ var deletedShares = {
+ url: OC.linkToOCS('apps/files_sharing/api/v1', 2) + 'deletedshares',
+ /* jshint camelcase: false */
+ data: {
+ format: 'json',
+ include_tags: true
+ },
+ type: 'GET',
+ beforeSend: function (xhr) {
+ xhr.setRequestHeader('OCS-APIREQUEST', 'true');
+ },
+ };
+
+ var shares = {
+ url: OC.linkToOCS('apps/files_sharing/api/v1') + 'shares',
+ /* jshint camelcase: false */
+ data: {
+ format: 'json',
+ shared_with_me: this._sharedWithUser !== false,
+ include_tags: true
+ },
+ type: 'GET',
+ beforeSend: function (xhr) {
+ xhr.setRequestHeader('OCS-APIREQUEST', 'true');
+ },
+ };
+
+ var remoteShares = {
+ url: OC.linkToOCS('apps/files_sharing/api/v1') + 'remote_shares',
+ /* jshint camelcase: false */
+ data: {
+ format: 'json',
+ include_tags: true
+ },
+ type: 'GET',
+ beforeSend: function (xhr) {
+ xhr.setRequestHeader('OCS-APIREQUEST', 'true');
+ },
+ };
+
+ // Add the proper ajax requests to the list and run them
+ // and make sure we have 2 promises
+ if (this._showDeleted) {
+ promises.push($.ajax(deletedShares));
} else {
- var promises = [];
- var sharedWith = $.ajax({
- url: OC.linkToOCS('apps/files_sharing/api/v1') + 'shares',
- /* jshint camelcase: false */
- data: {
- format: 'json',
- shared_with_me: true,
- include_tags: true
- },
- type: 'GET',
- beforeSend: function (xhr) {
- xhr.setRequestHeader('OCS-APIREQUEST', 'true');
- },
- });
- promises.push(sharedWith);
-
- var sharedBy = $.ajax({
- url: OC.linkToOCS('apps/files_sharing/api/v1') + 'shares',
- /* jshint camelcase: false */
- data: {
- format: 'json',
- shared_with_me: false,
- include_tags: true
- },
- type: 'GET',
- beforeSend: function (xhr) {
- xhr.setRequestHeader('OCS-APIREQUEST', 'true');
- },
- });
- promises.push(sharedBy);
-
- var remoteShares = $.ajax({
- url: OC.linkToOCS('apps/files_sharing/api/v1') + 'remote_shares',
- /* jshint camelcase: false */
- data: {
- format: 'json',
- include_tags: true
- },
- type: 'GET',
- beforeSend: function (xhr) {
- xhr.setRequestHeader('OCS-APIREQUEST', 'true');
- },
- });
- promises.push(remoteShares);
+ promises.push($.ajax(shares));
- this._reloadCall = $.when.apply($, promises);
- var callBack = this.reloadOverviewCallBack().bind(this);
- return this._reloadCall.then(callBack, callBack, callBack);
+ if (this._sharedWithUser !== false || this._isOverview) {
+ promises.push($.ajax(remoteShares));
+ }
+ if (this._isOverview) {
+ shares.data.shared_with_me = !shares.data.shared_with_me
+ promises.push($.ajax(shares));
+ }
}
- },
-
- reloadOverviewCallBack: function(sharedWith, sharedBy, remote) {
- delete this._reloadCall;
- this.hideMask();
- alert('foo');
+ this._reloadCall = $.when.apply($, promises);
+ var callBack = this.reloadCallback.bind(this);
+ return this._reloadCall.then(callBack, callBack);
},
- reloadCallback: function(shares, remoteShares) {
+ reloadCallback: function(shares, remoteShares, additionnalShares) {
delete this._reloadCall;
this.hideMask();
@@ -318,12 +268,21 @@
var files = [];
- if (shares[0].ocs && shares[0].ocs.data) {
- files = files.concat(this._makeFilesFromShares(shares[0].ocs.data));
+ // make sure to use the same format
+ if(shares[0] && shares[0].ocs) {
+ shares = shares[0];
+ }
+
+ if (shares.ocs && shares.ocs.data) {
+ files = files.concat(this._makeFilesFromShares(shares.ocs.data));
+ }
+
+ if (remoteShares && remoteShares.ocs && remoteShares.ocs.data) {
+ files = files.concat(this._makeFilesFromRemoteShares(remoteShares.ocs.data));
}
- if (remoteShares && remoteShares[0].ocs && remoteShares[0].ocs.data) {
- files = files.concat(this._makeFilesFromRemoteShares(remoteShares[0].ocs.data));
+ if (additionnalShares && additionnalShares[0] && additionnalShares[0].ocs && additionnalShares[0].ocs.data) {
+ files = files.concat(this._makeFilesFromShares(additionnalShares[0].ocs.data));
}
this.setFiles(files);