diff --git a/ui/scripts/configuration.js b/ui/scripts/configuration.js index 7dbf1e287ae..d9297f81b2e 100644 --- a/ui/scripts/configuration.js +++ b/ui/scripts/configuration.js @@ -13,10 +13,10 @@ label: 'Service Offerings', fields: { name: { label: 'Name', editable: true }, - displaytext: { label: 'Description' } + displaytext: { label: 'Description' } }, - - actions: { + + actions: { add: { label: 'Add service offering', @@ -36,7 +36,7 @@ }, createForm: { - title: 'Add service offering', + title: 'Add service offering', fields: { name: { label: 'Name', @@ -57,30 +57,30 @@ }, cpuNumber: { label: '# of CPU cores', - validation: { - required: true, - number: true + validation: { + required: true, + number: true } }, cpuSpeed: { label: 'CPU (in MHz)', - validation: { - required: true, - number: true + validation: { + required: true, + number: true } }, memory: { label: 'Memory (in MB)', - validation: { - required: true, - number: true + validation: { + required: true, + number: true } }, networkRate: { label: 'Network rate', - validation: { + validation: { required: false, //optional - number: true + number: true } }, offerHA: { @@ -98,68 +98,68 @@ label: 'CPU cap', isBoolean: true, isChecked: false - }, + }, isPublic: { label: 'Public', isBoolean: true, isReverse: true, - isChecked: true + isChecked: true }, domainId: { label: 'Domain', - dependsOn: 'isPublic', - select: function(args) { + dependsOn: 'isPublic', + select: function(args) { $.ajax({ url: createURL("listDomains"), dataType: "json", async: false, success: function(json) { var items = []; - var domainObjs = json.listdomainsresponse.domain; - $(domainObjs).each(function(){ + var domainObjs = json.listdomainsresponse.domain; + $(domainObjs).each(function(){ items.push({id: this.id, description: this.name}); - }); + }); args.response.success({data: items}); } - }); + }); }, isHidden: true - } + } } }, action: function(args) { - var array1 = []; + var array1 = []; array1.push("&name=" + args.data.name); array1.push("&displaytext=" + todb(args.data.description)); - array1.push("&storageType=" + todb(args.data.storageType)); - array1.push("&cpuNumber=" + args.data.cpuNumber); - array1.push("&cpuSpeed="+ args.data.cpuSpeed); - array1.push("&memory=" + args.data.memory); - + array1.push("&storageType=" + todb(args.data.storageType)); + array1.push("&cpuNumber=" + args.data.cpuNumber); + array1.push("&cpuSpeed="+ args.data.cpuSpeed); + array1.push("&memory=" + args.data.memory); + if(args.data.networkRate != null && args.data.networkRate.length > 0) - array1.push("&networkrate=" + args.data.networkRate); - - array1.push("&offerha=" + (args.data.offerHA == "on")); - + array1.push("&networkrate=" + args.data.networkRate); + + array1.push("&offerha=" + (args.data.offerHA == "on")); + if(args.data.storageTags != null && args.data.storageTags.length > 0) - array1.push("&tags=" + todb(args.data.storageTags)); - + array1.push("&tags=" + todb(args.data.storageTags)); + if(args.data.hostTags != null && args.data.hostTags.length > 0) - array1.push("&hosttags=" + todb(args.data.hostTags)); - - array1.push("&limitcpuuse=" + (args.data.cpuCap == "on")); - - if(args.$form.find('.form-item[rel=domainId]').css("display") != "none") - array1.push("&domainid=" + args.data.domainId); - + array1.push("&hosttags=" + todb(args.data.hostTags)); + + array1.push("&limitcpuuse=" + (args.data.cpuCap == "on")); + + if(args.$form.find('.form-item[rel=domainId]').css("display") != "none") + array1.push("&domainid=" + args.data.domainId); + $.ajax({ url: createURL("createServiceOffering&issystem=false"+array1.join("")), dataType: "json", async: true, - success: function(json) { - var item = json.createserviceofferingresponse.serviceoffering; - args.response.success({data: item}); + success: function(json) { + var item = json.createserviceofferingresponse.serviceoffering; + args.response.success({data: item}); } }); }, @@ -170,8 +170,8 @@ } } } - }, - + }, + dataProvider: function(args) { $.ajax({ url: createURL("listServiceOfferings&issystem=false&page=" + args.page + "&pagesize=" + pageSize), @@ -186,27 +186,27 @@ } }); }, - + detailView: { name: 'Service offering details', - actions: { + actions: { edit: { label: 'Edit', action: function(args) { var array1 = []; array1.push("&name=" + todb(args.data.name)); - array1.push("&displaytext=" + todb(args.data.displaytext)); + array1.push("&displaytext=" + todb(args.data.displaytext)); $.ajax({ url: createURL("updateServiceOffering&id=" + args.context.serviceOfferings[0].id + array1.join("")), dataType: "json", - success: function(json) { - var item = json.updateserviceofferingresponse.serviceoffering; + success: function(json) { + var item = json.updateserviceofferingresponse.serviceoffering; args.response.success({data: item}); } }); } }, - + 'delete': { label: 'Delete service offering', messages: { @@ -223,7 +223,7 @@ return 'Service offering has been deleted.'; } }, - action: function(args) { + action: function(args) { $.ajax({ url: createURL("deleteServiceOffering&id=" + args.context.serviceOfferings[0].id), dataType: "json", @@ -238,37 +238,37 @@ args.complete(); } } - } - }, - + } + }, + tabs: { details: { title: 'Details', fields: [ - { - name: { - label: 'Name', - isEditable: true + { + name: { + label: 'Name', + isEditable: true } - }, + }, { id: { label: 'ID' }, - displaytext: { + displaytext: { label: 'Description', - isEditable: true - }, + isEditable: true + }, storagetype: { label: 'Storage Type' }, cpunumber: { label: 'CPU number' }, - cpuspeed: { - label: 'CPU speed', - converter: function(args) { + cpuspeed: { + label: 'CPU speed', + converter: function(args) { return cloudStack.converters.convertHz(args); } }, - memory: { + memory: { label: 'Memory', - converter: function(args) { + converter: function(args) { return cloudStack.converters.convertBytes(args*1024*1024); } }, @@ -277,14 +277,14 @@ label: 'Offer HA', converter: cloudStack.converters.toBooleanText }, - limitcpuuse: { + limitcpuuse: { label: 'CPU cap', converter: cloudStack.converters.toBooleanText }, tags: { label: 'Storage tags' }, hosttags: { label: 'Host tags' }, domain: { label: 'Domain' }, - created: { label: 'Created' } + created: { label: 'Created' } } ], @@ -298,7 +298,7 @@ } } } - } + } } }, @@ -309,10 +309,10 @@ label: 'System Service Offerings', fields: { name: { label: 'Name', editable: true }, - displaytext: { label: 'Description' } + displaytext: { label: 'Description' } }, - - actions: { + + actions: { add: { label: 'Add system service offering', @@ -332,7 +332,7 @@ }, createForm: { - title: 'Add system service offering', + title: 'Add system service offering', fields: { name: { label: 'Name', @@ -353,30 +353,30 @@ }, cpuNumber: { label: '# of CPU cores', - validation: { - required: true, - number: true + validation: { + required: true, + number: true } }, cpuSpeed: { label: 'CPU (in MHz)', - validation: { - required: true, - number: true + validation: { + required: true, + number: true } }, memory: { label: 'Memory (in MB)', - validation: { - required: true, - number: true + validation: { + required: true, + number: true } }, networkRate: { label: 'Network rate', - validation: { + validation: { required: false, //optional - number: true + number: true } }, offerHA: { @@ -394,68 +394,68 @@ label: 'CPU cap', isBoolean: true, isChecked: false - }, + }, isPublic: { label: 'Public', isBoolean: true, isReverse: true, - isChecked: true + isChecked: true }, domainId: { label: 'Domain', - dependsOn: 'isPublic', - select: function(args) { + dependsOn: 'isPublic', + select: function(args) { $.ajax({ url: createURL("listDomains"), dataType: "json", async: false, success: function(json) { var items = []; - var domainObjs = json.listdomainsresponse.domain; - $(domainObjs).each(function(){ + var domainObjs = json.listdomainsresponse.domain; + $(domainObjs).each(function(){ items.push({id: this.id, description: this.name}); - }); + }); args.response.success({data: items}); } - }); + }); }, isHidden: true - } + } } }, action: function(args) { - var array1 = []; + var array1 = []; array1.push("&name=" + args.data.name); array1.push("&displaytext=" + todb(args.data.description)); - array1.push("&storageType=" + todb(args.data.storageType)); - array1.push("&cpuNumber=" + args.data.cpuNumber); - array1.push("&cpuSpeed="+ args.data.cpuSpeed); - array1.push("&memory=" + args.data.memory); - + array1.push("&storageType=" + todb(args.data.storageType)); + array1.push("&cpuNumber=" + args.data.cpuNumber); + array1.push("&cpuSpeed="+ args.data.cpuSpeed); + array1.push("&memory=" + args.data.memory); + if(args.data.networkRate != null && args.data.networkRate.length > 0) - array1.push("&networkrate=" + args.data.networkRate); - - array1.push("&offerha=" + (args.data.offerHA == "on")); - + array1.push("&networkrate=" + args.data.networkRate); + + array1.push("&offerha=" + (args.data.offerHA == "on")); + if(args.data.storageTags != null && args.data.storageTags.length > 0) - array1.push("&tags=" + todb(args.data.storageTags)); - + array1.push("&tags=" + todb(args.data.storageTags)); + if(args.data.hostTags != null && args.data.hostTags.length > 0) - array1.push("&hosttags=" + todb(args.data.hostTags)); - - array1.push("&limitcpuuse=" + (args.data.cpuCap == "on")); - - if(args.$form.find('.form-item[rel=domainId]').css("display") != "none") - array1.push("&domainid=" + args.data.domainId); - + array1.push("&hosttags=" + todb(args.data.hostTags)); + + array1.push("&limitcpuuse=" + (args.data.cpuCap == "on")); + + if(args.$form.find('.form-item[rel=domainId]').css("display") != "none") + array1.push("&domainid=" + args.data.domainId); + $.ajax({ url: createURL("createServiceOffering&issystem=true"+array1.join("")), dataType: "json", async: true, - success: function(json) { - var item = json.createserviceofferingresponse.serviceoffering; - args.response.success({data: item}); + success: function(json) { + var item = json.createserviceofferingresponse.serviceoffering; + args.response.success({data: item}); } }); }, @@ -467,7 +467,7 @@ } } }, - + dataProvider: function(args) { $.ajax({ url: createURL("listServiceOfferings&issystem=true&page="+args.page+"&pagesize="+pageSize), @@ -479,27 +479,27 @@ } }); }, - + detailView: { name: 'System service offering details', - actions: { + actions: { edit: { label: 'Edit', action: function(args) { var array1 = []; array1.push("&name=" + todb(args.data.name)); - array1.push("&displaytext=" + todb(args.data.displaytext)); + array1.push("&displaytext=" + todb(args.data.displaytext)); $.ajax({ url: createURL("updateServiceOffering&id=" + args.context.systemServiceOfferings[0].id + array1.join("")), dataType: "json", - success: function(json) { - var item = json.updateserviceofferingresponse.serviceoffering; + success: function(json) { + var item = json.updateserviceofferingresponse.serviceoffering; args.response.success({data: item}); } }); } }, - + 'delete': { label: 'Delete system service offering', messages: { @@ -516,7 +516,7 @@ return 'System service offering has been deleted.'; } }, - action: function(args) { + action: function(args) { $.ajax({ url: createURL("deleteServiceOffering&id=" + args.context.systemServiceOfferings[0].id), dataType: "json", @@ -531,37 +531,37 @@ args.complete(); } } - } - }, - + } + }, + tabs: { details: { title: 'Details', fields: [ - { - name: { - label: 'Name', - isEditable: true + { + name: { + label: 'Name', + isEditable: true } - }, + }, { id: { label: 'ID' }, - displaytext: { + displaytext: { label: 'Description', - isEditable: true - }, + isEditable: true + }, storagetype: { label: 'Storage Type' }, cpunumber: { label: 'CPU number' }, - cpuspeed: { - label: 'CPU speed', - converter: function(args) { + cpuspeed: { + label: 'CPU speed', + converter: function(args) { return cloudStack.converters.convertHz(args); } }, - memory: { + memory: { label: 'Memory', - converter: function(args) { + converter: function(args) { return cloudStack.converters.convertBytes(args*1024*1024); } }, @@ -570,14 +570,14 @@ label: 'Offer HA', converter: cloudStack.converters.toBooleanText }, - limitcpuuse: { + limitcpuuse: { label: 'CPU cap', converter: cloudStack.converters.toBooleanText }, tags: { label: 'Storage tags' }, hosttags: { label: 'Host tags' }, domain: { label: 'Domain' }, - created: { label: 'Created' } + created: { label: 'Created' } } ], @@ -591,7 +591,7 @@ } } } - } + } } }, @@ -600,15 +600,15 @@ title: 'Disk', listView: { label: 'Disk Offerings', - fields: { + fields: { name: { label: 'Name' }, - displaytext: { label: 'Description' }, - disksize: { + displaytext: { label: 'Description' }, + disksize: { label: 'Disk Size', converter: function(args) { return args + " GB"; - } - } + } + } }, dataProvider: function(args) { $.ajax({ @@ -621,8 +621,8 @@ } }); }, - - actions: { + + actions: { add: { label: 'Add disk offering', @@ -642,7 +642,7 @@ }, createForm: { - title: 'Add disk offering', + title: 'Add disk offering', fields: { name: { label: 'Name', @@ -660,7 +660,7 @@ }, disksize: { label: 'Disk size (in GB)', - dependsOn: 'isCustomized', + dependsOn: 'isCustomized', validation: { required: true, number: true } }, tags: { @@ -670,53 +670,53 @@ label: 'Public', isBoolean: true, isReverse: true, - isChecked: true + isChecked: true }, domainId: { label: 'Domain', - dependsOn: 'isPublic', - select: function(args) { + dependsOn: 'isPublic', + select: function(args) { $.ajax({ url: createURL("listDomains"), dataType: "json", async: false, success: function(json) { var items = []; - var domainObjs = json.listdomainsresponse.domain; - $(domainObjs).each(function(){ + var domainObjs = json.listdomainsresponse.domain; + $(domainObjs).each(function(){ items.push({id: this.id, description: this.name}); - }); + }); args.response.success({data: items}); } - }); + }); }, isHidden: true - } + } } }, action: function(args) { - var array1 = []; + var array1 = []; array1.push("&name=" + args.data.name); array1.push("&displaytext=" + todb(args.data.description)); - - array1.push("&customized=" + (args.data.isCustomized=="on")); - if(args.$form.find('.form-item[rel=disksize]').css("display") != "none") - array1.push("&disksize=" + args.data.disksize); - - if(args.data.tags != null && args.data.tags.length > 0) - array1.push("&tags=" + todb(args.data.tags)); - - if(args.$form.find('.form-item[rel=domainId]').css("display") != "none") - array1.push("&domainid=" + args.data.domainId); - + + array1.push("&customized=" + (args.data.isCustomized=="on")); + if(args.$form.find('.form-item[rel=disksize]').css("display") != "none") + array1.push("&disksize=" + args.data.disksize); + + if(args.data.tags != null && args.data.tags.length > 0) + array1.push("&tags=" + todb(args.data.tags)); + + if(args.$form.find('.form-item[rel=domainId]').css("display") != "none") + array1.push("&domainid=" + args.data.domainId); + $.ajax({ url: createURL("createDiskOffering&isMirrored=false" + array1.join("")), dataType: "json", async: true, - success: function(json) { - var item = json.creatediskofferingresponse.diskoffering; - args.response.success({data: item}); + success: function(json) { + var item = json.creatediskofferingresponse.diskoffering; + args.response.success({data: item}); } }); }, @@ -728,27 +728,27 @@ } } }, - + detailView: { name: 'Disk offering details', - actions: { + actions: { edit: { label: 'Edit', action: function(args) { var array1 = []; array1.push("&name=" + todb(args.data.name)); - array1.push("&displaytext=" + todb(args.data.displaytext)); + array1.push("&displaytext=" + todb(args.data.displaytext)); $.ajax({ url: createURL("updateDiskOffering&id=" + args.context.diskOfferings[0].id + array1.join("")), dataType: "json", - success: function(json) { - var item = json.updatediskofferingresponse.diskoffering; + success: function(json) { + var item = json.updatediskofferingresponse.diskoffering; args.response.success({data: item}); } }); } }, - + 'delete': { label: 'Delete disk offering', messages: { @@ -765,12 +765,12 @@ return 'Disk offering has been deleted.'; } }, - action: function(args) { + action: function(args) { $.ajax({ url: createURL("deleteDiskOffering&id=" + args.context.diskOfferings[0].id), dataType: "json", async: true, - success: function(json) { + success: function(json) { args.response.success(); } }); @@ -780,38 +780,38 @@ args.complete(); } } - } - }, - + } + }, + tabs: { details: { title: 'Details', fields: [ - { - name: { - label: 'Name', - isEditable: true + { + name: { + label: 'Name', + isEditable: true } - }, - { - id: { label: 'ID' }, - displaytext: { + }, + { + id: { label: 'ID' }, + displaytext: { label: 'Description', - isEditable: true + isEditable: true }, - iscustomized: { - label: 'Customized', + iscustomized: { + label: 'Customized', converter: cloudStack.converters.toBooleanText }, - disksize: { + disksize: { label: 'Disk Size', converter: function(args) { return args + " GB"; - } + } }, tags: { label: 'Storage tags' }, - domain: { label: 'Domain' } + domain: { label: 'Domain' } } ], @@ -825,7 +825,7 @@ } } } - } + } } }, networkOfferings: { @@ -834,7 +834,7 @@ listView: { label: 'Network Offerings', fields: { - name: { label: 'Name' }, + name: { label: 'Name' }, traffictype: { label: 'Traffic Type'} }, dataProvider: function(args) { @@ -850,28 +850,28 @@ }); } }); - }, + }, detailView: { - name: 'Network offering details', - actions: { + name: 'Network offering details', + actions: { edit: { label: 'Edit', - action: function(args) { + action: function(args) { var array1 = []; array1.push("&displayText=" + todb(args.data.displaytext)); - array1.push("&availability=" + todb(args.data.availability)); + array1.push("&availability=" + todb(args.data.availability)); $.ajax({ url: createURL("updateNetworkOffering&id=" + args.context.networkOfferings[0].id + array1.join("")), dataType: "json", success: function(json) { - var item = json.updatenetworkofferingresponse.networkoffering; + var item = json.updatenetworkofferingresponse.networkoffering; args.response.success({ data:item }); } - }); + }); } }, //??? -enable: { + enable: { label: 'Enable network offering', messages: { confirm: function(args) { @@ -889,14 +889,14 @@ enable: { }, action: function(args) { $.ajax({ - url: createURL("updateNetworkOffering&id=" + args.context.networkOfferings[0].id + "&state=Enabled"), + url: createURL("updateNetworkOffering&id=" + args.context.networkOfferings[0].id + "&state=Enabled"), dataType: "json", async: true, - success: function(json) { - var item = json.updatenetworkofferingresponse.networkoffering; - args.response.success({ + success: function(json) { + var item = json.updatenetworkofferingresponse.networkoffering; + args.response.success({ actionFilter: networkOfferingActionfilter, - data:item + data:item }); } }); @@ -926,15 +926,15 @@ enable: { }, action: function(args) { $.ajax({ - url: createURL("updateNetworkOffering&id=" + args.context.networkOfferings[0].id + "&state=Disabled"), + url: createURL("updateNetworkOffering&id=" + args.context.networkOfferings[0].id + "&state=Disabled"), dataType: "json", async: true, - success: function(json) { - var item = json.updatenetworkofferingresponse.networkoffering; - args.response.success({ + success: function(json) { + var item = json.updatenetworkofferingresponse.networkoffering; + args.response.success({ actionFilter: networkOfferingActionfilter, - data:item - }); + data:item + }); } }); }, @@ -943,8 +943,8 @@ enable: { args.complete(); } } - } - }, + } + }, tabs: { details: { title: 'Details', @@ -957,12 +957,12 @@ enable: { }, { id: { label: 'ID' }, - displaytext: { + displaytext: { label: 'Description', isEditable: true }, state: { label: 'State' }, - availability: { + availability: { label: 'Availability', isEditable: true, select: function(args) { @@ -972,7 +972,7 @@ enable: { //items.push({id: 'Unavailable', description: 'Unavailable'}); args.response.success({data: items}); } - }, + }, isdefault: { label: 'Default', converter:cloudStack.converters.toBooleanText @@ -982,73 +982,73 @@ enable: { converter:cloudStack.converters.toBooleanText }, networkrate: { - label: 'Network rate', - converter: function(args) { + label: 'Network rate', + converter: function(args) { var networkRate = args; if (args == null || args == -1) { - return "Unlimited"; - } + return "Unlimited"; + } else { return fromdb(args) + " Mb/s"; - - } + + } } }, traffictype: { label: 'Traffic type' - } + } } ], - dataProvider: function(args) { + dataProvider: function(args) { args.response.success( { actionFilter: networkOfferingActionfilter, data:args.context.networkOfferings[0] } ); - } + } } } - } + } } } } }; - + var serviceOfferingActionfilter = function(args) { - var jsonObj = args.context.item; + var jsonObj = args.context.item; var allowedActions = []; allowedActions.push("edit"); allowedActions.push("delete"); return allowedActions; - } - + }; + var systemServiceOfferingActionfilter = function(args) { - var jsonObj = args.context.item; + var jsonObj = args.context.item; var allowedActions = []; allowedActions.push("edit"); allowedActions.push("delete"); return allowedActions; - } - - var diskOfferingActionfilter = function(args) { - var jsonObj = args.context.item; + }; + + var diskOfferingActionfilter = function(args) { + var jsonObj = args.context.item; var allowedActions = []; allowedActions.push("edit"); allowedActions.push("delete"); return allowedActions; - } - + }; + var networkOfferingActionfilter = function(args) { - var jsonObj = args.context.item; + var jsonObj = args.context.item; var allowedActions = []; - allowedActions.push("edit"); + allowedActions.push("edit"); if(jsonObj.state == "Enabled") allowedActions.push("disable"); else if(jsonObj.state == "Disabled") allowedActions.push("enable"); return allowedActions; - } - + }; + })(cloudStack, testData);