1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-12 09:17:41 +03:00

F #5479: Add scheduled actions errors in vm info view (#1435)

This commit is contained in:
Frederick Borges 2021-09-06 12:10:59 +02:00 committed by GitHub
parent eb49ad2e6f
commit e5331ccb1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 82 additions and 20 deletions

View File

@ -34,6 +34,7 @@ define(function(require) {
*/
var TemplateInfo = require("hbs!./info/html");
var TemplateInfoError = require("hbs!utils/info-error/html");
/*
CONSTANTS
@ -118,26 +119,31 @@ define(function(require) {
if (this.element &&
this.element.USER_TEMPLATE &&
this.element.USER_TEMPLATE.ERROR){
errorMessageHTML =
"<div class='row'>" +
"<div class='large-9 columns'>" +
"<div class='callout warning warning-message' style='border-radius: .5em;' data-closable>" +
"<div class='row'>"+
"<div class='columns large-1'>" +
"<i class='fas fa-exclamation-circle'></i>"+
"</div>"+
"<div class='columns large-9'>"+
"<p>" + this.element.USER_TEMPLATE.ERROR + "</p>" +
"</div>"+
"<div class='columns large-2'>" +
"<a id='close_vm_async_error' data-close>" +
"<u>Dismiss</u>"+
"</a>" +
"</div>" +
"</div>" +
"</div>" +
"</div>" +
"</div>";
errorMessageHTML = TemplateInfoError(
{
error_msg: this.element.USER_TEMPLATE.ERROR,
error_title: Locale.tr("Driver Error"),
canDismiss: true,
dismisId: "close_vm_async_error"
}
);
}
if (this.element &&
this.element.TEMPLATE &&
this.element.TEMPLATE.SCHED_ACTION){
var arraySchedActions = Array.isArray(this.element.TEMPLATE.SCHED_ACTION) ?
this.element.TEMPLATE.SCHED_ACTION :
[this.element.TEMPLATE.SCHED_ACTION];
var lastErrorAndId = getLastSchedErrorAndId(arraySchedActions);
errorMessageHTML += TemplateInfoError(
{
error_msg: lastErrorAndId.error,
error_title: Locale.tr("Scheduled Action Error") + " (ID: #" + lastErrorAndId.id + ")",
canDismiss: false,
dismisId: ""
}
);
}
return TemplateInfo({
@ -162,6 +168,24 @@ define(function(require) {
});
}
function getLastSchedErrorAndId(sched_array){
var lastErrorAndId = {
error: "",
id: 0
}
var lastEnd = 0;
$.each(sched_array, function(_, sched_action){
if (sched_action.MESSAGE &&
sched_action.END_VALUE &&
parseInt(sched_action.END_VALUE) > lastEnd){
lastErrorAndId.error = sched_action.MESSAGE;
lastErrorAndId.id = parseInt(sched_action.ID);
lastEnd = parseInt(sched_action.END_VALUE);
}
});
return lastErrorAndId;
}
function _setup(context) {
var that = this;

View File

@ -0,0 +1,38 @@
{{! -------------------------------------------------------------------------- }}
{{! Copyright 2002-2021, OpenNebula Project, OpenNebula Systems }}
{{! }}
{{! Licensed under the Apache License, Version 2.0 (the "License"); you may }}
{{! not use this file except in compliance with the License. You may obtain }}
{{! a copy of the License at }}
{{! }}
{{! http://www.apache.org/licenses/LICENSE-2.0 }}
{{! }}
{{! Unless required by applicable law or agreed to in writing, software }}
{{! distributed under the License is distributed on an "AS IS" BASIS, }}
{{! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. }}
{{! See the License for the specific language governing permissions and }}
{{! limitations under the License. }}
{{! -------------------------------------------------------------------------- }}
<div class='row'>
<div class='large-9 columns'>
<div class='callout warning warning-message' style='border-radius: .5em;' data-closable>
<div class='row'>
<div class='columns large-1'>
<i class='fas fa-exclamation-circle'></i>
</div>
<div class='columns large-9'>
<b>{{error_title}}</b><br>
{{error_msg}}
</div>
<div class='columns large-2'>
{{#if canDismiss}}
<a id='{{dismissId}}' data-close>
<u>Dismiss</u>
</a>
{{/if}}
</div>
</div>
</div>
</div>
</div>