From 2e2851dc13d73352530dd4495c7e05603b2e520d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 10 Apr 2024 23:38:38 +0200 Subject: Adding upstream version 2.1.2~dev0+20240219. Signed-off-by: Daniel Baumann --- .../deluge-all/preferences/InstallPluginWindow.js | 83 ++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 deluge/ui/web/js/deluge-all/preferences/InstallPluginWindow.js (limited to 'deluge/ui/web/js/deluge-all/preferences/InstallPluginWindow.js') diff --git a/deluge/ui/web/js/deluge-all/preferences/InstallPluginWindow.js b/deluge/ui/web/js/deluge-all/preferences/InstallPluginWindow.js new file mode 100644 index 0000000..9aefce3 --- /dev/null +++ b/deluge/ui/web/js/deluge-all/preferences/InstallPluginWindow.js @@ -0,0 +1,83 @@ +/** + * Deluge.preferences.InstallPluginWindow.js + * + * Copyright (c) Damien Churchill 2009-2010 + * + * This file is part of Deluge and is licensed under GNU General Public License 3.0, or later, with + * the additional special exception to link portions of this program with the OpenSSL library. + * See LICENSE for more details. + */ +Ext.namespace('Deluge.preferences'); + +/** + * @class Deluge.preferences.InstallPluginWindow + * @extends Ext.Window + */ +Deluge.preferences.InstallPluginWindow = Ext.extend(Ext.Window, { + title: _('Install Plugin'), + layout: 'fit', + height: 115, + width: 350, + constrainHeader: true, + bodyStyle: 'padding: 10px 5px;', + buttonAlign: 'center', + closeAction: 'hide', + iconCls: 'x-deluge-install-plugin', + modal: true, + plain: true, + + initComponent: function () { + Deluge.preferences.InstallPluginWindow.superclass.initComponent.call( + this + ); + this.addButton(_('Install'), this.onInstall, this); + + this.form = this.add({ + xtype: 'form', + baseCls: 'x-plain', + labelWidth: 70, + autoHeight: true, + fileUpload: true, + items: [ + { + xtype: 'fileuploadfield', + width: 240, + emptyText: _('Select an egg'), + fieldLabel: _('Plugin Egg'), + name: 'file', + buttonCfg: { + text: _('Browse...'), + }, + }, + ], + }); + }, + + onInstall: function (field, e) { + this.form.getForm().submit({ + url: deluge.config.base + 'upload', + waitMsg: _('Uploading your plugin...'), + success: this.onUploadSuccess, + scope: this, + }); + }, + + onUploadPlugin: function (info, obj, response, request) { + this.fireEvent('pluginadded'); + }, + + onUploadSuccess: function (fp, upload) { + this.hide(); + if (upload.result.success) { + var filename = this.form.getForm().getFieldValues().file; + filename = filename.split('\\').slice(-1)[0]; + var path = upload.result.files[0]; + this.form.getForm().setValues({ file: '' }); + deluge.client.web.upload_plugin(filename, path, { + success: this.onUploadPlugin, + scope: this, + filename: filename, + }); + } + }, +}); -- cgit v1.2.3