1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

B #~: update schedule icon (#2324)

This commit is contained in:
Jorge Miguel Lobo Escalona 2022-10-25 18:48:12 +02:00 committed by GitHub
parent 5973b126b9
commit 1563476aa1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 43 additions and 9 deletions

View File

@ -291,7 +291,7 @@ define(function(require) {
}
if (that.service_template_json.DOCUMENT.TEMPLATE.BODY.roles) {
var charters = "";
var scheduleActionsList = ScheduleActions.retrieve(context, true)
var scheduleActionsList = ScheduleActions.retrieve(context, true);
$.each(scheduleActionsList, function(_,sched_action){
charters += TemplateUtils.templateToString(sched_action);
@ -338,9 +338,7 @@ define(function(require) {
}
});
if(charters.length){
(temp_role.vm_template_contents !== undefined)
? temp_role.vm_template_contents += charters
: temp_role.vm_template_contents = charters;
temp_role.vm_template_contents = charters;
}
extra_info.merge_template.roles.push(temp_role);
});

View File

@ -145,7 +145,7 @@ define(function (require) {
roles: optionsRoles
});
}
function _setupPerformAction(resource, service_id){
$("select#select_new_action").off("change").on("change",function(){
var snap_name = $("#snapname");
@ -727,7 +727,7 @@ define(function (require) {
$("#sched_" + this.res + "_actions_table .create", context).remove();
var actionsJSON = [];
$("#sched_" + this.res + "_actions_table tbody tr").each(function (index) {
$("#sched_" + this.res + "_actions_table tbody tr", context).each(function (index) {
var first = $(this).children("td")[0];
if (!$("select", first).html()) { //table header
var actionJSON = {};
@ -1016,14 +1016,14 @@ define(function (require) {
sched_obj.end_str = Locale.tr("None");
break;
case "1":
sched_obj.end_str = Locale.tr("After") +
sched_obj.end_str = Locale.tr("After") +
" " +
schedule_action.END_VALUE +
" " +
Locale.tr("times");
break;
case "2":
sched_obj.end_str = Locale.tr("On") +
sched_obj.end_str = Locale.tr("On") +
" " +
Humanize.prettyTime(schedule_action.END_VALUE);
break;
@ -1095,6 +1095,39 @@ define(function (require) {
});
}
/**
* This function updates the Service vm_template_contents with the scheduled
* actions of the first service vm.
*
* @param {object} service - Service object.
*/
function _updateVmTemplateContents(service){
if (
service &&
service.data &&
service.data[0] &&
service.data[0].nodes &&
service.data[0].nodes[0] &&
service.data[0].nodes[0].deploy_id >= 0){
OpenNebulaVM.show({
data : {
id: service.data[0].nodes[0].deploy_id
},
success: function(_, vmTemplate){
var sched_action = { SCHED_ACTION: vmTemplate.VM.TEMPLATE.SCHED_ACTION };
var sched_template = TemplateUtils.templateToString(sched_action);
service.body.roles.forEach(role => {
role.vm_template_contents = sched_template;
});
Sunstone.runAction("Service.update",service.id, JSON.stringify(service.body));
},
error: function(error){
Notifier.onError("VM: " +error);
}
});
}
}
/**
* This function updates the Service datatable with the services information
* of the first service vm.
@ -1189,6 +1222,7 @@ define(function (require) {
callback: function() {
var selector = "#sched_" + resource + "_actions_body";
_updateServiceHTMLTable(that, selector, _getScheduleActionTableContent);
_updateVmTemplateContents(that);
}
};
sendSchedActionToServiceRoles(roles, "VM.sched_action_add", sched_template, extraParams);
@ -1247,6 +1281,7 @@ define(function (require) {
callback: function() {
var selector = "#sched_" + resource + "_actions_body";
_updateServiceHTMLTable(that, selector, _getScheduleActionTableContent);
_updateVmTemplateContents(that);
}
};
sendSchedActionToServiceRoles(roles, "VM.sched_action_update", obj, extraParams);
@ -1286,6 +1321,7 @@ define(function (require) {
callback: function() {
var selector = "#sched_" + resource + "_actions_body";
_updateServiceHTMLTable(that, selector, _getScheduleActionTableContent);
_updateVmTemplateContents(that);
}
};
sendSchedActionToServiceRoles(roles, "VM.sched_action_delete", null, extraParams);
@ -1523,7 +1559,7 @@ define(function (require) {
});
}
}
return TemplateCharterTableHTML({
"res": resource,