[pve-devel] [PATCH manager v2 2/4] ui/Utils: add storage schema

Thomas Lamprecht t.lamprecht at proxmox.com
Tue Mar 27 14:19:44 CEST 2018


add a schema describing our storages name, the map for its
InputPanel, the icon we show in the add menu, and if it is available
at all there.

For now just use it to simplify the ugly if/else mess
format_storage_type was, future patches will use the information to
generalise Adding/Editing of those storages.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 www/manager6/Utils.js | 111 +++++++++++++++++++++++++++++++++++---------------
 1 file changed, 79 insertions(+), 32 deletions(-)

diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index 58cc9fb3..6da4c178 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -382,43 +382,90 @@ Ext.define('PVE.Utils', { utilities: {
     isoImageText: gettext('ISO image'),
     containersText: gettext('Container'),
 
+    storageSchema: {
+	dir: {
+	    name: Proxmox.Utils.directoryText,
+	    ipanel: 'DirInputPanel',
+	    faIcon: 'folder'
+	},
+	lvm: {
+	    name: 'LVM',
+	    ipanel: 'LVMInputPanel',
+	    faIcon: 'folder'
+	},
+	lvmthin: {
+	    name: 'LVM-Thin',
+	    ipanel: 'LvmThinInputPanel',
+	    faIcon: 'folder'
+	},
+	nfs: {
+	    name: 'NFS',
+	    ipanel: 'NFSInputPanel',
+	    faIcon: 'building'
+	},
+	cifs: {
+	    name: 'CIFS',
+	    ipanel: 'CIFSInputPanel',
+	    faIcon: 'building'
+	},
+	glusterfs: {
+	    name: 'GlusterFS',
+	    ipanel: 'GlusterFsInputPanel',
+	    faIcon: 'building'
+	},
+	iscsi: {
+	    name: 'iSCSI',
+	    ipanel: 'IScsiInputPanel',
+	    faIcon: 'building'
+	},
+	sheepdog: {
+	    name: 'Sheepdog',
+	    ipanel: 'SheepdogInputPanel',
+	    hideAdd: true,
+	    faIcon: 'building'
+	},
+	rbd: {
+	    name: 'RBD',
+	    ipanel: 'RBDInputPanel',
+	    hideAdd: true,
+	    faIcon: 'building'
+	},
+	rbd_ext: {
+	    name: 'RBD (external)',
+	    ipanel: 'RBDInputPanel',
+	    faIcon: 'building'
+	},
+	pveceph: {
+	    name: 'RBD (PVE)',
+	    ipanel: 'PVERBDInputPanel',
+	    faIcon: 'building'
+	},
+	zfs: {
+	    name: 'ZFS over iSCSI',
+	    ipanel: 'ZFSInputPanel',
+	    faIcon: 'building'
+	},
+	zfspool: {
+	    name: 'ZFS',
+	    ipanel: 'ZFSPoolInputPanel',
+	    faIcon: 'folder'
+	},
+	drbd: {
+	    name: 'DRBD',
+	    hideAdd: true
+	}
+    },
+
     format_storage_type: function(value, md, record) {
 	if (value === 'rbd' && record) {
 	    value = (record.get('monhost')?'rbd_ext':'pveceph');
 	}
-	if (value === 'dir') {
-	    return Proxmox.Utils.directoryText;
-	} else if (value === 'nfs') {
-	    return 'NFS';
-	} else if (value === 'cifs') {
-	    return 'CIFS';
-	} else if (value === 'glusterfs') {
-	    return 'GlusterFS';
-	} else if (value === 'lvm') {
-	    return 'LVM';
-	} else if (value === 'lvmthin') {
-	    return 'LVM-Thin';
-	} else if (value === 'iscsi') {
-	    return 'iSCSI';
-	} else if (value === 'rbd') {
-	    return 'RBD';
-	} else if (value === 'rbd_ext') {
-	    return 'RBD (external)';
-	} else if (value === 'pveceph') {
-	    return 'RBD (PVE)';
-	} else if (value === 'sheepdog') {
-	    return 'Sheepdog';
-	} else if (value === 'zfs') {
-	    return 'ZFS over iSCSI';
-	} else if (value === 'zfspool') {
-	    return 'ZFS';
-	} else if (value === 'iscsidirect') {
-	    return 'iSCSIDirect';
-	} else if (value === 'drbd') {
-	    return 'DRBD';
-	} else {
-	    return Proxmox.Utils.unknownText;
+
+	var schema = PVE.Utils.storageSchema[value];
+	if (schema) {
+	    return schema.name;
 	}
+	return Proxmox.Utils.unknownText;
     },
 
     format_ha: function(value) {
-- 
2.14.2





More information about the pve-devel mailing list