Return-Path: X-Original-To: apmail-cloudstack-commits-archive@www.apache.org Delivered-To: apmail-cloudstack-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 45656C423 for ; Thu, 18 Jul 2013 16:35:15 +0000 (UTC) Received: (qmail 20875 invoked by uid 500); 18 Jul 2013 16:34:57 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 20747 invoked by uid 500); 18 Jul 2013 16:34:56 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 16782 invoked by uid 99); 18 Jul 2013 16:34:38 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 18 Jul 2013 16:34:38 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id D78B78AD83B; Thu, 18 Jul 2013 16:34:37 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sebgoa@apache.org To: commits@cloudstack.apache.org Date: Thu, 18 Jul 2013 16:35:09 -0000 Message-Id: <53d90e7298e94b58a4e7033899eda73e@git.apache.org> In-Reply-To: <36fb562163bf488f9855509299744ab0@git.apache.org> References: <36fb562163bf488f9855509299744ab0@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [34/39] Format JS http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ad69bc8d/ui/scripts/configuration.js ---------------------------------------------------------------------- diff --git a/ui/scripts/configuration.js b/ui/scripts/configuration.js index 8bc40d6..68f38ec 100644 --- a/ui/scripts/configuration.js +++ b/ui/scripts/configuration.js @@ -17,1788 +17,1978 @@ (function(cloudStack, $) { - var requiredNetworkOfferingExists = false; - var networkServiceObjs = [], serviceCheckboxNames = []; - var serviceFields = []; - - cloudStack.sections.configuration = { - title: 'label.menu.service.offerings', - id: 'configuration', - sectionSelect: { - label: 'label.select.offering' - }, - sections: { - serviceOfferings: { - type: 'select', - title: 'label.compute.offerings', - listView: { - id: 'serviceOfferings', - label: 'label.menu.service.offerings', - fields: { - name: { label: 'label.name', editable: true }, - displaytext: { label: 'label.description' } - }, - - reorder: cloudStack.api.actions.sort('updateServiceOffering', 'serviceOfferings'), - - actions: { - add: { - label: 'label.add.compute.offering', - - messages: { - confirm: function(args) { - return 'message.add.service.offering'; - }, - notification: function(args) { - return 'label.add.compute.offering'; - } - }, - - createForm: { - bigSize: true, - title: 'label.add.compute.offering', - fields: { - name: { - label: 'label.name', - docID: 'helpComputeOfferingName', - validation: { required: true } - }, - description: { - label: 'label.description', - docID: 'helpComputeOfferingDescription', - validation: { required: true } - }, - storageType: { - label: 'label.storage.type', - docID: 'helpComputeOfferingStorageType', - select: function(args) { - var items = []; - items.push({id: 'shared', description: 'shared'}); - items.push({id: 'local', description: 'local'}); - args.response.success({data: items}); - } - }, - cpuNumber: { - label: 'label.num.cpu.cores', - docID: 'helpComputeOfferingCPUCores', - validation: { - required: true, - number: true - } - }, - cpuSpeed: { - label: 'label.cpu.mhz', - docID: 'helpComputeOfferingCPUMHz', - validation: { - required: true, - number: true - } - }, - memory: { - label: 'label.memory.mb', - docID: 'helpComputeOfferingMemory', - validation: { - required: true, - number: true - } - }, - networkRate: { - label: 'label.network.rate', - docID: 'helpComputeOfferingNetworkRate', - validation: { - required: false, //optional - number: true - } - }, - diskBytesReadRate: { - label: 'label.disk.bytes.read.rate', - docID: 'helpComputeOfferingDiskBytesReadRate', - validation: { - required: false, //optional - number: true - } - }, - diskBytesWriteRate: { - label: 'label.disk.bytes.write.rate', - docID: 'helpComputeOfferingDiskBytesWriteRate', - validation: { - required: false, //optional - number: true - } - }, - diskIopsReadRate: { - label: 'label.disk.iops.read.rate', - docID: 'helpComputeOfferingDiskIopsReadRate', - validation: { - required: false, //optional - number: true - } - }, - diskIopsWriteRate: { - label: 'label.disk.iops.write.rate', - docID: 'helpComputeOfferingDiskIopsWriteRate', - validation: { - required: false, //optional - number: true - } - }, - offerHA: { - label: 'label.offer.ha', - docID: 'helpComputeOfferingHA', - isBoolean: true, - isChecked: false - }, - storageTags: { - label: 'label.storage.tags', - docID: 'helpComputeOfferingStorageType' - }, - hostTags: { - label: 'label.host.tags', - docID: 'helpComputeOfferingHostTags' - }, - cpuCap: { - label: 'label.CPU.cap', - isBoolean: true, - isChecked: false, - docID: 'helpComputeOfferingCPUCap' - }, - isPublic: { - label: 'label.public', - isBoolean: true, - isReverse: true, - isChecked: true, - docID: 'helpComputeOfferingPublic' - }, + var requiredNetworkOfferingExists = false; + var networkServiceObjs = [], + serviceCheckboxNames = []; + var serviceFields = []; + + cloudStack.sections.configuration = { + title: 'label.menu.service.offerings', + id: 'configuration', + sectionSelect: { + label: 'label.select.offering' + }, + sections: { + serviceOfferings: { + type: 'select', + title: 'label.compute.offerings', + listView: { + id: 'serviceOfferings', + label: 'label.menu.service.offerings', + fields: { + name: { + label: 'label.name', + editable: true + }, + displaytext: { + label: 'label.description' + } + }, - isVolatile:{ - label:'isVolatile', - isBoolean:true, - isChecked:false + reorder: cloudStack.api.actions.sort('updateServiceOffering', 'serviceOfferings'), + + actions: { + add: { + label: 'label.add.compute.offering', + + messages: { + confirm: function(args) { + return 'message.add.service.offering'; + }, + notification: function(args) { + return 'label.add.compute.offering'; + } + }, + + createForm: { + bigSize: true, + title: 'label.add.compute.offering', + fields: { + name: { + label: 'label.name', + docID: 'helpComputeOfferingName', + validation: { + required: true + } + }, + description: { + label: 'label.description', + docID: 'helpComputeOfferingDescription', + validation: { + required: true + } + }, + storageType: { + label: 'label.storage.type', + docID: 'helpComputeOfferingStorageType', + select: function(args) { + var items = []; + items.push({ + id: 'shared', + description: 'shared' + }); + items.push({ + id: 'local', + description: 'local' + }); + args.response.success({ + data: items + }); + } + }, + cpuNumber: { + label: 'label.num.cpu.cores', + docID: 'helpComputeOfferingCPUCores', + validation: { + required: true, + number: true + } + }, + cpuSpeed: { + label: 'label.cpu.mhz', + docID: 'helpComputeOfferingCPUMHz', + validation: { + required: true, + number: true + } + }, + memory: { + label: 'label.memory.mb', + docID: 'helpComputeOfferingMemory', + validation: { + required: true, + number: true + } + }, + networkRate: { + label: 'label.network.rate', + docID: 'helpComputeOfferingNetworkRate', + validation: { + required: false, //optional + number: true + } + }, + diskBytesReadRate: { + label: 'label.disk.bytes.read.rate', + docID: 'helpComputeOfferingDiskBytesReadRate', + validation: { + required: false, //optional + number: true + } + }, + diskBytesWriteRate: { + label: 'label.disk.bytes.write.rate', + docID: 'helpComputeOfferingDiskBytesWriteRate', + validation: { + required: false, //optional + number: true + } + }, + diskIopsReadRate: { + label: 'label.disk.iops.read.rate', + docID: 'helpComputeOfferingDiskIopsReadRate', + validation: { + required: false, //optional + number: true + } + }, + diskIopsWriteRate: { + label: 'label.disk.iops.write.rate', + docID: 'helpComputeOfferingDiskIopsWriteRate', + validation: { + required: false, //optional + number: true + } + }, + offerHA: { + label: 'label.offer.ha', + docID: 'helpComputeOfferingHA', + isBoolean: true, + isChecked: false + }, + storageTags: { + label: 'label.storage.tags', + docID: 'helpComputeOfferingStorageType' + }, + hostTags: { + label: 'label.host.tags', + docID: 'helpComputeOfferingHostTags' + }, + cpuCap: { + label: 'label.CPU.cap', + isBoolean: true, + isChecked: false, + docID: 'helpComputeOfferingCPUCap' + }, + isPublic: { + label: 'label.public', + isBoolean: true, + isReverse: true, + isChecked: true, + docID: 'helpComputeOfferingPublic' + }, + + isVolatile: { + label: 'isVolatile', + isBoolean: true, + isChecked: false + + }, + + deploymentPlanner: { + label: 'Deployment Planner', + select: function(args) { + $.ajax({ + url: createURL('listDeploymentPlanners'), + dataType: 'json', + success: function(json) { + var items = [{ + id: '', + description: '' + }]; + var plannerObjs = json.listdeploymentplannersresponse.deploymentPlanner; + $(plannerObjs).each(function() { + items.push({ + id: this.name, + description: this.name + }); + }); + args.response.success({ + data: items + }); + + + } + }); + } + }, + + // plannerKey:{label:'Planner Key' , docID:'helpImplicitPlannerKey'}, + plannerMode: { + label: 'Planner Mode', + select: function(args) { + var items = []; + items.push({ + id: '', + description: '' + }); + items.push({ + id: 'Strict', + description: 'Strict' + }); + items.push({ + id: 'Preferred', + description: 'Preferred' + }); + args.response.success({ + data: items + }); + } + }, + + domainId: { + label: 'label.domain', + docID: 'helpComputeOfferingDomain', + dependsOn: 'isPublic', + select: function(args) { + $.ajax({ + url: createURL("listDomains&listAll=true"), + dataType: "json", + async: false, + success: function(json) { + var items = []; + var domainObjs = json.listdomainsresponse.domain; + $(domainObjs).each(function() { + items.push({ + id: this.id, + description: this.path + }); + }); + args.response.success({ + data: items + }); + } + }); + }, + isHidden: true + } + } + }, + + action: function(args) { + var data = { + issystem: false, + name: args.data.name, + displaytext: args.data.description, + storageType: args.data.storageType, + cpuNumber: args.data.cpuNumber, + cpuSpeed: args.data.cpuSpeed, + memory: args.data.memory + }; - }, + if (args.data.deploymentPlanner != null && args.data.deploymentPlanner.length > 0) { + $.extend(data, { + deploymentplanner: args.data.deploymentPlanner + }); + } + + var array1 = []; + if (args.data.deploymentPlanner == "ImplicitDedicationPlanner" && args.data.plannerMode != "") { + array1.push("&serviceofferingdetails[0].ImplicitDedicationMode" + "=" + args.data.plannerMode); + } + + if (args.data.networkRate != null && args.data.networkRate.length > 0) { + $.extend(data, { + networkrate: args.data.networkRate + }); + } + if (args.data.diskBytesReadRate != null && args.data.diskBytesReadRate.length > 0) { + $.extend(data, { + bytesreadrate: args.data.diskBytesReadRate + }); + } + if (args.data.diskBytesWriteRate != null && args.data.diskBytesWriteRate.length > 0) { + $.extend(data, { + byteswriterate: args.data.diskBytesWriteRate + }); + } + if (args.data.diskIopsReadRate != null && args.data.diskIopsReadRate.length > 0) { + $.extend(data, { + iopsreadrate: args.data.diskIopsReadRate + }); + } + if (args.data.diskIopsWriteRate != null && args.data.diskIopsWriteRate.length > 0) { + $.extend(data, { + iopswriterate: args.data.diskIopsWriteRate + }); + } + $.extend(data, { + offerha: (args.data.offerHA == "on") + }); + + if (args.data.storageTags != null && args.data.storageTags.length > 0) { + $.extend(data, { + tags: args.data.storageTags + }); + } + + if (args.data.hostTags != null && args.data.hostTags.length > 0) { + $.extend(data, { + hosttags: args.data.hostTags + }); + } + + $.extend(data, { + limitcpuuse: (args.data.cpuCap == "on") + }); + + $.extend(data, { + isvolatile: (args.data.isVolatile == "on") + }); + + if (args.$form.find('.form-item[rel=domainId]').css("display") != "none") { + $.extend(data, { + domainid: args.data.domainId + }); + } + + $.ajax({ + url: createURL('createServiceOffering' + array1.join("")), + data: data, + success: function(json) { + var item = json.createserviceofferingresponse.serviceoffering; + args.response.success({ + data: item + }); + }, + error: function(data) { + args.response.error(parseXMLHttpResponse(data)); + } + }); + }, + + notification: { + poll: function(args) { + args.complete(); + } + } + } + }, - deploymentPlanner:{ - label:'Deployment Planner', - select:function(args){ - $.ajax({ - url:createURL('listDeploymentPlanners'), - dataType:'json', - success:function(json){ - var items=[{id: '', description: ''}]; - var plannerObjs = json.listdeploymentplannersresponse.deploymentPlanner; - $(plannerObjs).each(function(){ - items.push({id: this.name, description: this.name}); - }); - args.response.success({data: items}); + dataProvider: function(args) { + var data = {}; + listViewDataProvider(args, data); + $.extend(data, { + issystem: false + }); + $.ajax({ + url: createURL('listServiceOfferings'), + data: data, + success: function(json) { + var items = json.listserviceofferingsresponse.serviceoffering; + args.response.success({ + actionFitler: serviceOfferingActionfilter, + data: items + }); + }, + error: function(data) { + args.response.error(parseXMLHttpResponse(data)); } - }); - } - }, + }); + }, - // plannerKey:{label:'Planner Key' , docID:'helpImplicitPlannerKey'}, - plannerMode:{ - label:'Planner Mode', - select:function(args){ - var items=[]; - items.push({id:'',description:''}); - items.push({id:'Strict', description:'Strict'}); - items.push({id:'Preferred', description:'Preferred'}); - args.response.success({data:items}); - } - }, + detailView: { + name: 'Service offering details', + actions: { + edit: { + label: 'label.edit', + action: function(args) { + var data = { + id: args.context.serviceOfferings[0].id, + name: args.data.name, + displaytext: args.data.displaytext + }; + $.ajax({ + url: createURL('updateServiceOffering'), + data: data, + success: function(json) { + var item = json.updateserviceofferingresponse.serviceoffering; + args.response.success({ + data: item + }); + }, + error: function(data) { + args.response.error(parseXMLHttpResponse(data)); + } + }); + } + }, + + remove: { + label: 'label.action.delete.service.offering', + messages: { + confirm: function(args) { + return 'message.action.delete.service.offering'; + }, + notification: function(args) { + return 'label.action.delete.service.offering'; + } + }, + action: function(args) { + var data = { + id: args.context.serviceOfferings[0].id + }; + $.ajax({ + url: createURL('deleteServiceOffering'), + data: data, + async: true, + success: function(json) { + args.response.success(); + }, + error: function(data) { + args.response.error(parseXMLHttpResponse(data)); + } + }); + }, + notification: { + poll: function(args) { + args.complete(); + } + } + } + }, - domainId: { - label: 'label.domain', - docID: 'helpComputeOfferingDomain', - dependsOn: 'isPublic', - select: function(args) { - $.ajax({ - url: createURL("listDomains&listAll=true"), - dataType: "json", - async: false, - success: function(json) { - var items = []; - var domainObjs = json.listdomainsresponse.domain; - $(domainObjs).each(function(){ - items.push({id: this.id, description: this.path}); - }); - args.response.success({data: items}); + tabs: { + details: { + title: 'label.details', + + fields: [{ + name: { + label: 'label.name', + isEditable: true, + validation: { + required: true + } + } + }, { + id: { + label: 'label.id' + }, + displaytext: { + label: 'label.description', + isEditable: true, + validation: { + required: true + } + }, + storagetype: { + label: 'label.storage.type' + }, + cpunumber: { + label: 'label.num.cpu.cores' + }, + cpuspeed: { + label: 'label.cpu.mhz', + converter: function(args) { + return cloudStack.converters.convertHz(args); + } + }, + memory: { + label: 'label.memory.mb', + converter: function(args) { + return cloudStack.converters.convertBytes(args * 1024 * 1024); + } + }, + networkrate: { + label: 'label.network.rate' + }, + diskBytesReadRate: { + label: 'label.disk.bytes.read.rate' + }, + diskBytesWriteRate: { + label: 'label.disk.bytes.write.rate' + }, + diskIopsReadRate: { + label: 'label.disk.iops.read.rate' + }, + diskIopsWriteRate: { + label: 'label.disk.iops.write.rate' + }, + offerha: { + label: 'label.offer.ha', + converter: cloudStack.converters.toBooleanText + }, + limitcpuuse: { + label: 'label.CPU.cap', + converter: cloudStack.converters.toBooleanText + }, + isvolatile: { + label: 'Volatile', + converter: cloudStack.converters.toBooleanText + }, + deploymentplanner: { + label: 'Deployment Planner' + }, + tags: { + label: 'label.storage.tags' + }, + hosttags: { + label: 'label.host.tags' + }, + domain: { + label: 'label.domain' + }, + created: { + label: 'label.created', + converter: cloudStack.converters.toLocalDate + } + }], + + dataProvider: function(args) { + var data = { + issystem: false, + id: args.context.serviceOfferings[0].id + }; + $.ajax({ + url: createURL('listServiceOfferings'), + data: data, + async: true, + success: function(json) { + var item = json.listserviceofferingsresponse.serviceoffering[0]; + args.response.success({ + actionFitler: serviceOfferingActionfilter, + data: item + }); + } + }); + } + } } - }); - }, - isHidden: true - } - } - }, - - action: function(args) { - var data = { - issystem: false, - name: args.data.name, - displaytext: args.data.description, - storageType: args.data.storageType, - cpuNumber: args.data.cpuNumber, - cpuSpeed: args.data.cpuSpeed, - memory: args.data.memory - }; - - if(args.data.deploymentPlanner != null && args.data.deploymentPlanner.length > 0) { - $.extend(data, { - deploymentplanner: args.data.deploymentPlanner - }); - } - - var array1 =[]; - if(args.data.deploymentPlanner == "ImplicitDedicationPlanner" && args.data.plannerMode != ""){ - array1.push("&serviceofferingdetails[0].ImplicitDedicationMode" + "=" + args.data.plannerMode); - } - - if(args.data.networkRate != null && args.data.networkRate.length > 0) { - $.extend(data, { - networkrate: args.data.networkRate - }); - } - if(args.data.diskBytesReadRate != null && args.data.diskBytesReadRate.length > 0) { - $.extend(data, { - bytesreadrate: args.data.diskBytesReadRate - }); - } - if(args.data.diskBytesWriteRate != null && args.data.diskBytesWriteRate.length > 0) { - $.extend(data, { - byteswriterate: args.data.diskBytesWriteRate - }); - } - if(args.data.diskIopsReadRate != null && args.data.diskIopsReadRate.length > 0) { - $.extend(data, { - iopsreadrate: args.data.diskIopsReadRate - }); - } - if(args.data.diskIopsWriteRate != null && args.data.diskIopsWriteRate.length > 0) { - $.extend(data, { - iopswriterate: args.data.diskIopsWriteRate - }); - } - $.extend(data, { - offerha: (args.data.offerHA == "on") - }); - - if(args.data.storageTags != null && args.data.storageTags.length > 0) { - $.extend(data, { - tags: args.data.storageTags - }); - } - - if(args.data.hostTags != null && args.data.hostTags.length > 0) { - $.extend(data, { - hosttags: args.data.hostTags - }); - } - - $.extend(data, { - limitcpuuse: (args.data.cpuCap == "on") - }); - - $.extend(data, { - isvolatile: (args.data.isVolatile == "on") - }); - - if(args.$form.find('.form-item[rel=domainId]').css("display") != "none") { - $.extend(data, { - domainid: args.data.domainId - }); - } - - $.ajax({ - url: createURL('createServiceOffering' + array1.join("")), - data: data, - success: function(json) { - var item = json.createserviceofferingresponse.serviceoffering; - args.response.success({data: item}); - }, - error: function(data) { - args.response.error(parseXMLHttpResponse(data)); - } - }); - }, - - notification: { - poll: function(args) { - args.complete(); - } - } - } - }, - - dataProvider: function(args) { - var data = {}; - listViewDataProvider(args, data); - - $.extend(data, { - issystem: false - }); - - $.ajax({ - url: createURL('listServiceOfferings'), - data: data, - success: function(json) { - var items = json.listserviceofferingsresponse.serviceoffering; - args.response.success({ - actionFitler: serviceOfferingActionfilter, - data:items - }); - }, - error: function(data) { - args.response.error(parseXMLHttpResponse(data)); - } - }); - }, - - detailView: { - name: 'Service offering details', - actions: { - edit: { - label: 'label.edit', - action: function(args) { - var data = { - id: args.context.serviceOfferings[0].id, - name: args.data.name, - displaytext: args.data.displaytext - }; - $.ajax({ - url: createURL('updateServiceOffering'), - data: data, - success: function(json) { - var item = json.updateserviceofferingresponse.serviceoffering; - args.response.success({data: item}); - }, - error: function(data) { - args.response.error(parseXMLHttpResponse(data)); } - }); } - }, + }, - remove: { - label: 'label.action.delete.service.offering', - messages: { - confirm: function(args) { - return 'message.action.delete.service.offering'; - }, - notification: function(args) { - return 'label.action.delete.service.offering'; - } - }, - action: function(args) { - var data = { - id: args.context.serviceOfferings[0].id - }; - $.ajax({ - url: createURL('deleteServiceOffering'), - data: data, - async: true, - success: function(json) { - args.response.success(); + systemServiceOfferings: { + type: 'select', + title: 'label.menu.system.service.offerings', + listView: { + id: 'systemServiceOfferings', + label: 'label.menu.system.service.offerings', + fields: { + name: { + label: 'label.name', + editable: true + }, + displaytext: { + label: 'label.description' + } }, - error: function(data) { - args.response.error(parseXMLHttpResponse(data)); - } - }); - }, - notification: { - poll: function(args) { - args.complete(); - } - } - } - }, - tabs: { - details: { - title: 'label.details', + reorder: cloudStack.api.actions.sort('updateServiceOffering', 'systemServiceOfferings'), + + actions: { + add: { + label: 'label.add.system.service.offering', + + messages: { + confirm: function(args) { + return 'message.add.system.service.offering'; + }, + notification: function(args) { + return 'label.add.system.service.offering'; + } + }, + + createForm: { + title: 'label.add.system.service.offering', + fields: { + name: { + label: 'label.name', + validation: { + required: true + }, + docID: 'helpSystemOfferingName' + }, + description: { + label: 'label.description', + validation: { + required: true + }, + docID: 'helpSystemOfferingDescription' + }, + systemvmtype: { + label: 'label.system.vm.type', + docID: 'helpSystemOfferingVMType', + select: function(args) { + var items = []; + items.push({ + id: 'domainrouter', + description: dictionary['label.domain.router'] + }); + items.push({ + id: 'consoleproxy', + description: dictionary['label.console.proxy'] + }); + items.push({ + id: 'secondarystoragevm', + description: dictionary['label.secondary.storage.vm'] + }); + args.response.success({ + data: items + }); + } + }, + storageType: { + label: 'label.storage.type', + docID: 'helpSystemOfferingStorageType', + select: function(args) { + var items = []; + items.push({ + id: 'shared', + description: 'shared' + }); + items.push({ + id: 'local', + description: 'local' + }); + args.response.success({ + data: items + }); + } + }, + cpuNumber: { + label: 'label.num.cpu.cores', + docID: 'helpSystemOfferingCPUCores', + validation: { + required: true, + number: true + } + }, + cpuSpeed: { + label: 'label.cpu.mhz', + docID: 'helpSystemOfferingCPUMHz', + validation: { + required: true, + number: true + } + }, + memory: { + label: 'label.memory.mb', + docID: 'helpSystemOfferingMemory', + validation: { + required: true, + number: true + } + }, + networkRate: { + label: 'label.network.rate', + docID: 'helpSystemOfferingNetworkRate', + validation: { + required: false, //optional + number: true + } + }, + diskBytesReadRate: { + label: 'label.disk.bytes.read.rate', + docID: 'helpSystemOfferingDiskBytesReadRate', + validation: { + required: false, //optional + number: true + } + }, + diskBytesWriteRate: { + label: 'label.disk.bytes.write.rate', + docID: 'helpSystemOfferingDiskBytesWriteRate', + validation: { + required: false, //optional + number: true + } + }, + diskIopsReadRate: { + label: 'label.disk.iops.read.rate', + docID: 'helpSystemOfferingDiskIopsReadRate', + validation: { + required: false, //optional + number: true + } + }, + diskIopsWriteRate: { + label: 'label.disk.iops.write.rate', + docID: 'helpSystemOfferingDiskIopsWriteRate', + validation: { + required: false, //optional + number: true + } + }, + offerHA: { + label: 'label.offer.ha', + docID: 'helpSystemOfferingHA', + isBoolean: true, + isChecked: false + }, + storageTags: { + label: 'label.storage.tags', + docID: 'helpSystemOfferingStorageTags' + }, + hostTags: { + label: 'label.host.tags', + docID: 'helpSystemOfferingHostTags' + }, + cpuCap: { + label: 'label.CPU.cap', + isBoolean: true, + isChecked: false, + docID: 'helpSystemOfferingCPUCap' + }, + isPublic: { + label: 'label.public', + isBoolean: true, + isReverse: true, + isChecked: true, + docID: 'helpSystemOfferingPublic' + }, + domainId: { + label: 'label.domain', + docID: 'helpSystemOfferingDomain', + dependsOn: 'isPublic', + select: function(args) { + $.ajax({ + url: createURL("listDomains&listAll=true"), + dataType: "json", + async: false, + success: function(json) { + var items = []; + var domainObjs = json.listdomainsresponse.domain; + $(domainObjs).each(function() { + items.push({ + id: this.id, + description: this.path + }); + }); + args.response.success({ + data: items + }); + } + }); + }, + isHidden: true + } + } + }, + + action: function(args) { + var data = { + issystem: true, + name: args.data.name, + displaytext: args.data.description, + systemvmtype: args.data.systemvmtype, + storageType: args.data.storageType, + cpuNumber: args.data.cpuNumber, + cpuSpeed: args.data.cpuSpeed, + memory: args.data.memory + }; - fields: [ - { - name: { - label: 'label.name', - isEditable: true, - validation: { required: true } - } - }, - { - id: { label: 'label.id' }, - displaytext: { - label: 'label.description', - isEditable: true, - validation: { required: true } - }, - storagetype: { label: 'label.storage.type' }, - cpunumber: { label: 'label.num.cpu.cores' }, - cpuspeed: { - label: 'label.cpu.mhz', - converter: function(args) { - return cloudStack.converters.convertHz(args); - } - }, - memory: { - label: 'label.memory.mb', - converter: function(args) { - return cloudStack.converters.convertBytes(args*1024*1024); - } - }, - networkrate: { label: 'label.network.rate' }, - diskBytesReadRate: { label: 'label.disk.bytes.read.rate' }, - diskBytesWriteRate: { label: 'label.disk.bytes.write.rate' }, - diskIopsReadRate: { label: 'label.disk.iops.read.rate' }, - diskIopsWriteRate: { label: 'label.disk.iops.write.rate' }, - offerha: { - label: 'label.offer.ha', - converter: cloudStack.converters.toBooleanText - }, - limitcpuuse: { - label: 'label.CPU.cap', - converter: cloudStack.converters.toBooleanText - }, - isvolatile:{ label:'Volatile' , converter: cloudStack.converters.toBooleanText }, - deploymentplanner:{label:'Deployment Planner'}, - tags: { label: 'label.storage.tags' }, - hosttags: { label: 'label.host.tags' }, - domain: { label: 'label.domain' }, - created: { label: 'label.created', converter: cloudStack.converters.toLocalDate } - } - ], - - dataProvider: function(args) { - var data = { - issystem: false, - id: args.context.serviceOfferings[0].id - }; - $.ajax({ - url: createURL('listServiceOfferings'), - data: data, - async: true, - success: function(json) { - var item = json.listserviceofferingsresponse.serviceoffering[0]; - args.response.success({ - actionFitler: serviceOfferingActionfilter, - data: item - }); - } - }); - } - } - } - } - } - }, - - systemServiceOfferings: { - type: 'select', - title: 'label.menu.system.service.offerings', - listView: { - id: 'systemServiceOfferings', - label: 'label.menu.system.service.offerings', - fields: { - name: { - label: 'label.name', - editable: true - }, - displaytext: { - label: 'label.description' - } - }, - - reorder: cloudStack.api.actions.sort('updateServiceOffering', 'systemServiceOfferings'), - - actions: { - add: { - label: 'label.add.system.service.offering', - - messages: { - confirm: function(args) { - return 'message.add.system.service.offering'; - }, - notification: function(args) { - return 'label.add.system.service.offering'; - } - }, - - createForm: { - title: 'label.add.system.service.offering', - fields: { - name: { - label: 'label.name', - validation: { required: true }, - docID: 'helpSystemOfferingName' - }, - description: { - label: 'label.description', - validation: { required: true }, - docID: 'helpSystemOfferingDescription' - }, - systemvmtype: { - label: 'label.system.vm.type', - docID: 'helpSystemOfferingVMType', - select: function(args) { - var items = []; - items.push({id: 'domainrouter', description: dictionary['label.domain.router']}); - items.push({id: 'consoleproxy', description: dictionary['label.console.proxy']}); - items.push({id: 'secondarystoragevm', description: dictionary['label.secondary.storage.vm']}); - args.response.success({data: items}); - } - }, - storageType: { - label: 'label.storage.type', - docID: 'helpSystemOfferingStorageType', - select: function(args) { - var items = []; - items.push({id: 'shared', description: 'shared'}); - items.push({id: 'local', description: 'local'}); - args.response.success({data: items}); - } - }, - cpuNumber: { - label: 'label.num.cpu.cores', - docID: 'helpSystemOfferingCPUCores', - validation: { - required: true, - number: true - } - }, - cpuSpeed: { - label: 'label.cpu.mhz', - docID: 'helpSystemOfferingCPUMHz', - validation: { - required: true, - number: true - } - }, - memory: { - label: 'label.memory.mb', - docID: 'helpSystemOfferingMemory', - validation: { - required: true, - number: true - } - }, - networkRate: { - label: 'label.network.rate', - docID: 'helpSystemOfferingNetworkRate', - validation: { - required: false, //optional - number: true - } - }, - diskBytesReadRate: { - label: 'label.disk.bytes.read.rate', - docID: 'helpSystemOfferingDiskBytesReadRate', - validation: { - required: false, //optional - number: true - } - }, - diskBytesWriteRate: { - label: 'label.disk.bytes.write.rate', - docID: 'helpSystemOfferingDiskBytesWriteRate', - validation: { - required: false, //optional - number: true - } - }, - diskIopsReadRate: { - label: 'label.disk.iops.read.rate', - docID: 'helpSystemOfferingDiskIopsReadRate', - validation: { - required: false, //optional - number: true - } - }, - diskIopsWriteRate: { - label: 'label.disk.iops.write.rate', - docID: 'helpSystemOfferingDiskIopsWriteRate', - validation: { - required: false, //optional - number: true - } - }, - offerHA: { - label: 'label.offer.ha', - docID: 'helpSystemOfferingHA', - isBoolean: true, - isChecked: false - }, - storageTags: { - label: 'label.storage.tags', - docID: 'helpSystemOfferingStorageTags' - }, - hostTags: { - label: 'label.host.tags', - docID: 'helpSystemOfferingHostTags' - }, - cpuCap: { - label: 'label.CPU.cap', - isBoolean: true, - isChecked: false, - docID: 'helpSystemOfferingCPUCap' - }, - isPublic: { - label: 'label.public', - isBoolean: true, - isReverse: true, - isChecked: true, - docID: 'helpSystemOfferingPublic' - }, - domainId: { - label: 'label.domain', - docID: 'helpSystemOfferingDomain', - dependsOn: 'isPublic', - select: function(args) { - $.ajax({ - url: createURL("listDomains&listAll=true"), - dataType: "json", - async: false, - success: function(json) { - var items = []; - var domainObjs = json.listdomainsresponse.domain; - $(domainObjs).each(function(){ - items.push({id: this.id, description: this.path}); - }); - args.response.success({data: items}); + if (args.data.networkRate != null && args.data.networkRate.length > 0) { + $.extend(data, { + networkrate: args.data.networkRate + }); + } + if (args.data.diskBytesReadRate != null && args.data.diskBytesReadRate.length > 0) { + $.extend(data, { + bytesreadrate: args.data.diskBytesReadRate + }); + } + if (args.data.diskBytesWriteRate != null && args.data.diskBytesWriteRate.length > 0) { + $.extend(data, { + byteswriterate: args.data.diskBytesWriteRate + }); + } + if (args.data.diskIopsReadRate != null && args.data.diskIopsReadRate.length > 0) { + $.extend(data, { + iopsreadrate: args.data.diskIopsReadRate + }); + } + if (args.data.diskIopsWriteRate != null && args.data.diskIopsWriteRate.length > 0) { + $.extend(data, { + iopswriterate: args.data.diskIopsWriteRate + }); + } + + $.extend(data, { + offerha: (args.data.offerHA == "on") + }); + + if (args.data.storageTags != null && args.data.storageTags.length > 0) { + $.extend(data, { + tags: args.data.storageTags + }); + } + + if (args.data.hostTags != null && args.data.hostTags.length > 0) { + $.extend(data, { + hosttags: args.data.hostTags + }); + } + + $.extend(data, { + limitcpuuse: (args.data.cpuCap == "on") + }); + + if (args.$form.find('.form-item[rel=domainId]').css("display") != "none") { + $.extend(data, { + domainid: args.data.domainId + }); + } + + $.ajax({ + url: createURL('createServiceOffering'), + data: data, + success: function(json) { + var item = json.createserviceofferingresponse.serviceoffering; + args.response.success({ + data: item + }); + }, + error: function(data) { + args.response.error(parseXMLHttpResponse(data)); + } + }); + }, + + notification: { + poll: function(args) { + args.complete(); + } + } } - }); }, - isHidden: true - } - } - }, - - action: function(args) { - var data = { - issystem: true, - name: args.data.name, - displaytext: args.data.description, - systemvmtype: args.data.systemvmtype, - storageType: args.data.storageType, - cpuNumber: args.data.cpuNumber, - cpuSpeed: args.data.cpuSpeed, - memory: args.data.memory - }; - - if(args.data.networkRate != null && args.data.networkRate.length > 0) { - $.extend(data, { - networkrate: args.data.networkRate - }); - } - if(args.data.diskBytesReadRate != null && args.data.diskBytesReadRate.length > 0) { - $.extend(data, { - bytesreadrate: args.data.diskBytesReadRate - }); - } - if(args.data.diskBytesWriteRate != null && args.data.diskBytesWriteRate.length > 0) { - $.extend(data, { - byteswriterate: args.data.diskBytesWriteRate - }); - } - if(args.data.diskIopsReadRate != null && args.data.diskIopsReadRate.length > 0) { - $.extend(data, { - iopsreadrate: args.data.diskIopsReadRate - }); - } - if(args.data.diskIopsWriteRate != null && args.data.diskIopsWriteRate.length > 0) { - $.extend(data, { - iopswriterate: args.data.diskIopsWriteRate - }); - } - $.extend(data, { - offerha: (args.data.offerHA == "on") - }); - - if(args.data.storageTags != null && args.data.storageTags.length > 0) { - $.extend(data, { - tags: args.data.storageTags - }); - } - - if(args.data.hostTags != null && args.data.hostTags.length > 0) { - $.extend(data, { - hosttags: args.data.hostTags - }); - } - - $.extend(data, { - limitcpuuse: (args.data.cpuCap == "on") - }); - - if(args.$form.find('.form-item[rel=domainId]').css("display") != "none") { - $.extend(data, { - domainid: args.data.domainId - }); - } - - $.ajax({ - url: createURL('createServiceOffering'), - data: data, - success: function(json) { - var item = json.createserviceofferingresponse.serviceoffering; - args.response.success({data: item}); - }, - error: function(data) { - args.response.error(parseXMLHttpResponse(data)); - } - }); - }, - - notification: { - poll: function(args) { - args.complete(); - } - } - } - }, - - dataProvider: function(args) { - var data = {}; - listViewDataProvider(args, data); - - $.extend(data, { - issystem: true - }); - - $.ajax({ - url: createURL('listServiceOfferings'), - data: data, - success: function(json) { - var items = json.listserviceofferingsresponse.serviceoffering; - args.response.success({data:items}); - }, - error: function(data) { - args.response.error(parseXMLHttpResponse(data)); - } - }); - }, - - detailView: { - name: 'System service offering details', - actions: { - edit: { - label: 'label.edit', - action: function(args) { - var data = { - id: args.context.systemServiceOfferings[0].id, - name: args.data.name, - displaytext: args.data.displaytext - }; - $.ajax({ - url: createURL('updateServiceOffering'), - data: data, - success: function(json) { - var item = json.updateserviceofferingresponse.serviceoffering; - args.response.success({data: item}); - }, - error: function(data) { - args.response.error(parseXMLHttpResponse(data)); - } - }); - } - }, + dataProvider: function(args) { + var data = {}; + listViewDataProvider(args, data); - remove: { - label: 'label.action.delete.system.service.offering', - messages: { - confirm: function(args) { - return 'message.action.delete.system.service.offering'; - }, - notification: function(args) { - return 'label.action.delete.system.service.offering'; - } - }, - action: function(args) { - var data = { - id: args.context.systemServiceOfferings[0].id - }; - $.ajax({ - url: createURL('deleteServiceOffering'), - data: data, - success: function(json) { - args.response.success(); + $.extend(data, { + issystem: true + }); + + $.ajax({ + url: createURL('listServiceOfferings'), + data: data, + success: function(json) { + var items = json.listserviceofferingsresponse.serviceoffering; + args.response.success({ + data: items + }); + }, + error: function(data) { + args.response.error(parseXMLHttpResponse(data)); + } + }); }, - error: function(data) { - args.response.error(parseXMLHttpResponse(data)); - } - }); - }, - notification: { - poll: function(args) { - args.complete(); - } - } - } - }, - tabs: { - details: { - title: 'label.details', + detailView: { + name: 'System service offering details', + actions: { + edit: { + label: 'label.edit', + action: function(args) { + var data = { + id: args.context.systemServiceOfferings[0].id, + name: args.data.name, + displaytext: args.data.displaytext + }; + $.ajax({ + url: createURL('updateServiceOffering'), + data: data, + success: function(json) { + var item = json.updateserviceofferingresponse.serviceoffering; + args.response.success({ + data: item + }); + }, + error: function(data) { + args.response.error(parseXMLHttpResponse(data)); + } + }); + } + }, + + remove: { + label: 'label.action.delete.system.service.offering', + messages: { + confirm: function(args) { + return 'message.action.delete.system.service.offering'; + }, + notification: function(args) { + return 'label.action.delete.system.service.offering'; + } + }, + action: function(args) { + var data = { + id: args.context.systemServiceOfferings[0].id + }; + $.ajax({ + url: createURL('deleteServiceOffering'), + data: data, + success: function(json) { + args.response.success(); + }, + error: function(data) { + args.response.error(parseXMLHttpResponse(data)); + } + }); + }, + notification: { + poll: function(args) { + args.complete(); + } + } + } + }, - fields: [ - { - name: { - label: 'label.name', - isEditable: true, - validation: { required: true } + tabs: { + details: { + title: 'label.details', + + fields: [{ + name: { + label: 'label.name', + isEditable: true, + validation: { + required: true + } + } + }, { + id: { + label: 'label.id' + }, + displaytext: { + label: 'label.description', + isEditable: true, + validation: { + required: true + } + }, + systemvmtype: { + label: 'label.system.vm.type', + converter: function(args) { + var text = ''; + switch (args) { + case 'domainrouter': + text = dictionary['label.domain.router']; + break; + case 'consoleproxy': + text = dictionary['label.console.proxy']; + break; + case 'secondarystoragevm': + text = dictionary['label.secondary.storage.vm']; + break; + } + return text; + } + }, + storagetype: { + label: 'label.storage.type' + }, + cpunumber: { + label: 'label.num.cpu.cores' + }, + cpuspeed: { + label: 'label.cpu.mhz', + converter: function(args) { + return cloudStack.converters.convertHz(args); + } + }, + memory: { + label: 'label.memory.mb', + converter: function(args) { + return cloudStack.converters.convertBytes(args * 1024 * 1024); + } + }, + networkrate: { + label: 'label.network.rate' + }, + diskBytesReadRate: { + label: 'label.disk.bytes.write.rate' + }, + diskBytesWriteRate: { + label: 'label.disk.bytes.write.rate' + }, + diskIopsReadRate: { + label: 'label.disk.iops.write.rate' + }, + diskIopsWriteRate: { + label: 'label.disk.iops.write.rate' + }, + offerha: { + label: 'label.offer.ha', + converter: cloudStack.converters.toBooleanText + }, + limitcpuuse: { + label: 'label.CPU.cap', + converter: cloudStack.converters.toBooleanText + }, + tags: { + label: 'label.storage.tags' + }, + hosttags: { + label: 'label.host.tags' + }, + domain: { + label: 'label.domain' + }, + created: { + label: 'label.created', + converter: cloudStack.converters.toLocalDate + } + }], + + dataProvider: function(args) { +