mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-21 04:12:37 +09:00
appstage: Update app stage to use the new Sunstone layout
This commit is contained in:
1 parent
dbdaafc61e
commit
6fb50d43bc
5 files changed
+280
-299
No files matched your search
@@ -531,7 +531,7 @@ function updateServiceTemplateInfo(request,elem){
|
||||
|
||||
// Prepare the creation dialog
|
||||
function setupCreateServiceTemplateDialog(){
|
||||
dialogs_context.append('<div title="'+tr("Create service template")+'" id="create_service_template_dialog"></div>');
|
||||
dialogs_context.append('<div id="create_service_template_dialog"></div>');
|
||||
$create_service_template_dialog = $('#create_service_template_dialog',dialogs_context);
|
||||
|
||||
var dialog = $create_service_template_dialog;
|
||||
|
||||
+1
-1
@@ -21,6 +21,6 @@
|
||||
copy_files "lib/* cli/*" "$LIB_LOCATION/stage"
|
||||
copy_files "bin/*" "$BIN_LOCATION"
|
||||
copy_files "share/packages/*" "$PACKAGES_LOCATION"
|
||||
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"
|
||||
@@ -19,8 +19,8 @@ require 'json'
|
||||
|
||||
require 'opennebula'
|
||||
|
||||
require 'OpenNebula/document_json'
|
||||
require 'OpenNebula/document_pool_json'
|
||||
require 'opennebula/document_json'
|
||||
require 'opennebula/document_pool_json'
|
||||
|
||||
require 'onecast'
|
||||
|
||||
|
||||
+1
-1
@@ -85,7 +85,7 @@ var appstage_dashboard_tmpl = '\
|
||||
|
||||
var appstage_dashboard_tab = {
|
||||
title: '<i class="icon-magic"></i>AppStage',
|
||||
content: appstage_dashboard_tmpl,
|
||||
//content: appstage_dashboard_tmpl,
|
||||
}
|
||||
|
||||
|
||||
+275
-294
@@ -114,56 +114,104 @@ var appstage_tab_content = '\
|
||||
</form>';
|
||||
|
||||
var create_appstage_tmpl = '\
|
||||
<div class="create_form"><form id="create_appstage_form" action="">\
|
||||
<fieldset>\
|
||||
<legend style="display:none;">' + tr("Environment") + '</legend>\
|
||||
<div class="appstage_param">\
|
||||
<label for="name">' + tr("Name") + ':</label><input type="text" name="name" />\
|
||||
</div>\
|
||||
<div class="appstage_param">\
|
||||
<label for="description">' + tr("Description") + ':</label><input type="text" name="description" />\
|
||||
</div>\
|
||||
<div class="appstage_param">\
|
||||
<label for="templates">'+tr("Compatible templates")+':</label>\
|
||||
<select type="text" id="env_templates" name="templates" multiple>\
|
||||
</select>\
|
||||
</div>\
|
||||
<div class="appstage_param">\
|
||||
<label for="cookbooks">' + tr("Cookbooks URL") + ':</label><input type="text" name="cookbooks" />\
|
||||
</div>\
|
||||
</fieldset>\
|
||||
<!--\
|
||||
<fieldset>\
|
||||
<div class="appstage_param">\
|
||||
<label for="node">'+tr("Variables")+':</label>\
|
||||
<div class="clear"></div>\
|
||||
<label for="custom_var_appstage_name">'+tr("Name")+':</label>\
|
||||
<input type="text" id="custom_var_appstage_name" name="custom_var_appstage_name" /><br />\
|
||||
<label for="custom_var_appstage_value">'+tr("Value")+':</label>\
|
||||
<input type="text" id="custom_var_appstage_value" name="custom_var_appstage_value" /><br />\
|
||||
<button class="add_remove_button add_button" id="add_custom_var_appstage_button" value="add_custom_appstage_var">'+tr("Add")+'</button>\
|
||||
<button class="add_remove_button" id="remove_custom_var_appstage_button" value="remove_custom_appstage_var">'+tr("Remove selected")+'</button>\
|
||||
<div class="clear"></div>\
|
||||
<label for="custom_var_appstage_box">'+tr("Custom attributes")+':</label>\
|
||||
<select id="custom_var_appstage_box" name="custom_var_appstage_box" style="height:100px;" multiple>\
|
||||
</select>\
|
||||
</div>\
|
||||
</fieldset>\
|
||||
-->\
|
||||
<fieldset>\
|
||||
<div class="appstage_param">\
|
||||
<label for="node">'+tr("Node")+':</label>\
|
||||
<div class="clear"></div>\
|
||||
<textarea name="node" style="width:100%; height:14em;"></textarea>\
|
||||
</div>\
|
||||
</fieldset>\
|
||||
<fieldset>\
|
||||
<div class="form_buttons">\
|
||||
<div><button class="button" type="submit" value="AppStage.create">' + tr("Create") + '</button>\
|
||||
<button class="button" type="reset" value="reset">' + tr("Reset") + '</button></div>\
|
||||
<div class="panel">\
|
||||
<h3>\
|
||||
<small id="create_appstage_template_header">'+tr("Create Environment")+'</small>\
|
||||
</h3>\
|
||||
</div>\
|
||||
<div class="reveal-body create_form">\
|
||||
<form id="create_appstage_form" action="">\
|
||||
<div class="row">\
|
||||
<div class="appstage_param six columns">\
|
||||
<div class="row">\
|
||||
<div class="four columns">\
|
||||
<label class="inline right" for="name">' + tr("Name") + ':</label>\
|
||||
</div>\
|
||||
<div class="seven columns">\
|
||||
<input type="text" name="name" />\
|
||||
</div>\
|
||||
<div class="one columns">\
|
||||
<div class="tip">'+ tr("Name for this environment") +'</div>\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class="row">\
|
||||
<div class="four columns">\
|
||||
<label class="inline right" for="description">' + tr("Description") + ':</label>\
|
||||
</div>\
|
||||
<div class="seven columns">\
|
||||
<textarea type="text" name="description" rows="3"/>\
|
||||
</div>\
|
||||
<div class="one columns">\
|
||||
<div class="tip">'+ tr("Description for this environment") +'</div>\
|
||||
</div>\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class="appstage_param st_man six columns">\
|
||||
<fieldset>\
|
||||
<legend>'+tr("Compatible templates")+'</legend>\
|
||||
<div class="eleven columns">\
|
||||
<select type="text" id="env_templates" name="templates" style=\'font-size: 12PX;font-weight: normal;font-family: "Open Sans";width: 100%;\' multiple>\
|
||||
</select>\
|
||||
</div>\
|
||||
<div class="one columns">\
|
||||
<div class="tip">'+ tr("Templates compatible with the node. This is useful to instantiate the same environment with different OS installations") +'</div>\
|
||||
</div>\
|
||||
</fieldset>\
|
||||
</div>\
|
||||
</div>\
|
||||
</fieldset>\
|
||||
</form></div>';
|
||||
<div class="row appstage_param">\
|
||||
<fieldset>\
|
||||
<legend>'+tr("Node")+'</legend>\
|
||||
<div class="appstage_param six columns">\
|
||||
<div class="row ">\
|
||||
<div class="four columns">\
|
||||
<label class="inline right" for="cookbooks">'+tr("Cookbooks URL")+':</label>\
|
||||
</div>\
|
||||
<div class="seven columns">\
|
||||
<input type="text" name="cookbooks" />\
|
||||
</div>\
|
||||
<div class="one columns">\
|
||||
<div class="tip">'+ tr("URL to extra cookbooks (tar.gz file). Standard recipes will use the chef cookbooks repository") +'</div>\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class="row ">\
|
||||
<div class="twelve columns">\
|
||||
<textarea name="node" rows="10" placeholder="'+tr("JSON encoded string containing the recipes"+
|
||||
" that are going to be run on the VM and parameters that will be used to install and configure"+
|
||||
" the software. Check the example on the right")+'"></textarea>\
|
||||
</div>\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class="five columns">\
|
||||
Example:\
|
||||
<pre style=\'font-family: "Open Sans", sans-serif; line-height: 1.6; font-size:12px\'>'+
|
||||
JSON.stringify({
|
||||
name: "wordpress",
|
||||
run_list: [
|
||||
"recipe[wordpress]"
|
||||
],
|
||||
wordpress: {
|
||||
db: {
|
||||
user: "${WP_DB_USER|wordpress}",
|
||||
password: "${WP_DB_PASSWORD|password}"
|
||||
}
|
||||
}
|
||||
}, undefined, 2)+
|
||||
'</pre>\
|
||||
</div>\
|
||||
</fieldset>\
|
||||
</div>\
|
||||
<div class="reveal-footer">\
|
||||
<hr>\
|
||||
<div class="form_buttons">\
|
||||
<button class="button radius right success" type="submit" value="AppStage.create">' + tr("Create") + '</button>\
|
||||
<button class="button radius secondary" type="reset" value="reset">' + tr("Reset") + '</button>\
|
||||
<button class="close-reveal-modal button secondary radius" type="button" value="close">' + tr("Close") + '</button>\
|
||||
</div>\
|
||||
</div>\
|
||||
<a class="close-reveal-modal">×</a>\
|
||||
</form>\
|
||||
</div>';
|
||||
|
||||
var update_appstage_tmpl =
|
||||
'<form action="javascript:alert(\'js error!\');">\
|
||||
@@ -217,6 +265,25 @@ var update_appstage_tmpl =
|
||||
</fieldset>\
|
||||
</form>';
|
||||
|
||||
var instantiate_env_tmpl ='\
|
||||
<div class="panel">\
|
||||
<h3>\
|
||||
<small id="instantiate_env_header">'+tr("Instantiate Environment")+'</small>\
|
||||
</h3>\
|
||||
</div>\
|
||||
<form id="instantiate_env_form" action="">\
|
||||
<div id="instantiate_env_form_content">\
|
||||
</div>\
|
||||
<div class="reveal-footer">\
|
||||
<hr>\
|
||||
<div class="form_buttons">\
|
||||
<button class="button radius right success" id="instantiate_vm_tenplate_proceed" value="Template.instantiate_vms">'+tr("Instantiate")+'</button>\
|
||||
<button class="close-reveal-modal button secondary radius" type="button" value="close">' + tr("Close") + '</button>\
|
||||
</div>\
|
||||
</div>\
|
||||
<a class="close-reveal-modal">×</a>\
|
||||
</form>';
|
||||
|
||||
var dataTable_appstages;
|
||||
var $create_appstage_dialog;
|
||||
|
||||
@@ -235,6 +302,18 @@ var appstage_actions = {
|
||||
call: popUpCreateAppStageDialog
|
||||
},
|
||||
|
||||
"AppStage.instantiate_dialog" : {
|
||||
type: "custom",
|
||||
call: popUpEnvInstantiateDialog
|
||||
},
|
||||
|
||||
"AppStage.show_to_instantiate" : {
|
||||
type: "single",
|
||||
call: AppStage.show,
|
||||
callback: fillEnvInstantiateDialog,
|
||||
error: onError
|
||||
},
|
||||
|
||||
"AppStage.list" : {
|
||||
type: "list",
|
||||
call: AppStage.list,
|
||||
@@ -352,22 +431,9 @@ var appstage_actions = {
|
||||
"AppStage.chmod" : {
|
||||
type: "single",
|
||||
call: AppStage.chmod,
|
||||
// callback
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
/*
|
||||
"AppStage.clone_dialog" : {
|
||||
type: "custom",
|
||||
call: popUpAppStageCloneDialog
|
||||
},
|
||||
"AppStage.clone" : {
|
||||
type: "single",
|
||||
call: AppStage.clone,
|
||||
error: onError,
|
||||
notify: true
|
||||
},
|
||||
*/
|
||||
"AppStage.help" : {
|
||||
type: "custom",
|
||||
call: function() {
|
||||
@@ -391,8 +457,12 @@ var appstage_buttons = {
|
||||
"AppStage.update_dialog" : {
|
||||
type: "action",
|
||||
text: tr("Update"),
|
||||
layout: "main",
|
||||
alwaysActive: true
|
||||
layout: "main"
|
||||
},
|
||||
"AppStage.instantiate_dialog" : {
|
||||
type: "action",
|
||||
text: tr("Instantiate"),
|
||||
layout: "main"
|
||||
},
|
||||
"AppStage.chown" : {
|
||||
type: "confirm_with_select",
|
||||
@@ -410,12 +480,6 @@ var appstage_buttons = {
|
||||
tip: tr("Select the new group")+":",
|
||||
condition: mustBeAdmin
|
||||
},
|
||||
/*
|
||||
"AppStage.clone_dialog" : {
|
||||
type: "action",
|
||||
text: tr("Clone")
|
||||
},
|
||||
*/
|
||||
"AppStage.delete" : {
|
||||
type: "confirm",
|
||||
layout: "del",
|
||||
@@ -445,7 +509,7 @@ var appstages_tab = {
|
||||
}
|
||||
|
||||
Sunstone.addActions(appstage_actions);
|
||||
Sunstone.addMainTab('appstages_tab',appstages_tab);
|
||||
Sunstone.addMainTab('apptools-appstage',appstages_tab);
|
||||
Sunstone.addInfoPanel('appstage_info_panel',appstage_info_panel);
|
||||
|
||||
|
||||
@@ -507,35 +571,14 @@ function updateAppStageInfo(request,elem){
|
||||
var elem_info = elem.DOCUMENT;
|
||||
elem_info.TEMPLATE.BODY = JSON.parse(elem_info.TEMPLATE.BODY);
|
||||
|
||||
// Form trs for variables
|
||||
var vars = '';
|
||||
var defaults = elem_info.TEMPLATE.BODY.defaults;
|
||||
if (!$.isEmptyObject(defaults)){
|
||||
for (key in defaults){
|
||||
vars += '<tr>\
|
||||
<td class="key_td">'+ key +'</td>\
|
||||
<td class="value_td">\
|
||||
<input type="text" name="'+ key +'"value="'+ defaults[key] +'"></input>\
|
||||
</td></tr>';
|
||||
};
|
||||
}
|
||||
|
||||
// Form options of compatible templates
|
||||
var compat_templates = '';
|
||||
var templates = elem_info.TEMPLATE.BODY.templates;
|
||||
if (templates)
|
||||
for (var i = 0; i < templates.length; i++)
|
||||
compat_templates += '<option value="'+ templates[i] +'">\
|
||||
'+ getTemplateName(templates[i]) +'\
|
||||
</option>';
|
||||
|
||||
|
||||
|
||||
|
||||
var info_tab = {
|
||||
title: tr("Environment information"),
|
||||
title: tr("Information"),
|
||||
content:
|
||||
'<table id="info_appstage_table" class="info_table">\
|
||||
'<div class="">\
|
||||
<div class="six columns">\
|
||||
<table id="info_appstage_table" class="twelve datatable extended_table">\
|
||||
<thead>\
|
||||
<tr><th colspan="2">'+tr("Environment")+' "'+elem_info.NAME+'" '+
|
||||
tr("information")+'</th></tr>\
|
||||
@@ -552,71 +595,55 @@ function updateAppStageInfo(request,elem){
|
||||
<td class="key_td">'+tr("Description")+'</td>\
|
||||
<td class="value_td">'+(elem_info.TEMPLATE.BODY.description ? elem_info.TEMPLATE.BODY.description : "None" )+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">'+tr("Owner")+'</td>\
|
||||
<td class="value_td">'+elem_info.UNAME+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td">'+tr("Group")+'</td>\
|
||||
<td class="value_td">'+elem_info.GNAME+'</td>\
|
||||
</tr>\
|
||||
'+ (templates ?
|
||||
'<tr><td class="key_td">'+tr("Compatible templates")+'</td><td class="value_td">'+ templates.join(',')+'</td></tr>' : "")
|
||||
+ (elem_info.TEMPLATE.BODY.cookbooks ?
|
||||
'<tr><td class="key_td">'+tr("Cookbooks")+'</td><td class="value_td">'+elem_info.TEMPLATE.BODY.cookbooks+'</td></tr>' : "")+
|
||||
' <tr><td class="key_td">'+tr("Permissions")+'</td><td></td></tr>\
|
||||
<tr>\
|
||||
<td class="key_td"> '+tr("Owner")+'</td>\
|
||||
<td class="value_td" style="font-family:monospace;">'+ownerPermStr(elem_info)+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td"> '+tr("Group")+'</td>\
|
||||
<td class="value_td" style="font-family:monospace;">'+groupPermStr(elem_info)+'</td>\
|
||||
</tr>\
|
||||
<tr>\
|
||||
<td class="key_td"> '+tr("Other")+'</td>\
|
||||
<td class="value_td" style="font-family:monospace;">'+otherPermStr(elem_info)+'</td>\
|
||||
</tr>\
|
||||
'+ (!$.isEmptyObject(defaults) ?
|
||||
'<tr><td class="key_td">'+tr("Default variables")+'</td><td></td></tr>' +
|
||||
'<tr>\
|
||||
<td class="key_td">'+tr("Cookbooks")+'</td>\
|
||||
<td class="value_td">'+elem_info.TEMPLATE.BODY.cookbooks+'</td>\
|
||||
</tr>' : "")+
|
||||
(!$.isEmptyObject(defaults) ?
|
||||
'<thead><tr><th class="key_td">'+tr("Default variables")+'</th><th></th></tr></thead>' +
|
||||
prettyPrintJSON(defaults, 28) : "") + '</table>\
|
||||
\
|
||||
<table class="info_table" id="appstage_instantiate_table">\
|
||||
<thead>\
|
||||
<tr><th colspan="2">'+tr("Instantiate this environment")+'</th></tr>\
|
||||
</thead>\
|
||||
<tr>\
|
||||
<td class="key_td">'+tr("Template")+':</td>\
|
||||
<td class="value_td"><select>'+ compat_templates +'</select></td>\
|
||||
<tr>\
|
||||
<td class="key_td">'+tr("Variables")+':</td>\
|
||||
<td class="value_td"><input type="hidden" name="id" value="'+elem_info.ID+'"/></td>\
|
||||
</tr>\
|
||||
'+ vars +'\
|
||||
<tr>\
|
||||
<td class="key_td"></td>\
|
||||
<td class="value_td"><button id="appstage_instantiate_button" value="AppStage.instantiate">'+tr("Instantiate")+'</button></td>\
|
||||
</table>'
|
||||
</div>\
|
||||
<div class="six columns">' + insert_permissions_table('apptools-appstage',
|
||||
"AppStage",
|
||||
elem_info.ID,
|
||||
elem_info.UNAME,
|
||||
elem_info.GNAME,
|
||||
elem_info.UID,
|
||||
elem_info.GID) +
|
||||
'</div>\
|
||||
</div>'
|
||||
}
|
||||
|
||||
var node_tab = {
|
||||
title: tr("Node"),
|
||||
content: '<table id="appstage_node_table" class="info_table" style="width:80%;">\
|
||||
content: '<div class="columns twelve">\
|
||||
<div id="datatable_cluster_hosts_info_div">\
|
||||
<table id="appstage_node_table" class="twelve datatable extended_table">\
|
||||
<thead><tr><th colspan="2">'+tr("Node")+'</th></tr></thead>'+
|
||||
(elem_info.TEMPLATE.BODY.node ? prettyPrintJSON(elem_info.TEMPLATE.BODY.node) : "" )+
|
||||
'</table>'
|
||||
'</table>\
|
||||
</div'
|
||||
}
|
||||
|
||||
Sunstone.updateInfoPanelTab("appstage_info_panel","appstage_info_tab",info_tab);
|
||||
Sunstone.updateInfoPanelTab("appstage_info_panel","appstage_node_tab",node_tab);
|
||||
|
||||
Sunstone.popUpInfoPanel("appstage_info_panel");
|
||||
Sunstone.popUpInfoPanel("appstage_info_panel", "apptools-appstage");
|
||||
|
||||
setPermissionsTable(elem_info,'');
|
||||
|
||||
$("#appstage_info_panel_refresh", $("#appstage_info_panel")).click(function(){
|
||||
$(this).html(spinner);
|
||||
Sunstone.runAction('AppStage.showinfo', elem_info.ID);
|
||||
})
|
||||
}
|
||||
|
||||
// Prepare the creation dialog
|
||||
function setupCreateAppStageDialog(){
|
||||
dialogs_context.append('<div title="'+tr("Create environment")+'" id="create_appstage_dialog"></div>');
|
||||
dialogs_context.append('<div id="create_appstage_dialog"></div>');
|
||||
$create_appstage_dialog = $('#create_appstage_dialog',dialogs_context);
|
||||
|
||||
var dialog = $create_appstage_dialog;
|
||||
@@ -625,7 +652,7 @@ function setupCreateAppStageDialog(){
|
||||
var height = Math.floor($(window).height()*0.8); //set height to a percentage of the window
|
||||
|
||||
//Prepare jquery dialog
|
||||
dialog.addClass("reveal-modal xlarge");
|
||||
dialog.addClass("reveal-modal xlarge max-height");
|
||||
|
||||
$('select[name="templates"]', dialog).change(function(){
|
||||
$(this).val("");
|
||||
@@ -646,31 +673,6 @@ function setupCreateAppStageDialog(){
|
||||
return false;
|
||||
});
|
||||
|
||||
/******** UNUSED
|
||||
$('#add_custom_var_appstage_button', dialog).click(
|
||||
function(){
|
||||
var name = $('#custom_var_appstage_name',dialog).val();
|
||||
var value = $('#custom_var_appstage_value',dialog).val();
|
||||
if (!name.length || !value.length) {
|
||||
notifyError("Variable name and value must be filled in");
|
||||
return false;
|
||||
}
|
||||
option= '<option value=\''+value+'\' name=\''+name+'\'>'+
|
||||
name+'='+value+
|
||||
'</option>';
|
||||
$('select#custom_var_appstage_box',dialog).append(option);
|
||||
return false;
|
||||
}
|
||||
);
|
||||
|
||||
$('#remove_custom_var_appstage_button', dialog).click(
|
||||
function(){
|
||||
$('select#custom_var_appstage_box :selected',dialog).remove();
|
||||
return false;
|
||||
}
|
||||
);
|
||||
*/
|
||||
|
||||
|
||||
$('#create_appstage_form',dialog).submit(function(){
|
||||
var name = $('input[name="name"]', this).val();
|
||||
@@ -702,20 +704,6 @@ function setupCreateAppStageDialog(){
|
||||
appstage_obj.templates = tmpls
|
||||
};
|
||||
|
||||
//UNUSED AT THIS POINT
|
||||
/*
|
||||
var variables_array = [];
|
||||
var variables;
|
||||
$('#custom_var_appstage_box option', this).each(function(){
|
||||
var attr_name = $(this).attr('name');
|
||||
var attr_value = $(this).val();
|
||||
variables_array.push(attr_name +'='+ attr_value);
|
||||
});
|
||||
variables = variables_array.join(',');
|
||||
|
||||
if (variables) appstage_obj.variables = variables;
|
||||
*/
|
||||
|
||||
Sunstone.runAction("AppStage.create", { 'DOCUMENT': appstage_obj });
|
||||
dialog.trigger("reveal:close")
|
||||
return false;
|
||||
@@ -731,9 +719,112 @@ function popUpCreateAppStageDialog(){
|
||||
});
|
||||
|
||||
dialog.reveal();
|
||||
|
||||
}
|
||||
|
||||
function popUpEnvInstantiateDialog(){
|
||||
var selected_nodes = getSelectedNodes(dataTable_appstages);
|
||||
|
||||
if ( selected_nodes.length != 1 )
|
||||
{
|
||||
notifyMessage("Please select one (and just one) environment to instantiate.");
|
||||
return false;
|
||||
}
|
||||
|
||||
var env_id = ""+selected_nodes[0];
|
||||
Sunstone.runAction("AppStage.show_to_instantiate", env_id);
|
||||
}
|
||||
|
||||
function setupEnvInstantiateDialog(){
|
||||
//Append to DOM
|
||||
dialogs_context.append('<div id="appstage_env_instantiate_dialog"></div>');
|
||||
var dialog = $('#appstage_env_instantiate_dialog',dialogs_context);
|
||||
|
||||
//Put HTML in place
|
||||
dialog.html(instantiate_env_tmpl);
|
||||
|
||||
//Convert into jQuery
|
||||
dialog.addClass("reveal-modal large max-height");
|
||||
|
||||
$("#appstage_env_instantiate_dialog").submit(function(){
|
||||
var vars = [];
|
||||
|
||||
var id = $('input[type="hidden"]', this).val();
|
||||
var template_id = $('select', this).val();
|
||||
|
||||
$('input[type="text"]', this).each(function(){
|
||||
var key = $(this).attr('name');
|
||||
var val = $(this).val();
|
||||
|
||||
if (val)
|
||||
vars.push(key +'='+ val)
|
||||
});
|
||||
|
||||
var obj = { vars: vars,
|
||||
template_id: template_id
|
||||
};
|
||||
|
||||
if (vars.length)
|
||||
Sunstone.runAction("AppStage.instantiate", id, obj);
|
||||
return false;
|
||||
})
|
||||
}
|
||||
|
||||
function fillEnvInstantiateDialog(request, response){
|
||||
var elem_info = response.DOCUMENT;
|
||||
elem_info.TEMPLATE.BODY = JSON.parse(elem_info.TEMPLATE.BODY);
|
||||
|
||||
var str = '<input type="hidden" name="id" value="'+elem_info.ID+'"/>'
|
||||
|
||||
// Form options of compatible templates
|
||||
var templates = elem_info.TEMPLATE.BODY.templates;
|
||||
if (templates) {
|
||||
str += '<div class="row">\
|
||||
<div class="four columns">\
|
||||
<label class="inline right" for="env_template">'+tr("Template")+':</label>\
|
||||
</div>\
|
||||
<div class="seven columns">\
|
||||
<select name="env_template">';
|
||||
|
||||
for (var i = 0; i < templates.length; i++) {
|
||||
str += '<option value="'+ templates[i] +'">\
|
||||
'+ getTemplateName(templates[i]) +'\
|
||||
</option>';
|
||||
}
|
||||
|
||||
str += '</select>\
|
||||
</div>\
|
||||
<div class="one columns">\
|
||||
</div>\
|
||||
</div>'
|
||||
}
|
||||
|
||||
// Form variables
|
||||
var defaults = elem_info.TEMPLATE.BODY.defaults;
|
||||
if (!$.isEmptyObject(defaults)){
|
||||
str += '<div class="row">\
|
||||
<fieldset>\
|
||||
<legend>'+tr("Variables")+'</legend>'
|
||||
|
||||
for (key in defaults){
|
||||
str += '<div class="row centered">\
|
||||
<div class="four columns">\
|
||||
<label class="inline right" for="'+key+'">'+key+':</label>\
|
||||
</div>\
|
||||
<div class="seven columns">\
|
||||
<input type="text" name="'+ key +'"value="'+ defaults[key] +'"></input>\
|
||||
</div>\
|
||||
<div class="one columns">\
|
||||
</div>\
|
||||
</div>'
|
||||
};
|
||||
|
||||
str += '</fieldset>\
|
||||
</div>'
|
||||
}
|
||||
|
||||
$("#instantiate_env_form_content").html(str);
|
||||
$('#appstage_env_instantiate_dialog',dialogs_context).reveal();
|
||||
}
|
||||
|
||||
|
||||
function setupAppStageTemplateUpdateDialog(){
|
||||
@@ -871,34 +962,6 @@ function popUpAppStageTemplateUpdateDialog(){
|
||||
return false;
|
||||
};
|
||||
|
||||
function setupAppStageInstantiate(){
|
||||
$('button#appstage_instantiate_button').live('click', function(){
|
||||
var vars = [];
|
||||
var context = $(this).parents('table#appstage_instantiate_table');
|
||||
|
||||
var id = $('input[type="hidden"]', context).val();
|
||||
var template_id = $('select', context).val();
|
||||
|
||||
$('input[type="text"]', context).each(function(){
|
||||
var key = $(this).attr('name');
|
||||
var val = $(this).val();
|
||||
|
||||
if (val)
|
||||
vars.push(key +'='+ val)
|
||||
});
|
||||
|
||||
var obj = { vars: vars,
|
||||
template_id: template_id
|
||||
};
|
||||
|
||||
if (vars.length)
|
||||
Sunstone.runAction("AppStage.instantiate", id, obj);
|
||||
return false;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Set the autorefresh interval for the datatable
|
||||
function setAppStageAutorefresh() {
|
||||
setInterval(function(){
|
||||
@@ -911,87 +974,6 @@ function setAppStageAutorefresh() {
|
||||
},INTERVAL+someTime());
|
||||
};
|
||||
|
||||
/*
|
||||
function setupAppStageCloneDialog(){
|
||||
//Append to DOM
|
||||
dialogs_context.append('<div id="appstage_clone_dialog" title="'+tr("Clone an environment")+'"></div>');
|
||||
var dialog = $('#appstage_clone_dialog',dialogs_context);
|
||||
|
||||
//Put HTML in place
|
||||
|
||||
var html = '<form><fieldset>\
|
||||
<div class="clone_one">'+tr("Choose a new name for the environment")+':</div>\
|
||||
<div class="clone_several">'+tr("Several environments are selected, please choose prefix to name the new copies")+':</div>\
|
||||
<br />\
|
||||
<label class="clone_one">'+tr("Name")+':</label>\
|
||||
<label class="clone_several">'+tr("Prefix")+':</label>\
|
||||
<input type="text" name="name"></input>\
|
||||
<div class="form_buttons">\
|
||||
<button class="button" id="appstage_clone_button" value="AppStage.clone">\
|
||||
'+tr("Clone")+'\
|
||||
</button>\
|
||||
</div></fieldset></form>\
|
||||
';
|
||||
|
||||
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 = appStageElements();
|
||||
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('AppStage.clone',
|
||||
sel_elems[i],
|
||||
name + getName(sel_elems[i],
|
||||
dataTable_appstages,
|
||||
4));
|
||||
} else {
|
||||
Sunstone.runAction('AppStage.clone',sel_elems[0],name)
|
||||
};
|
||||
dialog.trigger("reveal:close")
|
||||
setTimeout(function(){
|
||||
Sunstone.runAction('AppStage.refresh');
|
||||
}, 1500);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
function popUpAppStageCloneDialog(){
|
||||
var dialog = $('#appstage_clone_dialog');
|
||||
var sel_elems = appStageElements();
|
||||
//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_appstages, 4));
|
||||
};
|
||||
|
||||
$(dialog).addClass("reveal-modal xlarge")
|
||||
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
//The DOM is ready at this point
|
||||
$(document).ready(function(){
|
||||
|
||||
@@ -1017,9 +999,8 @@ $(document).ready(function(){
|
||||
|
||||
setupCreateAppStageDialog();
|
||||
setupAppStageTemplateUpdateDialog();
|
||||
setupAppStageInstantiate();
|
||||
setupEnvInstantiateDialog();
|
||||
setupTips($create_appstage_dialog);
|
||||
// setupImageCloneDialog();
|
||||
setAppStageAutorefresh();
|
||||
|
||||
initCheckAllBoxes(dataTable_appstages);
|
||||
@@ -1027,4 +1008,4 @@ $(document).ready(function(){
|
||||
infoListener(dataTable_appstages,'AppStage.showinfo');
|
||||
|
||||
$('div#appstages_tab div.legend_div').hide();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user