Fix external sharing loading script
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
parent
4fff033c12
commit
ab2b3d2755
3 changed files with 66 additions and 69 deletions
|
@ -23,22 +23,6 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use OCA\FederatedFileSharing\Notifier;
|
|
||||||
use OCA\FederatedFileSharing\AppInfo\Application;
|
use OCA\FederatedFileSharing\AppInfo\Application;
|
||||||
|
|
||||||
$app = \OC::$server->query(Application::class);
|
\OC::$server->query(Application::class);
|
||||||
$eventDispatcher = \OC::$server->getEventDispatcher();
|
|
||||||
|
|
||||||
$manager = \OC::$server->getNotificationManager();
|
|
||||||
$manager->registerNotifierService(Notifier::class);
|
|
||||||
|
|
||||||
$federatedShareProvider = $app->getFederatedShareProvider();
|
|
||||||
|
|
||||||
$eventDispatcher->addListener(
|
|
||||||
'OCA\Files::loadAdditionalScripts',
|
|
||||||
function() use ($federatedShareProvider) {
|
|
||||||
if ($federatedShareProvider->isIncomingServer2serverShareEnabled()) {
|
|
||||||
\OCP\Util::addScript('federatedfilesharing', 'external');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/**
|
||||||
* Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
|
* Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
|
||||||
*
|
*
|
||||||
* This file is licensed under the Affero General Public License version 3
|
* This file is licensed under the Affero General Public License version 3
|
||||||
|
@ -7,17 +7,22 @@
|
||||||
* See the COPYING-README file.
|
* See the COPYING-README file.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
(function () {
|
(function() {
|
||||||
|
|
||||||
|
OCA.Sharing = OCA.Sharing || {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows "add external share" dialog.
|
* Shows "add external share" dialog.
|
||||||
*
|
*
|
||||||
* @param {String} remote remote server URL
|
* @param {Object} share the share
|
||||||
* @param {String} owner owner name
|
* @param {String} share.remote remote server URL
|
||||||
* @param {String} name name of the shared folder
|
* @param {String} share.owner owner name
|
||||||
* @param {String} token authentication token
|
* @param {String} share.name name of the shared folder
|
||||||
|
* @param {String} share.token authentication token
|
||||||
* @param {bool} passwordProtected true if the share is password protected
|
* @param {bool} passwordProtected true if the share is password protected
|
||||||
|
* @param {Function} callback the callback
|
||||||
*/
|
*/
|
||||||
OCA.Sharing.showAddExternalDialog = function (share, passwordProtected, callback) {
|
OCA.Sharing.showAddExternalDialog = function(share, passwordProtected, callback) {
|
||||||
var remote = share.remote;
|
var remote = share.remote;
|
||||||
var owner = share.ownerDisplayName || share.owner;
|
var owner = share.ownerDisplayName || share.owner;
|
||||||
var name = share.name;
|
var name = share.name;
|
||||||
|
@ -28,10 +33,10 @@
|
||||||
t(
|
t(
|
||||||
'files_sharing',
|
'files_sharing',
|
||||||
'Do you want to add the remote share {name} from {owner}@{remote}?',
|
'Do you want to add the remote share {name} from {owner}@{remote}?',
|
||||||
{name: name, owner: owner, remote: remoteClean}
|
{ name: name, owner: owner, remote: remoteClean }
|
||||||
),
|
),
|
||||||
t('files_sharing','Remote share'),
|
t('files_sharing', 'Remote share'),
|
||||||
function (result) {
|
function(result) {
|
||||||
callback(result, share);
|
callback(result, share);
|
||||||
},
|
},
|
||||||
true
|
true
|
||||||
|
@ -41,15 +46,15 @@
|
||||||
t(
|
t(
|
||||||
'files_sharing',
|
'files_sharing',
|
||||||
'Do you want to add the remote share {name} from {owner}@{remote}?',
|
'Do you want to add the remote share {name} from {owner}@{remote}?',
|
||||||
{name: name, owner: owner, remote: remoteClean}
|
{ name: name, owner: owner, remote: remoteClean }
|
||||||
),
|
),
|
||||||
t('files_sharing','Remote share'),
|
t('files_sharing', 'Remote share'),
|
||||||
function (result, password) {
|
function(result, password) {
|
||||||
share.password = password;
|
share.password = password;
|
||||||
callback(result, share);
|
callback(result, share);
|
||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
t('files_sharing','Remote share password'),
|
t('files_sharing', 'Remote share password'),
|
||||||
true
|
true
|
||||||
).then(this._adjustDialog);
|
).then(this._adjustDialog);
|
||||||
}
|
}
|
||||||
|
@ -93,7 +98,7 @@
|
||||||
processIncomingShareFromUrl: function() {
|
processIncomingShareFromUrl: function() {
|
||||||
var fileList = this.filesApp.fileList;
|
var fileList = this.filesApp.fileList;
|
||||||
var params = OC.Util.History.parseUrlQuery();
|
var params = OC.Util.History.parseUrlQuery();
|
||||||
//manually add server-to-server share
|
// manually add server-to-server share
|
||||||
if (params.remote && params.token && params.owner && params.name) {
|
if (params.remote && params.token && params.owner && params.name) {
|
||||||
|
|
||||||
var callbackAddShare = function(result, share) {
|
var callbackAddShare = function(result, share) {
|
||||||
|
@ -109,19 +114,15 @@
|
||||||
name: share.name,
|
name: share.name,
|
||||||
password: password
|
password: password
|
||||||
}
|
}
|
||||||
).done(
|
).done(function(data) {
|
||||||
function(data) {
|
if (data.hasOwnProperty('legacyMount')) {
|
||||||
if (data.hasOwnProperty('legacyMount')) {
|
fileList.reload();
|
||||||
fileList.reload();
|
} else {
|
||||||
} else {
|
OC.Notification.showTemporary(data.message);
|
||||||
OC.Notification.showTemporary(data.message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
).fail(
|
|
||||||
function(data) {
|
|
||||||
OC.Notification.showTemporary(JSON.parse(data.responseText).message);
|
|
||||||
}
|
}
|
||||||
);
|
}).fail(function(data) {
|
||||||
|
OC.Notification.showTemporary(JSON.parse(data.responseText).message);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -142,36 +143,31 @@
|
||||||
processSharesToConfirm: function() {
|
processSharesToConfirm: function() {
|
||||||
var fileList = this.filesApp.fileList;
|
var fileList = this.filesApp.fileList;
|
||||||
// check for new server-to-server shares which need to be approved
|
// check for new server-to-server shares which need to be approved
|
||||||
$.get(OC.generateUrl('/apps/files_sharing/api/externalShares'),
|
$.get(OC.generateUrl('/apps/files_sharing/api/externalShares'), {}, function(shares) {
|
||||||
{},
|
|
||||||
function(shares) {
|
|
||||||
var index;
|
var index;
|
||||||
for (index = 0; index < shares.length; ++index) {
|
for (index = 0; index < shares.length; ++index) {
|
||||||
OCA.Sharing.showAddExternalDialog(
|
OCA.Sharing.showAddExternalDialog(
|
||||||
shares[index],
|
shares[index],
|
||||||
false,
|
false,
|
||||||
function(result, share) {
|
function(result, share) {
|
||||||
if (result) {
|
if (result) {
|
||||||
// Accept
|
// Accept
|
||||||
$.post(OC.generateUrl('/apps/files_sharing/api/externalShares'), {id: share.id})
|
$.post(OC.generateUrl('/apps/files_sharing/api/externalShares'), {id: share.id})
|
||||||
.then(function() {
|
.then(function() {
|
||||||
fileList.reload();
|
fileList.reload();
|
||||||
});
|
|
||||||
} else {
|
|
||||||
// Delete
|
|
||||||
$.ajax({
|
|
||||||
url: OC.generateUrl('/apps/files_sharing/api/externalShares/'+share.id),
|
|
||||||
type: 'DELETE'
|
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
|
// Delete
|
||||||
|
$.ajax({
|
||||||
|
url: OC.generateUrl('/apps/files_sharing/api/externalShares/'+share.id),
|
||||||
|
type: 'DELETE'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}});
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
})();
|
})(OC, OCA);
|
||||||
|
|
||||||
OC.Plugins.register('OCA.Files.App', OCA.Sharing.ExternalShareDialogPlugin);
|
OC.Plugins.register('OCA.Files.App', OCA.Sharing.ExternalShareDialogPlugin);
|
||||||
|
|
|
@ -32,7 +32,7 @@ use OCA\FederatedFileSharing\AddressHandler;
|
||||||
use OCA\FederatedFileSharing\Controller\RequestHandlerController;
|
use OCA\FederatedFileSharing\Controller\RequestHandlerController;
|
||||||
use OCA\FederatedFileSharing\FederatedShareProvider;
|
use OCA\FederatedFileSharing\FederatedShareProvider;
|
||||||
use OCA\FederatedFileSharing\Notifications;
|
use OCA\FederatedFileSharing\Notifications;
|
||||||
use OCA\FederatedFileSharing\OCM\CloudFederationProvider;
|
use OCA\FederatedFileSharing\Notifier;
|
||||||
use OCA\FederatedFileSharing\OCM\CloudFederationProviderFiles;
|
use OCA\FederatedFileSharing\OCM\CloudFederationProviderFiles;
|
||||||
use OCP\AppFramework\App;
|
use OCP\AppFramework\App;
|
||||||
use OCP\GlobalScale\IConfig;
|
use OCP\GlobalScale\IConfig;
|
||||||
|
@ -99,6 +99,23 @@ class Application extends App {
|
||||||
$server->getCloudFederationProviderManager()
|
$server->getCloudFederationProviderManager()
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// register events listeners
|
||||||
|
$eventDispatcher = $server->getEventDispatcher();
|
||||||
|
$manager = $server->getNotificationManager();
|
||||||
|
$federatedShareProvider = $this->getFederatedShareProvider();
|
||||||
|
|
||||||
|
$manager->registerNotifierService(Notifier::class);
|
||||||
|
|
||||||
|
$eventDispatcher->addListener(
|
||||||
|
'OCA\Files::loadAdditionalScripts',
|
||||||
|
function() use ($federatedShareProvider) {
|
||||||
|
if ($federatedShareProvider->isIncomingServer2serverShareEnabled()) {
|
||||||
|
\OCP\Util::addScript('federatedfilesharing', 'external');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -106,7 +123,7 @@ class Application extends App {
|
||||||
*
|
*
|
||||||
* @return FederatedShareProvider
|
* @return FederatedShareProvider
|
||||||
*/
|
*/
|
||||||
public function getFederatedShareProvider() {
|
protected function getFederatedShareProvider() {
|
||||||
if ($this->federatedShareProvider === null) {
|
if ($this->federatedShareProvider === null) {
|
||||||
$this->initFederatedShareProvider();
|
$this->initFederatedShareProvider();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue