cockpit/js/instance.js in cpee-2.1.71 vs cockpit/js/instance.js in cpee-2.1.73
- old
+ new
@@ -7,10 +7,13 @@
var subscription;
var subscription_state = 'less';
var graph_changed = new Event("graph:changed", {"bubbles":true, "cancelable":false});
var graph_theme = null;
var graph_position = null;
+var graph_highlight = null;
+var graph_highlight_tasks = []
+var graph_highlight_color = null;
var model_loaded = new Event("model:loaded", {"bubbles":true, "cancelable":false});
var save = {};
save['endpoints'] = undefined;
save['dataelements'] = undefined;
save['attributes'] = undefined;
@@ -23,11 +26,10 @@
subscription_state = 'less';
save['states']= {};
save['state']= undefined;
save['dsl'] = undefined;
save['activity_red_states'] = {}
- save['activity_blue_states'] = {}
save['graph'] = undefined;
save['graph_theme'] = undefined;
save['graph_adaptor'] = undefined;
save['endpoints_cache'] = {};
save['endpoints_list'] = {};
@@ -126,11 +128,20 @@
if (q.min || q.min == "") {
uidash_toggle_vis_tab($('#instance'));
uidash_toggle_vis_tab($('#parameters'));
}
if (q.theme) { graph_theme = q.theme; }
- if (q.position) { graph_position = q.position; }
+ if (q.position) { graph_position = q.position == 'false' ? 'false' : 'true'; }
+ if (q.highlight) {
+ graph_highlight = q.highlight.match(/((a\d+,)+)([a-z0-9]{6,8})$/);
+ if (graph_highlight.length > 0) {
+ graph_highlight_color = graph_highlight[3];
+ graph_highlight_tasks = graph_highlight[1].split(',');
+ graph_highlight_tasks.pop();
+ graph_highlight = graph_highlight[0];
+ }
+ }
if (q.monitor && q.load) {
if (q.load.match(/https?:\/\//)) {
$('body').attr('load-testset',q.load);
} else {
$("#templates div.menuitem").each(function(k,v){
@@ -293,11 +304,11 @@
await monitor_instance_values("attributes");
monitor_instance_values("endpoints");
} else {
monitor_instance_values("attributes");
}
- if (save['graph_theme'] != data.content.values.theme) {
+ if (typeof data.content.values.theme !== "undefined" && save['graph_theme'] != data.content.values.theme) {
monitor_graph_change(true);
}
break;
case 'task':
if ($('#trackcolumn').length > 0) {
@@ -346,10 +357,12 @@
$("input[name=res-url]").val($("body").attr('current-resources'));
$('#parameters ui-content ui-area > button').attr('disabled','disabled');
$('#dat_details').empty();
+ $('#modifiers > div').remove();
+
url = $("body").attr('current-instance');
$.ajax({
type: "GET",
url: url,
@@ -373,11 +386,11 @@
$("#current-graph").show();
$("#current-graph").attr('href','graph.html?monitor=' + url);
$("#current-track").show();
$("#current-track").attr('href','track.html?monitor=' + url);
var q = $.parseQuerySimple();
- history.replaceState({}, '', '?' + (graph_position ? "position=" + graph_position + "&" : "") + (graph_theme ? "theme=" + graph_theme + "&" : "") + (q.min || q.min=="" ? "min&" : "") + 'monitor='+url);
+ history.replaceState({}, '', '?' + (graph_position ? "position=" + graph_position + "&" : "") + (graph_highlight ? "highlight=" + graph_highlight + "&" : "") + (graph_theme ? "theme=" + graph_theme + "&" : "") + (q.min || q.min=="" ? "min&" : "") + 'monitor='+url);
// Change url to return to current instance when reloading (because new subscription is made)
$("input[name=votecontinue]").prop( "checked", false );
$.ajax({
@@ -562,10 +575,22 @@
suspended_redrawing = true;
save['graph_theme'] = theme;
save['graph_adaptor'] = new WfAdaptor($('body').data('theme-base') + '/' + theme + '/theme.js',function(graphrealization){
manifestation.endpoints = save.endpoints_list;
graphrealization.draw_labels = function(max,labels,dimensions,striped) {
+ // highlight
+
+ if (graph_highlight) {
+ graph_highlight_tasks.forEach((ele) => {
+ let er = $('g[element-id=' + ele + ']').attr('element-row');
+ styletext = 'svg rect[element-row="'+ er + '"], div.graphlast[element-row="'+ er + '"] { fill: #' + graph_highlight_color + ' !important; background-color: #' + graph_highlight_color + ' !important; } ';
+ $('head').append('<style type="text/css">' + styletext + '</style>');
+ scroll_into_view(ele);
+ })
+ }
+
+ // labels
$('#graphcanvas').css('grid-row', '1/span ' + (max.row + 2));
if (striped == true) {
if (!$('#graphgrid').hasClass('striped')) {
$('#graphgrid').addClass('striped');
}
@@ -785,10 +810,11 @@
if (manifestation.selected() == "unknown") { // nothing selected
$('#dat_details').empty();
}
};
adaptor_update();
+
monitor_instance_pos();
$('#dat_details').empty();
// while inside and svgs are reloaded, do nothing here
suspended_redrawing = false;
@@ -860,12 +886,12 @@
}
});
}// }}}
function monitor_instance_pos() {// {{{
- if (graph_position) {
- save['instance_pos'] = $X('<' + graph_position + '>after</' + graph_position + '>');
+ if (graph_position && graph_position == 'false') {
+ save['instance_pos'] = [];
format_visual_clear();
format_instance_pos();
return;
};
var url = $('body').attr('current-instance');
@@ -894,38 +920,28 @@
} else if (event == "done") {
if (save['activity_red_states'][content['activity-uuid']]) {
format_visual_remove(content.activity,"active");
}
save['activity_red_states'][content['activity-uuid']] = true
- setTimeout(() => {delete save['activity_red_states'][content['activity-uuid']]},5000);
+ setTimeout(() => {delete save['activity_red_states'][content['activity-uuid']]},1);
}
} // }}}
function monitor_instance_pos_change(content) {// {{{
- if (graph_position) { return } ;
+ if (graph_position && graph_position == 'false') { return; }
if (content['at']) {
$.each(content['at'],function(a,b){
- if (!save['activity_blue_states'][b.uuid]) {
- save['activity_blue_states'][b.uuid] = true
- format_visual_add(b.position,"passive");
- }
+ format_visual_add(b.position,"passive",false);
});
}
if (content['after']) {
$.each(content['after'],function(a,b){
- if (!save['activity_blue_states'][b.uuid]) {
- save['activity_blue_states'][b.uuid] = true
- format_visual_add(b.position,"passive");
- }
+ format_visual_add(b.position,"passive",false);
});
}
if (content['unmark']) {
$.each(content['unmark'],function(a,b){
- if (save['activity_blue_states'][b.uuid]) {
- format_visual_remove(b.position,"passive")
- }
- save['activity_blue_states'][b.uuid] = true
- setTimeout(() => {delete save['activity_blue_states'][b.uuid]},5000);
+ format_visual_remove(b.position,"passive",false)
});
}
if (!content['at'] && !content['unmark'] && !content['after'] && !content['wait']) {
monitor_instance_pos();
}
@@ -954,19 +970,15 @@
if (notification == "stopped") {
monitor_instance_pos();
}
if (notification == "running") {
- // // we cant do that, because the events might not be ordered. so jus remove all the blue ones.
- // format_visual_clear();
-
for (const [key, ele] of Object.entries(node_state)) {
for (i=0; i<ele.passive; i++) {
format_visual_remove(key,'passive');
}
}
- // save_blue_states has to be left alone, because we dont know the uuid
}
var but = "";
if (notification == "ready" || notification == "stopped") {
$('#state_extended').show();
@@ -1434,25 +1446,31 @@
}
});
return Promise.all(promises);
}// }}}
-function format_visual_add(what,cls) {//{{{
+function format_visual_add(what,cls,sum=true) {//{{{
if (node_state[what] == undefined)
node_state[what] = {};
if (node_state[what][cls] == undefined)
node_state[what][cls] = 0;
node_state[what][cls] += 1;
+ if (sum == false && node_state[what][cls] > 1) {
+ node_state[what][cls] = 1;
+ }
format_visual_set(what);
}//}}}
-function format_visual_remove(what,cls) {//{{{
+function format_visual_remove(what,cls,sum=true) {//{{{
if (node_state[what] == undefined)
node_state[what] = {};
if (node_state[what][cls] == undefined)
node_state[what][cls] = 0;
node_state[what][cls] -= 1;
if (node_state[what][cls] < 0)
node_state[what][cls] = 0;
+ if (sum == false && node_state[what][cls] < 0) {
+ node_state[what][cls] = 0;
+ }
format_visual_set(what);
}//}}}
function scroll_into_view(what) { //{{{
if (save['state'] != "running") return;