Instance detail view UI: Fix 'view all hosts'
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/c95e8969 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/c95e8969 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/c95e8969 Branch: refs/heads/ui-quick-view-v2 Commit: c95e89696ac30aeaac257569bdce8592d439093f Parents: a756f7d Author: Brian Federle <[email protected]> Authored: Mon Jan 14 11:53:10 2013 -0800 Committer: Brian Federle <[email protected]> Committed: Mon Jan 14 11:53:10 2013 -0800 ---------------------------------------------------------------------- ui/scripts/instances.js | 107 +++++++++++++++++++++++++---------------- ui/scripts/system.js | 16 ++++-- 2 files changed, 76 insertions(+), 47 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c95e8969/ui/scripts/instances.js ---------------------------------------------------------------------- diff --git a/ui/scripts/instances.js b/ui/scripts/instances.js index ca16929..9756fb5 100644 --- a/ui/scripts/instances.js +++ b/ui/scripts/instances.js @@ -34,21 +34,21 @@ }, label: 'state.Destroyed' } - }, + }, preFilter: function(args) { var hiddenFields = []; - if(!isAdmin()) { + if(!isAdmin()) { hiddenFields.push('instancename'); - } + } return hiddenFields; - }, - fields: { + }, + fields: { name: { label: 'label.name' }, instancename: { label: 'label.internal.name' }, displayname: { label: 'label.display.name' }, zonename: { label: 'label.zone.name' }, state: { - label: 'label.state', + label: 'label.state', indicator: { 'Running': 'on', 'Stopped': 'off', @@ -57,18 +57,18 @@ } } }, - + advSearchFields: { name: { label: 'Name' }, - zoneid: { - label: 'Zone', - select: function(args) { + zoneid: { + label: 'Zone', + select: function(args) { $.ajax({ url: createURL('listZones'), data: { listAll: true }, - success: function(json) { + success: function(json) { var zones = json.listzonesresponse.zone; args.response.success({ @@ -81,16 +81,16 @@ }); } }); - } - }, - - domainid: { - label: 'Domain', + } + }, + + domainid: { + label: 'Domain', select: function(args) { if(isAdmin() || isDomainAdmin()) { $.ajax({ url: createURL('listDomains'), - data: { + data: { listAll: true, details: 'min' }, @@ -120,21 +120,21 @@ else return true; } - }, - account: { + }, + account: { label: 'Account', isHidden: function(args) { if(isAdmin() || isDomainAdmin()) return false; else return true; - } + } }, - + tagKey: { label: 'Tag Key' }, - tagValue: { label: 'Tag Value' } - }, - + tagValue: { label: 'Tag Value' } + }, + // List view actions actions: { // Add instance wizard @@ -145,9 +145,9 @@ custom: cloudStack.uiCustom.instanceWizard(cloudStack.instanceWizard) }, - messages: { - notification: function(args) { - return 'label.vm.add'; + messages: { + notification: function(args) { + return 'label.vm.add'; } }, notification: { @@ -158,49 +158,49 @@ dataProvider: function(args) { var data = {}; - listViewDataProvider(args, data); - + listViewDataProvider(args, data); + if(args.filterBy != null) { //filter dropdown if(args.filterBy.kind != null) { switch(args.filterBy.kind) { - case "all": + case "all": break; case "mine": if (!args.context.projects) { $.extend(data, { - domainid: g_domainid, + domainid: g_domainid, account: g_account - }); - } + }); + } break; case "running": $.extend(data, { state: 'Running' - }); + }); break; case "stopped": $.extend(data, { state: 'Stopped' - }); + }); break; case "destroyed": $.extend(data, { state: 'Destroyed' - }); + }); break; } - } + } } - - if("hosts" in args.context) { + + if("hosts" in args.context) { $.extend(data, { hostid: args.context.hosts[0].id }); } - + $.ajax({ url: createURL('listVirtualMachines'), - data: data, + data: data, success: function(json) { var items = json.listvirtualmachinesresponse.virtualmachine; // Code for hiding "Expunged VMs" @@ -234,7 +234,30 @@ viewAll: [ { path: 'storage.volumes', label: 'label.volumes' }, { path: 'storage.snapshots', label: 'label.snapshots' }, - { path: 'system', label: 'label.hosts' } + { + path: '_zone.hosts', + label: 'label.hosts', + preFiter: function(args) { + return isAdmin(); + }, + updateContext: function(args) { + var instance = args.context.instances[0]; + var zone; + + $.ajax({ + url: createURL('listZones'), + data: { + id: instance.zoneid + }, + async: false, + success: function(json) { + zone = json.listzonesresponse.zone[0] + } + }); + + return { zones: [zone] }; + } + } ], tabFilter: function(args) { var hiddenTabs = []; http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c95e8969/ui/scripts/system.js ---------------------------------------------------------------------- diff --git a/ui/scripts/system.js b/ui/scripts/system.js index 6733da1..fc251f1 100644 --- a/ui/scripts/system.js +++ b/ui/scripts/system.js @@ -7967,11 +7967,17 @@ } } } - array1.push("&zoneid=" + args.context.zones[0].id); - if("pods" in args.context) - array1.push("&podid=" + args.context.pods[0].id); - if("clusters" in args.context) - array1.push("&clusterid=" + args.context.clusters[0].id); + + if (!args.context.instances) { + array1.push("&zoneid=" + args.context.zones[0].id); + if("pods" in args.context) + array1.push("&podid=" + args.context.pods[0].id); + if("clusters" in args.context) + array1.push("&clusterid=" + args.context.clusters[0].id); + } else { + array1.push("&hostid=" + args.context.instances[0].hostid); + } + $.ajax({ url: createURL("listHosts&type=Routing" + array1.join("") + "&page=" + args.page + "&pagesize=" + pageSize), dataType: "json",
