feature #3748: Refactor saved templates list

TODO: delete & chmod should apply to all the images of the template
This commit is contained in:
Daniel Molina committed 2015-06-19 20:06:53 +02:00
1 parent 97ae9ffe7f
commit 9a58c519df
5 files changed
+449 -410

No files matched your search

+3 -396
View File
@@ -19,6 +19,7 @@ define(function(require) {
var ProvisionQuotaWidget = require('./provision-tab/users/quota-widget');
var ProvisionVmsList = require('./provision-tab/vms/list');
var ProvisionTemplatesList = require('./provision-tab/templates/list');
var ProvisionUsersList = require('./provision-tab/users/list');
var ProvisionFlowsList = require('./provision-tab/flows/list');
@@ -33,7 +34,6 @@ define(function(require) {
var TemplateDashboardUsers = require('hbs!./provision-tab/dashboard/users');
var TemplateGroupInfo = require('hbs!./provision-tab/group/info');
var TemplateTemplatesList = require('hbs!./provision-tab/templates/list');
var TAB_ID = require('./provision-tab/tabId');
@@ -276,21 +276,6 @@ define(function(require) {
'</div>'+
'</div>';
var list_templates_accordion_id = 0;
function provision_list_templates(opts_arg){
opts = $.extend({
title: Locale.tr("Saved Templates"),
refresh: true,
create: true,
active: true,
filter: true
},opts_arg)
list_templates_accordion_id += 1;
return TemplateTemplatesList({'accordionId': list_templates_accordion_id, 'opts': opts});
}
var povision_actions = {
"Provision.User.show" : {
type: "single",
@@ -1422,52 +1407,6 @@ define(function(require) {
Sunstone.runAction('Provision.Group.show', "-1");
}
function show_provision_template_list(timeout) {
$(".section_content").hide();
$(".provision_templates_list_section").fadeIn();
//$("dd:not(.active) .provision_back", $(".provision_templates_list_section")).trigger("click");
$(".provision_templates_list_refresh_button", $(".provision_templates_list_section")).trigger("click");
}
function update_provision_templates_datatable(datatable, timeout) {
datatable.html('<div class="text-center">'+
'<span class="fa-stack fa-5x" style="color: #dfdfdf">'+
'<i class="fa fa-cloud fa-stack-2x"></i>'+
'<i class="fa fa-spinner fa-spin fa-stack-1x fa-inverse"></i>'+
'</span>'+
'<br>'+
'<br>'+
'<span style="font-size: 18px; color: #999">'+
'</span>'+
'</div>');
setTimeout( function(){
OpenNebula.Template.list({
timeout: true,
success: function (request, item_list){
datatable.fnClearTable(true);
if (item_list.length == 0) {
datatable.html('<div class="text-center">'+
'<span class="fa-stack fa-5x" style="color: #dfdfdf">'+
'<i class="fa fa-cloud fa-stack-2x"></i>'+
'<i class="fa fa-info-circle fa-stack-1x fa-inverse"></i>'+
'</span>'+
'<br>'+
'<br>'+
'<span style="font-size: 18px; color: #999">'+
Locale.tr("There are no templates available")+
'</span>'+
'</div>');
} else {
datatable.fnAddData(item_list);
}
},
error: Notifier.onError
});
}, timeout);
}
function update_provision_instance_types_datatable(datatable) {
datatable.fnClearTable(true);
if (!config['instance_types'] || config['instance_types'].length == 0) {
@@ -1561,338 +1500,6 @@ define(function(require) {
}, timeout);
}
function setup_provision_templates_list(context, opts) {
var provision_templates_datatable = $('.provision_templates_table', context).dataTable({
"iDisplayLength": 8,
"sDom" : '<"H">t<"F"lp>',
"aLengthMenu": [[6, 12, 36, 72], [6, 12, 36, 72]],
"aaSorting" : [[0, "desc"]],
"aoColumnDefs": [
{ "bVisible": false, "aTargets": ["all"]}
],
"aoColumns": [
{ "mDataProp": "VMTEMPLATE.ID" },
{ "mDataProp": "VMTEMPLATE.NAME" },
{ "mDataProp": "VMTEMPLATE.TEMPLATE.SAVED_TEMPLATE_ID", "sDefaultContent" : "-" },
{ "mDataProp": "VMTEMPLATE.UID" }
],
"fnPreDrawCallback": function (oSettings) {
// create a thumbs container if it doesn't exist. put it in the dataTables_scrollbody div
if (this.$('tr', {"filter": "applied"} ).length == 0) {
this.html('<div class="text-center">'+
'<span class="fa-stack fa-5x" style="color: #dfdfdf">'+
'<i class="fa fa-cloud fa-stack-2x"></i>'+
'<i class="fa fa-info-circle fa-stack-1x fa-inverse"></i>'+
'</span>'+
'<br>'+
'<br>'+
'<span style="font-size: 18px; color: #999">'+
Locale.tr("There are no saved templates available")+
'<br>'+
Locale.tr("Create a template by saving a running Virtual Machine")+
'</span>'+
'</div>');
} else {
$(".provision_templates_table", context).html('<ul class="provision_templates_ul large-block-grid-3 medium-block-grid-3 small-block-grid-1 text-center"></ul>');
}
return true;
},
"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
var data = aData.VMTEMPLATE;
var actions_html = "";
if (Config.isTabActionEnabled("provision-tab", "Template.chmod")) {
if (data.UID == config['user_id']) {
if (data.PERMISSIONS.GROUP_U == "1") {
actions_html += '<a class="provision_confirm_unshare_template_button left" data-tooltip title="'+ Locale.tr("Unshare")+'" style="color:#555" href="#"><i class="fa fa-fw fa-lg fa-ban only-on-hover"/></a>';
actions_html += '<span style="font-size:12px; color: #777">' + Locale.tr("SHARED") + '</span>';
} else {
actions_html += '<a class="provision_confirm_chmod_template_button left" data-tooltip title="'+ Locale.tr("Share")+'" style="color:#555" href="#"><i class="fa fa-fw fa-lg fa-share-alt only-on-hover"/></a>';
}
}
}
if (Config.isTabActionEnabled("provision-tab", "Template.delete")) {
actions_html += '<a class="provision_confirm_delete_template_button" data-tooltip title="'+ Locale.tr("Delete")+'" style="color:#555" href="#"><i class="fa fa-fw fa-lg fa-trash-o right only-on-hover"/></a>';
}
$(".provision_templates_ul", context).append('<li>'+
'<ul class="provision-pricing-table" opennebula_id="'+data.ID+'" saved_to_image_id="'+data.TEMPLATE.SAVED_TO_IMAGE_ID+'" datatable_index="'+iDisplayIndexFull+'">'+
'<li class="provision-title text-left" title="'+data.NAME+'">'+
data.NAME +
'</li>'+
'<li class="provision-description text-left" style="padding-top:0px; padding-bottom: 5px">'+
(data.TEMPLATE.DESCRIPTION || '...')+
'</li>'+
'<li class="provision-bullet-item text-left" style="margin-left: 5px">'+
'<i class="fa fa-fw fa-file-text-o"/>&emsp;'+
'x'+(data.TEMPLATE.CPU||'-')+' - '+
((data.TEMPLATE.MEMORY > 1000) ?
(Math.floor(data.TEMPLATE.MEMORY/1024)+'GB') :
((data.TEMPLATE.MEMORY||'-')+'MB'))+
'</li>'+
'<li class="provision-bullet-item text-left" style="margin-left: 5px">'+
'<i class="fa fa-fw fa-user"/>&emsp;'+
data.UNAME+
'</li>'+
'<li class="provision-description text-right" style="padding-top:5px; margin-right: 5px">'+
'<i class="fa fa-fw fa-clock-o"/>'+
Humanize.prettyTimeAgo(data.REGTIME)+
'</li>'+
'<li class="provision-title" style="padding-top:10px">'+
actions_html+
'</li>'+
'</ul>'+
'</li>');
return nRow;
}
});
provision_templates_datatable.fnFilter("^(?!\-$)", 2, true, false);
$('.provision_list_templates_search', context).keyup(function(){
provision_templates_datatable.fnFilter( $(this).val() );
})
$('.provision_list_templates_search', context).change(function(){
provision_templates_datatable.fnFilter( $(this).val() );
})
context.on("click", ".provision_templates_list_refresh_button", function(){
OpenNebula.Action.clear_cache("VMTEMPLATE");
$(".provision_confirm_delete_template_div", context).html("");
update_provision_templates_datatable(provision_templates_datatable, 0);
return false;
});
context.on("click", ".provision_templates_list_search_button", function(){
$(".provision_list_templates_search", context).fadeIn();
});
$(".provision_list_templates_filter", context).on("change", ".resource_list_select", function(){
if ($(this).val() != "-2"){
provision_templates_datatable.fnFilter("^" + $(this).val() + "$", 3, true, false);
} else {
provision_templates_datatable.fnFilter("", 3);
}
})
ResourceSelect.insert(
".provision_list_templates_filter",
context,
"User",
(opts.filter_expression ? opts.filter_expression : "-2"),
false,
'<option value="-2">'+Locale.tr("ALL")+'</option>',
null,
null,
true,
true);
context.on("click", ".provision_templates_list_filter_button", function(){
$(".provision_list_templates_filter", context).fadeIn();
return false;
});
if (Config.isTabActionEnabled("provision-tab", "Template.delete")) {
context.on("click", ".provision_confirm_delete_template_button", function(){
var ul_context = $(this).parents(".provision-pricing-table");
var template_id = ul_context.attr("opennebula_id");
var image_id = ul_context.attr("saved_to_image_id");
var template_name = $(".provision-title", ul_context).text();
$(".provision_confirm_delete_template_div", context).html(
'<div data-alert class="alert-box secondary radius">'+
'<div class="row">'+
'<div class="large-9 columns">'+
'<span style="font-size: 14px; line-height: 20px">'+
Locale.tr("Handle with care! This action will inmediately destroy the template")+
' "' + template_name + '" ' +
Locale.tr("and the image associated.") +
'</span>'+
'</div>'+
'<div class="large-3 columns">'+
'<a href"#" class="provision_delete_template_button alert button large-12 radius right" style="margin-right: 15px" image_id="'+image_id+'" template_id="'+template_id+'">'+Locale.tr("Delete")+'</a>'+
'</div>'+
'</div>'+
'<a href="#" class="close">&times;</a>'+
'</div>');
});
context.on("click", ".provision_delete_template_button", function(){
var button = $(this);
button.attr("disabled", "disabled");
var template_id = $(this).attr("template_id");
var image_id = $(this).attr("image_id");
OpenNebula.Image.del({
timeout: true,
data : {
id : image_id
},
success: function (){
OpenNebula.Template.del({
timeout: true,
data : {
id : template_id
},
success: function (){
$(".provision_templates_list_refresh_button", context).trigger("click");
},
error: function (request,error_json, container) {
Notifier.onError(request, error_json, container);
}
})
},
error: function (request,error_json, container) {
if (error_json.error.http_status=="404") {
OpenNebula.Template.del({
timeout: true,
data : {
id : template_id
},
success: function (){
$(".provision_templates_list_refresh_button", context).trigger("click");
},
error: function (request,error_json, container) {
Notifier.onError(request, error_json, container);
$(".provision_templates_list_refresh_button", context).trigger("click");
}
})
} else {
Notifier.onError(request, error_json, container);
}
}
})
});
}
if (Config.isTabActionEnabled("provision-tab", "Template.chmod")) {
context.on("click", ".provision_confirm_chmod_template_button", function(){
var ul_context = $(this).parents(".provision-pricing-table");
var template_id = ul_context.attr("opennebula_id");
var image_id = ul_context.attr("saved_to_image_id");
var template_name = $(".provision-title", ul_context).text();
$(".provision_confirm_delete_template_div", context).html(
'<div data-alert class="alert-box secondary radius">'+
'<div class="row">'+
'<div class="large-8 columns">'+
'<span style="font-size: 14px; line-height: 20px">'+
Locale.tr("The template")+
' "' + template_name + '" ' +
Locale.tr("and the image associated will be shared and all the users will be able to instantiate new VMs using this template.") +
'</span>'+
'</div>'+
'<div class="large-4 columns">'+
'<a href"#" class="provision_chmod_template_button success button large-12 radius right" style="margin-right: 15px" image_id="'+image_id+'" template_id="'+template_id+'">'+Locale.tr("Share template")+'</a>'+
'</div>'+
'</div>'+
'<a href="#" class="close">&times;</a>'+
'</div>');
});
context.on("click", ".provision_chmod_template_button", function(){
var button = $(this);
button.attr("disabled", "disabled");
var template_id = $(this).attr("template_id");
var image_id = $(this).attr("image_id");
OpenNebula.Template.chmod({
timeout: true,
data : {
id : template_id,
extra_param: {'group_u': 1}
},
success: function (){
$(".provision_templates_list_refresh_button", context).trigger("click");
OpenNebula.Image.chmod({
timeout: true,
data : {
id : image_id,
extra_param: {'group_u': 1}
},
success: function (){
},
error: Notifier.onError
})
},
error: Notifier.onError
})
});
context.on("click", ".provision_confirm_unshare_template_button", function(){
var ul_context = $(this).parents(".provision-pricing-table");
var template_id = ul_context.attr("opennebula_id");
var image_id = ul_context.attr("saved_to_image_id");
var template_name = $(".provision-title", ul_context).first().text();
$(".provision_confirm_delete_template_div", context).html(
'<div data-alert class="alert-box secondary radius">'+
'<div class="row">'+
'<div class="large-8 columns">'+
'<span style="font-size: 14px; line-height: 20px">'+
Locale.tr("The template")+
' "' + template_name + '" ' +
Locale.tr("and the image associated will be unshared and the users will not be able to instantiate new VMs using this template.") +
'</span>'+
'</div>'+
'<div class="large-4 columns">'+
'<a href"#" class="provision_unshare_template_button success button large-12 radius right" style="margin-right: 15px" image_id="'+image_id+'" template_id="'+template_id+'">'+Locale.tr("Unshare template")+'</a>'+
'</div>'+
'</div>'+
'<a href="#" class="close">&times;</a>'+
'</div>');
});
context.on("click", ".provision_unshare_template_button", function(){
var button = $(this);
button.attr("disabled", "disabled");
var template_id = $(this).attr("template_id");
var image_id = $(this).attr("image_id");
OpenNebula.Template.chmod({
timeout: true,
data : {
id : template_id,
extra_param: {'group_u': 0}
},
success: function (){
$(".provision_templates_list_refresh_button", context).trigger("click");
OpenNebula.Image.chmod({
timeout: true,
data : {
id : image_id,
extra_param: {'group_u': 0}
},
success: function (){
},
error: Notifier.onError
})
},
error: Notifier.onError
})
});
}
OpenNebula.Action.clear_cache("VMTEMPLATE");
update_provision_templates_datatable(provision_templates_datatable, 0);
context.foundation();
}
function generate_provision_templates_list(context, opts) {
context.off();
context.html(provision_list_templates(opts));
setup_provision_templates_list(context, opts);
}
// Closes and resets the create user wizard
function clear_provision_create_user(){
OpenNebula.Action.clear_cache("USER");
@@ -1951,7 +1558,7 @@ define(function(require) {
ProvisionVmsList.generate($(".provision_vms_list_section"), {active: true});
if (Config.isTabPanelEnabled("provision-tab", "templates")) {
generate_provision_templates_list($(".provision_templates_list_section"), {active: true});
ProvisionTemplatesList.generate($(".provision_templates_list_section"), {active: true});
}
// TODO check if active
@@ -1976,7 +1583,7 @@ define(function(require) {
$(document).on("click", ".provision_templates_list_button", function(){
OpenNebula.Action.clear_cache("VMTEMPLATE");
show_provision_template_list(0);
ProvisionTemplatesList.show(0);
});
$(document).on("click", ".provision_flows_list_button", function(){
@@ -1,24 +1,24 @@
<dl class="accordion accordion_list provision_list_templates" data-accordion="dfsaf">
<dd class="{{#if opts.active}}active{{/if}} accordion-navigation">
<a class="right only-not-active" href="#provision_list_template_accordion{{accordionId}}">
<span class="button medium radius"> <i class="fa fa-fw fa-lg fa-th"/><i class="fa fa-fw fa-lg fa-chevron-left"/>
<span class="button small radius"> <i class="fa fa-fw fa-lg fa-th"/><i class="fa fa-fw fa-lg fa-chevron-left"/>
</span>
</a>
<h2 class="subheader">
{{opts.title}}
<span href"#" class="right only-active button medium radius secondary provision_templates_list_refresh_button"
{{#if opts.refresh}}style="display:none"{{/if}} data-tooltip title=" {{tr "Refresh"}}">
<h3 class="subheader">
{{!opts.title}}
<span href"#" class="right only-active button small radius secondary provision_templates_list_refresh_button"
{{#unless opts.refresh}}style="display:none"{{/unless}} data-tooltip title=" {{tr "Refresh"}}">
<i class="fa fa-fw fa-lg fa-refresh"/></span>
<span href"#" class="right only-active button medium radius secondary provision_templates_list_filter_button"
{{#if opts.filter}}style="display:none"{{/if}} data-tooltip title=" {{tr "Filter by User"}}">
<span href"#" class="right only-active button small radius secondary provision_templates_list_filter_button"
{{#unless opts.filter}}style="display:none"{{/unless}} data-tooltip title=" {{tr "Filter by User"}}">
<i class="fa fa-fw fa-lg fa-filter"/>
</span>
<span class="right only-active provision_list_templates_filter" style="display: none"></span>
<input type="search" class="provision_list_templates_search right only-active provision-search-input right" placeholder="Search"/>
</h2>
<input type="search" class="provision_list_templates_search only-active provision-search-input" placeholder="Search Templates"/>
</h3>
<div id="provision_list_template_accordion{{accordionId}}" class="content {{#if opts.active}}active{{/if}}">
<div class="row">
<div class="provision_confirm_delete_template_div large-10 large-centered columns"></div>
<div class="provision_confirm_delete_template_div large-12 large-centered columns"></div>
</div>
<div class="row">
<div class="large-12 large-centered columns">
@@ -0,0 +1,432 @@
define(function(require) {
var OpenNebula = require('opennebula');
var Locale = require('utils/locale');
var Config = require('sunstone-config');
var Notifier = require('utils/notifier');
var Humanize = require('utils/humanize');
var ResourceSelect = require('utils/resource-select');
var TemplateTemplatesList = require('hbs!./list');
var _accordionId = 0;
return {
'generate': generate_provision_templates_list,
'show': show_provision_template_list,
'updateDatatable': update_provision_templates_datatable,
};
function show_provision_template_list(timeout) {
$(".section_content").hide();
$(".provision_templates_list_section").fadeIn();
$(".provision_templates_list_refresh_button", $(".provision_templates_list_section")).trigger("click");
}
function generate_provision_templates_list(context, opts) {
context.off();
context.html(html(opts));
setup_provision_templates_list(context, opts);
}
function html(opts_arg){
opts = $.extend({
title: Locale.tr("Saved Templates"),
refresh: true,
create: true,
active: true,
filter: true
},opts_arg)
_accordionId += 1;
return TemplateTemplatesList({'accordionId': _accordionId, 'opts': opts});
}
function update_provision_templates_datatable(datatable, timeout) {
datatable.html('<div class="text-center">'+
'<span class="fa-stack fa-5x" style="color: #dfdfdf">'+
'<i class="fa fa-cloud fa-stack-2x"></i>'+
'<i class="fa fa-spinner fa-spin fa-stack-1x fa-inverse"></i>'+
'</span>'+
'<br>'+
'<br>'+
'<span style="font-size: 18px; color: #999">'+
'</span>'+
'</div>');
setTimeout( function(){
OpenNebula.Template.list({
timeout: true,
success: function (request, item_list){
datatable.fnClearTable(true);
if (item_list.length == 0) {
datatable.html('<div class="text-center">'+
'<span class="fa-stack fa-5x" style="color: #dfdfdf">'+
'<i class="fa fa-cloud fa-stack-2x"></i>'+
'<i class="fa fa-info-circle fa-stack-1x fa-inverse"></i>'+
'</span>'+
'<br>'+
'<br>'+
'<span style="font-size: 18px; color: #999">'+
Locale.tr("There are no templates available")+
'</span>'+
'</div>');
} else {
datatable.fnAddData(item_list);
}
},
error: Notifier.onError
});
}, timeout);
}
function setup_provision_templates_list(context, opts) {
var provision_templates_datatable = $('.provision_templates_table', context).dataTable({
"iDisplayLength": 8,
"sDom" : '<"H">t<"F"lp>',
"aLengthMenu": [[6, 12, 36, 72], [6, 12, 36, 72]],
"aaSorting" : [[0, "desc"]],
"aoColumnDefs": [
{ "bVisible": false, "aTargets": ["all"]}
],
"aoColumns": [
{ "mDataProp": "VMTEMPLATE.ID" },
{ "mDataProp": "VMTEMPLATE.NAME" },
{ "mDataProp": "VMTEMPLATE.TEMPLATE.SAVED_TEMPLATE_ID", "sDefaultContent" : "-" },
{ "mDataProp": "VMTEMPLATE.UID" }
],
"fnPreDrawCallback": function (oSettings) {
// create a thumbs container if it doesn't exist. put it in the dataTables_scrollbody div
if (this.$('tr', {"filter": "applied"} ).length == 0) {
this.html('<div class="text-center">'+
'<span class="fa-stack fa-5x" style="color: #dfdfdf">'+
'<i class="fa fa-cloud fa-stack-2x"></i>'+
'<i class="fa fa-info-circle fa-stack-1x fa-inverse"></i>'+
'</span>'+
'<br>'+
'<br>'+
'<span style="font-size: 18px; color: #999">'+
Locale.tr("There are no saved templates available")+
'<br>'+
Locale.tr("Create a template by saving a running Virtual Machine")+
'</span>'+
'</div>');
} else {
$(".provision_templates_table", context).html('<ul class="provision_templates_ul large-block-grid-3 medium-block-grid-3 small-block-grid-1 text-center"></ul>');
}
return true;
},
"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
var data = aData.VMTEMPLATE;
var actions_html = "";
if (Config.isTabActionEnabled("provision-tab", "Template.chmod")) {
if (data.UID == config['user_id']) {
if (data.PERMISSIONS.GROUP_U == "1") {
actions_html += '<a class="provision_confirm_unshare_template_button left" data-tooltip title="'+ Locale.tr("Unshare")+'" style="color:#555" href="#"><i class="fa fa-fw fa-lg fa-ban only-on-hover"/></a>';
actions_html += '<span style="font-size:12px; color: #777">' + Locale.tr("SHARED") + '</span>';
} else {
actions_html += '<a class="provision_confirm_chmod_template_button left" data-tooltip title="'+ Locale.tr("Share")+'" style="color:#555" href="#"><i class="fa fa-fw fa-lg fa-share-alt only-on-hover"/></a>';
}
}
}
if (Config.isTabActionEnabled("provision-tab", "Template.delete")) {
actions_html += '<a class="provision_confirm_delete_template_button" data-tooltip title="'+ Locale.tr("Delete")+'" style="color:#555" href="#"><i class="fa fa-fw fa-lg fa-trash-o right only-on-hover"/></a>';
}
$(".provision_templates_ul", context).append('<li>'+
'<ul class="provision-pricing-table" opennebula_id="'+data.ID+'" saved_to_image_id="'+data.TEMPLATE.SAVED_TO_IMAGE_ID+'" datatable_index="'+iDisplayIndexFull+'">'+
'<li class="provision-title text-left" title="'+data.NAME+'">'+
data.NAME +
'</li>'+
'<li class="provision-bullet-item text-left" >'+
'<i class="fa fa-fw fa-lg fa-laptop"/> '+
'x'+data.TEMPLATE.CPU+' - '+
((data.TEMPLATE.MEMORY > 1000) ?
(Math.floor(data.TEMPLATE.MEMORY/1024)+'GB') :
(data.TEMPLATE.MEMORY+'MB'))+
' - '+
get_provision_disk_image(data) +
'</li>'+
'<li class="provision-description text-left" style="padding-top:0px; padding-bottom: 5px">'+
(data.TEMPLATE.DESCRIPTION || '')+
'</li>'+
'<li class="provision-bullet-item" style="padding-top:10px">'+
actions_html+
'</li>'+
'<li class="provision-bullet-item-last text-left" >'+
'<span class="">'+
'<i class="fa fa-fw fa-lg fa-user"/> '+
data.UNAME+
'</span>'+
'<span class="right">'+
Humanize.prettyTimeAgo(data.REGTIME)+
'</span>'+
'</li>'+
'</ul>'+
'</li>');
return nRow;
}
});
provision_templates_datatable.fnFilter("^(?!\-$)", 2, true, false);
$('.provision_list_templates_search', context).keyup(function(){
provision_templates_datatable.fnFilter( $(this).val() );
})
$('.provision_list_templates_search', context).change(function(){
provision_templates_datatable.fnFilter( $(this).val() );
})
context.on("click", ".provision_templates_list_refresh_button", function(){
OpenNebula.Action.clear_cache("VMTEMPLATE");
$(".provision_confirm_delete_template_div", context).html("");
update_provision_templates_datatable(provision_templates_datatable, 0);
return false;
});
context.on("click", ".provision_templates_list_search_button", function(){
$(".provision_list_templates_search", context).fadeIn();
});
$(".provision_list_templates_filter", context).on("change", ".resource_list_select", function(){
if ($(this).val() != "-2"){
provision_templates_datatable.fnFilter("^" + $(this).val() + "$", 3, true, false);
} else {
provision_templates_datatable.fnFilter("", 3);
}
})
ResourceSelect.insert(
".provision_list_templates_filter",
context,
"User",
(opts.filter_expression ? opts.filter_expression : "-2"),
false,
'<option value="-2">'+Locale.tr("ALL")+'</option>',
null,
null,
true,
true);
context.on("click", ".provision_templates_list_filter_button", function(){
$(".provision_list_templates_filter", context).fadeIn();
return false;
});
if (Config.isTabActionEnabled("provision-tab", "Template.delete")) {
context.on("click", ".provision_confirm_delete_template_button", function(){
var ul_context = $(this).parents(".provision-pricing-table");
var template_id = ul_context.attr("opennebula_id");
var image_id = ul_context.attr("saved_to_image_id");
var template_name = $(".provision-title", ul_context).text();
$(".provision_confirm_delete_template_div", context).html(
'<div data-alert class="alert-box secondary radius">'+
'<div class="row">'+
'<div class="large-9 columns">'+
'<span style="font-size: 14px; line-height: 20px">'+
Locale.tr("Handle with care! This action will inmediately destroy the template")+
' "' + template_name + '" ' +
Locale.tr("and the image associated.") +
'</span>'+
'</div>'+
'<div class="large-3 columns">'+
'<a href"#" class="provision_delete_template_button alert button large-12 radius right" style="margin-right: 15px" image_id="'+image_id+'" template_id="'+template_id+'">'+Locale.tr("Delete")+'</a>'+
'</div>'+
'</div>'+
'<a href="#" class="close">&times;</a>'+
'</div>');
});
context.on("click", ".provision_delete_template_button", function(){
/* TODO SAVED_TO_IMAGE_ID does not exists anymore and now all the images of the template
are cloned instead of only the main disk, therefore all the images should be deleted now.
Probably this could be done in the core
var button = $(this);
button.attr("disabled", "disabled");
var template_id = $(this).attr("template_id");
var image_id = $(this).attr("image_id");
OpenNebula.Image.del({
timeout: true,
data : {
id : image_id
},
success: function (){
OpenNebula.Template.del({
timeout: true,
data : {
id : template_id
},
success: function (){
$(".provision_templates_list_refresh_button", context).trigger("click");
},
error: function (request,error_json, container) {
Notifier.onError(request, error_json, container);
}
})
},
error: function (request,error_json, container) {
if (error_json.error.http_status=="404") {
OpenNebula.Template.del({
timeout: true,
data : {
id : template_id
},
success: function (){
$(".provision_templates_list_refresh_button", context).trigger("click");
},
error: function (request,error_json, container) {
Notifier.onError(request, error_json, container);
$(".provision_templates_list_refresh_button", context).trigger("click");
}
})
} else {
Notifier.onError(request, error_json, container);
}
}
})*/
});
}
if (Config.isTabActionEnabled("provision-tab", "Template.chmod")) {
context.on("click", ".provision_confirm_chmod_template_button", function(){
var ul_context = $(this).parents(".provision-pricing-table");
var template_id = ul_context.attr("opennebula_id");
var image_id = ul_context.attr("saved_to_image_id");
var template_name = $(".provision-title", ul_context).text();
$(".provision_confirm_delete_template_div", context).html(
'<div data-alert class="alert-box secondary radius">'+
'<div class="row">'+
'<div class="large-8 columns">'+
'<span style="font-size: 14px; line-height: 20px">'+
Locale.tr("The template")+
' "' + template_name + '" ' +
Locale.tr("and the image associated will be shared and all the users will be able to instantiate new VMs using this template.") +
'</span>'+
'</div>'+
'<div class="large-4 columns">'+
'<a href"#" class="provision_chmod_template_button success button large-12 radius right" style="margin-right: 15px" image_id="'+image_id+'" template_id="'+template_id+'">'+Locale.tr("Share template")+'</a>'+
'</div>'+
'</div>'+
'<a href="#" class="close">&times;</a>'+
'</div>');
});
context.on("click", ".provision_chmod_template_button", function(){
/* TODO SAVED_TO_IMAGE_ID does not exists anymore and now all the images of the template
are cloned instead of only the main disk, therefore all the images should be chmod now.
Probably this could be done in the core
var button = $(this);
button.attr("disabled", "disabled");
var template_id = $(this).attr("template_id");
var image_id = $(this).attr("image_id");
OpenNebula.Template.chmod({
timeout: true,
data : {
id : template_id,
extra_param: {'group_u': 1}
},
success: function (){
$(".provision_templates_list_refresh_button", context).trigger("click");
OpenNebula.Image.chmod({
timeout: true,
data : {
id : image_id,
extra_param: {'group_u': 1}
},
success: function (){
},
error: Notifier.onError
})
},
error: Notifier.onError
})*/
});
context.on("click", ".provision_confirm_unshare_template_button", function(){
var ul_context = $(this).parents(".provision-pricing-table");
var template_id = ul_context.attr("opennebula_id");
var image_id = ul_context.attr("saved_to_image_id");
var template_name = $(".provision-title", ul_context).first().text();
$(".provision_confirm_delete_template_div", context).html(
'<div data-alert class="alert-box secondary radius">'+
'<div class="row">'+
'<div class="large-8 columns">'+
'<span style="font-size: 14px; line-height: 20px">'+
Locale.tr("The template")+
' "' + template_name + '" ' +
Locale.tr("and the image associated will be unshared and the users will not be able to instantiate new VMs using this template.") +
'</span>'+
'</div>'+
'<div class="large-4 columns">'+
'<a href"#" class="provision_unshare_template_button success button large-12 radius right" style="margin-right: 15px" image_id="'+image_id+'" template_id="'+template_id+'">'+Locale.tr("Unshare template")+'</a>'+
'</div>'+
'</div>'+
'<a href="#" class="close">&times;</a>'+
'</div>');
});
context.on("click", ".provision_unshare_template_button", function(){
var button = $(this);
button.attr("disabled", "disabled");
var template_id = $(this).attr("template_id");
var image_id = $(this).attr("image_id");
OpenNebula.Template.chmod({
timeout: true,
data : {
id : template_id,
extra_param: {'group_u': 0}
},
success: function (){
$(".provision_templates_list_refresh_button", context).trigger("click");
OpenNebula.Image.chmod({
timeout: true,
data : {
id : image_id,
extra_param: {'group_u': 0}
},
success: function (){
},
error: Notifier.onError
})
},
error: Notifier.onError
})
});
}
OpenNebula.Action.clear_cache("VMTEMPLATE");
update_provision_templates_datatable(provision_templates_datatable, 0);
context.foundation();
}
function get_provision_disk_image(data) {
var disks = []
if ($.isArray(data.TEMPLATE.DISK))
disks = data.TEMPLATE.DISK
else if (!$.isEmptyObject(data.TEMPLATE.DISK))
disks = [data.TEMPLATE.DISK]
if (disks.length > 0 && disks[0].IMAGE) {
return disks[0].IMAGE;
} else {
return '';
}
}
});
+1 -1
View File
@@ -1 +1 @@
meta.foundation-version {font-family:"/5.5.1/";}meta.foundation-mq-small {font-family:"/only screen/";width:0;}meta.foundation-mq-small-only {font-family:"/only screen and (max-width: 40em)/";width:0;}meta.foundation-mq-medium {font-family:"/only screen and (min-width:40.063em)/";width:40.063em;}meta.foundation-mq-medium-only {font-family:"/only screen and (min-width:40.063em) and (max-width:64em)/";width:40.063em;}meta.foundation-mq-large {font-family:"/only screen and (min-width:64.063em)/";width:64.063em;}meta.foundation-mq-large-only {font-family:"/only screen and (min-width:64.063em) and (max-width:90em)/";width:64.063em;}meta.foundation-mq-xlarge {font-family:"/only screen and (min-width:90.063em)/";width:90.063em;}meta.foundation-mq-xlarge-only {font-family:"/only screen and (min-width:90.063em) and (max-width:120em)/";width:90.063em;}meta.foundation-mq-xxlarge {font-family:"/only screen and (min-width:120.063em)/";width:120.063em;}meta.foundation-data-attribute-namespace {font-family:false;}html ,body {height:100%;}* ,*:before ,*:after {-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;}html ,body {font-size:100%;}body {background:#ffffff;color:#555555;padding:0;margin:0;font-family:"Open Sans",sans-serif;font-weight:normal;font-style:normal;line-height:1.5;position:relative;cursor:auto;}a:hover {cursor:pointer;}img {max-width:100%;height:auto;}img {-ms-interpolation-mode:bicubic;}#map_canvas img ,#map_canvas embed ,#map_canvas object ,.map_canvas img ,.map_canvas embed ,.map_canvas object {max-width:none !important;}.left {float:left !important;}.right {float:right !important;}.clearfix:before ,.clearfix:after {content:" ";display:table;}.clearfix:after {clear:both;}.hide {display:none;}.invisible {visibility:hidden;}.antialiased {-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;}img {display:inline-block;vertical-align:middle;}textarea {height:auto;min-height:50px;}select {width:100%;}.row {width:100%;margin-left:auto;margin-right:auto;margin-top:0;margin-bottom:0;max-width:75rem;}.row:before ,.row:after {content:" ";display:table;}.row:after {clear:both;}.row.collapse>.column ,.row.collapse>.columns {padding-left:0;padding-right:0;}.row.collapse .row {margin-left:0;margin-right:0;}.row .row {width:auto;margin-left:-0.9375rem;margin-right:-0.9375rem;margin-top:0;margin-bottom:0;max-width:none;}.row .row:before ,.row .row:after {content:" ";display:table;}.row .row:after {clear:both;}.row .row.collapse {width:auto;margin:0;max-width:none;}.row .row.collapse:before ,.row .row.collapse:after {content:" ";display:table;}.row .row.collapse:after {clear:both;}.column ,.columns {padding-left:0.9375rem;padding-right:0.9375rem;width:100%;float:left;}[class*="column"]+[class*="column"]:last-child {float:right;}[class*="column"]+[class*="column"].end {float:left;}@media only screen{.small-push-0 {position:relative;left:0%;right:auto;}.small-pull-0 {position:relative;right:0%;left:auto;}.small-push-1 {position:relative;left:8.33333%;right:auto;}.small-pull-1 {position:relative;right:8.33333%;left:auto;}.small-push-2 {position:relative;left:16.66667%;right:auto;}.small-pull-2 {position:relative;right:16.66667%;left:auto;}.small-push-3 {position:relative;left:25%;right:auto;}.small-pull-3 {position:relative;right:25%;left:auto;}.small-push-4 {position:relative;left:33.33333%;right:auto;}.small-pull-4 {position:relative;right:33.33333%;left:auto;}.small-push-5 {position:relative;left:41.66667%;right:auto;}.small-pull-5 {position:relative;right:41.66667%;left:auto;}.small-push-6 {position:relative;left:50%;right:auto;}.small-pull-6 {position:relative;right:50%;left:auto;}.small-push-7 {position:relative;left:58.33333%;right:auto;}.small-pull-7 {position:relative;right:58.33333%;left:auto;}.small-push-8 {position:relative;left:66.66667%;right:auto;}.small-pull-8 {position:relative;right:66.66667%;left:auto;}.small-push-9 {position:relative;left:75%;right:auto;}.small-pull-9 {position:relative;right:75%;left:auto;}.small-push-10 {position:relative;left:83.33333%;right:auto;}.small-pull-10 {position:relative;right:83.33333%;left:auto;}.small-push-11 {position:relative;left:91.66667%;right:auto;}.small-pull-11 {position:relative;right:91.66667%;left:auto;}.column ,.columns {position:relative;padding-left:0.9375rem;padding-right:0.9375rem;float:left;}.small-1 {width:8.33333%;}.small-2 {width:16.66667%;}.small-3 {width:25%;}.small-4 {width:33.33333%;}.small-5 {width:41.66667%;}.small-6 {width:50%;}.small-7 {width:58.33333%;}.small-8 {width:66.66667%;}.small-9 {width:75%;}.small-10 {width:83.33333%;}.small-11 {width:91.66667%;}.small-12 {width:100%;}.small-offset-0 {margin-left:0% !important;}.small-offset-1 {margin-left:8.33333% !important;}.small-offset-2 {margin-left:16.66667% !important;}.small-offset-3 {margin-left:25% !important;}.small-offset-4 {margin-left:33.33333% !important;}.small-offset-5 {margin-left:41.66667% !important;}.small-offset-6 {margin-left:50% !iLine truncated
meta.foundation-version {font-family:"/5.5.1/";}meta.foundation-mq-small {font-family:"/only screen/";width:0;}meta.foundation-mq-small-only {font-family:"/only screen and (max-width: 40em)/";width:0;}meta.foundation-mq-medium {font-family:"/only screen and (min-width:40.063em)/";width:40.063em;}meta.foundation-mq-medium-only {font-family:"/only screen and (min-width:40.063em) and (max-width:64em)/";width:40.063em;}meta.foundation-mq-large {font-family:"/only screen and (min-width:64.063em)/";width:64.063em;}meta.foundation-mq-large-only {font-family:"/only screen and (min-width:64.063em) and (max-width:90em)/";width:64.063em;}meta.foundation-mq-xlarge {font-family:"/only screen and (min-width:90.063em)/";width:90.063em;}meta.foundation-mq-xlarge-only {font-family:"/only screen and (min-width:90.063em) and (max-width:120em)/";width:90.063em;}meta.foundation-mq-xxlarge {font-family:"/only screen and (min-width:120.063em)/";width:120.063em;}meta.foundation-data-attribute-namespace {font-family:false;}html ,body {height:100%;}* ,*:before ,*:after {-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;}html ,body {font-size:100%;}body {background:#ffffff;color:#555555;padding:0;margin:0;font-family:"Open Sans",sans-serif;font-weight:normal;font-style:normal;line-height:1.5;position:relative;cursor:auto;}a:hover {cursor:pointer;}img {max-width:100%;height:auto;}img {-ms-interpolation-mode:bicubic;}#map_canvas img ,#map_canvas embed ,#map_canvas object ,.map_canvas img ,.map_canvas embed ,.map_canvas object {max-width:none !important;}.left {float:left !important;}.right {float:right !important;}.clearfix:before ,.clearfix:after {content:" ";display:table;}.clearfix:after {clear:both;}.hide {display:none;}.invisible {visibility:hidden;}.antialiased {-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;}img {display:inline-block;vertical-align:middle;}textarea {height:auto;min-height:50px;}select {width:100%;}.row {width:100%;margin-left:auto;margin-right:auto;margin-top:0;margin-bottom:0;max-width:75rem;}.row:before ,.row:after {content:" ";display:table;}.row:after {clear:both;}.row.collapse>.column ,.row.collapse>.columns {padding-left:0;padding-right:0;}.row.collapse .row {margin-left:0;margin-right:0;}.row .row {width:auto;margin-left:-0.9375rem;margin-right:-0.9375rem;margin-top:0;margin-bottom:0;max-width:none;}.row .row:before ,.row .row:after {content:" ";display:table;}.row .row:after {clear:both;}.row .row.collapse {width:auto;margin:0;max-width:none;}.row .row.collapse:before ,.row .row.collapse:after {content:" ";display:table;}.row .row.collapse:after {clear:both;}.column ,.columns {padding-left:0.9375rem;padding-right:0.9375rem;width:100%;float:left;}[class*="column"]+[class*="column"]:last-child {float:right;}[class*="column"]+[class*="column"].end {float:left;}@media only screen{.small-push-0 {position:relative;left:0%;right:auto;}.small-pull-0 {position:relative;right:0%;left:auto;}.small-push-1 {position:relative;left:8.33333%;right:auto;}.small-pull-1 {position:relative;right:8.33333%;left:auto;}.small-push-2 {position:relative;left:16.66667%;right:auto;}.small-pull-2 {position:relative;right:16.66667%;left:auto;}.small-push-3 {position:relative;left:25%;right:auto;}.small-pull-3 {position:relative;right:25%;left:auto;}.small-push-4 {position:relative;left:33.33333%;right:auto;}.small-pull-4 {position:relative;right:33.33333%;left:auto;}.small-push-5 {position:relative;left:41.66667%;right:auto;}.small-pull-5 {position:relative;right:41.66667%;left:auto;}.small-push-6 {position:relative;left:50%;right:auto;}.small-pull-6 {position:relative;right:50%;left:auto;}.small-push-7 {position:relative;left:58.33333%;right:auto;}.small-pull-7 {position:relative;right:58.33333%;left:auto;}.small-push-8 {position:relative;left:66.66667%;right:auto;}.small-pull-8 {position:relative;right:66.66667%;left:auto;}.small-push-9 {position:relative;left:75%;right:auto;}.small-pull-9 {position:relative;right:75%;left:auto;}.small-push-10 {position:relative;left:83.33333%;right:auto;}.small-pull-10 {position:relative;right:83.33333%;left:auto;}.small-push-11 {position:relative;left:91.66667%;right:auto;}.small-pull-11 {position:relative;right:91.66667%;left:auto;}.column ,.columns {position:relative;padding-left:0.9375rem;padding-right:0.9375rem;float:left;}.small-1 {width:8.33333%;}.small-2 {width:16.66667%;}.small-3 {width:25%;}.small-4 {width:33.33333%;}.small-5 {width:41.66667%;}.small-6 {width:50%;}.small-7 {width:58.33333%;}.small-8 {width:66.66667%;}.small-9 {width:75%;}.small-10 {width:83.33333%;}.small-11 {width:91.66667%;}.small-12 {width:100%;}.small-offset-0 {margin-left:0% !important;}.small-offset-1 {margin-left:8.33333% !important;}.small-offset-2 {margin-left:16.66667% !important;}.small-offset-3 {margin-left:25% !important;}.small-offset-4 {margin-left:33.33333% !important;}.small-offset-5 {margin-left:41.66667% !important;}.small-offset-6 {margin-left:50% !iLine truncated
+3 -3
View File
@@ -609,11 +609,11 @@ fieldset {
}
}
.provision-header {
font-size: rem-calc(16px);
font-size: rem-calc(14px);
border-bottom: 1px solid #efefef;
li {
padding: 0px 10px 5px 0px;
padding-bottom: 5px;
}
li.active {
@@ -1108,7 +1108,7 @@ hr {
}
select {
height: 39px !important;
height: 33px !important;
margin: 0px 5px 0px 0px !important;
float: right !important;
width: auto !important;