From d7c370ffbca3a943ba0aa13486e069f5550c84cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Fri, 9 Jan 2015 16:03:18 +0100 Subject: [PATCH] Feature #3471: Create VDC tab for sunstone --- install.sh | 6 +- src/sunstone/etc/sunstone-views.yaml | 1 + src/sunstone/etc/sunstone-views/admin.yaml | 14 + src/sunstone/models/OpenNebulaJSON.rb | 1 + .../models/OpenNebulaJSON/PoolJSON.rb | 1 + src/sunstone/models/OpenNebulaJSON/VdcJSON.rb | 114 ++++ src/sunstone/models/SunstoneServer.rb | 3 + src/sunstone/public/js/opennebula.js | 80 +++ src/sunstone/public/js/plugins/vdcs-tab.js | 494 ++++++++++++++++++ 9 files changed, 712 insertions(+), 2 deletions(-) create mode 100644 src/sunstone/models/OpenNebulaJSON/VdcJSON.rb create mode 100644 src/sunstone/public/js/plugins/vdcs-tab.js diff --git a/install.sh b/install.sh index ce0d32dc48..8aad811205 100755 --- a/install.sh +++ b/install.sh @@ -1530,7 +1530,8 @@ SUNSTONE_MODELS_JSON_FILES="src/sunstone/models/OpenNebulaJSON/HostJSON.rb \ src/sunstone/models/OpenNebulaJSON/DatastoreJSON.rb \ src/sunstone/models/OpenNebulaJSON/VirtualNetworkJSON.rb \ src/sunstone/models/OpenNebulaJSON/ZoneJSON.rb \ - src/sunstone/models/OpenNebulaJSON/SecurityGroupJSON.rb" + src/sunstone/models/OpenNebulaJSON/SecurityGroupJSON.rb \ + src/sunstone/models/OpenNebulaJSON/VdcJSON.rb" SUNSTONE_VIEWS_FILES="src/sunstone/views/index.erb \ src/sunstone/views/login.erb \ @@ -1568,7 +1569,8 @@ SUNSTONE_PUBLIC_JS_PLUGINS_FILES="\ src/sunstone/public/js/plugins/oneflow-templates.js \ src/sunstone/public/js/plugins/support-tab.js \ src/sunstone/public/js/plugins/zones-tab.js \ - src/sunstone/public/js/plugins/secgroups-tab.js" + src/sunstone/public/js/plugins/secgroups-tab.js \ + src/sunstone/public/js/plugins/vdcs-tab.js" SUNSTONE_ROUTES_FILES="src/sunstone/routes/oneflow.rb \ src/sunstone/routes/vcenter.rb \ diff --git a/src/sunstone/etc/sunstone-views.yaml b/src/sunstone/etc/sunstone-views.yaml index 0bdddc39aa..2b7b0f70be 100644 --- a/src/sunstone/etc/sunstone-views.yaml +++ b/src/sunstone/etc/sunstone-views.yaml @@ -5,6 +5,7 @@ available_tabs: - system-tab - users-tab - groups-tab + - vdcs-tab - acls-tab - vresources-tab - vms-tab diff --git a/src/sunstone/etc/sunstone-views/admin.yaml b/src/sunstone/etc/sunstone-views/admin.yaml index b9999f795f..7c60956313 100644 --- a/src/sunstone/etc/sunstone-views/admin.yaml +++ b/src/sunstone/etc/sunstone-views/admin.yaml @@ -5,6 +5,7 @@ enabled_tabs: system-tab: true users-tab: true groups-tab: true + vdcs-tab: true acls-tab: true vresources-tab: true vms-tab: true @@ -97,6 +98,19 @@ tabs: Group.create_dialog: true Group.quotas_dialog: true Group.delete: true + vdcs-tab: + panel_tabs: + vdc_info_tab: true + table_columns: + - 0 # Checkbox + - 1 # ID + - 2 # Name + actions: + Vdc.refresh: true + Vdc.create_dialog: true + Vdc.update_dialog: true + Vdc.delete: true + acls-tab: panel_tabs: table_columns: diff --git a/src/sunstone/models/OpenNebulaJSON.rb b/src/sunstone/models/OpenNebulaJSON.rb index 76a1be236a..01ec44ae74 100644 --- a/src/sunstone/models/OpenNebulaJSON.rb +++ b/src/sunstone/models/OpenNebulaJSON.rb @@ -31,6 +31,7 @@ require 'OpenNebulaJSON/AclJSON' require 'OpenNebulaJSON/DatastoreJSON' require 'OpenNebulaJSON/ZoneJSON' require 'OpenNebulaJSON/SecurityGroupJSON' +require 'OpenNebulaJSON/VdcJSON' module OpenNebula class Error diff --git a/src/sunstone/models/OpenNebulaJSON/PoolJSON.rb b/src/sunstone/models/OpenNebulaJSON/PoolJSON.rb index 5855209c60..e5b84011f7 100644 --- a/src/sunstone/models/OpenNebulaJSON/PoolJSON.rb +++ b/src/sunstone/models/OpenNebulaJSON/PoolJSON.rb @@ -29,4 +29,5 @@ module OpenNebulaJSON class DatastorePoolJSON < OpenNebula::DatastorePool; include JSONUtils; end class ZonePoolJSON < OpenNebula::ZonePool; include JSONUtils; end class SecurityGroupPoolJSON < OpenNebula::SecurityGroupPool; include JSONUtils; end + class VdcPoolJSON < OpenNebula::VdcPool; include JSONUtils; end end diff --git a/src/sunstone/models/OpenNebulaJSON/VdcJSON.rb b/src/sunstone/models/OpenNebulaJSON/VdcJSON.rb new file mode 100644 index 0000000000..ccb9bbdf1b --- /dev/null +++ b/src/sunstone/models/OpenNebulaJSON/VdcJSON.rb @@ -0,0 +1,114 @@ +# -------------------------------------------------------------------------- # +# Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # + +require 'OpenNebulaJSON/JSONUtils' + +module OpenNebulaJSON + class VdcJSON < OpenNebula::Vdc + include JSONUtils + + def create(template_json) + vdc_hash = parse_json(template_json, 'vdc') + + if OpenNebula.is_error?(vdc_hash) + return vdc_hash + end + + if vdc_hash['vdc_raw'] + template = vdc_hash['vdc_raw'] + else + template = template_to_str(vdc_hash) + end + + self.allocate(template) + end + + def perform_action(template_json) + action_hash = parse_json(template_json, 'action') + if OpenNebula.is_error?(action_hash) + return action_hash + end + + rc = case action_hash['perform'] + when "add_group" then self.add_group(action_hash['params']) + when "del_group" then self.del_group(action_hash['params']) + when "add_cluster" then self.add_cluster(action_hash['params']) + when "del_cluster" then self.del_cluster(action_hash['params']) + when "add_host" then self.add_host(action_hash['params']) + when "del_host" then self.del_host(action_hash['params']) + when "add_datastore" then self.add_datastore(action_hash['params']) + when "del_datastore" then self.del_datastore(action_hash['params']) + when "add_vnet" then self.add_vnet(action_hash['params']) + when "del_vnet" then self.del_vnet(action_hash['params']) + when "update" then self.update(action_hash['params']) + when "rename" then self.rename(action_hash['params']) + + else + error_msg = "#{action_hash['perform']} action not " << + " available for this resource" + OpenNebula::Error.new(error_msg) + end + end + + def add_group(params=Hash.new) + super(params['group_id'].to_i) + end + + def del_group(params=Hash.new) + super(params['group_id'].to_i) + end + + def add_cluster(params=Hash.new) + super(params['zone_id'].to_i, params['cluster_id'].to_i) + end + + def del_cluster(params=Hash.new) + super(params['zone_id'].to_i, params['cluster_id'].to_i) + end + + def add_host(params=Hash.new) + super(params['zone_id'].to_i, params['host_id'].to_i) + end + + def del_host(params=Hash.new) + super(params['zone_id'].to_i, params['host_id'].to_i) + end + + def add_datastore(params=Hash.new) + super(params['zone_id'].to_i, params['ds_id'].to_i) + end + + def del_datastore(params=Hash.new) + super(params['zone_id'].to_i, params['ds_id'].to_i) + end + + def add_vnet(params=Hash.new) + super(params['zone_id'].to_i, params['vnet_id'].to_i) + end + + def del_vnet(params=Hash.new) + super(params['zone_id'].to_i, params['vnet_id'].to_i) + end + + def update(params=Hash.new) + super(params['template_raw']) + end + + def rename(params=Hash.new) + super(params['name']) + end + end +end diff --git a/src/sunstone/models/SunstoneServer.rb b/src/sunstone/models/SunstoneServer.rb index 5aaa8b2054..78bfe8ac44 100644 --- a/src/sunstone/models/SunstoneServer.rb +++ b/src/sunstone/models/SunstoneServer.rb @@ -64,6 +64,7 @@ class SunstoneServer < CloudServer when "datastore" then DatastorePoolJSON.new(client) when "zone" then ZonePoolJSON.new(client) when "security_group" then SecurityGroupPoolJSON.new(client, user_flag) + when "vdc" then VdcPoolJSON.new(client) else error = Error.new("Error: #{kind} resource not supported") return [404, error.to_json] @@ -120,6 +121,7 @@ class SunstoneServer < CloudServer when "datastore" then DatastoreJSON.new(Acl.build_xml, @client) when "zone" then ZoneJSON.new(Zone.build_xml, @client) when "security_group" then SecurityGroupJSON.new(SecurityGroup.build_xml, @client) + when "vdc" then VdcJSON.new(Vdc.build_xml, @client) else error = Error.new("Error: #{kind} resource not supported") return [404, error.to_json] @@ -440,6 +442,7 @@ class SunstoneServer < CloudServer when "datastore" then DatastoreJSON.new_with_id(id, @client) when "zone" then ZoneJSON.new_with_id(id, @client) when "security_group" then SecurityGroupJSON.new_with_id(id, @client) + when "vdc" then VdcJSON.new_with_id(id, @client) else error = Error.new("Error: #{kind} resource not supported") return error diff --git a/src/sunstone/public/js/opennebula.js b/src/sunstone/public/js/opennebula.js index 152c4c5019..346ae44da3 100644 --- a/src/sunstone/public/js/opennebula.js +++ b/src/sunstone/public/js/opennebula.js @@ -1580,6 +1580,86 @@ var OpenNebula = { } }, + + "Vdc" : { + "resource" : "VDC", + + "create" : function(params){ + OpenNebula.Action.create(params,OpenNebula.Vdc.resource); + }, + "del" : function(params){ + OpenNebula.Action.del(params,OpenNebula.Vdc.resource); + }, + "list" : function(params){ + OpenNebula.Action.list(params,OpenNebula.Vdc.resource); + }, + "show" : function(params){ + OpenNebula.Action.show(params,OpenNebula.Vdc.resource); + }, + "update" : function(params){ + var action_obj = {"template_raw" : params.data.extra_param }; + OpenNebula.Action.simple_action(params, + OpenNebula.Vdc.resource, + "update", + action_obj); + }, + "fetch_template" : function(params){ + OpenNebula.Action.show(params,OpenNebula.Vdc.resource,"template"); + }, + "rename" : function(params){ + var action_obj = params.data.extra_param; + OpenNebula.Action.simple_action(params, + OpenNebula.Vdc.resource, + "rename", + action_obj); + }, + + "add_group" : function(params){ + var action_obj = params.data.extra_param; + OpenNebula.Action.simple_action(params,OpenNebula.Vdc.resource,"add_group",action_obj); + }, + "del_group" : function(params){ + var action_obj = params.data.extra_param; + OpenNebula.Action.simple_action(params,OpenNebula.Vdc.resource,"del_group",action_obj); + }, + + "add_cluster" : function(params){ + var action_obj = params.data.extra_param; + OpenNebula.Action.simple_action(params,OpenNebula.Vdc.resource,"add_cluster",action_obj); + }, + "del_cluster" : function(params){ + var action_obj = params.data.extra_param; + OpenNebula.Action.simple_action(params,OpenNebula.Vdc.resource,"del_cluster",action_obj); + }, + + "add_host" : function(params){ + var action_obj = params.data.extra_param; + OpenNebula.Action.simple_action(params,OpenNebula.Vdc.resource,"add_host",action_obj); + }, + "del_host" : function(params){ + var action_obj = params.data.extra_param; + OpenNebula.Action.simple_action(params,OpenNebula.Vdc.resource,"del_host",action_obj); + }, + + "add_datastore" : function(params){ + var action_obj = params.data.extra_param; + OpenNebula.Action.simple_action(params,OpenNebula.Vdc.resource,"add_datastore",action_obj); + }, + "del_datastore" : function(params){ + var action_obj = params.data.extra_param; + OpenNebula.Action.simple_action(params,OpenNebula.Vdc.resource,"del_datastore",action_obj); + }, + + "add_vnet" : function(params){ + var action_obj = params.data.extra_param; + OpenNebula.Action.simple_action(params,OpenNebula.Vdc.resource,"add_vnet",action_obj); + }, + "del_vnet" : function(params){ + var action_obj = params.data.extra_param; + OpenNebula.Action.simple_action(params,OpenNebula.Vdc.resource,"del_vnet",action_obj); + } + }, + "Marketplace" : { "resource" : "MARKETPLACE", diff --git a/src/sunstone/public/js/plugins/vdcs-tab.js b/src/sunstone/public/js/plugins/vdcs-tab.js new file mode 100644 index 0000000000..e5af0b94b7 --- /dev/null +++ b/src/sunstone/public/js/plugins/vdcs-tab.js @@ -0,0 +1,494 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); you may */ +/* not use this file except in compliance with the License. You may obtain */ +/* a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ +/* See the License for the specific language governing permissions and */ +/* limitations under the License. */ +/* -------------------------------------------------------------------------- */ + +var create_vdc_wizard_html = + '
\ +
\ +
\ +

