From af4d7c462ab9dcdd6da710fb86adbad29bddda14 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Fri, 10 May 2013 18:29:04 +0200 Subject: [PATCH] Start working on appFlow integration with the new Sunstone --- flow/install.sh | 2 +- ...board.js => apptools-appflow-dashboard.js} | 2 +- ...rvices.js => apptools-appflow-services.js} | 130 +++--- ...lates.js => apptools-appflow-templates.js} | 395 ++++++++---------- 4 files changed, 248 insertions(+), 281 deletions(-) rename flow/sunstone/public/js/{apptools.appflow-dashboard.js => apptools-appflow-dashboard.js} (98%) rename flow/sunstone/public/js/{apptools.appflow.services.js => apptools-appflow-services.js} (93%) rename flow/sunstone/public/js/{apptools.appflow.templates.js => apptools-appflow-templates.js} (77%) diff --git a/flow/install.sh b/flow/install.sh index 15ce378d37..def55e38c6 100755 --- a/flow/install.sh +++ b/flow/install.sh @@ -45,7 +45,7 @@ copy_files "lib/* models.rb config.ru Gemfile Gemfile.lock \ Rakefile" "$LIB_LOCATION/flow" # Sunstone -copy_files "sunstone/public/js/*" "$SUNSTONE_LOCATION/public/js" +copy_files "sunstone/public/js/*" "$SUNSTONE_LOCATION/public/js/plugins" copy_files "sunstone/public/images/*" "$SUNSTONE_LOCATION/public/images" copy_files "sunstone/routes/*" "$SUNSTONE_LOCATION/routes" diff --git a/flow/sunstone/public/js/apptools.appflow-dashboard.js b/flow/sunstone/public/js/apptools-appflow-dashboard.js similarity index 98% rename from flow/sunstone/public/js/apptools.appflow-dashboard.js rename to flow/sunstone/public/js/apptools-appflow-dashboard.js index 60546ff742..2dac8f6ff9 100644 --- a/flow/sunstone/public/js/apptools.appflow-dashboard.js +++ b/flow/sunstone/public/js/apptools-appflow-dashboard.js @@ -91,7 +91,7 @@ var appflow_dashboard_tmpl = '\ var appflow_dashboard_tab = { title: 'AppFlow', - content: appflow_dashboard_tmpl, + //content: appflow_dashboard_tmpl, } diff --git a/flow/sunstone/public/js/apptools.appflow.services.js b/flow/sunstone/public/js/apptools-appflow-services.js similarity index 93% rename from flow/sunstone/public/js/apptools.appflow.services.js rename to flow/sunstone/public/js/apptools-appflow-services.js index f61555a287..ab24c80660 100644 --- a/flow/sunstone/public/js/apptools.appflow.services.js +++ b/flow/sunstone/public/js/apptools-appflow-services.js @@ -85,33 +85,54 @@ var Role = { } var service_tab_content = '\ -

'+tr("AppFlow - Services")+'

\ -
\ -
\ +\ +
\ +
\ +
\ +

\ + \ + '+tr("AppFlow - Services")+'\ + \ + \ +  \ + \ + \ +

