function _fill(context, element) { if (this.action != "update") {return;} this.setHeader(element); this.resourceId = element.ID; $("#default_sg_warning").hide(); // Populates the Avanced mode Tab $('#template', context).val(TemplateUtils.templateToString(element.TEMPLATE)); WizardFields.fillInput($('[wizard_field="NAME"]', context), element.NAME); $('[wizard_field="NAME"]', context).prop("disabled", true).prop('wizard_field_disabled', true); // Show all network mode inputs, and make them not required. This will change // if a different network model is selected $('input#vn_mad,label[for="vn_mad"]', context).show().prop('wizard_field_disabled', false).removeAttr('required'); $('input#bridge,label[for="bridge"]', context).show().prop('wizard_field_disabled', false).removeAttr('required'); $('input#phydev,label[for="phydev"]', context).show().prop('wizard_field_disabled', false).removeAttr('required'); $('input#vlan_id,label[for="vlan_id"]', context).show().prop('wizard_field_disabled', false).removeAttr('required'); $('input#ip_spoofing,label[for="ip_spoofing"]', context).show().prop('wizard_field_disabled', false); $('input#mac_spoofing,label[for="mac_spoofing"]', context).show().prop('wizard_field_disabled', false); WizardFields.fillInput($('input#vn_mad', context), element.TEMPLATE["VN_MAD"]); WizardFields.fill($("#vnetCreateGeneralTab", context), element.TEMPLATE); WizardFields.fill($("#vnetCreateBridgeTab", context), element.TEMPLATE); WizardFields.fill($("#vnetCreateContextTab", context), element.TEMPLATE); if ($('#network_mode', context).val() == undefined){ $('#network_mode', context).val("custom").change(); } if (element.TEMPLATE["SECURITY_GROUPS"] != undefined && element.TEMPLATE["SECURITY_GROUPS"].length != 0) { var secgroups = element.TEMPLATE["SECURITY_GROUPS"].split(","); this.securityGroupsTable.selectResourceTableSelect({ids : secgroups}); } else { this.securityGroupsTable.refreshResourceTableSelect(); } // Delete so these attributes don't end in the custom tags table also delete element.TEMPLATE["SECURITY_GROUPS"]; var fields = $('[wizard_field]', context); fields.each(function() { var field = $(this); var field_name = field.attr('wizard_field'); delete element.TEMPLATE[field_name]; }); CustomTagsTable.fill($("#vnetCreateContextTab", context), element.TEMPLATE); // Remove the first AR added in initialize_ $("#vnetCreateARTab i.remove-tab", context).trigger("click"); $("#vnetCreateARTab #vnetCreateARTabUpdate", context).show(); $("#vnetCreateARTab #vnetCreateARTabCreate", context).hide(); }
function _submitWizard(context) { var name = WizardFields.retrieveInput($('#security_group_name', context)); var description = WizardFields.retrieveInput($('#security_group_description', context)); var rules = []; $(".security_group_rules tbody tr").each(function(){ rules.push($(this).data("rule")); }); var security_group_json = { "NAME" : name, "DESCRIPTION": description, "RULE" : rules }; if (this.action == "create") { security_group_json = { "security_group" : security_group_json }; Sunstone.runAction("SecurityGroup.create",security_group_json); return false; } else if (this.action == "update") { delete security_group_json["NAME"]; Sunstone.runAction( "SecurityGroup.update", this.resourceId, TemplateUtils.templateToString(security_group_json)); return false; } }
context.on("change", ".input_edit_value_vectorial", function() { var key_str = $.trim(this.id.substring(11, this.id.length)); var value_str = $.trim(this.value); var templateJSON_bk = $.extend({}, templateJSON); var list_of_classes = this.className.split(" "); var ocurrence = null; var vectorial_key = null; if (list_of_classes.length != 1) { $.each(list_of_classes, function(index, value) { if (value.match(/^ocurrence_/)) ocurrence = value.substring(10, value.length); }); } if (list_of_classes.length != 1) { $.each(list_of_classes, function(index, value) { if (value.match(/^vectorial_key_/)) vectorial_key = value.substring(14, value.length); }); } if (ocurrence != null) templateJSON[vectorial_key][ocurrence][key_str] = value_str; else templateJSON[vectorial_key][key_str] = value_str; template_str = TemplateUtils.templateToString(templateJSON, unshownValues); // Let OpenNebula know Sunstone.runAction(resourceType + ".update_template", resourceId, template_str); templateJSON = templateJSON_bk; });
$(document).off("click", ".update_reserved").on("click", ".update_reserved", function(){ var reservedCPU = document.getElementById("textInput_reserved_cpu").value; var reservedMem = document.getElementById("textInput_reserved_mem").value; var obj = { RESERVED_CPU: reservedCPU, RESERVED_MEM: reservedMem }; Sunstone.runAction("Cluster.append_template", that.element.ID, TemplateUtils.templateToString(obj)); });
function _submitWizard(context) { var templateJSON = {} $.each(this.wizardTabs, function(index, wizardTab) { $.extend(true, templateJSON, wizardTab.retrieve($('#' + wizardTab.wizardTabId, context))); }); // vCenter PUBLIC_CLOUD is not defined in the hybrid tab. Because it is // part of an array, and it is filled in different tabs, the $.extend deep // merge can't work. We define an auxiliary attribute for it. if (templateJSON["VCENTER_PUBLIC_CLOUD"]) { if (templateJSON['PUBLIC_CLOUD'] == undefined) { templateJSON['PUBLIC_CLOUD'] = []; } templateJSON['PUBLIC_CLOUD'].push(templateJSON["VCENTER_PUBLIC_CLOUD"]); delete templateJSON["VCENTER_PUBLIC_CLOUD"]; } if (this.action == "create") { Sunstone.runAction("Template.create", {'vmtemplate': templateJSON}); return false; } else if (this.action == "update") { Sunstone.runAction("Template.update", this.resourceId, TemplateUtils.templateToString(templateJSON)); return false; } }
$(document).off('click', '.update_reserved').on("click", '.update_reserved', function(){ var reservedCPU = document.getElementById('change_bar_cpu').value+'%'; var reservedMem = document.getElementById('change_bar_mem').value+'%'; var obj = {RESERVED_CPU: reservedCPU, RESERVED_MEM: reservedMem}; Sunstone.runAction("Cluster.append_template", that.element.ID, TemplateUtils.templateToString(obj)); });
context.on("click", "#div_minus_vectorial", function() { // Remove div_minus_ from the id var field = this.firstElementChild.id.substring(10, this.firstElementChild.id.length); var list_of_classes = this.firstElementChild.className.split(" "); var ocurrence = null; var vectorial_key = null; if (list_of_classes.length != 1) { $.each(list_of_classes, function(index, value) { if (value.match(/^ocurrence_/)) ocurrence = value.substring(10, value.length); }); } if (list_of_classes.length != 1) { $.each(list_of_classes, function(index, value) { if (value.match(/^vectorial_key_/)) vectorial_key = value.substring(14, value.length); }); } // Erase the value from the template if (ocurrence != null) delete templateJSON_Others[vectorial_key][ocurrence][field]; else delete templateJSON_Others[vectorial_key][field]; templateJSON = $.extend({}, templateJSON_Others, templateJSON); template_str = TemplateUtils.templateToString(templateJSON, unshownValues); // Let OpenNebula know Sunstone.runAction(resourceType + ".update_template", resourceId, template_str); });
role_section.on("change", ".service_network_checkbox", role_section, function(){ var vm_template_contents = {}; vm_template_contents["NIC"] = []; var old_template = $(".vm_template_contents", role_section).val(); $(".service_network_checkbox:checked", role_section).each(function(){ vm_template_contents["NIC"].push({"NETWORK_ID":"$"+$(this).val()}); }); if(old_template != ""){ var template = TemplateUtils.stringToTemplate(old_template); template["NIC"] = vm_template_contents["NIC"]; $(".vm_template_contents", role_section).val(TemplateUtils.templateToString(template)); return false; } $(".vm_template_contents", role_section).val(TemplateUtils.templateToString(vm_template_contents)); });
function _elementArray(element_json) { this.totalUsers++; var element = element_json[XML_ROOT]; var vms = '<span class="progress-text right" style="font-size: 12px">-</span>'; var memory = '<span class="progress-text right" style="font-size: 12px">-</span>'; var cpu = '<span class="progress-text right" style="font-size: 12px">-</span>'; var default_user_quotas = QuotaDefaults.getDefaultUserQuotas(); QuotaWidgets.initEmptyQuotas(element); if (!$.isEmptyObject(element.VM_QUOTA)){ vms = QuotaWidgets.quotaBar( element.VM_QUOTA.VM.VMS_USED, element.VM_QUOTA.VM.VMS, default_user_quotas.VM_QUOTA.VM.VMS); memory = QuotaWidgets.quotaBarMB( element.VM_QUOTA.VM.MEMORY_USED, element.VM_QUOTA.VM.MEMORY, default_user_quotas.VM_QUOTA.VM.MEMORY); cpu = QuotaWidgets.quotaBarFloat( element.VM_QUOTA.VM.CPU_USED, element.VM_QUOTA.VM.CPU, default_user_quotas.VM_QUOTA.VM.CPU); } // Build hidden user template var hidden_template = TemplateUtils.htmlEncode(TemplateUtils.templateToString(element)); var search = { NAME: element.NAME, GNAME: element.GNAME, PASSWORD: element.PASSWORD, AUTH_DRIVER: element.AUTH_DRIVER } return [ '<input class="check_item" type="checkbox" id="'+RESOURCE.toLowerCase()+'_' + element.ID + '" name="selected_items" ' + 'value="' + element.ID + '"/>', element.ID, element.NAME, element.GNAME, element.AUTH_DRIVER, element.PASSWORD, vms, memory, cpu, element.GID, hidden_template, (LabelsUtils.labelsStr(element[TEMPLATE_ATTR])||''), btoa(unescape(encodeURIComponent(JSON.stringify(search)))) ]; }
function _html() { return '<div class="row">'+ '<div class="large-12 columns">'+ '<h5>' + Locale.tr("User template") + '</h5>'+ '<pre class="template-pre monospace">'+ TemplateUtils.templateToString(this.element.USER_TEMPLATE)+ '</pre>'+ '</div>'+ '</div>'+ '<div class="row">'+ '<div class="large-12 columns">'+ '<h5>' + Locale.tr("Template") + '</h5>'+ '<pre class="template-pre monospace">'+ TemplateUtils.templateToString(this.element.TEMPLATE)+ '</pre>'+ '</div>'+ '</div>'; }
context.on('click', '.remove-tab', function() { $(this).closest('li').remove(); var labels = _retrieveLabels(context); var templateObj = that.element[LabelsUtils.TEMPLATE_ATTR]; templateObj[LabelsUtils.LABELS_ATTR] = labels.join(); templateStr = TemplateUtils.templateToString(templateObj); Sunstone.runAction(that.resource + ".update_template", that.element.ID, templateStr); return false; });
success: function(request, response) { var sunstone_template = {}; if (response[XML_ROOT].TEMPLATE.SUNSTONE) { $.extend(sunstone_template, response[XML_ROOT].TEMPLATE.SUNSTONE); } $.extend(sunstone_template, params.data.extra_param) var template_str = TemplateUtils.templateToString({'SUNSTONE': sunstone_template}); Sunstone.runAction("User.append_template", params.data.id, template_str); },
function _submitWizard(context) { var templateJSON = {} $.each(this.wizardTabs, function(index, wizardTab) { $.extend(true, templateJSON, wizardTab.retrieve($('#' + wizardTab.wizardTabId, context))); }); Sunstone.runAction("VM.updateconf", this.resourceId, TemplateUtils.templateToString(templateJSON)); return false; }
function _elementArray(element_json) { var element = element_json[XML_ROOT]; var state; if (element.STATE == OpenNebulaVM.STATES.ACTIVE) { state = OpenNebulaVM.shortLcmStateStr(element.LCM_STATE); } else { state = OpenNebulaVM.stateStr(element.STATE); } // VNC icon var vncIcon; if (OpenNebulaVM.isVNCSupported(element)) { vncIcon = '<a class="vnc" href="#" vm_id="' + element.ID + '"><i class="fa fa-desktop"/></a>'; } else if (OpenNebulaVM.isSPICESupported(element)) { vncIcon = '<a class="spice" href="#" vm_id="' + element.ID + '"><i class="fa fa-desktop"/></a>'; } else { vncIcon = ''; } var cpuMonitoring = 0; var memoryMonitoring = 0; if (element.MONITORING) { if (element.MONITORING.CPU) { cpuMonitoring = element.MONITORING.CPU } if (element.MONITORING.MEMORY) { memoryMonitoring = element.MONITORING.MEMORY } } return [ '<input class="check_item" '+ 'type="checkbox" '+ 'id="' + RESOURCE.toLowerCase() + '_' + element.ID + '" '+ 'name="selected_items" '+ 'value="' + element.ID + '" '+ 'state="'+element.STATE+'" lcm_state="'+element.LCM_STATE+'"/>', element.ID, element.UNAME, element.GNAME, element.NAME, state, cpuMonitoring, Humanize.size(memoryMonitoring), OpenNebulaVM.hostnameStr(element), OpenNebulaVM.ipsStr(element), Humanize.prettyTime(element.STIME), vncIcon, TemplateUtils.templateToString(element), (LabelsUtils.labelsStr(element[TEMPLATE_ATTR])||'') ]; }
function _submitWizard(context) { var templateJSON = this.retrieve(context); if (this.action == "create") { Sunstone.runAction(this.resource+".create", {'vmtemplate': templateJSON}); return false; } else if (this.action == "update") { Sunstone.runAction(this.resource+".update", this.resourceId, TemplateUtils.templateToString(templateJSON)); return false; } }
context.on('click', '.addLabel', function() { var labels = _retrieveLabels(context); var newLabel = $('.newLabel', context).val(); labels.push(newLabel); var templateObj = that.element[TEMPLATE_ATTR]; templateObj[LABELS_ATTR] = labels.join(); templateStr = TemplateUtils.templateToString(templateObj); Sunstone.runAction(that.resource + '.update_template', that.element.ID, templateStr); return false; });
function _fill(context, element) { if (this.action != "update") {return;} this.resourceId = element.ID; var templateJSON = element.TEMPLATE; // Populates the Avanced mode Tab $('#template', context).val( TemplateUtils.templateToString(templateJSON).replace(/^[\r\n]+$/g, "")); $.each(this.wizardTabs, function(index, wizardTab) { wizardTab.fill($('#' + wizardTab.wizardTabId, context), templateJSON); }); }
function _fill(context, templateJSON) { var selectedContext; if(templateJSON.SIZE){ templateJSON.SIZE = templateJSON.SIZE / 1024; } if (templateJSON.IMAGE_ID || templateJSON.IMAGE) { $('input#' + this.diskTabId + 'radioImage', context).click(); if (templateJSON.IMAGE_ID != undefined) { var selectedResources = { ids : templateJSON.IMAGE_ID } this.imageTable.selectResourceTableSelect(selectedResources); } else if (templateJSON.IMAGE != undefined && templateJSON.IMAGE_UNAME != undefined) { var selectedResources = { names : { name: templateJSON.IMAGE, uname: templateJSON.IMAGE_UNAME } } this.imageTable.selectResourceTableSelect(selectedResources); } selectedContext = $(".image", context); } else { $('input#' + this.diskTabId + 'radioVolatile', context).click(); selectedContext = $(".volatile", context); } WizardFields.fill(selectedContext, templateJSON); $('#templateStr',context).val(TemplateUtils.templateToString(templateJSON)); var dev_prefix = templateJSON["DEV_PREFIX"]; if (dev_prefix != undefined && dev_prefix.length) { WizardFields.fillInput($('#disk_dev_prefix', selectedContext), dev_prefix); var val = $('#disk_dev_prefix', selectedContext).val(); if (val == "" || val == undefined){ $('#disk_dev_prefix', selectedContext).val("custom").change(); WizardFields.fillInput($('#custom_disk_dev_prefix', selectedContext), dev_prefix); } } }
$(document).off('click', '.update_reserved_hosts').on("click", '.update_reserved', function(){ var reservedCPU = parseInt(document.getElementById('change_bar_cpu_hosts').value); var CPU = parseInt(that.element.HOST_SHARE.FREE_CPU); var reservedMem = parseInt(document.getElementById('change_bar_mem_hosts').value); var MEM = parseInt(that.element.HOST_SHARE.FREE_MEM); if(parseInt(that.element.HOST_SHARE.USED_CPU) > 0) CPU += parseInt(that.element.HOST_SHARE.USED_CPU); reservedCPU = CPU - reservedCPU; if(parseInt(that.element.HOST_SHARE.USED_MEM) > 0) MEM += parseInt(that.element.HOST_SHARE.USED_MEM); reservedMem = MEM - reservedMem; var obj = {RESERVED_CPU: reservedCPU, RESERVED_MEM: reservedMem}; Sunstone.runAction("Host.append_template", that.element.ID, TemplateUtils.templateToString(obj)); });
context.on("click", ".remove_action_x", function() { var index = this.id.substring(6, this.id.length); var tmp_tmpl = new Array(); $.each(that.element.USER_TEMPLATE.SCHED_ACTION, function(i, element) { if (element.ID != index) tmp_tmpl[i] = element }) that.element.USER_TEMPLATE.SCHED_ACTION = tmp_tmpl; var template_str = TemplateUtils.templateToString(that.element.USER_TEMPLATE); // Let OpenNebula know Sunstone.runAction("VM.update_template", that.element.ID, template_str); });
context.on("change", ".input_edit_value", function() { var key_str = $.trim(this.id.substring(11, this.id.length)); var value_str = $.trim(this.value); var templateJSON_bk = $.extend({}, templateJSON); delete templateJSON[key_str]; templateJSON[key_str] = value_str; template_str = TemplateUtils.templateToString(templateJSON, unshownValues); // Let OpenNebula know Sunstone.runAction(resourceType + ".update_template", resourceId, template_str); templateJSON = templateJSON_bk; });
context.on("click", '#button_add_value', function() { new_value = $('#new_value', $(this).parent().parent()).val(); new_key = $('#new_key', $(this).parent().parent()).val(); if (new_key != "") { var templateJSON_bk = $.extend({}, templateJSON); if (templateJSON[$.trim(new_key)] && (templateJSON[$.trim(new_key)] instanceof Array)) { templateJSON[$.trim(new_key)].push($.trim(new_value)); } else { templateJSON[$.trim(new_key)] = $.trim(new_value); } template_str = TemplateUtils.templateToString(templateJSON, unshownValues); Sunstone.runAction(resourceType + ".update_template", resourceId, template_str); templateJSON = templateJSON_bk; } });
$(context).off("click", "#update_reserved_hosts").on("click", "#update_reserved_hosts", function(){ $("#update_reserved_hosts", context).prop("disabled", true); var reservedCPU = parseInt($("#textInput_reserved_cpu_hosts", context).val()); var CPU = parseInt(that.element.HOST_SHARE.FREE_CPU); var reservedMem = parseInt(Humanize.sizeToMB($("#textInput_reserved_mem_hosts").val()) * 1024); var MEM = parseInt(that.element.HOST_SHARE.FREE_MEM); if (parseInt(that.element.HOST_SHARE.USED_CPU) > 0){ CPU += parseInt(that.element.HOST_SHARE.USED_CPU); } reservedCPU = CPU - reservedCPU; if (parseInt(that.element.HOST_SHARE.USED_MEM) > 0){ MEM += parseInt(that.element.HOST_SHARE.USED_MEM); } reservedMem = MEM - reservedMem; var obj = { RESERVED_CPU: reservedCPU, RESERVED_MEM: reservedMem }; Sunstone.runAction("Host.append_template", that.element.ID, TemplateUtils.templateToString(obj)); });
$('#' + that.dialogId + 'Form', context).submit(function() { var obj = WizardFields.retrieve(context); if (obj.RESERVED_CPU == undefined){ obj.RESERVED_CPU = ""; } if (obj.RESERVED_MEM == undefined){ obj.RESERVED_MEM = ""; } Sunstone.runAction(that.action, that.element.ID, TemplateUtils.templateToString(obj)); Sunstone.getDialog(that.dialogId).hide(); Sunstone.getDialog(that.dialogId).reset(); return false; });
function _submitWizard(dialog) { var that = this; var marketObj = {}; $.extend(marketObj, WizardFields.retrieve(dialog)); if (this.action == "create") { marketObj = { "marketplace" : marketObj }; Sunstone.runAction("MarketPlace.create", marketObj); return false; } else if (this.action == "update") { Sunstone.runAction("MarketPlace.update", this.resourceId, TemplateUtils.templateToString(marketObj)); return false; } }
context.on("click" , "#add_vms_action_json", function(){ var sched_action = ScheduleActions.retrieveNewAction(context); if (sched_action != false) { $("#no_actions_tr", context).remove(); $("#sched_vms_actions_body").append(ScheduleActions.fromJSONtoActionsTable(sched_action)); } else { return false; } that.element.USER_TEMPLATE.SCHED_ACTION = ScheduleActions.retrieve(context); // Let OpenNebula know var template_str = TemplateUtils.templateToString(that.element.USER_TEMPLATE); Sunstone.runAction("VM.update_template", that.element.ID, template_str); $("#add_scheduling_vms_action", context).removeAttr("disabled"); return false; });
function _submitWizard(context) { var that = this; //Fetch values var network_json = {}; $.extend(network_json, WizardFields.retrieve($("#vnetCreateGeneralTab", context))); $.extend(network_json, WizardFields.retrieve($("#vnetCreateBridgeTab", context))); $.extend(network_json, WizardFields.retrieve($("#vnetCreateQoSTab", context))); $.extend(network_json, WizardFields.retrieve($("#vnetCreateContextTab", context))); var secgroups = this.securityGroupsTable.retrieveResourceTableSelect(); if (secgroups != undefined && secgroups.length != 0) { network_json["SECURITY_GROUPS"] = secgroups.join(","); } var cluster_id = $(".resource_list_select", $("#vnet_cluster_id", context)).val(); $.extend(network_json, CustomTagsTable.retrieve($("#vnetCreateContextTab", context))); $(".ar_tab", context).each(function() { var ar_id = $(this).attr("ar_id"); var hash = that.arTabObjects[ar_id].retrieve(); if (!$.isEmptyObject(hash)) { if (!network_json["AR"]) network_json["AR"] = []; network_json["AR"].push(hash); } }); if (this.action == "create") { network_json = { "vnet" : network_json, "cluster_id": cluster_id }; Sunstone.runAction("Network.create", network_json); return false; } else if (this.action == "update") { Sunstone.runAction("Network.update", this.resourceId, TemplateUtils.templateToString(network_json)); return false; } }
context.on("click", "#submit_scheduling_action", function() { var date_input_value = $("#date_input", context).val(); var time_input_value = $("#time_input", context).val(); if (date_input_value == "" || time_input_value == "") return false; var time_value = date_input_value + ' ' + time_input_value // Calculate MAX_ID var max_id = -1; if (that.element.USER_TEMPLATE.SCHED_ACTION) { if (!that.element.USER_TEMPLATE.SCHED_ACTION.length) { var tmp_element = that.element.USER_TEMPLATE.SCHED_ACTION; that.element.USER_TEMPLATE.SCHED_ACTION = new Array(); that.element.USER_TEMPLATE.SCHED_ACTION.push(tmp_element); } $.each(that.element.USER_TEMPLATE.SCHED_ACTION, function(i, element) { if (max_id < element.ID) max_id = element.ID }) } else { that.element.USER_TEMPLATE.SCHED_ACTION = new Array(); } var new_action = {}; new_action.ID = parseInt(max_id) + 1; new_action.ACTION = $("#select_new_action", context).val(); var epoch_str = new Date(time_value); new_action.TIME = parseInt(epoch_str.getTime()) / 1000; that.element.USER_TEMPLATE.SCHED_ACTION.push(new_action); // Let OpenNebula know var template_str = TemplateUtils.templateToString(that.element.USER_TEMPLATE); Sunstone.runAction("VM.update_template", that.element.ID, template_str); $("#add_scheduling_action", context).removeAttr("disabled"); return false; });
function _fill(context, element) { if (this.action != "update") {return;} this.setHeader(element); this.resourceId = element.ID; var templateJSON = element.TEMPLATE; // Populates the Avanced mode Tab $('#template', context).val(TemplateUtils.templateToString(templateJSON)); $.each(this.wizardTabs, function(index, wizardTab) { wizardTab.fill($('#' + wizardTab.wizardTabId, context), templateJSON); }); // After all tabs have been filled, perform a notify this.notify(); }
function _fill(context, element) { var that = this; this.setHeader(element); this.resourceId = element.ID; // Populates the Avanced mode Tab $('#template', context).val(TemplateUtils.templateToString(element.TEMPLATE)); WizardFields.fillInput($('#security_group_name',context), element.NAME); $('#security_group_name',context).prop("disabled", true); WizardFields.fillInput($('#security_group_description', context), element.TEMPLATE.DESCRIPTION ); var rules = element.TEMPLATE.RULE; if (!rules) { //empty rules = []; } else if (rules.constructor != Array) { //>1 rule rules = [rules]; } $.each(rules, function(){ var text = Utils.sgRuleToSt(this); $(".security_group_rules tbody", context).append( '<tr>\ <td>'+text.PROTOCOL+'</td>\ <td>'+text.RULE_TYPE+'</td>\ <td>'+text.RANGE+'</td>\ <td>'+text.NETWORK+'</td>\ <td>'+text.ICMP_TYPE+'</td>\ <td>'+text.ICMPv6_TYPE+'</td>\ <td>\ <a href="#"><i class="fas fa-times-circle remove-tab"></i></a>\ </td>\ </tr>'); $(".security_group_rules tbody", context).children("tr").last().data("rule", this); }); }