// this singleton contains miscellaneous utilities
+ yesText: gettext('Yes'),
+ noText: gettext('No'),
+ enabledText: gettext('Enabled'),
+ disabledText: gettext('Disabled'),
+ noneText: gettext('none'),
+ errorText: gettext('Error'),
+ unknownText: gettext('Unknown'),
+ defaultText: gettext('Default'),
+ daysText: gettext('days'),
+ dayText: gettext('day'),
+ runningText: gettext('running'),
+ stoppedText: gettext('stopped'),
+ neverText: gettext('never'),
+ totalText: gettext('Total'),
+ usedText: gettext('Used'),
+ directoryText: gettext('Directory'),
+ stateText: gettext('State'),
+ groupText: gettext('Group'),
+
+ format_boolean_with_default: function(value) {
+ if (Ext.isDefined(value) && value !== '__default__') {
+ return value ? Proxmox.Utils.yesText : Proxmox.Utils.noText;
+ }
+ return Proxmox.Utils.defaultText;
+ },
+
+ format_boolean: function(value) {
+ return value ? Proxmox.Utils.yesText : Proxmox.Utils.noText;
+ },
+
+ format_neg_boolean: function(value) {
+ return !value ? Proxmox.Utils.yesText : Proxmox.Utils.noText;
+ },
+
+ format_enabled_toggle: function(value) {
+ return value ? Proxmox.Utils.enabledText : Proxmox.Utils.disabledText;
+ },
+
+ compute_min_label_width: function(text, width) {
+
+ if (width === undefined) { width = 100; }
+
+ var tm = new Ext.util.TextMetrics();
+ var min = tm.getWidth(text + ':');
+
+ return min < width ? width : min;
+ },
+
authOK: function() {
return (Proxmox.UserName !== '') && Ext.util.Cookies.get(Proxmox.Setup.auth_cookie_name);
},
Ext.Ajax.request(newopts);
},
+ assemble_field_data: function(values, data) {
+ if (Ext.isObject(data)) {
+ Ext.Object.each(data, function(name, val) {
+ if (values.hasOwnProperty(name)) {
+ var bucket = values[name];
+ if (!Ext.isArray(bucket)) {
+ bucket = values[name] = [bucket];
+ }
+ if (Ext.isArray(val)) {
+ values[name] = bucket.concat(val);
+ } else {
+ bucket.push(val);
+ }
+ } else {
+ values[name] = val;
+ }
+ });
+ }
+ },
+
+ dialog_title: function(subject, create, isAdd) {
+ if (create) {
+ if (isAdd) {
+ return gettext('Add') + ': ' + subject;
+ } else {
+ return gettext('Create') + ': ' + subject;
+ }
+ } else {
+ return gettext('Edit') + ': ' + subject;
+ }
+ },
+
+ network_iface_types: {
+ eth: gettext("Network Device"),
+ bridge: 'Linux Bridge',
+ bond: 'Linux Bond',
+ OVSBridge: 'OVS Bridge',
+ OVSBond: 'OVS Bond',
+ OVSPort: 'OVS Port',
+ OVSIntPort: 'OVS IntPort'
+ },
+
+ render_network_iface_type: function(value) {
+ return Proxmox.Utils.network_iface_types[value] ||
+ Proxmox.Utils.unknownText;
+ },
+
+ // you can override this to provide nicer task descriptions
+ format_task_description: function(type, id) {
+ return type + ' ' + id;
+ },
+
+ render_upid: function(value, metaData, record) {
+ var type = record.data.type;
+ var id = record.data.id;
+
+ return Proxmox.Utils.format_task_description(type, id);
+ },
+
+ parse_task_upid: function(upid) {
+ var task = {};
+
+ var res = upid.match(/^UPID:(\S+):([0-9A-Fa-f]{8}):([0-9A-Fa-f]{8,9}):([0-9A-Fa-f]{8}):([^:\s]+):([^:\s]*):([^:\s]+):$/);
+ if (!res) {
+ throw "unable to parse upid '" + upid + "'";
+ }
+ task.node = res[1];
+ task.pid = parseInt(res[2], 16);
+ task.pstart = parseInt(res[3], 16);
+ task.starttime = parseInt(res[4], 16);
+ task.type = res[5];
+ task.id = res[6];
+ task.user = res[7];
+
+ task.desc = Proxmox.Utils.format_task_description(task.type, task.id);
+
+ return task;
+ },
+
+ render_timestamp: function(value, metaData, record, rowIndex, colIndex, store) {
+ var servertime = new Date(value * 1000);
+ return Ext.Date.format(servertime, 'Y-m-d H:i:s');
+ },
+
},
singleton: true,