]> git.proxmox.com Git - pve-manager.git/commitdiff
ui/Utils: add storage schema
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 27 Mar 2018 12:19:44 +0000 (14:19 +0200)
committerDominik Csapak <d.csapak@proxmox.com>
Wed, 28 Mar 2018 11:19:41 +0000 (13:19 +0200)
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@proxmox.com>
www/manager6/Utils.js

index 58cc9fb3d15c508ac3614c5008fcee583f99b300..6da4c178be7416b5ad08e102d7f0eb14eda9b182 100644 (file)
@@ -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) {