Browse Source

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>
tags/v14.0.0beta1
John Molakvoæ (skjnldsv) 6 years ago
parent
commit
34368cc031
No account linked to committer's email address
1 changed files with 71 additions and 112 deletions
  1. 71
    112
      apps/files_sharing/js/sharedfilelist.js

+ 71
- 112
apps/files_sharing/js/sharedfilelist.js View File

@@ -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);

Loading…
Cancel
Save