Updated Branches: refs/heads/4.3 592863f1e -> 5b5ec7fa3
CLOUDSTACK-4793: UI > Virtual Routers > add "Select View" dropdown on top of listView. Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/5b5ec7fa Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/5b5ec7fa Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/5b5ec7fa Branch: refs/heads/4.3 Commit: 5b5ec7fa327c6ef02be8c7baee8c310d18f478be Parents: 592863f Author: Jessica Wang <jessicaw...@apache.org> Authored: Thu Nov 21 16:03:03 2013 -0800 Committer: Jessica Wang <jessicaw...@apache.org> Committed: Thu Nov 21 16:03:16 2013 -0800 ---------------------------------------------------------------------- ui/scripts/system.js | 761 +++------------------------------------------- 1 file changed, 38 insertions(+), 723 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5b5ec7fa/ui/scripts/system.js ---------------------------------------------------------------------- diff --git a/ui/scripts/system.js b/ui/scripts/system.js index 63e0c90..91674eb 100644 --- a/ui/scripts/system.js +++ b/ui/scripts/system.js @@ -7391,8 +7391,7 @@ return listView; }, virtualRouters: function() { - var listView = $.extend(true, {}, cloudStack.sections.system.subsections.virtualRouters, { - //??????? + var listView = $.extend(true, {}, cloudStack.sections.system.subsections.virtualRouters, { sections: { virtualRouterNoGrouping: { listView: { @@ -7808,8 +7807,7 @@ } } } - } - //??????? + } }); return listView; @@ -8636,160 +8634,20 @@ } } } - }, - routerByZone: { - id: 'routers', + }, + routerGroupByZone: { + id: 'routerGroupByZone', type: 'select', - title: 'By zone', + title: 'group by zone', listView: { + id: 'routerGroupByZone', label: 'label.virtual.appliances', - id: 'routers', fields: { name: { - label: 'label.name' - }, - zonename: { label: 'label.zone' }, - routerType: { - label: 'label.type' - }, - state: { - converter: function(str) { - // For localization - return str; - }, - label: 'label.status', - indicator: { - 'Running': 'on', - 'Stopped': 'off', - 'Error': 'off' - } - } - }, - - advSearchFields: { - name: { - label: 'Name' - }, - zoneid: { - label: 'Zone', - select: function(args) { - $.ajax({ - url: createURL('listZones'), - data: { - listAll: true - }, - success: function(json) { - var zones = json.listzonesresponse.zone ? json.listzonesresponse.zone : []; - - args.response.success({ - data: $.map(zones, function(zone) { - return { - id: zone.id, - description: zone.name - }; - }) - }); - } - }); - } - }, - podid: { - label: 'Pod', - dependsOn: 'zoneid', - select: function (args) { - $.ajax({ - url: createURL("listPods&zoneid=" + args.zoneid), - dataType: "json", - async: true, - success: function (json) { - var pods = json.listpodsresponse.pod ? json.listpodsresponse.pod : []; - args.response.success({ - data: $.map(pods, function(pod) { - return { - id: pod.id, - description: pod.name - }; - }) - }); - } - }); - } - }, - clusterid: { - label: 'label.cluster', - dependsOn: 'podid', - select: function(args) { - $.ajax({ - url: createURL("listClusters&podid=" + args.podid), - dataType: "json", - async: false, - success: function(json) { - var clusters = json.listclustersresponse.cluster ? json.listclustersresponse.cluster : []; - args.response.success({ - data: $.map(clusters, function(cluster) { - return { - id: cluster.id, - description: cluster.name - }; - }) - }); - } - }); - } - }, - domainid: { - label: 'Domain', - select: function(args) { - if (isAdmin() || isDomainAdmin()) { - $.ajax({ - url: createURL('listDomains'), - data: { - listAll: true, - details: 'min' - }, - success: function(json) { - var array1 = [{ - id: '', - description: '' - }]; - var domains = json.listdomainsresponse.domain; - if (domains != null && domains.length > 0) { - for (var i = 0; i < domains.length; i++) { - array1.push({ - id: domains[i].id, - description: domains[i].path - }); - } - } - args.response.success({ - data: array1 - }); - } - }); - } else { - args.response.success({ - data: null - }); - } - }, - isHidden: function(args) { - if (isAdmin() || isDomainAdmin()) - return false; - else - return true; - } - }, - - account: { - label: 'Account', - isHidden: function(args) { - if (isAdmin() || isDomainAdmin()) - return false; - else - return true; - } + routerCount: { + label: 'Total of Virtual Routers' } }, @@ -8798,588 +8656,45 @@ if (args.filterBy != null) { if (args.filterBy.search != null && args.filterBy.search.by != null && args.filterBy.search.value != null) { switch (args.filterBy.search.by) { - case "name": - if (args.filterBy.search.value.length > 0) - array1.push("&keyword=" + args.filterBy.search.value); - break; + case "name": + if (args.filterBy.search.value.length > 0) + array1.push("&keyword=" + args.filterBy.search.value); + break; } } } - - var data2 = { - forvpc: false - }; - - var routers = []; $.ajax({ - url: createURL("listRouters&listAll=true&page=" + args.page + "&pagesize=" + pageSize + array1.join("")), - data: data2, + url: createURL("listZones&page=" + args.page + "&pagesize=" + pageSize + array1.join("")), + dataType: "json", + async: true, success: function(json) { - var items = json.listroutersresponse.router ? - json.listroutersresponse.router : []; - - $(items).map(function(index, item) { - routers.push(item); - }); - // Get project routers - $.ajax({ - url: createURL("listRouters&listAll=true&page=" + args.page + "&pagesize=" + pageSize + array1.join("") + "&projectid=-1"), - data: data2, - success: function(json) { - var items = json.listroutersresponse.router ? - json.listroutersresponse.router : []; - - $(items).map(function(index, item) { - routers.push(item); - }); - args.response.success({ - actionFilter: routerActionfilter, - data: $(routers).map(mapRouterType) - }); - } + var zoneObjs = json.listzonesresponse.zone; + if (zoneObjs != null) { + for (var i = 0; i < zoneObjs.length; i++) { + $.ajax({ + url: createURL('listRouters'), + data: { + zoneid: zoneObjs[i].id + }, + async: false, + success: function(json) { + if (json.listroutersresponse.count != undefined) { + zoneObjs[i].routerCount = json.listroutersresponse.count; + } else { + zoneObjs[i].routerCount = 0; + } + } + }); + } + } + args.response.success({ + data: zoneObjs }); } }); - }, - detailView: { - name: 'Virtual applicance details', - actions: { - start: { - label: 'label.action.start.router', - messages: { - confirm: function(args) { - return 'message.action.start.router'; - }, - notification: function(args) { - return 'label.action.start.router'; - } - }, - action: function(args) { - $.ajax({ - url: createURL('startRouter&id=' + args.context.routers[0].id), - dataType: 'json', - async: true, - success: function(json) { - var jid = json.startrouterresponse.jobid; - args.response.success({ - _custom: { - jobId: jid, - getUpdatedItem: function(json) { - return json.queryasyncjobresultresponse.jobresult.domainrouter; - }, - getActionFilter: function() { - return routerActionfilter; - } - } - }); - } - }); - }, - notification: { - poll: pollAsyncJobResult - } - }, - - stop: { - label: 'label.action.stop.router', - createForm: { - title: 'label.action.stop.router', - desc: 'message.action.stop.router', - fields: { - forced: { - label: 'force.stop', - isBoolean: true, - isChecked: false - } - } - }, - messages: { - notification: function(args) { - return 'label.action.stop.router'; - } - }, - action: function(args) { - var array1 = []; - array1.push("&forced=" + (args.data.forced == "on")); - $.ajax({ - url: createURL('stopRouter&id=' + args.context.routers[0].id + array1.join("")), - dataType: 'json', - async: true, - success: function(json) { - var jid = json.stoprouterresponse.jobid; - args.response.success({ - _custom: { - jobId: jid, - getUpdatedItem: function(json) { - return json.queryasyncjobresultresponse.jobresult.domainrouter; - }, - getActionFilter: function() { - return routerActionfilter; - } - } - }); - } - }); - }, - notification: { - poll: pollAsyncJobResult - } - }, - - upgradeRouterToUseNewerTemplate: { - label: 'Upgrade Router to Use Newer Template', - messages: { - confirm: function(args) { - return 'Please confirm that you want to upgrade router to use newer template'; - }, - notification: function (args) { - return 'Upgrade Router to Use Newer Template'; - } - }, - action: function (args) { - $.ajax({ - url: createURL('upgradeRouterTemplate'), - data: { - id: args.context.routers[0].id - }, - success: function (json) { - var jobs = json.upgraderoutertemplateresponse.asyncjobs; - if (jobs != undefined) { - args.response.success({ - _custom: { - jobId: jobs[0].jobid - } - }); - } - } - }); - }, - notification: { - poll: pollAsyncJobResult - } - }, - - 'remove': { - label: 'label.destroy.router', - messages: { - confirm: function(args) { - return 'message.confirm.destroy.router'; - }, - notification: function(args) { - return 'label.destroy.router'; - } - }, - action: function(args) { - $.ajax({ - url: createURL("destroyRouter&id=" + args.context.routers[0].id), - dataType: "json", - async: true, - success: function(json) { - var jid = json.destroyrouterresponse.jobid; - args.response.success({ - _custom: { - jobId: jid - } - }); - } - }); - }, - notification: { - poll: pollAsyncJobResult - } - }, - - restart: { - label: 'label.action.reboot.router', - messages: { - confirm: function(args) { - return 'message.action.reboot.router'; - }, - notification: function(args) { - return 'label.action.reboot.router'; - } - }, - action: function(args) { - $.ajax({ - url: createURL('rebootRouter&id=' + args.context.routers[0].id), - dataType: 'json', - async: true, - success: function(json) { - var jid = json.rebootrouterresponse.jobid; - args.response.success({ - _custom: { - jobId: jid, - getUpdatedItem: function(json) { - return json.queryasyncjobresultresponse.jobresult.domainrouter; - }, - getActionFilter: function() { - return routerActionfilter; - } - } - }); - } - }); - }, - notification: { - poll: pollAsyncJobResult - } - }, - - migrate: { - label: 'label.action.migrate.router', - createForm: { - title: 'label.action.migrate.router', - desc: '', - fields: { - hostId: { - label: 'label.host', - validation: { - required: true - }, - select: function(args) { - $.ajax({ - url: createURL("findHostsForMigration&VirtualMachineId=" + args.context.routers[0].id), - dataType: "json", - async: true, - success: function(json) { - var hostObjs = json.findhostsformigrationresponse.host; - var items = []; - $(hostObjs).each(function() { - items.push({ - id: this.id, - description: (this.name + " (" + (this.suitableformigration ? "Suitable" : "Not Suitable") + ")") - }); - }); - args.response.success({ - data: items - }); - } - }); - }, - error: function(XMLHttpResponse) { - var errorMsg = parseXMLHttpResponse(XMLHttpResponse); - args.response.error(errorMsg); - } - } - } - }, - messages: { - notification: function(args) { - return 'label.action.migrate.router'; - } - }, - action: function(args) { - $.ajax({ - url: createURL("migrateSystemVm&hostid=" + args.data.hostId + "&virtualmachineid=" + args.context.routers[0].id), - dataType: "json", - async: true, - success: function(json) { - var jid = json.migratesystemvmresponse.jobid; - args.response.success({ - _custom: { - jobId: jid, - getUpdatedItem: function(json) { - //return json.queryasyncjobresultresponse.jobresult.systemvminstance; //not all properties returned in systemvminstance - $.ajax({ - url: createURL("listRouters&id=" + json.queryasyncjobresultresponse.jobresult.systemvminstance.id), - dataType: "json", - async: false, - success: function(json) { - var items = json.listroutersresponse.router; - if (items != null && items.length > 0) { - return items[0]; - } - } - }); - }, - getActionFilter: function() { - return routerActionfilter; - } - } - }); - } - }); - }, - notification: { - poll: pollAsyncJobResult - } - }, - - scaleUp: { - label: 'label.change.service.offering', - createForm: { - title: 'label.change.service.offering', - desc: function(args) { - var description = ''; - var vmObj = args.jsonObj; - //if (vmObj.state == 'Running' && vmObj.hypervisor == 'VMware') { //needs to wait for API fix that will return hypervisor property - if (vmObj.state == 'Running') { - description = 'Please read the dynamic scaling section in the admin guide before scaling up.'; - } - return description; - }, - fields: { - serviceOfferingId: { - label: 'label.compute.offering', - select: function(args) { - $.ajax({ - url: createURL('listServiceOfferings'), - data: { - issystem: true, - systemvmtype: 'domainrouter' - }, - success: function(json) { - var serviceofferings = json.listserviceofferingsresponse.serviceoffering; - var items = []; - $(serviceofferings).each(function() { - // if(this.id != args.context.routers[0].serviceofferingid) { - items.push({ - id: this.id, - description: this.name - }); //default one (i.e. "System Offering For Software Router") doesn't have displaytext property. So, got to use name property instead. - - }); - args.response.success({ - data: items - }); - } - }); - } - } - } - }, - - action: function(args) { - $.ajax({ - url: createURL("scaleSystemVm&id=" + args.context.routers[0].id + "&serviceofferingid=" + args.data.serviceOfferingId), - dataType: "json", - async: true, - success: function(json) { - var jid = json.changeserviceforsystemvmresponse.jobid; - args.response.success({ - _custom: { - jobId: jid, - getUpdatedItem: function(json) { - return json.queryasyncjobresultresponse.jobresult.systemvm; - }, - getActionFilter: function() { - return routerActionfilter; - } - } - }); - - }, - error: function(json) { - args.response.error(parseXMLHttpResponse(json)); - } - - }); - }, - messages: { - confirm: function(args) { - return 'Do you really want to scale up the Router VM ?'; - }, - notification: function(args) { - - return 'Router VM Scaled Up'; - } - }, - notification: { - poll: pollAsyncJobResult - } - - }, - - - viewConsole: { - label: 'label.view.console', - action: { - externalLink: { - url: function(args) { - return clientConsoleUrl + '?cmd=access&vm=' + args.context.routers[0].id; - }, - title: function(args) { - return args.context.routers[0].id.substr(0, 8); //title in window.open() can't have space nor longer than 8 characters. Otherwise, IE browser will have error. - }, - width: 820, - height: 640 - } - } - } - }, - tabs: { - details: { - title: 'label.details', - preFilter: function(args) { - var hiddenFields = []; - if (!args.context.routers[0].project) { - hiddenFields.push('project'); - hiddenFields.push('projectid'); - } - $.ajax({ - url: createURL('listZones'), - data: { - id: args.context.routers[0].zoneid - }, - async: false, - success: function(json) { - if (json.listzonesresponse.zone != undefined) { - var zoneObj = json.listzonesresponse.zone[0]; - if (zoneObj.networktype == 'Basic') { - hiddenFields.push('publicip'); //In Basic zone, guest IP is public IP. So, publicip is not returned by listRouters API. Only guestipaddress is returned by listRouters API. - } - } - } - }); - - return hiddenFields; - }, - fields: [{ - name: { - label: 'label.name' - }, - project: { - label: 'label.project' - } - }, { - id: { - label: 'label.id' - }, - projectid: { - label: 'label.project.id' - }, - state: { - label: 'label.state' - }, - version: { - label: 'label.version' - }, - requiresupgrade: { - label: 'Requires Upgrade', - converter: cloudStack.converters.toBooleanText - }, - guestnetworkid: { - label: 'label.network.id' - }, - publicip: { - label: 'label.public.ip' - }, - guestipaddress: { - label: 'label.guest.ip' - }, - linklocalip: { - label: 'label.linklocal.ip' - }, - hostname: { - label: 'label.host' - }, - serviceofferingname: { - label: 'label.compute.offering' - }, - networkdomain: { - label: 'label.network.domain' - }, - domain: { - label: 'label.domain' - }, - account: { - label: 'label.account' - }, - created: { - label: 'label.created', - converter: cloudStack.converters.toLocalDate - }, - isredundantrouter: { - label: 'label.redundant.router', - converter: cloudStack.converters.toBooleanText - }, - redundantRouterState: { - label: 'label.redundant.state' - }, - vpcid: { - label: 'VPC ID' - } - }], - dataProvider: function(args) { - $.ajax({ - url: createURL("listRouters&id=" + args.context.routers[0].id), - dataType: 'json', - async: true, - success: function(json) { - var jsonObj = json.listroutersresponse.router[0]; - addExtraPropertiesToRouterInstanceObject(jsonObj); - args.response.success({ - actionFilter: routerActionfilter, - data: jsonObj - }); - } - }); - } - }, - nics: { - title: 'label.nics', - multiple: true, - fields: [{ - name: { - label: 'label.name', - header: true - }, - type: { - label: 'label.type' - }, - traffictype: { - label: 'label.traffic.type' - }, - networkname: { - label: 'label.network.name' - }, - netmask: { - label: 'label.netmask' - }, - ipaddress: { - label: 'label.ip.address' - }, - id: { - label: 'label.id' - }, - networkid: { - label: 'label.network.id' - }, - isolationuri: { - label: 'label.isolation.uri' - }, - broadcasturi: { - label: 'label.broadcast.uri' - } - }], - dataProvider: function(args) { - $.ajax({ - url: createURL("listRouters&id=" + args.context.routers[0].id), - dataType: 'json', - async: true, - success: function(json) { - var jsonObj = json.listroutersresponse.router[0].nic; - - args.response.success({ - actionFilter: routerActionfilter, - data: $.map(jsonObj, function(nic, index) { - var name = 'NIC ' + (index + 1); - if (nic.isdefault) { - name += ' (' + _l('label.default') + ')'; - } - return $.extend(nic, { - name: name - }); - }) - }); - } - }); - } - } - } } } - } + } } }, systemVms: {