'+tr("General")+'
\ +
\ +
\ +
\ +
\ +
\ + \ + \ +
\ +
\ +
\ +
\ + \ + ' + + '
' + + '
' + + ''; + +var dataTable_vdcs; + +//Setup actions + +var vdc_actions = { + "Vdc.create" : { + type: "create", + call: OpenNebula.Vdc.create, + callback: function(request, response) { + $("a[href=back]", $("#vdcs-tab")).trigger("click"); + popFormDialog("create_vdc_form", $("#vdcs-tab")); + + addVdcElement(request, response); + notifyCustom(tr("Virtual Data Center created"), " ID: " + response.VDC.ID, false); + }, + error: onError + }, + + "Vdc.create_dialog" : { + type: "custom", + call: function(){ + Sunstone.popUpFormPanel("create_vdc_form", "vdcs-tab", "create", true, function(context){ + refreshSecurityGroupTableSelect(context, "vdc_create"); + + $("#default_sg_warning").show(); + $("input#name",context).focus(); + }); + } + }, + + "Vdc.list" : { + type: "list", + call: OpenNebula.Vdc.list, + callback: updateVdcsView, + error: onError + }, + + "Vdc.show" : { + type: "single", + call: OpenNebula.Vdc.show, + callback: function(request, response) { + updateVdcElement(request, response); + if (Sunstone.rightInfoVisible($("#vdcs-tab"))) { + updateVdcInfo(request, response); + } + }, + error: onError + }, + + "Vdc.refresh" : { + type: "custom", + call: function(){ + var tab = dataTable_vdcs.parents(".tab"); + if (Sunstone.rightInfoVisible(tab)) { + Sunstone.runAction("Vdc.show", Sunstone.rightInfoResourceId(tab)) + } else { + waitingNodes(dataTable_vdcs); + Sunstone.runAction("Vdc.list", {force: true}); + } + } + }, + + "Vdc.delete" : { + type: "multiple", + call: OpenNebula.Vdc.del, + callback: deleteVdcElement, + elements: vdcElements, + error: onError + }, + + "Vdc.rename" : { + type: "single", + call: OpenNebula.Vdc.rename, + callback: function(request) { + Sunstone.runAction('Vdc.show',request.request.data[0][0]); + }, + error: onError + }, + + "Vdc.update_dialog" : { + type: "custom", + call: function(){ + var selected_nodes = getSelectedNodes(dataTable_vdcs); + if ( selected_nodes.length != 1 ) { + notifyMessage("Please select one (and just one) Virtual Data Center to update."); + return false; + } + + var resource_id = ""+selected_nodes[0]; + Sunstone.runAction("Vdc.show_to_update", resource_id); + } + }, + + "Vdc.show_to_update" : { + type: "single", + call: OpenNebula.Vdc.show, + callback: function(request, response) { + // TODO: global var, better use jquery .data + vdc_to_update_id = response.VDC.ID; + + Sunstone.popUpFormPanel("create_vdc_form", "vdcs-tab", "update", true, function(context){ + fillVdcUpdateFormPanel(response.VDC, context); + + $("#default_sg_warning").hide(); + }); + }, + error: onError + }, + + "Vdc.update" : { + type: "single", + call: OpenNebula.Vdc.update, + callback: function(request, response){ + $("a[href=back]", $("#vdcs-tab")).trigger("click"); + popFormDialog("create_vdc_form", $("#vdcs-tab")); + + notifyMessage(tr("Virtual Data Center updated correctly")); + }, + error: function(request, response){ + popFormDialog("create_vdc_form", $("#vdcs-tab")); + + onError(request, response); + } + }, + + "Vdc.update_template" : { + type: "single", + call: OpenNebula.Vdc.update, + callback: function(request) { + Sunstone.runAction('Vdc.show',request.request.data[0][0]); + }, + error: onError + } +}; + + +var vdc_buttons = { + "Vdc.refresh" : { + type: "action", + layout: "refresh", + alwaysActive: true + }, + +// "Sunstone.toggle_top" : { +// type: "custom", +// layout: "top", +// alwaysActive: true +// }, + + "Vdc.create_dialog" : { + type: "create_dialog", + layout: "create" + }, + "Vdc.update_dialog" : { + type: "action", + layout: "main", + text: tr("Update") + }, + + "Vdc.delete" : { + type: "confirm", + layout: "del", + text: tr("Delete") + } +} + +var vdc_info_panel = { + "vdc_info_tab" : { + title: tr("Virtual Data Center information"), + content: "" + } +} + +var vdcs_tab = { + title: tr("Virtual Data Centers"), + resource: 'Vdc', + buttons: vdc_buttons, + tabClass: "subTab", + parentTab: "system-tab", + search_input: '', + list_header: ' '+tr("Virtual Data Centers"), + info_header: ' '+tr("Virtual Data Center"), + subheader: ' '+tr("TOTAL")+'', + table: '\ + \ + \ + \ + \ + \ + \ + \ + \ + \ +
'+tr("ID")+''+tr("Name")+'
', + forms: { + "create_vdc_form": { + actions: { + create: { + title: tr("Create Virtual Data Center"), + submit_text: tr("Create") + }, + update: { + title: tr("Update Virtual Data Center"), + submit_text: tr("Update"), + reset_button: false + } + }, + wizard_html: create_vdc_wizard_html, + advanced_html: create_vdc_advanced_html, + setup: initialize_create_vdc_dialog + } + } +} + +Sunstone.addActions(vdc_actions); +Sunstone.addMainTab('vdcs-tab',vdcs_tab); +Sunstone.addInfoPanel('vdc_info_panel',vdc_info_panel); + +// return list of selected elements in list +function vdcElements(){ + return getSelectedNodes(dataTable_vdcs); +} + +//returns an array with the VDC information fetched from the JSON object +function vdcElementArray(vdc_json){ + var vdc = vdc_json.VDC; + + return [ + '', + vdc.ID, + vdc.NAME + ]; +} + +//Callback to update a vdc element after an action on it +function updateVdcElement(request, vdc_json){ + id = vdc_json.VDC.ID; + element = vdcElementArray(vdc_json); + updateSingleElement(element,dataTable_vdcs,'#vdc_'+id); +} + +//Callback to delete a vdc element from the table +function deleteVdcElement(req){ + deleteElement(dataTable_vdcs,'#vdc_'+req.request.data); +} + +//Callback to add a new element +function addVdcElement(request,vdc_json){ + var element = vdcElementArray(vdc_json); + addElement(element,dataTable_vdcs); +} + +//updates the list of vdcs +function updateVdcsView(request, vdc_list){ + var vdc_list_array = []; + + $.each(vdc_list,function(){ + vdc_list_array.push(vdcElementArray(this)); + }); + + updateView(vdc_list_array,dataTable_vdcs); + + $(".total_vdcs").text(vdc_list.length); +} + +//updates the information panel tabs and pops the panel up +function updateVdcInfo(request,vdc){ + var vdc_info = vdc.VDC; + + $(".resource-info-header", $("#vdcs-tab")).html(vdc_info.NAME); + + var info_tab_content = + '
\ +
\ + \ + \ + \ + \ + \ + \ + \ + \ + '+ + insert_rename_tr( + 'vdcs-tab', + "Vdc", + vdc_info.ID, + vdc_info.NAME)+ + '
'+tr("Information")+'
'+tr("ID")+''+vdc_info.ID+'
\ +
\ +
\ +
\ +
' + + insert_extended_template_table(vdc_info.TEMPLATE, + "Vdc", + vdc_info.ID, + tr("Attributes")) + + '
\ +
'; + + var info_tab = { + title : tr("Info"), + icon: "fa-info-circle", + content: info_tab_content + }; + + Sunstone.updateInfoPanelTab("vdc_info_panel","vdc_info_tab",info_tab); + + Sunstone.popUpInfoPanel("vdc_info_panel", "vdcs-tab"); +} + +function initialize_create_vdc_dialog(dialog) { + + setupCustomTags($("#vdcCreateGeneralTab", dialog)); + + dialog.foundation(); + + //Process form + $('#create_vdc_form_wizard',dialog).on('invalid.fndtn.abide', function () { + notifyError(tr("One or more required fields are missing or malformed.")); + popFormDialog("create_vdc_form", $("#vdcs-tab")); + }).on('valid.fndtn.abide', function() { + //Fetch values + var vdc_json = {}; + + retrieveWizardFields($("#vdcCreateGeneralTab", dialog), vdc_json); + + retrieveCustomTags($("#vdcCreateGeneralTab", dialog), vdc_json); + + if ($('#create_vdc_form_wizard',dialog).attr("action") == "create") { + vdc_json = { + "vdc" : vdc_json + }; + + Sunstone.runAction("Vdc.create",vdc_json); + return false; + } else if ($('#create_vdc_form_wizard',dialog).attr("action") == "update") { + Sunstone.runAction("Vdc.update", vdc_to_update_id, convert_template_to_string(vdc_json)); + return false; + } + }); + + $('#create_vdc_form_advanced',dialog).on('invalid.fndtn.abide', function () { + notifyError(tr("One or more required fields are missing or malformed.")); + popFormDialog("create_vdc_form", $("#vdcs-tab")); + }).on('valid.fndtn.abide', function() { + if ($('#create_vdc_form_advanced',dialog).attr("action") == "create") { + + var template = $('textarea#template',dialog).val(); + var vdc_json = {vdc: {vdc_raw: template}}; + Sunstone.runAction("Vdc.create",vdc_json); + return false; + + } else if ($('#create_vdc_form_advanced',dialog).attr("action") == "update") { + var template_raw = $('textarea#template',dialog).val(); + + Sunstone.runAction("Vdc.update",vdc_to_update_id,template_raw); + return false; + } + }); + + setupTips(dialog); +} + +function fillVdcUpdateFormPanel(vdc, dialog){ + + // Populates the Avanced mode Tab + $('#template',dialog).val(convert_template_to_string(vdc.TEMPLATE).replace(/^[\r\n]+$/g, "")); + + $('[wizard_field="NAME"]',dialog).val( + escapeDoubleQuotes(htmlDecode( vdc.NAME ))). + prop("disabled", true). + prop('wizard_field_disabled', true); + + fillWizardFields($("#vdcCreateGeneralTab", dialog), vdc.TEMPLATE); + + // Delete so these attributes don't end in the custom tags table also + var fields = $('[wizard_field]', dialog); + + fields.each(function(){ + var field = $(this); + var field_name = field.attr('wizard_field'); + + delete vdc.TEMPLATE[field_name]; + }); + + fillCustomTags($("#vdcCreateGeneralTab", dialog), vdc.TEMPLATE); +} + +//The DOM is ready and the ready() from sunstone.js +//has been executed at this point. +$(document).ready(function(){ + var tab_name = 'vdcs-tab'; + + if (Config.isTabEnabled(tab_name)) { + dataTable_vdcs = $("#datatable_vdcs",main_tabs_context).dataTable({ + "bSortClasses": false, + "bDeferRender": true, + "aoColumnDefs": [ + { "bSortable": false, "aTargets": ["check"] }, + { "sWidth": "35px", "aTargets": [0] }, + { "bVisible": true, "aTargets": Config.tabTableColumns(tab_name)}, + { "bVisible": false, "aTargets": ['_all']} + ] + }); + + $('#vdc_search').keyup(function(){ + dataTable_vdcs.fnFilter( $(this).val() ); + }) + + dataTable_vdcs.on('draw', function(){ + recountCheckboxes(dataTable_vdcs); + }) + + Sunstone.runAction("Vdc.list"); + + initCheckAllBoxes(dataTable_vdcs); + tableCheckboxesListener(dataTable_vdcs); + infoListener(dataTable_vdcs,'Vdc.show'); + + $('div#vdcs_tab div.legend_div').hide(); + + dataTable_vdcs.fnSort( [ [1,config['user_config']['table_order']] ] ); + } +});