From 8f15c07ebfd06ace0ec7aed2de8a5b2d5ac89e81 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Wed, 14 Dec 2011 14:35:36 -0800 Subject: [PATCH] bug 12534: Add Guest network - remove isTagged dropdown. --- ui/scripts/system.js | 638 +------------------------------------------ 1 file changed, 4 insertions(+), 634 deletions(-) diff --git a/ui/scripts/system.js b/ui/scripts/system.js index 5481984817c..ce6d6904416 100644 --- a/ui/scripts/system.js +++ b/ui/scripts/system.js @@ -518,8 +518,7 @@ createForm: { title: 'Create network', preFilter: function(args) { - if(selectedZoneObj.networktype == "Basic") { - args.$form.find('.form-item[rel=vlanTagged]').hide(); + if(selectedZoneObj.networktype == "Basic") { args.$form.find('.form-item[rel=vlanId]').hide(); args.$form.find('.form-item[rel=scope]').hide(); args.$form.find('.form-item[rel=domainId]').hide(); @@ -529,7 +528,6 @@ args.$form.find('.form-item[rel=podId]').css('display', 'inline-block'); } else { //"Advanced" - args.$form.find('.form-item[rel=vlanTagged]').css('display', 'inline-block'); args.$form.find('.form-item[rel=vlanId]').css('display', 'inline-block'); args.$form.find('.form-item[rel=scope]').css('display', 'inline-block'); //args.$form.find('.form-item[rel=domainId]').css('display', 'inline-block'); //depends on scope field @@ -547,13 +545,7 @@ description: { label: 'Description', validation: { required: true } - }, - vlanTagged: { - label: 'VLAN', - select: function(args) { - args.response.success({data: {id: "tagged", description: "tagged"}}); - } - }, + }, vlanId: { label: "VLAN ID" }, scope: { label: 'Scope', @@ -760,13 +752,9 @@ array1.push("&vlan=untagged"); } else { //"Advanced" - if (args.data.vlanTagged == "tagged") - array1.push("&vlan=" + todb(args.data.vlanId)); - else - array1.push("&vlan=untagged"); + array1.push("&vlan=" + todb(args.data.vlanId)); var $form = args.$form; - if($form.find('.form-item[rel=domainId]').css("display") != "none") { if($form.find('.form-item[rel=account]').css("display") != "none") { //account-specific array1.push("&acltype=account"); @@ -4597,625 +4585,7 @@ } } } - }, - - /* - networks: { - sectionSelect: { label: 'Network type' }, - sections: { - publicNetworks: { - type: 'select', - title: 'Public network', - listView: { - section: 'networks', - id: 'networks', - fields: { - //id: { label: "ID" }, - traffictype: { label: "Traffic type" }, - broadcastdomaintype: { label: "Broadcast domain type" } - }, - - dataProvider: function(args) { //public network - var showPublicNetwork = true; - - if(selectedZoneObj.networktype == "Basic") { - //$("#add_network_button").hide(); - $.ajax({ - url: createURL("listExternalFirewalls&zoneid=" + selectedZoneObj.id), - dataType: "json", - async: false, - success: function(json) { - var items = json.listexternalfirewallsresponse.externalfirewall; - if(items != null && items.length > 0) { - showPublicNetwork = true; - //$("#add_iprange_button,#tab_ipallocation").show(); - } - else { - showPublicNetwork = false; - //$("#add_iprange_button,#tab_ipallocation").hide(); - } - } - }); - } - else { // Advanced zone - showPublicNetwork = true; - //$("#add_network_button,#add_iprange_button,#tab_ipallocation").show(); - //listMidMenuItems2(("listNetworks&type=Direct&zoneId="+selectedZoneObj.id), networkGetSearchParams, "listnetworksresponse", "network", directNetworkToMidmenu, directNetworkToRightPanel, directNetworkGetMidmenuId, false, 1); - } - - if(showPublicNetwork == true && selectedZoneObj.securitygroupsenabled == false) { //public network - $.ajax({ - url: createURL("listNetworks&trafficType=Public&isSystem=true&zoneId="+selectedZoneObj.id), - dataType: "json", - async: false, - success: function(json) { - var items = json.listnetworksresponse.network; - args.response.success({data: items}); - } - }); - } - else if (showPublicNetwork == true && selectedZoneObj.securitygroupsenabled == true){ - $.ajax({ - url: createURL("listNetworks&type=Direct&trafficType=Guest&isSystem=true&zoneId="+selectedZoneObj.id), - dataType: "json", - async: false, - success: function(json) { - var items = json.listnetworksresponse.network; - args.response.success({data: items}); - } - }); - } - else { - args.response.success({data: null}); - } - } , - - detailView: { - //viewAll: { label: 'Hosts', path: 'instances' }, - - actions: { - addIpRange: { - label: 'Add IP range', - messages: { - confirm: function(args) { - return 'Are you sure you want to add IP range?'; - }, - success: function(args) { - return 'IP range is being added.'; - }, - notification: function(args) { - return 'Adding IP range'; - }, - complete: function(args) { - return 'IP range has been added.'; - } - }, - createForm: { - title: 'Add IP range', - fields: { - vlanTagged: { - label: 'VLAN', - dependsOn: 'isBootable', - select: function(args) { - var items = []; - items.push({id: "untagged", description: "untagged"}); - items.push({id: "tagged", description: "tagged"}); - args.response.success({data: items}); - args.$select.change(function() { - var $form = $(this).closest('form'); - if($(this).val() == "tagged") - $form.find('.form-item[rel=vlanId]').css('display', 'inline-block'); - else //"untagged" - $form.find('.form-item[rel=vlanId]').hide(); - }); - } - }, - vlanId: { label: "VLAN ID" }, - - scope: { - label: 'Scope', - select: function(args) { - var array1 = []; - if(selectedZoneObj.securitygroupsenabled) { - array1.push({id: 'account-specific', description: 'account-specific'}); - } - else { - array1.push({id: 'zone-wide', description: 'zone-wide'}); - array1.push({id: 'domain-specific', description: 'domain-specific'}); - array1.push({id: 'account-specific', description: 'account-specific'}); - } - args.response.success({data: array1}); - - args.$select.change(function() { - var $form = $(this).closest('form'); - if($(this).val() == "zone-wide") { - $form.find('.form-item[rel=domainId]').hide(); - $form.find('.form-item[rel=account]').hide(); - } - else if ($(this).val() == "domain-specific") { - $form.find('.form-item[rel=domainId]').css('display', 'inline-block'); - $form.find('.form-item[rel=account]').hide(); - } - else if($(this).val() == "account-specific") { - $form.find('.form-item[rel=domainId]').css('display', 'inline-block'); - $form.find('.form-item[rel=account]').css('display', 'inline-block'); - } - }); - } - }, - domainId: { - label: 'Domain', - validation: { required: true }, - select: function(args) { - var items = []; - if(selectedZoneObj.domainid != null) { //list only domains under selectedZoneObj.domainid - $.ajax({ - url: createURL("listDomainChildren&id=" + selectedZoneObj.domainid + "&isrecursive=true"), - dataType: "json", - async: false, - success: function(json) { - var domainObjs = json.listdomainchildrenresponse.domain; - $(domainObjs).each(function() { - items.push({id: this.id, description: this.name}); - }); - } - }); - $.ajax({ - url: createURL("listDomains&id=" + selectedZoneObj.domainid), - dataType: "json", - async: false, - success: function(json) { - var domainObjs = json.listdomainsresponse.domain; - $(domainObjs).each(function() { - items.push({id: this.id, description: this.name}); - }); - } - }); - } - else { //list all domains - $.ajax({ - url: createURL("listDomains"), - dataType: "json", - async: false, - success: function(json) { - var domainObjs = json.listdomainsresponse.domain; - $(domainObjs).each(function() { - items.push({id: this.id, description: this.name}); - }); - } - }); - } - args.response.success({data: items}); - } - }, - account: { label: 'Account' }, - - gateway: { label: 'Gateway' }, - netmask: { label: 'Netmask' }, - startip: { label: 'Start IP' }, - endip: { label: 'End IP' } - } - }, - action: function(args) { - var $form = args.$form; - var array1 = []; - array1.push("&zoneId=" + args.context.zones[0].id); - - if (args.data.vlanTagged == "tagged") - array1.push("&vlan=" + todb(args.data.vlanId)); - else - array1.push("&vlan=untagged"); - - if($form.find('.form-item[rel=domainId]').css("display") != "none") { - if($form.find('.form-item[rel=account]').css("display") != "none") { //account-specific - array1.push("&domainId=" + args.data.domainId); - array1.push("&account=" + args.data.account); - } - else { //domain-specific - array1.push("&domainId=" + args.data.domainId); - array1.push("&isshared=true"); - } - } - else { //zone-wide - array1.push("&isshared=true"); - } - - array1.push("&gateway=" + args.data.gateway); - array1.push("&netmask=" + args.data.netmask); - array1.push("&startip=" + args.data.startip); - if(args.data.endip != null && args.data.endip.length > 0) - array1.push("&endip=" + args.data.endip); - - if(args.context.zones[0].securitygroupsenabled == false) - array1.push("&forVirtualNetwork=true"); - else - array1.push("&forVirtualNetwork=false"); - - $.ajax({ - url: createURL("createVlanIpRange" + array1.join("")), - dataType: "json", - success: function(json) { - var item = json.createvlaniprangeresponse.vlan; - args.response.success({data: item}); - }, - error: function(XMLHttpResponse) { - var errorMsg = parseXMLHttpResponse(XMLHttpResponse); - args.response.error(errorMsg); - } - }); - }, - notification: { - poll: function(args) { - args.complete(); - } - } - } - }, - - tabs: { - details: { - title: 'Details', - fields: [ - { - networkofferingdisplaytext: { label: "Network offering description" } - }, - { - id: { label: "ID" }, - broadcastdomaintype: { label: 'Broadcast domain type' }, - traffictype: { label: 'Traffic type' }, - gateway: { label: 'Gateway' }, - netmask: { label: 'Netmask' }, - startip: { label: 'Start IP' }, - endip: { label: 'End IP' }, - zoneid: { label: 'Zone ID' }, - networkofferingid: { label: 'Network offering ID' }, - networkofferingname: { label: 'Network offering name' }, - networkofferingavailability: { label: 'network offering availability' }, - isshared: { - label: 'Shared', - converter: cloudStack.converters.toBooleanText - }, - issystem: { - label: 'System', - converter: cloudStack.converters.toBooleanText - }, - isdefault: { - label: 'Default', - converter: cloudStack.converters.toBooleanText - }, - securitygroupenabled: { - label: 'Security group enabled', - converter: cloudStack.converters.toBooleanText - }, - state: { label: 'State' }, - related: { label: 'Related' }, - dns1: { label: 'DNS 1' }, - dns2: { label: 'DNS 2' }, - vlan: { label: 'VLAN' }, - domainid: { label: 'Domain ID' }, - account: { label: 'Account' } - } - ], - dataProvider: function(args) { - args.response.success({data: args.context.publicNetworks[0]}); - } - }, - ipAllocations: { - title: 'IP Allocations', - multiple: true, - fields: [ - { - id: { label: 'ID' }, - vlan: { label: 'VLAN' }, - gateway: { label: 'Gateway' }, - netmask: { label: 'Netmask' }, - startip: { label: 'Start IP' }, - endip: { label: 'End IP' }, - domain: { label: 'Domain' }, - account: { label: 'Account' } - } - ], - dataProvider: function(args) { - $.ajax({ - url: createURL("listVlanIpRanges&zoneid=" + args.context.zones[0].id + "&networkId=" + args.context.publicNetworks[0].id), - dataType: "json", - success: function(json) { - var items = json.listvlaniprangesresponse.vlaniprange; - args.response.success({ - actionFilter: publicNetworkActionfilter, - data: items}); - } - }); - } - } - } - } - } - }, - directNetworks: { - title: 'Direct network', - type: 'select', - listView: { - section: 'networks', - id: 'networks', - fields: { - //id: { label: "ID" }, - vlan: { label: "VLAN ID" }, - traffictype: { label: "Traffic type" } - }, - actions: { - //create direct network action has moved to Guest network - }, - dataProvider: function(args) { //direct netwoerk - if(selectedZoneObj.networktype == "Basic") { - args.response.success({data: null}); - } - else { // Advanced zone - //$("#add_network_button,#add_iprange_button,#tab_ipallocation").show(); - $.ajax({ - url: createURL("listNetworks&type=Direct&zoneId="+selectedZoneObj.id), - dataType: "json", - async: false, - success: function(json) { - var items = json.listnetworksresponse.network; - args.response.success({ - actionFilter: directNetworkActionfilter, - data: items}); - } - }); - } - } , - - detailView: { - //viewAll: { label: 'Hosts', path: 'instances' }, - actions: { - addIpRange: { - label: 'Add IP range', - messages: { - confirm: function(args) { - return 'Are you sure you want to add IP range?'; - }, - success: function(args) { - return 'IP range is being added.'; - }, - notification: function(args) { - return 'Adding IP range'; - }, - complete: function(args) { - return 'IP range has been added.'; - } - }, - createForm: { - title: 'Add IP range', - preFilter: function(args) { - if(args.context.zones[0].securitygroupsenabled) { - args.$form.find('.form-item[rel=vlanId]').css('display', 'inline-block'); - args.$form.find('.form-item[rel=gateway]').css('display', 'inline-block'); - args.$form.find('.form-item[rel=netmask]').css('display', 'inline-block'); - } - else { - args.$form.find('.form-item[rel=vlanId]').hide(); - args.$form.find('.form-item[rel=gateway]').hide(); - args.$form.find('.form-item[rel=netmask]').hide(); - } - }, - fields: { - vlanId: { label: 'VLAN ID' }, - gateway: { label: 'Gateway' }, - netmask: { label: 'Netmask' }, - startip: { label: 'Start IP' }, - endip: { label: 'End IP' } - } - }, - action: function(args) { - var $form = args.$form; - var array1 = []; - if($form.find('.form-item[rel=vlanId]').css("display") != "none") { - array1.push("&vlan="+todb(args.data.vlanId)); - } - //else { //Bug 8950 (don't specify "vlan=untagged" if vlanId is not available when Adding Ip Range to Direct Network) - // array1.push("&vlan=untagged"); - //} - - if($form.find('.form-item[rel=gateway]').css("display") != "none") { - array1.push("&gateway=" + todb(args.data.gateway)); - } - - if($form.find('.form-item[rel=netmask]').css("display") != "none") { - array1.push("&netmask=" + todb(args.data.netmask)); - } - - array1.push("&startip=" + todb(args.data.startip)); - - if(args.data.endip != null && args.data.endip.length > 0) - array1.push("&endip=" + todb(args.data.endip)); - - - $.ajax({ - url: createURL("createVlanIpRange&forVirtualNetwork=false&networkid=" + args.context.directNetworks[0].id + array1.join("")), - dataType: "json", - success: function(json) { - var item = json.createvlaniprangeresponse.vlan; - args.response.success({data: item}); - }, - error: function(XMLHttpResponse) { - var errorMsg = parseXMLHttpResponse(XMLHttpResponse); - args.response.error(errorMsg); - } - }); - }, - notification: { - poll: function(args) { - args.complete(); - } - } - }, - - edit: { - label: 'Edit', - - messages: { - confirm: function(args) { - return 'Are you sure you want to edit network?'; - }, - success: function(args) { - return 'Network is being edited.'; - }, - notification: function(args) { - return 'Editing network'; - }, - complete: function(args) { - return 'Network has been edited.'; - } - }, - - action: function(args) { - var array1 = []; - array1.push("&name=" + todb(args.data.name)); - array1.push("&displayText=" + todb(args.data.displaytext)); - array1.push("&networkdomain=" + todb(args.data.networkdomain)); - array1.push("&tags=" + todb(args.data.tags)); - - $.ajax({ - url: createURL("updateNetwork&id=" + args.context.directNetworks[0].id + array1.join("")), - dataType: "json", - success: function(json) { - var jid = json.updatenetworkresponse.jobid; - args.response.success( - {_custom: - {jobId: jid, - getUpdatedItem: function(json) { - var item = json.queryasyncjobresultresponse.jobresult.network; - return {data: item}; - }, - getActionFilter: function() { - return directNetworkActionfilter; - } - } - } - ); - } - }); - }, - notification: { - poll: pollAsyncJobResult - } - }, - - 'delete': { - label: 'Delete network', - messages: { - confirm: function(args) { - return 'Are you sure you want to delete network ?'; - }, - success: function(args) { - return 'Network is being deleted.'; - }, - notification: function(args) { - return 'Deleting network'; - }, - complete: function(args) { - return 'Network has been deleted.'; - } - }, - action: function(args) { - $.ajax({ - url: createURL("deleteNetwork&id=" + args.context.directNetworks[0].id), - dataType: "json", - async: true, - success: function(json) { - var jid = json.deletenetworkresponse.jobid; - args.response.success( - {_custom: - {jobId: jid, - getUpdatedItem: function(json) { - return {}; //nothing in this template needs to be updated, in fact, this whole template has being deleted - }, - getActionFilter: function() { - return directNetworkActionfilter; - } - } - } - ); - } - }); - }, - notification: { - poll: pollAsyncJobResult - } - } - }, - - tabs: { - details: { - title: 'Details', //direct network details - fields: [ - { - name: { - label: 'Name', - isEditable: true - } - }, - { - id: { label: "ID" }, - displaytext: { - label: 'Description', - isEditable: true - }, - isdefault: { - label: 'Default', - converter: cloudStack.converters.toBooleanText - }, - vlan: { label: 'VLAN ID' }, - domain: { label: 'Domain' }, - account: { label: 'Account' }, - gateway: { label: 'Gateway' }, - netmask: { label: 'Netmask' }, - startip: { label: 'Start IP' }, - endip: { label: 'End IP' }, - networkdomain: { - label: 'Network domain', - isEditable: true - }, - tags: { - label: 'Tags', - isEditable: true - } - } - ], - dataProvider: function(args) { - args.response.success({data: args.context.directNetworks[0]}); - } - }, - ipAllocations: { - title: 'IP Allocations', - multiple: true, - fields: [ - { - id: { label: 'ID' }, - vlan: { label: 'VLAN' }, - startip: { label: 'Start IP' }, - endip: { label: 'End IP' } - } - ], - dataProvider: function(args) { - $.ajax({ - url: createURL("listVlanIpRanges&zoneid="+ args.context.zones[0].id + "&networkid="+ args.context.directNetworks[0].id), - dataType: "json", - success: function(json) { - var items = json.listvlaniprangesresponse.vlaniprange; - args.response.success({data: items}); - } - }); - } - } - } - } - } - } - } - }, - */ + }, pods: { title: 'Pods',