[pve-devel] [PATCH manager 4/5] ui/UploadToStorage.js: add checksum and algorithm

Lorenz Stechauner l.stechauner at proxmox.com
Tue Jul 20 13:51:46 CEST 2021


Signed-off-by: Lorenz Stechauner <l.stechauner at proxmox.com>
---
 www/manager6/window/UploadToStorage.js | 42 ++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/www/manager6/window/UploadToStorage.js b/www/manager6/window/UploadToStorage.js
index 75423b0f..ca89692e 100644
--- a/www/manager6/window/UploadToStorage.js
+++ b/www/manager6/window/UploadToStorage.js
@@ -83,6 +83,16 @@ Ext.define('PVE.window.UploadToStorage', {
 	    fd.append("new-filename", field.getValue());
 	    field.setDisabled(true);
 
+	    field = form.findField('checksum-algorithm');
+	    field.setDisabled(true);
+	    if (field.getValue() !== '__default__') {
+		fd.append("checksum-algorithm", field.getValue());
+
+		field = form.findField('checksum');
+		fd.append("checksum", field.getValue());
+		field.setDisabled(true);
+	    }
+
 	    field = form.findField('filename');
 	    const file = field.fileInputEl.dom;
 	    fd.append("filename", file.files[0]);
@@ -139,6 +149,18 @@ 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) {
+	    const checksum = Ext.getCmp('downloadUrlChecksum');
+	    if (field.getValue() === '__default__') {
+		checksum.setDisabled(true);
+		checksum.setValue("");
+		checksum.allowBlank = true;
+	    } else {
+		checksum.setDisabled(false);
+		checksum.allowBlank = false;
+	    }
+	},
     },
 
     items: [
@@ -193,6 +215,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: true,
+		    disabled: true,
+		    emptyText: gettext('none'),
+		    id: 'downloadUrlChecksum',
+		},
 		{
 		    xtype: 'progressbar',
 		    text: 'Ready',
-- 
2.30.2






More information about the pve-devel mailing list