From 8ee4cb0379e13ebdc367589e776be9435b1e8ca1 Mon Sep 17 00:00:00 2001 From: Tino Vazquez Date: Tue, 14 Jan 2014 11:38:42 +0100 Subject: [PATCH] Feature #2613: Add endpoint display, Zone creation dialog on Sunstone --- .../models/OpenNebulaJSON/ZoneJSON.rb | 5 +- .../public/js/plugins/clusters-tab.js | 2 +- src/sunstone/public/js/plugins/users-tab.js | 2 +- src/sunstone/public/js/plugins/zones-tab.js | 86 +++++++++++++------ 4 files changed, 66 insertions(+), 29 deletions(-) diff --git a/src/sunstone/models/OpenNebulaJSON/ZoneJSON.rb b/src/sunstone/models/OpenNebulaJSON/ZoneJSON.rb index fd9f7fa1ec..4959ac90b0 100644 --- a/src/sunstone/models/OpenNebulaJSON/ZoneJSON.rb +++ b/src/sunstone/models/OpenNebulaJSON/ZoneJSON.rb @@ -22,11 +22,14 @@ module OpenNebulaJSON def create(template_json) zone_hash = parse_json(template_json, 'zone') + if OpenNebula.is_error?(zone_hash) return zone_hash end - self.allocate(zone_hash['name']) + template = template_to_str(zone_hash) + + self.allocate(template) end def perform_action(template_json) diff --git a/src/sunstone/public/js/plugins/clusters-tab.js b/src/sunstone/public/js/plugins/clusters-tab.js index 6a4f10aa0d..a5d7f6716e 100644 --- a/src/sunstone/public/js/plugins/clusters-tab.js +++ b/src/sunstone/public/js/plugins/clusters-tab.js @@ -1462,7 +1462,7 @@ $(document).ready(function(){ var tab_name = "clusters-tab" if (Config.isTabEnabled(tab_name)) { - //prepare host datatabl + //prepare clusters datatable dataTable_clusters = $("#datatable_clusters",main_tabs_context).dataTable({ "aoColumnDefs": [ { "bSortable": false, "aTargets": ["check"] }, diff --git a/src/sunstone/public/js/plugins/users-tab.js b/src/sunstone/public/js/plugins/users-tab.js index 4a7dc13ec2..30144f435c 100644 --- a/src/sunstone/public/js/plugins/users-tab.js +++ b/src/sunstone/public/js/plugins/users-tab.js @@ -146,7 +146,7 @@ var user_creation_div = var create_user_tmpl = '
\

\ - '+tr("Create User")+'\ + '+tr("Create User")+'\

\
\
'+ diff --git a/src/sunstone/public/js/plugins/zones-tab.js b/src/sunstone/public/js/plugins/zones-tab.js index ae388f8a04..8dfa357463 100644 --- a/src/sunstone/public/js/plugins/zones-tab.js +++ b/src/sunstone/public/js/plugins/zones-tab.js @@ -20,7 +20,7 @@ //Prepares the dialog to create function setupCreateZoneDialog(){ // TODO -/* + dialogs_context.append('
'); $create_zone_dialog = $('#create_zone_dialog',dialogs_context); var dialog = $create_zone_dialog; @@ -29,30 +29,64 @@ function setupCreateZoneDialog(){ dialog.addClass("reveal-modal"); $('#create_zone_form',dialog).submit(function(){ - var name=$('#name',this).val(); - var zone_json = { "zone" : { "name" : name }}; + var name=$('#zonename',this).val(); + var endpoint=$("#endpoint",this).val(); + var zone_json = { "zone" : { "name" : name, "endpoint" : endpoint}}; Sunstone.runAction("Zone.create",zone_json); $create_zone_dialog.trigger("reveal:close"); return false; }); -*/ + } function popUpCreateZoneDialog(){ - // TODO - return false; -/* $create_zone_dialog.reveal(); $("input#name",$create_zone_dialog).focus(); return false; -*/ } // Open update dialog -function popUpUpdateZoneDialog(){ +//function popUpUpdateZoneDialog(){ // TODO -} +//} + +var create_zone_tmpl = +'
\ +

\ + '+tr("Create Zone")+'\ +

\ +
\ +\ +
\ +
\ + \ +
\ +
\ + \ +
\ +
\ +
\ +
\ +
\ +
\ +
\ + \ +
\ +
\ + \ +
\ +
\ +
\ +
\ +
\ +
\ +
\ + \ + \ +
\ + ×\ +
'; var zones_tab_content = '\ @@ -90,6 +124,7 @@ var zones_tab_content = '\ \ ' + tr("ID") + '\ ' + tr("Name") + '\ + ' + tr("Endpoint") + '\ \ \ \ @@ -101,7 +136,7 @@ var zones_select=""; var dataTable_zones; var $create_zone_dialog; -// TODO: Some methods are not yet implemented in oned (rename, update) +// TODO: Some methods are not yet implemented in oned (eg, rename) //Setup actions var zone_actions = { @@ -111,9 +146,6 @@ var zone_actions = { call: OpenNebula.Zone.create, callback: function(request, response){ Sunstone.runAction('Zone.list'); - - //Sunstone.runAction('Zone.list'); - // Sunstone.runAction('Zone.show',response.ZONE.ID); }, error: onError, notify: true @@ -197,10 +229,10 @@ var zone_actions = { error: onError }, - "Zone.update_dialog" : { - type: "single", - call: popUpUpdateZoneDialog - }, + // "Zone.update_dialog" : { + // type: "single", + // call: popUpUpdateZoneDialog + // }, "Zone.rename" : { type: "single", @@ -225,12 +257,12 @@ var zone_buttons = { type: "create_dialog", layout: "create" }, - "Zone.update_dialog" : { - type : "action", - layout: "main", - text : tr("Update"), - alwaysActive: true - }, + // "Zone.update_dialog" : { + // type : "action", + // layout: "main", + // text : tr("Update"), + // alwaysActive: true + // }, "Zone.delete" : { type: "confirm", layout: "del", @@ -270,7 +302,8 @@ function zoneElementArray(element_json){ return [ '', element.ID, - element.NAME + element.NAME, + element.TEMPLATE.ENDPOINT ]; } @@ -281,6 +314,7 @@ function updateZoneSelect(){ zones_select += makeSelectOptions(dataTable_zones, 1,//id_col 2,//name_col + 3,//endpoint_col [],//status_cols [],//bad_st true @@ -418,7 +452,7 @@ $(document).ready(function(){ var tab_name = "zones-tab" if (Config.isTabEnabled(tab_name)) { - //prepare zone datatabl + //prepare zone datatable dataTable_zones = $("#datatable_zones",main_tabs_context).dataTable({ "aoColumnDefs": [ { "bSortable": false, "aTargets": ["check"] },