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