Commit 9f2be06b authored by Otto Jonassen Wittner's avatar Otto Jonassen Wittner
Browse files

Default selectbox selection behavior optimized

parent 43a8314d
......@@ -149,6 +149,78 @@ dragonlab:
descr: "List of hosts in latest routes"
default_field: "anomality_class"
default_event_type: "gap"
uninett:
title: "Uninett"
event_type:
# Event types for variant
gapsum:
title: "Gap summary"
# Relevant data field for event type (matches ES field names)
field:
down_ppm:
title: "Unavailability"
unit: "ppm"
h_ddelay:
title: "Queue"
unit: "ms"
h_jit:
title: "Jitter"
unit: "ms"
h_min_d:
title: "Min delay"
unit: "ms"
big_gaps:
title: "Avg delay"
unit: "ms"
big_time:
title: "Big gap time"
unit: "s"
small_gaps:
title: "Small gaps"
unit: "#"
small_time:
title: "Small gap time"
unit: "s"
# Data field to select as default
default_field: "down_ppm"
gap:
title: "Gaps"
field:
down_ppm:
title: "Unavailability"
unit: "ppm"
tloss:
title: "Time lost"
unit: "ms"
h_ddelay:
title: "Queue"
unit: "ms"
h_jit:
title: "Jitter"
unit: "ms"
h_min_d:
title: "Min delay"
unit: "ms"
h_slope_10:
title: "Slope"
unit: ""
default_field: "down_ppm"
jitter:
title: "Queues"
field:
h_ddelay:
title: "Queue"
unit: "ms"
h_jit:
title: "Jitter"
unit: "ms"
h_min_d:
title: "Min delay"
unit: "ms"
h_slope_10:
title: "Slope"
unit: ""
default_field: "h_ddelay"
default_event_type: "jitter"
......@@ -243,7 +243,7 @@ var loads=0; // number of loaded point series
var duplines=[];
var points_cache=[];
function update_props(mvar) {
function update_props() {
// Repopulate property structures based on given measuerment network variant and config file
// Also re-init event type and variable select-lists
......@@ -255,13 +255,13 @@ var points_cache=[];
prop_names_list ={};
prop_desc ={};
event_desc={};
for (const e in conffile[mvar].event_type) {
for (const e in conffile[parms.net].event_type) {
prop_names_list[e]=[];
event_desc[e] = conffile[mvar].event_type[e].title
for (const f in conffile[mvar].event_type[e].field) {
event_desc[e] = conffile[parms.net].event_type[e].title
for (const f in conffile[parms.net].event_type[e].field) {
prop_names_list[e].push(f);
var unit = conffile[mvar].event_type[e].field[f].unit
var title = conffile[mvar].event_type[e].field[f].title
var unit = conffile[parms.net].event_type[e].field[f].unit
var title = conffile[parms.net].event_type[e].field[f].title
prop_desc[f] = title + ( unit ? " (" + unit + ")" : "") ;
}
}
......@@ -270,7 +270,8 @@ var points_cache=[];
event_names = Object.keys(prop_names_list);
make_prop_select("event_type", event_names, event_desc );
// Select event type
if (parms.event) {
if (parms.event && (event_names.indexOf(parms.event) > -1)) {
// Reapply already selected
$("#event_type").val(parms.event);
} else {
// Apply default event type if available
......@@ -284,7 +285,8 @@ var points_cache=[];
prop_names = prop_names_list[ $("#event_type").val() ];
make_prop_select("prop_select", prop_names, prop_desc );
// Select measurement variable
if (parms.property) {
if (parms.property && (prop_names.indexOf(parms.property) > -1) ) {
// Reapply already selected
$("#prop_select").val(parms.property);
} else {
// Apply default measurement variable/property if available
......@@ -1964,7 +1966,7 @@ $(document).ready ( function(){
// network change
$("#network").change( function(){
parms.net= $("#network").val();
update_props(parms.net);
update_props();
remove_links(links);
load_name_to_address();
show_network(parms.net);
......@@ -1976,17 +1978,17 @@ $(document).ready ( function(){
$("#event_type").change( function(){
parms.event = $("#event_type").val()
// Refresh measurement variable (property) select list
prop_names = prop_names_list[ $("#event_type").val() ];
prop_names = prop_names_list[ parms.event ];
//remove_links();
prop_names = prop_names_list[ $("#event_type").val() ];
prop_names = prop_names_list[ parms.event ];
make_prop_select("prop_select", prop_names, prop_desc );
// Select measurement variable
if (parms.property && (parms.property in prop_names)) {
if (parms.property && (prop_names.indexOf(parms.property) > -1)) {
$("#prop_select").val(parms.property);
} else {
// Apply default measurement variable/property if available
if ( "default_field" in conffile[parms.net].event_type[$("#event_type").val()] ) {
$("#prop_select").val(conffile[parms.net].event_type[$("#event_type").val()].default_field);
if ( "default_field" in conffile[parms.net].event_type[parms.event] ) {
$("#prop_select").val(conffile[parms.net].event_type[parms.event].default_field);
}
parms.property = $("#prop_select").val()
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment