From 4733263c7b79ce84197bc5ae4d16ced02014e1d2 Mon Sep 17 00:00:00 2001 From: Jorge Lobo <47326048+jloboescalona2@users.noreply.github.com> Date: Wed, 29 Apr 2020 15:32:03 +0200 Subject: [PATCH] M #-: Add tooltip Charters (#4628) Signed-off-by: Jorge Lobo --- .../public/app/tabs/vms-tab/datatable.js | 2 + .../tabs/vms-tab/utils/datatable-common.js | 49 +++++++++++++++++-- .../public/app/utils/schedule_action.js | 1 + 3 files changed, 47 insertions(+), 5 deletions(-) diff --git a/src/sunstone/public/app/tabs/vms-tab/datatable.js b/src/sunstone/public/app/tabs/vms-tab/datatable.js index deb7aca73d..708b684503 100644 --- a/src/sunstone/public/app/tabs/vms-tab/datatable.js +++ b/src/sunstone/public/app/tabs/vms-tab/datatable.js @@ -165,6 +165,8 @@ define(function(require) { DashboardUtils.counterAnimation(".failed_vms", this.failedVms); $(".off_vms").text(this.offVms); + + VMsTableUtils.tooltipCharters() } function _initialize(opts) { diff --git a/src/sunstone/public/app/tabs/vms-tab/utils/datatable-common.js b/src/sunstone/public/app/tabs/vms-tab/utils/datatable-common.js index e9cc66eebb..755ad241ef 100644 --- a/src/sunstone/public/app/tabs/vms-tab/utils/datatable-common.js +++ b/src/sunstone/public/app/tabs/vms-tab/utils/datatable-common.js @@ -22,6 +22,7 @@ define(function(require) { var TemplateUtils = require('utils/template-utils'); var LabelsUtils = require('utils/labels/utils'); var Status = require('utils/status'); + var ScheduleActions = require("utils/schedule_action"); var RESOURCE = "VM"; var XML_ROOT = "VM"; @@ -48,10 +49,11 @@ define(function(require) { return { 'elementArray': _elementArray, 'emptyElementArray': _emptyElementArray, + 'tooltipCharters': showCharterInfo, 'columns': _columns }; - function checkTime(startTime, addedEndTime, warningTime){ + function checkTime(startTime, addedEndTime, warningTime, rtnTime){ var rtn = false; if(startTime && addedEndTime){ var regexNumber = new RegExp('[0-9]*$','gm'); @@ -69,11 +71,12 @@ define(function(require) { break; } now = new Date(); - var nowInSeconds = Math.round(parseInt(now.getTime()) / 1000); + var nowGetTime = parseInt(now.getTime(),10) + var nowInSeconds = Math.round(nowGetTime / 1000); if(finalTime >= nowInSeconds && warningTime === undefined){ - rtn = true; + rtn = rtnTime? finalTime - nowInSeconds : true; }else if(!!warningTime){ - var warning = parseInt(warningTime.match(regexNumber)[0]); + var warning = parseInt(warningTime.match(regexNumber)[0],10); if(!isNaN(warning)){ operator = warningTime.replace(regexNumber, ""); var wtime = date; @@ -95,6 +98,42 @@ define(function(require) { return rtn; } + function showCharterInfo(){ + var classInfo = "charterInfo"; + var styleTips = { + "position":"absolute", + "background":"#d7d0d0", + "padding":"8px", + "z-index":"1", + "min-width":"8rem", + "font-family": '"Lato","Helvetica Neue",Helvetica,Roboto,Arial,sans-serif', + "font-weight": "100" + }; + $(".describeCharter").off("mouseenter").on("mouseenter",function(e){ + $(this).find(".charterInfo").remove(); + var start = $(this).attr("data_start"); + var add = $(this).attr("data_add"); + var action = $(this).attr("data_action"); + if((start && start.length) && (add && add.length) && (action && action.length)){ + var date = checkTime(start, add, undefined, true); + if(typeof date === "number"){ + $(this).append( + $("
",{"class":classInfo}).css(styleTips).append( + $("").css({"display":"inline"}).text(action).add( + $("
").css({"display":"inline"}).text( + " "+Locale.tr("will run in")+" "+ScheduleActions.parseTime(date) + ) + ) + ) + ); + } + } + }) + $(".describeCharter").on("mouseleave").on("mouseleave", function(e){ + $(this).find("."+classInfo).remove(); + }); + } + function leasesClock(element){ var rtn = ""; if( @@ -126,7 +165,7 @@ define(function(require) { leases[action.ACTION].color ){ if(checkTime(element.STIME, action.TIME)){ - rtn = $("",{class:"fa fa-clock"}).css("color",leases[action.ACTION].color); + rtn = $("",{class:"describeCharter fa fa-clock",data_start:element.STIME, data_add:action.TIME, data_action:action.ACTION}).css({"position":"relative","color":leases[action.ACTION].color}); if( leases[action.ACTION].warning && leases[action.ACTION].warning.time && diff --git a/src/sunstone/public/app/utils/schedule_action.js b/src/sunstone/public/app/utils/schedule_action.js index 1b4e1732ce..79c1050af9 100644 --- a/src/sunstone/public/app/utils/schedule_action.js +++ b/src/sunstone/public/app/utils/schedule_action.js @@ -788,6 +788,7 @@ define(function (require) { "retrieveNewAction": _retrieveNewAction, "retrieve": _retrieve, "fill": _fill, + "parseTime": _time, "reset": _reset }; }); \ No newline at end of file