return PVE.Utils.render_size(value);
},
- render_resource_type: function(value, metaData, record, rowIndex, colIndex, store) {
-
- var icon = '';
- var gridcls = '';
-
- switch (value) {
- case 'lxc': icon = 'cube';
- gridcls = '-stopped';
- break;
- case 'qemu': icon = 'desktop';
- gridcls = '-stopped';
- break;
- case 'node': icon = 'building';
- gridcls = '-offline';
- break;
- case 'storage': icon = 'database'; break;
- case 'pool': icon = 'tags'; break;
- default: icon = 'file';
- }
-
- if (value === 'lxc' || value === 'qemu') {
- if (record.data.running && record.data.status !== 'paused') {
- gridcls = '-running';
- } else if (record.data.running) {
- gridcls = '-paused';
- }
- if (record.data.template) {
- icon = 'file-o';
- gridcls = '-template-' + value;
- }
- } else if (value === 'node') {
- if (record.data.running) {
- gridcls = '-online';
- }
+ get_object_icon_class: function(type, record) {
+ var status = '';
+ var objType = type;
+
+ if (type === 'type') {
+ // for folder view
+ objType = record.groupbyid;
+ } else if (record.template) {
+ // templates
+ objType = 'template';
+ status = type;
+ } else {
+ // everything else
+ status = record.status + ' ha-' + record.hastate;
}
- // overwrite anything else
- if (record.data.hastate === 'error') {
- gridcls = '-offline';
+ var defaults = PVE.tree.ResourceTree.typeDefaults[objType];
+ if (defaults && defaults.iconCls) {
+ var retVal = defaults.iconCls + ' ' + status;
+ return retVal;
}
- var fa = '<i class="fa fa-fw x-fa-grid' + gridcls + ' fa-' + icon + '"></i> ';
+ return '';
+ },
+
+ render_resource_type: function(value, metaData, record, rowIndex, colIndex, store) {
+
+ var cls = PVE.Utils.get_object_icon_class(value,record.data);
+
+ var fa = '<i class="fa-fw x-grid-icon-custom ' + cls + '"></i> ';
return fa + value;
},
statics: {
typeDefaults: {
node: {
- iconCls: 'fa fa-building x-fa-tree',
+ iconCls: 'fa fa-building',
text: gettext('Nodes')
},
pool: {
- iconCls: 'fa fa-tags fa-dark x-fa-tree',
+ iconCls: 'fa fa-tags',
text: gettext('Resource Pool')
},
storage: {
- iconCls: 'fa fa-database fa-dark x-fa-tree',
+ iconCls: 'fa fa-database',
text: gettext('Storage')
},
qemu: {
- iconCls: 'fa fa-desktop x-fa-tree',
+ iconCls: 'fa fa-desktop',
text: gettext('Virtual Machine')
},
lxc: {
//iconCls: 'x-tree-node-lxc',
- iconCls: 'fa fa-cube x-fa-tree',
+ iconCls: 'fa fa-cube',
text: gettext('LXC Container')
},
template: {
- iconCls: 'fa fa-file-o fa-dark x-fa-tree-template'
- },
- datacenter: {
- iconCls: 'fa fa-server x-fa-tree-datacenter'
+ iconCls: 'fa fa-file-o'
}
}
},
setIconCls: function(info) {
var me = this;
- var defaults = PVE.tree.ResourceTree.typeDefaults[info.type];
- if (info.id === 'root') {
- defaults = PVE.tree.ResourceTree.typeDefaults.datacenter;
- } else if (info.type === 'type') {
- defaults = PVE.tree.ResourceTree.typeDefaults[info.groupbyid];
- }
- if (defaults && defaults.iconCls) {
- var iconClsAdd = '';
-
- if (info.running && info.type === 'node') {
- iconClsAdd = '-online';
- } else if (info.running) {
- iconClsAdd = '-running';
- if (info.status === 'paused') {
- iconClsAdd = '-paused';
- }
- } else if (info.type === 'lxc' || info.type === 'qemu') {
- iconClsAdd = '-stopped';
- } else if (info.type === 'node') {
- iconClsAdd = '-offline';
- }
-
- // overwrite any other class
- if (info.hastate === 'error') {
- iconClsAdd = '-offline';
- }
-
- info.iconCls = defaults.iconCls + iconClsAdd;
-
- if (info.template) {
- iconClsAdd = '-template';
- info.iconCls = PVE.tree.ResourceTree.typeDefaults.template.iconCls + '-' + info.type;
- }
+ var cls = PVE.Utils.get_object_icon_class(info.type, info);
+ if (cls !== '') {
+ info.iconCls = cls;
}
},
root: {
expanded: true,
id: 'root',
- text: gettext('Datacenter')
+ text: gettext('Datacenter'),
+ iconCls: 'fa fa-server'
}
});
store.suspendEvents();
var rootnode = me.store.getRootNode();
- me.setIconCls(rootnode.data);
// remember selected node (and all parents)
var sm = me.getSelectionModel();