This is an automated email from the ASF dual-hosted git repository. bhaisaab pushed a commit to branch debian9-systemvmtemplate in repository https://gitbox.apache.org/repos/asf/cloudstack.git
commit 30b830507684155a0166069151841ed1cf66b44a Author: Rohit Yadav <[email protected]> AuthorDate: Mon Nov 27 22:53:12 2017 +0530 CLoudstack UX improvements Signed-off-by: Rohit Yadav <[email protected]> --- ui/scripts/events.js | 6 +- ui/scripts/instances.js | 277 +++++++++++++++++++++++++++++------------------- ui/scripts/network.js | 52 +++++++-- ui/scripts/storage.js | 34 +++++- ui/scripts/templates.js | 27 +++++ 5 files changed, 272 insertions(+), 124 deletions(-) diff --git a/ui/scripts/events.js b/ui/scripts/events.js index 6c4aeb4..82550a9 100644 --- a/ui/scripts/events.js +++ b/ui/scripts/events.js @@ -46,12 +46,12 @@ label: 'label.type', truncate: true }, - domain: { - label: 'label.domain' - }, account: { label: 'label.account' }, + domain: { + label: 'label.domain' + }, created: { label: 'label.date', converter: cloudStack.converters.toLocalDate diff --git a/ui/scripts/instances.js b/ui/scripts/instances.js index ca77c27..07fdd02 100644 --- a/ui/scripts/instances.js +++ b/ui/scripts/instances.js @@ -17,6 +17,153 @@ (function($, cloudStack) { var vmMigrationHostObjs, ostypeObjs; + var vmStopAction = function(args) { + var action = { + messages: { + confirm: function(args) { + return 'message.action.stop.instance'; + }, + notification: function(args) { + return 'label.action.stop.instance'; + } + }, + label: 'label.action.stop.instance', + compactLabel: 'label.stop', + addRow: 'false', + createForm: { + title: 'notification.stop.instance', + desc: 'message.action.stop.instance', + fields: { + forced: { + label: 'force.stop', + isBoolean: true, + isChecked: false + } + } + }, + action: function(args) { + var instances = args.context.instances; + $(instances).map(function(index, instance) { + var data = { + id: instance.id, + forced: (args.data.forced == "on") + }; + $.ajax({ + url: createURL("stopVirtualMachine"), + data: data, + dataType: "json", + success: function(json) { + var jid = json.stopvirtualmachineresponse.jobid; + args.response.success({ + _custom: { + jobId: jid, + getUpdatedItem: function(json) { + return $.extend(json.queryasyncjobresultresponse.jobresult.virtualmachine, { hostid: null }); + }, + getActionFilter: function() { + return vmActionfilter; + } + } + }); + }, + error: function(json) { + args.response.error(parseXMLHttpResponse(json)); + } + }); + }); + }, + notification: { + poll: pollAsyncJobResult + } + }; + + + if (args && args.listView) { + $.extend(action, { + isHeader: true, + isMultiSelectAction: true + }); + } + + return action; + }; + + var vmDestroyAction = function(args) { + var action = { + messages: { + notification: function(args) { + return 'label.action.destroy.instance'; + } + }, + label: 'label.action.destroy.instance', + compactLabel: 'label.destroy', + addRow: 'false', + createForm: { + title: 'label.action.destroy.instance', + desc: 'label.action.destroy.instance', + isWarning: true, + preFilter: function(args) { + if (! g_allowUserExpungeRecoverVm) { + args.$form.find('.form-item[rel=expunge]').hide(); + } + }, + fields: { + expunge: { + label: 'label.expunge', + isBoolean: true, + isChecked: false + } + } + }, + action: function(args) { + var instances = args.context.instances; + $(instances).map(function(index, instance) { + var data = { + id: instance.id + }; + if (args.data.expunge == 'on') { + $.extend(data, { + expunge: true + }); + } + $.ajax({ + url: createURL('destroyVirtualMachine'), + data: data, + success: function(json) { + var jid = json.destroyvirtualmachineresponse.jobid; + args.response.success({ + _custom: { + jobId: jid, + getUpdatedItem: function(json) { + if ('virtualmachine' in json.queryasyncjobresultresponse.jobresult) //destroy without expunge + return json.queryasyncjobresultresponse.jobresult.virtualmachine; + else //destroy with expunge + return { 'toRemove': true }; + }, + getActionFilter: function() { + return vmActionfilter; + } + } + }); + } + }); + }); + }, + notification: { + poll: pollAsyncJobResult + } + }; + + if (args && args.listView) { + $.extend(action, { + isHeader: true, + isMultiSelectAction: true + }); + } + + return action; + }; + var vmSnapshotAction = function(args) { var action = { messages: { @@ -162,6 +309,7 @@ var hiddenFields = []; if (!isAdmin()) { hiddenFields.push('instancename'); + hiddenFields.push('account'); } return hiddenFields; }, @@ -180,16 +328,28 @@ ipaddress: { label: 'label.ip.address' }, + account: { + label: 'label.account' + }, zonename: { label: 'label.zone.name' }, state: { - label: 'label.state', + label: 'label.metrics.state', + converter: function (str) { + // For localization + return str; + }, indicator: { 'Running': 'on', 'Stopped': 'off', + 'Error': 'off', 'Destroyed': 'off', - 'Error': 'off' + 'Expunging': 'off', + 'Stopping': 'transition', + 'Starting': 'transition', + 'Migrating': 'transition', + 'Shutdowned': 'warning' } } }, @@ -304,6 +464,8 @@ poll: pollAsyncJobResult } }, + stop: vmStopAction({ listView: true}), + destroy: vmDestroyAction({ listView: true }), snapshot: vmSnapshotAction({ listView: true }), viewMetrics: { label: 'label.metrics', @@ -680,55 +842,7 @@ poll: pollAsyncJobResult } }, - stop: { - label: 'label.action.stop.instance', - compactLabel: 'label.stop', - createForm: { - title: 'notification.stop.instance', - desc: 'message.action.stop.instance', - fields: { - forced: { - label: 'force.stop', - isBoolean: true, - isChecked: false - } - } - }, - action: function(args) { - var array1 = []; - array1.push("&forced=" + (args.data.forced == "on")); - $.ajax({ - url: createURL("stopVirtualMachine&id=" + args.context.instances[0].id + array1.join("")), - dataType: "json", - async: true, - success: function(json) { - var jid = json.stopvirtualmachineresponse.jobid; - args.response.success({ - _custom: { - jobId: jid, - getUpdatedItem: function(json) { - return $.extend(json.queryasyncjobresultresponse.jobresult.virtualmachine, { hostid: null }); - }, - getActionFilter: function() { - return vmActionfilter; - } - } - }); - } - }); - }, - messages: { - confirm: function(args) { - return 'message.action.stop.instance'; - }, - notification: function(args) { - return 'label.action.stop.instance'; - } - }, - notification: { - poll: pollAsyncJobResult - } - }, + stop: vmStopAction(), restart: { label: 'label.action.reboot.instance', compactLabel: 'label.reboot', @@ -772,66 +886,7 @@ } }, snapshot: vmSnapshotAction(), - destroy: { - label: 'label.action.destroy.instance', - compactLabel: 'label.destroy', - createForm: { - title: 'label.action.destroy.instance', - desc: 'label.action.destroy.instance', - isWarning: true, - preFilter: function(args) { - if (! g_allowUserExpungeRecoverVm) { - args.$form.find('.form-item[rel=expunge]').hide(); - } - }, - fields: { - expunge: { - label: 'label.expunge', - isBoolean: true, - isChecked: false - } - } - }, - messages: { - notification: function(args) { - return 'label.action.destroy.instance'; - } - }, - action: function(args) { - var data = { - id: args.context.instances[0].id - }; - if (args.data.expunge == 'on') { - $.extend(data, { - expunge: true - }); - } - $.ajax({ - url: createURL('destroyVirtualMachine'), - data: data, - success: function(json) { - var jid = json.destroyvirtualmachineresponse.jobid; - args.response.success({ - _custom: { - jobId: jid, - getUpdatedItem: function(json) { - if ('virtualmachine' in json.queryasyncjobresultresponse.jobresult) //destroy without expunge - return json.queryasyncjobresultresponse.jobresult.virtualmachine; - else //destroy with expunge - return { 'toRemove': true }; - }, - getActionFilter: function() { - return vmActionfilter; - } - } - }); - } - }); - }, - notification: { - poll: pollAsyncJobResult - } - }, + destroy: vmDestroyAction(), expunge: { label: 'label.action.expunge.instance', compactLabel: 'label.expunge', diff --git a/ui/scripts/network.js b/ui/scripts/network.js index 16feaf1..10e8c3f 100644 --- a/ui/scripts/network.js +++ b/ui/scripts/network.js @@ -804,13 +804,16 @@ }, id: 'networks', + preFilter: function(args) { + if (isAdmin() || isDomainAdmin()) { + return [] + } + return ['account'] + }, fields: { name: { label: 'label.name' }, - account: { - label: 'label.account' - }, type: { label: 'label.type' }, @@ -819,6 +822,28 @@ }, ip6cidr: { label: 'label.ipv6.CIDR' + }, + account: { + label: 'label.account' + }, + zonename: { + label: 'label.zone' + }, + state: { + converter: function(str) { + // For localization + return str; + }, + label: 'label.state', + indicator: { + 'Allocated': 'on', + 'Released': 'off', + 'Destroy': 'off', + 'Shutdown': 'off', + 'Setup': 'warning', + 'Implementing': 'transition', + 'Implemented': 'on' + } } }, @@ -1615,11 +1640,14 @@ networkid: args.context.networks[0].id }, dataType: 'json', - async: true, + async: false, success: function(json) { var response = json.listegressfirewallrulesresponse.firewallrule ? json.listegressfirewallrulesresponse.firewallrule : []; + if (response.length > 0) { + isConfigRulesMsgShown = true; + } args.response.success({ data: $.map(response, function(rule) { if (rule.protocol == 'all') { @@ -1879,6 +1907,12 @@ listView: { id: 'ipAddresses', label: 'label.ips', + preFilter: function(args) { + if (isAdmin()) { + return ['account'] + } + return [] + }, fields: { ipaddress: { label: 'label.ips', @@ -1890,12 +1924,18 @@ return text; } }, - zonename: { - label: 'label.zone' + associatednetworkname: { + label: 'label.network' }, virtualmachinedisplayname: { label: 'label.vm.name' }, + account: { + label: 'label.account' + }, + zonename: { + label: 'label.zone' + }, state: { converter: function(str) { // For localization diff --git a/ui/scripts/storage.js b/ui/scripts/storage.js index 9c017b1..1427b2a 100644 --- a/ui/scripts/storage.js +++ b/ui/scripts/storage.js @@ -36,8 +36,10 @@ label: 'label.volumes', preFilter: function(args) { var hiddenFields = []; - if (isAdmin() != true) + if (isAdmin() != true) { hiddenFields.push('hypervisor'); + hiddenFields.push('account'); + } return hiddenFields; }, fields: { @@ -47,11 +49,34 @@ type: { label: 'label.type' }, + vmdisplayname: { + label: 'label.vm.display.name' + }, hypervisor: { label: 'label.hypervisor' }, - vmdisplayname: { - label: 'label.vm.display.name' + account: { + label: 'label.account' + }, + zonename: { + label: 'label.zone' + }, + state: { + label: 'label.metrics.state', + converter: function (str) { + // For localization + return str; + }, + indicator: { + 'Allocated': 'transition', + 'Creating': 'transition', + 'Ready': 'on', + 'Destroy': 'off', + 'Expunging': 'off', + 'Migrating': 'warning', + 'UploadOp': 'transition', + 'Snapshotting': 'warning', + } } }, @@ -1955,7 +1980,8 @@ label: 'label.state', indicator: { 'BackedUp': 'on', - 'Destroyed': 'off' + 'Destroyed': 'off', + 'BackingUp': 'transition' } } }, diff --git a/ui/scripts/templates.js b/ui/scripts/templates.js index 1ab1b9b..b2df73e 100755 --- a/ui/scripts/templates.js +++ b/ui/scripts/templates.js @@ -55,12 +55,24 @@ label: 'label.community' } }, + preFilter: function() { + if (isAdmin()||isDomainAdmin()) { + return [] + } + return ['account'] + }, fields: { name: { label: 'label.name' }, hypervisor: { label: 'label.hypervisor' + }, + ostypename: { + label: 'label.os.type' + }, + account: { + label: 'label.account' } }, @@ -2038,9 +2050,21 @@ label: 'label.community' } }, + preFilter: function() { + if (isAdmin()||isDomainAdmin()) { + return [] + } + return ['account'] + }, fields: { name: { label: 'label.name' + }, + ostypename: { + label: 'label.os.type' + }, + account: { + label: 'label.account' } }, @@ -2347,7 +2371,10 @@ id: item.id, name: item.name, description: item.description, + ostypename: item.ostypename, ostypeid: item.ostypeid, + account: item.account, + domain: item.domain, zones: item.zonename, zoneids: [item.zoneid] }; -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
