]> git.proxmox.com Git - pve-manager.git/blobdiff - www/manager6/window/UploadToStorage.js
ui: guest import: update text for cdrom-image-ignored warning
[pve-manager.git] / www / manager6 / window / UploadToStorage.js
index e9c35f77be5be64cc4905e6b36c9b6bc4af17184..3c5bba8881b63f66d306c4c1004257b15da97a0f 100644 (file)
@@ -10,7 +10,7 @@ Ext.define('PVE.window.UploadToStorage', {
 
     acceptedExtensions: {
        iso: ['.img', '.iso'],
-       vztmpl: ['.tar.gz', '.tar.xz'],
+       vztmpl: ['.tar.gz', '.tar.xz', '.tar.zst'],
     },
 
     cbindData: function(initialConfig) {
@@ -21,6 +21,7 @@ Ext.define('PVE.window.UploadToStorage', {
 
        return {
            extensions: ext.join(', '),
+           filenameRegex: RegExp('^.*(?:' + ext.join('|').replaceAll('.', '\\.') + ')$', 'i'),
        };
     },
 
@@ -62,6 +63,16 @@ Ext.define('PVE.window.UploadToStorage', {
            const filename = filenameField.getValue();
            filenameField.setDisabled(true);
 
+           const algorithmField = form.findField('checksum-algorithm');
+           algorithmField.setDisabled(true);
+           if (algorithmField.getValue() !== '__default__') {
+               fd.append("checksum-algorithm", algorithmField.getValue());
+
+               const checksumField = form.findField('checksum');
+               fd.append("checksum", checksumField.getValue()?.trim());
+               checksumField.setDisabled(true);
+           }
+
            fd.append("filename", file, filename);
 
            pbar.setVisible(true);
@@ -72,7 +83,21 @@ Ext.define('PVE.window.UploadToStorage', {
 
            xhr.addEventListener("load", function(e) {
                if (xhr.status === 200) {
-                   view.close();
+                   view.hide();
+
+                   const result = JSON.parse(xhr.response);
+                   const upid = result.data;
+                   Ext.create('Proxmox.window.TaskViewer', {
+                       autoShow: true,
+                       upid: upid,
+                       taskDone: view.taskDone,
+                       listeners: {
+                           destroy: function() {
+                               view.close();
+                           },
+                       },
+                   });
+
                    return;
                }
                const err = Ext.htmlEncode(xhr.statusText);
@@ -115,6 +140,16 @@ Ext.define('PVE.window.UploadToStorage', {
            vm.set('size', (fileInput.files[0] && Proxmox.Utils.format_size(fileInput.files[0].size)) || '-');
            vm.set('mimetype', (fileInput.files[0] && fileInput.files[0].type) || '-');
        },
+
+       hashChange: function(field, value) {
+           const checksum = this.lookup('downloadUrlChecksum');
+           if (value === '__default__') {
+               checksum.setDisabled(true);
+               checksum.setValue("");
+           } else {
+               checksum.setDisabled(false);
+           }
+       },
     },
 
     items: [
@@ -152,6 +187,10 @@ Ext.define('PVE.window.UploadToStorage', {
                    bind: {
                        value: '{filename}',
                    },
+                   cbind: {
+                       regex: '{filenameRegex}',
+                   },
+                   regexText: gettext('Wrong file extension'),
                },
                {
                    xtype: 'displayfield',
@@ -169,6 +208,26 @@ Ext.define('PVE.window.UploadToStorage', {
                        value: '{mimetype}',
                    },
                },
+               {
+                   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: false,
+                   disabled: true,
+                   emptyText: gettext('none'),
+                   reference: 'downloadUrlChecksum',
+               },
                {
                    xtype: 'progressbar',
                    text: 'Ready',