]> git.proxmox.com Git - pve-manager.git/commitdiff
ui: move download URL to storage window into own file
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 2 Jul 2021 22:44:01 +0000 (00:44 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 2 Jul 2021 22:45:09 +0000 (00:45 +0200)
As 200 lines is a bit much for the content view, i.e., basically
growing it by 50% in size for a very specific feature is not ideal.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
www/manager6/Makefile
www/manager6/storage/ContentView.js
www/manager6/window/DownloadUrlToStorage.js [new file with mode: 0644]

index ecd6657ebbb41b9f76828645a1ef4f8c295ba549..75d355a598c702ef00c5bca857302d50caae4f7b 100644 (file)
@@ -105,6 +105,7 @@ JSSRC=                                                      \
        window/Settings.js                              \
        window/Snapshot.js                              \
        window/StartupEdit.js                           \
+       window/DownloadUrlToStorage.js                  \
        window/Wizard.js                                \
        ha/Fencing.js                                   \
        ha/GroupEdit.js                                 \
index 4dc394a010e49747478a46cd48e06a5fd60aa48a..3f5b686baba1e561260fa04c5a55057e0fa8967a 100644 (file)
@@ -191,206 +191,6 @@ Ext.define('PVE.storage.Upload', {
     },
 });
 
-Ext.define('PVE.storage.DownloadUrl', {
-    extend: 'Proxmox.window.Edit',
-    alias: 'widget.pveStorageDownloadUrl',
-    mixins: ['Proxmox.Mixin.CBind'],
-
-    isCreate: true,
-
-    method: 'POST',
-
-    showTaskViewer: true,
-
-    title: gettext('Download from URL'),
-    submitText: gettext('Download'),
-
-    cbindData: function(initialConfig) {
-       var me = this;
-       return {
-           nodename: me.nodename,
-           storage: me.storage,
-           content: me.content,
-       };
-    },
-
-    cbind: {
-       url: '/nodes/{nodename}/storage/{storage}/download-url',
-    },
-
-    controller: {
-       xclass: 'Ext.app.ViewController',
-
-       urlChange: function(field) {
-           let me = this;
-           let view = me.getView();
-           field = view.down('[name=url]');
-           field.setValidation(gettext("Please check URL"));
-           field.validate();
-           view.setValues({
-               size: gettext("unknown"),
-               mimetype: gettext("unknown"),
-           });
-       },
-
-       urlCheck: function(field) {
-           let me = this;
-           let view = me.getView();
-           field = view.down('[name=url]');
-           view.setValues({
-               size: gettext("unknown"),
-               mimetype: gettext("unknown"),
-           });
-           Proxmox.Utils.API2Request({
-               url: `/nodes/${view.nodename}/query-url-metadata`,
-               method: 'GET',
-               params: {
-                   url: field.getValue(),
-                   'verify-certificates': view.getValues()['verify-certificates'],
-               },
-               waitMsgTarget: view,
-               failure: function(res, opt) {
-                   field.setValidation(res.result.message);
-                   field.validate();
-               },
-               success: function(res, opt) {
-                   field.setValidation();
-                   field.validate();
-
-                   let data = res.result.data;
-                   view.setValues({
-                       filename: data.filename || "",
-                       size: (data.size && Proxmox.Utils.format_size(data.size)) || gettext("unknown"),
-                       mimetype: data.mimetype || gettext("unknown"),
-                   });
-               },
-           });
-       },
-
-       hashChange: function(field) {
-           let checksum = Ext.getCmp('downloadUrlChecksum');
-           if (field.getValue() === '__default__') {
-               checksum.setDisabled(true);
-               checksum.setValue("");
-               checksum.allowBlank = true;
-           } else {
-               checksum.setDisabled(false);
-               checksum.allowBlank = false;
-           }
-       },
-    },
-
-    items: [
-       {
-           xtype: 'inputpanel',
-           border: false,
-           columnT: [
-               {
-                   xtype: 'fieldcontainer',
-                   layout: 'hbox',
-                   fieldLabel: gettext('URL'),
-                   items: [
-                       {
-                           xtype: 'textfield',
-                           name: 'url',
-                           allowBlank: false,
-                           flex: 1,
-                           listeners: {
-                               change: 'urlChange',
-                           },
-                       },
-                       {
-                           xtype: 'button',
-                           name: 'check',
-                           text: gettext('Check'),
-                           margin: '0 0 0 5',
-                           listeners: {
-                               click: 'urlCheck',
-                           },
-                       },
-                   ],
-               },
-               {
-                   xtype: 'textfield',
-                   name: 'filename',
-                   allowBlank: false,
-                   fieldLabel: gettext('File name'),
-               },
-           ],
-           column1: [
-               {
-                   xtype: 'displayfield',
-                   name: 'size',
-                   fieldLabel: gettext('File size'),
-                   value: gettext('unknown'),
-               },
-           ],
-           column2: [
-               {
-                   xtype: 'displayfield',
-                   name: 'mimetype',
-                   fieldLabel: gettext('MIME type'),
-                   value: gettext('unknown'),
-               },
-           ],
-           advancedColumn1: [
-               {
-                   xtype: 'pveHashAlgorithmSelector',
-                   name: 'checksum-algorithm',
-                   fieldLabel: gettext('Hash algorithm'),
-                   allowBlank: true,
-                   hasNoneOption: true,
-                   value: '__default__',
-                   listeners: {
-                       change: 'hashChange',
-                   },
-               },
-               {
-                   xtype: 'textfield',
-                   name: 'checksum',
-                   fieldLabel: gettext('Checksum'),
-                   allowBlank: true,
-                   disabled: true,
-                   emptyText: gettext('none'),
-                   id: 'downloadUrlChecksum',
-               },
-           ],
-           advancedColumn2: [
-               {
-                   xtype: 'proxmoxcheckbox',
-                   name: 'verify-certificates',
-                   fieldLabel: gettext('Verify certificates'),
-                   uncheckedValue: 0,
-                   checked: true,
-                   listeners: {
-                       change: 'urlChange',
-                   },
-               },
-           ],
-       },
-       {
-           xtype: 'hiddenfield',
-           name: 'content',
-           cbind: {
-               value: '{content}',
-           },
-       },
-    ],
-
-    initComponent: function() {
-        var me = this;
-
-       if (!me.nodename) {
-           throw "no node name specified";
-       }
-       if (!me.storage) {
-           throw "no storage ID specified";
-       }
-
-        me.callParent();
-    },
-});
-
 Ext.define('PVE.storage.ContentView', {
     extend: 'Ext.grid.GridPanel',
 
@@ -473,7 +273,7 @@ Ext.define('PVE.storage.ContentView', {
                    text: gettext('Download from URL'),
                    disabled: !me.enableDownloadUrlButton,
                    handler: function() {
-                       Ext.create('PVE.storage.DownloadUrl', {
+                       Ext.create('PVE.window.DownloadUrlToStorage', {
                            nodename: nodename,
                            storage: storage,
                            content: content,
diff --git a/www/manager6/window/DownloadUrlToStorage.js b/www/manager6/window/DownloadUrlToStorage.js
new file mode 100644 (file)
index 0000000..69788b6
--- /dev/null
@@ -0,0 +1,200 @@
+Ext.define('PVE.window.DownloadUrlToStorage', {
+    extend: 'Proxmox.window.Edit',
+    alias: 'widget.pveStorageDownloadUrl',
+    mixins: ['Proxmox.Mixin.CBind'],
+
+    isCreate: true,
+
+    method: 'POST',
+
+    showTaskViewer: true,
+
+    title: gettext('Download from URL'),
+    submitText: gettext('Download'),
+
+    cbindData: function(initialConfig) {
+       var me = this;
+       return {
+           nodename: me.nodename,
+           storage: me.storage,
+           content: me.content,
+       };
+    },
+
+    cbind: {
+       url: '/nodes/{nodename}/storage/{storage}/download-url',
+    },
+
+    controller: {
+       xclass: 'Ext.app.ViewController',
+
+       urlChange: function(field) {
+           let me = this;
+           let view = me.getView();
+           field = view.down('[name=url]');
+           field.setValidation(gettext("Please check URL"));
+           field.validate();
+           view.setValues({
+               size: gettext("unknown"),
+               mimetype: gettext("unknown"),
+           });
+       },
+
+       urlCheck: function(field) {
+           let me = this;
+           let view = me.getView();
+           field = view.down('[name=url]');
+           view.setValues({
+               size: gettext("unknown"),
+               mimetype: gettext("unknown"),
+           });
+           Proxmox.Utils.API2Request({
+               url: `/nodes/${view.nodename}/query-url-metadata`,
+               method: 'GET',
+               params: {
+                   url: field.getValue(),
+                   'verify-certificates': view.getValues()['verify-certificates'],
+               },
+               waitMsgTarget: view,
+               failure: function(res, opt) {
+                   field.setValidation(res.result.message);
+                   field.validate();
+               },
+               success: function(res, opt) {
+                   field.setValidation();
+                   field.validate();
+
+                   let data = res.result.data;
+                   view.setValues({
+                       filename: data.filename || "",
+                       size: (data.size && Proxmox.Utils.format_size(data.size)) || gettext("unknown"),
+                       mimetype: data.mimetype || gettext("unknown"),
+                   });
+               },
+           });
+       },
+
+       hashChange: function(field) {
+           let checksum = Ext.getCmp('downloadUrlChecksum');
+           if (field.getValue() === '__default__') {
+               checksum.setDisabled(true);
+               checksum.setValue("");
+               checksum.allowBlank = true;
+           } else {
+               checksum.setDisabled(false);
+               checksum.allowBlank = false;
+           }
+       },
+    },
+
+    items: [
+       {
+           xtype: 'inputpanel',
+           border: false,
+           columnT: [
+               {
+                   xtype: 'fieldcontainer',
+                   layout: 'hbox',
+                   fieldLabel: gettext('URL'),
+                   items: [
+                       {
+                           xtype: 'textfield',
+                           name: 'url',
+                           allowBlank: false,
+                           flex: 1,
+                           listeners: {
+                               change: 'urlChange',
+                           },
+                       },
+                       {
+                           xtype: 'button',
+                           name: 'check',
+                           text: gettext('Check'),
+                           margin: '0 0 0 5',
+                           listeners: {
+                               click: 'urlCheck',
+                           },
+                       },
+                   ],
+               },
+               {
+                   xtype: 'textfield',
+                   name: 'filename',
+                   allowBlank: false,
+                   fieldLabel: gettext('File name'),
+               },
+           ],
+           column1: [
+               {
+                   xtype: 'displayfield',
+                   name: 'size',
+                   fieldLabel: gettext('File size'),
+                   value: gettext('unknown'),
+               },
+           ],
+           column2: [
+               {
+                   xtype: 'displayfield',
+                   name: 'mimetype',
+                   fieldLabel: gettext('MIME type'),
+                   value: gettext('unknown'),
+               },
+           ],
+           advancedColumn1: [
+               {
+                   xtype: 'pveHashAlgorithmSelector',
+                   name: 'checksum-algorithm',
+                   fieldLabel: gettext('Hash algorithm'),
+                   allowBlank: true,
+                   hasNoneOption: true,
+                   value: '__default__',
+                   listeners: {
+                       change: 'hashChange',
+                   },
+               },
+               {
+                   xtype: 'textfield',
+                   name: 'checksum',
+                   fieldLabel: gettext('Checksum'),
+                   allowBlank: true,
+                   disabled: true,
+                   emptyText: gettext('none'),
+                   id: 'downloadUrlChecksum',
+               },
+           ],
+           advancedColumn2: [
+               {
+                   xtype: 'proxmoxcheckbox',
+                   name: 'verify-certificates',
+                   fieldLabel: gettext('Verify certificates'),
+                   uncheckedValue: 0,
+                   checked: true,
+                   listeners: {
+                       change: 'urlChange',
+                   },
+               },
+           ],
+       },
+       {
+           xtype: 'hiddenfield',
+           name: 'content',
+           cbind: {
+               value: '{content}',
+           },
+       },
+    ],
+
+    initComponent: function() {
+        var me = this;
+
+       if (!me.nodename) {
+           throw "no node name specified";
+       }
+       if (!me.storage) {
+           throw "no storage ID specified";
+       }
+
+        me.callParent();
+    },
+});
+