\
\ -\ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ -
'+tr("All")+''+tr("ID")+''+tr("Owner")+''+tr("Group")+''+tr("Name")+''+tr("State")+'
\ -\ +
\ +
\ +
\ +
\ +
\ +
\ + \ +
\ +
\ +
\ +
\ +
\ +
\ +
\ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ +
'+tr("ID")+''+tr("Owner")+''+tr("Group")+''+tr("Name")+''+tr("State")+'
\ +
\ +
\ '; + /*+++++++++++++++++++++++++++++++ var create_service_tmpl = '\
\ @@ -222,11 +243,6 @@ var service_actions = { error: onError }, - "Service.update_dialog" : { - type : "custom", - call : popUpServiceUpdateDialog - }, - "Service.show" : { type : "single", call: Service.show, @@ -339,13 +355,7 @@ var service_actions = { var service_buttons = { "Service.refresh" : { type: "action", - text: '', - alwaysActive: true - }, - - "Service.update_dialog" : { - type: "action", - text: tr("Update properties"), + layout: "refresh", alwaysActive: true }, @@ -354,6 +364,7 @@ var service_buttons = { text: tr("Change owner"), select: users_sel, tip: tr("Select the new owner")+":", + layout: "user_select", condition: mustBeAdmin }, "Service.chgrp" : { @@ -361,6 +372,7 @@ var service_buttons = { text: tr("Change group"), select: groups_sel, tip: tr("Select the new group")+":", + layout: "user_select", condition: mustBeAdmin }, /* @@ -371,17 +383,14 @@ var service_buttons = { */ "Service.shutdown" : { type: "action", + layout: "main", text: tr("Shutdown") }, "Service.delete" : { type: "confirm", text: tr("Delete"), + layout: "del", tip: tr("This will delete the selected services") - }, - "Service.help" : { - type: "action", - text: '?', - alwaysActive: true } } @@ -401,7 +410,7 @@ var services_tab = { } Sunstone.addActions(service_actions); -Sunstone.addMainTab('services_tab',services_tab); +Sunstone.addMainTab('apptools-appflow-services',services_tab); Sunstone.addInfoPanel('service_info_panel',service_info_panel); @@ -614,7 +623,7 @@ function updateServiceInfo(request,elem){ if (logs) { log_info += '\ ' - + for (var i = 0; i < logs.length; i++) { log_info += '\ \ @@ -719,15 +728,8 @@ function setupServiceUpdateDialog(){ var height = Math.floor($(window).height()*0.8); //set height to a percentage of the window //Convert into jQuery - dialog.dialog({ - autoOpen:false, - width:500, - modal:true, - height:height, - resizable:true - }); + dialog.addClass("reveal-modal xlarge"); - $('button',dialog).button(); $('#service_update_select',dialog).change(function(){ var id = $(this).val(); @@ -746,7 +748,7 @@ function setupServiceUpdateDialog(){ var dialog = $(this); var id = $('#service_update_select',dialog).val(); if (!id || !id.length) { - $(this).parents('#service_update_dialog').dialog('close'); + $(this).parents('#service_update_dialog').trigger("reveal:close") return false; }; @@ -758,7 +760,7 @@ function setupServiceUpdateDialog(){ Sunstone.runAction("Service.chmod", id, perms); }; - $(this).parents('#service_update_dialog').dialog('close'); + $(this).parents('#service_update_dialog').trigger("reveal:close") return false; }); }; @@ -797,7 +799,7 @@ function popUpServiceUpdateDialog(){ }; }; - dialog.dialog('open'); + dialog.reveal(); return false; } @@ -898,33 +900,23 @@ function popUpServiceCloneDialog(){ $(document).ready(function(){ dataTable_services = $("#datatable_services",main_tabs_context).dataTable({ - "bJQueryUI": true, - "bSortClasses": false, - "bAutoWidth":false, - "sDom" : '<"H"lfrC>t<"F"ip>', + "sDom" : "<'H'>t<'row'<'six columns'i><'six columns'p>>", "oColVis": { "aiExclude": [ 0 ] }, - "sPaginationType": "full_numbers", "aoColumnDefs": [ { "bSortable": false, "aTargets": ["check"] }, { "sWidth": "60px", "aTargets": [0] }, { "sWidth": "100px", "aTargets": [2,3] }, { "sWidth": "200px", "aTargets": [5] }, { "sWidth": "35px", "aTargets": [1] } - ], - "oLanguage": (datatable_lang != "") ? - { - sUrl: "locale/"+lang+"/"+datatable_lang - } : "" + ] }); + $('#services_search').keyup(function(){ + dataTable_services.fnFilter( $(this).val() ); + }) - - dataTable_services.fnClearTable(); - addElement([ - spinner, - '','','','','',''],dataTable_services); Sunstone.runAction("Service.list"); setupServiceUpdateDialog(); diff --git a/flow/sunstone/public/js/apptools.appflow.templates.js b/flow/sunstone/public/js/apptools-appflow-templates.js similarity index 77% rename from flow/sunstone/public/js/apptools.appflow.templates.js rename to flow/sunstone/public/js/apptools-appflow-templates.js index e8ecb5296f..f37344c3e6 100644 --- a/flow/sunstone/public/js/apptools.appflow.templates.js +++ b/flow/sunstone/public/js/apptools-appflow-templates.js @@ -56,98 +56,173 @@ var ServiceTemplate = { } var service_template_tab_content = '\ -

'+tr("AppFlow - Templates")+'

\ -\ -
\ +\ +
\ +
\ +
\ +

\ + \ + '+tr("AppFlow - Templates")+'\ + \ + \ +  \ + \ + \ +

\
\ -
'+pretty_time(logs[i].timestamp)+' ['+logs[i].severity + '] ' + logs[i].message+ '
\ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ -
'+tr("All")+''+tr("ID")+''+tr("Owner")+''+tr("Group")+''+tr("Name")+'
\ -\ +
\ +
\ +
\ +
\ +
\ +
\ + \ +
\ +
\ +
\ +
\ +
\ +
\ +
\ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ +
'+tr("ID")+''+tr("Owner")+''+tr("Group")+''+tr("Name")+'
\ +
\ +
\ '; var create_service_template_tmpl = '\ -
\ -

'+ - tr("Fields marked with")+' '+ - tr("are mandatory")+'
\ -

\ - ' + tr("Service") + '\ -
\ - \ -
'+ tr("Name for this template") +'
\ -
\ -
\ - \ - \ -
'+ tr("Straight strategy will instantiate each role in order: parents role will be deployed before their children. None strategy will instantiate the roles regardless of their relationships.") +'
\ -
\ -
\ -
\ - ' + tr("Roles") + '\ -
\ - \ -
'+ tr("Name for the role") +'
\ -
\ -
\ - \ -
'+ tr("Number of VMs to instantiate with this role") +'
\ -
\ -
\ - \ - \ -
'+ tr("Template associated to this role") +'
\ -
\ -
\ - \ - \ -
'+ tr("Mark the roles that will be deployed before this one when using the straight strategy") +'
\ -
\ - \ - \ -
\ -
\ - ' + tr("Current Roles") + '\ - \ - \ - \ - \ - \ - \ - \ - \ - \ -
'+tr("Name")+''+tr("Card.")+''+tr("Template")+''+tr("Parents")+''+tr("Delete")+'
\ -
\ -
\ -
\ -
\ -
\ +
\ +

\ + '+tr("Create Service Template")+'\ +

\ +
\ +
\ + \ +
\ +
\ +
\ + \ +
\ +
\ + \ +
\ +
\ +
'+ tr("Name for this template") +'
\ +
\ +
\ +
\ +
\ + \ +
\ +
\ + \ +
\ +
\ +
'+ tr("Straight strategy will instantiate each role in order: parents role will be deployed before their children. None strategy will instantiate the roles regardless of their relationships.") +'
\ +
\ +
\
\ -
\ -
'; +
\ +
\ + ' + tr("Roles") + '\ +
\ +
\ +
\ + \ +
\ +
\ + \ +
\ +
\ +
'+ tr("Number of VMs to instantiate with this role") +'
\ +
\ +
\ +
\ +
\ + \ +
\ +
\ + \ +
\ +
\ +
'+ tr("Number of VMs to instantiate with this role") +'
\ +
\ +
\ +
\ +
\ + \ +
\ +
\ + \ +
\ +
\ +
'+ tr("Template associated to this role") +'
\ +
\ +
\ +
\ +
\ +
\ +
\ + \ +
\ +
\ + \ +
\ +
\ +
'+ tr("Mark the roles that will be deployed before this one when using the straight strategy") +'
\ +
\ +
\ +
\ +
\ +
\ + \ +
\ +
\ +
\ +
\ +
\ + \ + \ + \ + \ + \ + \ + \ + \ + \ +
'+tr("Name")+''+tr("Card.")+''+tr("Template")+''+tr("Parents")+''+tr("Delete")+'
\ +
\ +
\ +
\ + \ + ×\ + \ +
'; var update_service_template_tmpl = @@ -340,28 +415,31 @@ var service_template_actions = { var service_template_buttons = { "ServiceTemplate.refresh" : { type: "action", - text: '', + layout: "refresh", alwaysActive: true }, "ServiceTemplate.create_dialog" : { type: "create_dialog", - text: tr("+ New") + layout: "create" }, "ServiceTemplate.update_dialog" : { type: "action", - text: tr("Update properties"), + text: tr("Update"), + layout: "main", alwaysActive: true }, "ServiceTemplate.instantiate" : { type: "action", + layout: "main", text: tr("Instantiate") }, "ServiceTemplate.chown" : { type: "confirm_with_select", text: tr("Change owner"), select: users_sel, + layout: "user_select", tip: tr("Select the new owner")+":", condition: mustBeAdmin }, @@ -369,6 +447,7 @@ var service_template_buttons = { type: "confirm_with_select", text: tr("Change group"), select: groups_sel, + layout: "user_select", tip: tr("Select the new group")+":", condition: mustBeAdmin }, @@ -381,12 +460,8 @@ var service_template_buttons = { "ServiceTemplate.delete" : { type: "confirm", text: tr("Delete"), + layout: "del", tip: tr("This will delete the selected templates") - }, - "ServiceTemplate.help" : { - type: "action", - text: '?', - alwaysActive: true } } @@ -406,7 +481,7 @@ var service_templates_tab = { } Sunstone.addActions(service_template_actions); -Sunstone.addMainTab('service_templates_tab',service_templates_tab); +Sunstone.addMainTab('apptools-appflow-templates',service_templates_tab); Sunstone.addInfoPanel('service_template_info_panel',service_template_info_panel); @@ -581,7 +656,7 @@ function updateServiceTemplateInfo(request,elem){ else Sunstone.removeInfoPanelTab("service_template_info_panel","service_template_roles_tab"); - Sunstone.popUpInfoPanel("service_template_info_panel"); + Sunstone.popUpInfoPanel("service_template_info_panel", "apptools-appflow-templates"); } @@ -597,14 +672,8 @@ function setupCreateServiceTemplateDialog(){ var height = Math.floor($(window).height()*0.8); //set height to a percentage of the window //Prepare jquery dialog - dialog.dialog({ - autoOpen: false, - modal:true, - width: 650, - height: height - }); + dialog.addClass("reveal-modal xlarge max-height"); - $('button',dialog).button(); var addParentRole = function(name){ var select = $('select[name="parents"]', dialog); @@ -645,7 +714,7 @@ function setupCreateServiceTemplateDialog(){ }); $('button#add_role', dialog).click(function(){ - var context = $(this).parent(); + var context = $(this).closest('#new_role'); var name = $('input[name="name"]', context).val(); var cardinality = $('input[name="cardinality"]', context).val(); var template = $('select[name="vm_template"]', context).val(); @@ -715,7 +784,7 @@ function setupCreateServiceTemplateDialog(){ } Sunstone.runAction("ServiceTemplate.create", obj ); - dialog.dialog('close'); + dialog.trigger("reveal:close"); return false; }); } @@ -742,7 +811,7 @@ function popUpCreateServiceTemplateDialog(){ // return false; // }); - dialog.dialog('open'); + dialog.reveal(); } @@ -757,15 +826,8 @@ function setupServiceTemplateUpdateDialog(){ var height = Math.floor($(window).height()*0.8); //set height to a percentage of the window //Convert into jQuery - dialog.dialog({ - autoOpen:false, - width:500, - modal:true, - height:height, - resizable:true - }); + dialog.addClass("reveal-modal xlarge"); - $('button',dialog).button(); $('#service_template_update_select',dialog).change(function(){ var id = $(this).val(); @@ -784,7 +846,7 @@ function setupServiceTemplateUpdateDialog(){ var dialog = $(this); var id = $('#service_template_update_select',dialog).val(); if (!id || !id.length) { - $(this).parents('#service_template_update_dialog').dialog('close'); + $(this).parents('#service_template_update_dialog').trigger("reveal:close"); return false; }; @@ -796,7 +858,7 @@ function setupServiceTemplateUpdateDialog(){ Sunstone.runAction("ServiceTemplate.chmod", id, perms); }; - $(this).parents('#service_template_update_dialog').dialog('close'); + $(this).parents('#service_template_update_dialog').trigger("reveal:close"); return false; }); }; @@ -835,7 +897,7 @@ function popUpServiceTemplateUpdateDialog(){ }; }; - dialog.dialog('open'); + dialog.reveal(); return false; } @@ -851,114 +913,27 @@ function setServiceTemplateAutorefresh() { },INTERVAL+someTime()); }; -/* -function setupServiceTemplateCloneDialog(){ - //Append to DOM - dialogs_context.append('
'); - var dialog = $('#service_template_clone_dialog',dialogs_context); - - //Put HTML in place - - var html = '
\ -
'+tr("Choose a new name for the flowironment")+':
\ -
'+tr("Several flowironments are selected, please choose prefix to name the new copies")+':
\ -
\ -\ -\ -\ -
\ - \ -
\ -'; - - dialog.html(html); - - //Convert into jQuery - dialog.dialog({ - autoOpen:false, - width:375, - modal:true, - resizable:false - }); - - $('button',dialog).button(); - - $('form',dialog).submit(function(){ - var name = $('input', this).val(); - var sel_elems = serviceTemplateElements(); - if (!name || !sel_elems.length) - notifyError('A name or prefix is needed!'); - if (sel_elems.length > 1){ - for (var i=0; i< sel_elems.length; i++) - //If we are cloning several items we - //use the name as prefix - Sunstone.runAction('ServiceTemplate.clone', - sel_elems[i], - name + getName(sel_elems[i], - dataTable_service_templates, - 4)); - } else { - Sunstone.runAction('ServiceTemplate.clone',sel_elems[0],name) - }; - dialog.dialog('close'); - setTimeout(function(){ - Sunstone.runAction('ServiceTemplate.refresh'); - }, 1500); - return false; - }); -} - -function popUpServiceTemplateCloneDialog(){ - var dialog = $('#service_template_clone_dialog'); - var sel_elems = serviceTemplateElements(); - //show different text depending on how many elements are selected - if (sel_elems.length > 1){ - $('.clone_one',dialog).hide(); - $('.clone_several',dialog).show(); - $('input',dialog).val('Copy of '); - } - else { - $('.clone_one',dialog).show(); - $('.clone_several',dialog).hide(); - $('input',dialog).val('Copy of '+getName(sel_elems[0], - dataTable_service_templates, 4)); - }; - - $(dialog).dialog('open'); -} - -*/ //The DOM is ready at this point $(document).ready(function(){ dataTable_service_templates = $("#datatable_service_templates",main_tabs_context).dataTable({ - "bJQueryUI": true, - "bSortClasses": false, - "bAutoWidth":false, - "sDom" : '<"H"lfrC>t<"F"ip>', + "sDom" : "<'H'>t<'row'<'six columns'i><'six columns'p>>", "oColVis": { "aiExclude": [ 0 ] }, - "sPaginationType": "full_numbers", "aoColumnDefs": [ { "bSortable": false, "aTargets": ["check"] }, { "sWidth": "60px", "aTargets": [0] }, { "sWidth": "100px", "aTargets": [2,3] }, { "sWidth": "35px", "aTargets": [1] } - ], - "oLanguage": (datatable_lang != "") ? - { - sUrl: "locale/"+lang+"/"+datatable_lang - } : "" + ] }); - dataTable_service_templates.fnClearTable(); - addElement([ - spinner, - '','','','',''],dataTable_service_templates); + $('#service_templates_search').keyup(function(){ + dataTable_service_templates.fnFilter( $(this).val() ); + }) + Sunstone.runAction("ServiceTemplate.list");