Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
IOU
microdep
Commits
57c29d94
Commit
57c29d94
authored
Feb 03, 2022
by
Olav Kvittem
Browse files
top margin
parent
b53a8bad
Pipeline
#61088
passed with stages
in 1 minute
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
server/script/microdep-map-live.html
View file @
57c29d94
...
...
@@ -54,13 +54,7 @@
<script
src=
"js/sorttable.js"
></script>
<script
src=
"graph.js"
></script>
<script>
// assigning new property with function so child window can point it
document
.
functionToBeCalledFromChildWindow
=
function
(
param
){
alert
(
param
);
// further processing.
}
</script>
<style
type=
"text/css"
>
#mapid
{
height
:
900px
;
z-index
:
1
;}
#midding
{
width
:
600px
}
...
...
@@ -91,7 +85,7 @@
</head>
<body
style=
"height:
5
0%"
>
<body
style=
"height:
8
0%
;padding-top:5px;
"
>
<!-- <h2>Micro dependability measurement node map</h2> -->
<!--
<button class=knapp id="draw">Connections</button>
...
...
@@ -140,7 +134,7 @@
<span
class=
knapp
id=
refs
></span>
<button
class=
knapp
id=
live
title=
"Refresh display every minute"
>
Autorefresh
</button>
<img
id=
busy
src=
js/ajax-loader.gif
>
<img
id=
busy
src=
/
js/ajax-loader.gif
>
<!--
<div id=busy><img width=100% src=/js/ajax-loader.gif></div>
-->
...
...
@@ -257,27 +251,63 @@ 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
if
(
jQuery
.
isEmptyObject
(
conffile
))
{
// No config file data available
return
// Also re-init event type and variable select-lists
if
(
!
jQuery
.
isEmptyObject
(
conffile
))
{
// Config file data is available. Update lists.
prop_names_list
=
{};
prop_desc
=
{};
event_desc
=
{};
for
(
const
e
in
conffile
[
parms
.
net
].
event_type
)
{
prop_names_list
[
e
]
=
[];
event_desc
[
e
]
=
conffile
[
parms
.
net
].
event_type
[
e
].
title
for
(
const
f
in
conffile
[
parms
.
net
].
event_type
[
e
].
field
)
{
// Add only numeric properties/variables
if
(
conffile
[
parms
.
net
].
event_type
[
e
].
field
[
f
].
type
==
"
number
"
)
{
prop_names_list
[
e
].
push
(
f
);
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
+
"
)
"
:
""
)
;
}
}
}
}
// Init select list for measurement types / datasets / event types
event_names
=
Object
.
keys
(
prop_names_list
);
make_prop_select
(
"
event_type
"
,
event_names
,
event_desc
);
// Select event type
if
(
parms
.
event
&&
(
event_names
.
indexOf
(
parms
.
event
)
>
-
1
))
{
// Reapply already selected
$
(
"
#event_type
"
).
val
(
parms
.
event
);
}
else
{
// Apply default event type if available
if
(
"
default_event_type
"
in
conffile
[
parms
.
net
]
)
{
$
(
"
#event_type
"
).
val
(
conffile
[
parms
.
net
].
default_event_type
);
}
parms
.
event
=
$
(
"
#event_type
"
).
val
()
}
// Clear list first
prop_names_list
=
{};
prop_
d
es
c
=
{};
event
_desc
=
{}
;
for
(
const
e
in
conffile
[
mvar
].
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
)
{
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
prop_
desc
[
f
]
=
title
+
(
unit
?
"
(
"
+
unit
+
"
)
"
:
""
)
;
// Init measurement variable select list
prop_
nam
es
=
prop_names_list
[
$
(
"
#event_type
"
).
val
()
];
make_prop_select
(
"
prop_select
"
,
prop_names
,
prop
_desc
)
;
// Select measurement variable
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
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
()
}
// Update period
if
(
parms
.
period
)
$
(
"
#period
"
).
val
(
parms
.
period
);
}
// sorting table
...
...
@@ -313,7 +343,7 @@ function show_map (network) {
});
$
(
window
).
on
(
"
resize
"
,
function
()
{
$
(
"
#mapid
"
).
height
(
$
(
window
).
height
()
-
40
0
);
$
(
"
#mapid
"
).
height
(
$
(
window
).
height
()
-
25
0
);
}).
trigger
(
"
resize
"
);
}
...
...
@@ -365,6 +395,7 @@ function update_url(parameter, value){
"
period=
"
+
$
(
"
#period
"
).
val
()
];
if
(
etype
===
"
jitter
"
&&
$
(
"
#stats_type
"
).
val
()
)
pars
.
push
(
"
stats=
"
+
$
(
"
#stats_type
"
).
val
()
);
if
(
parms
.
conffile
)
pars
.
push
(
"
conffile=
"
+
parms
.
conffile
);
// Add configfile to url if relevant
if
(
parameter
)
pars
.
push
(
parameter
+
"
=
"
+
value
);
url
=
urlBase
+
'
?
'
+
pars
.
join
(
'
&
'
);
...
...
@@ -413,6 +444,10 @@ function make_prop_select(id, names, desc){
option
.
text
=
text
;
selectList
.
appendChild
(
option
);
}
// Sort list alphabetically (from https://stackoverflow.com/questions/667010/sorting-dropdown-list-using-javascript/667198#667198)
$
(
"
#
"
+
id
).
html
(
$
(
"
#
"
+
id
+
"
option
"
).
sort
(
function
(
a
,
b
)
{
return
a
.
text
==
b
.
text
?
0
:
a
.
text
<
b
.
text
?
-
1
:
1
}))
}
...
...
@@ -703,17 +738,6 @@ function update_legend(title, threshes){
function
link_popup
(
link
){
var
dato
=
$
(
"
#datepicker
"
).
val
();
//if (parms.net === "dragonlab") dato = dato.replace(/-/g, "");
/* var html = `<head>
<script >
function onload(){
// some code for task
alert('task completed');
window.opener.document.functionToBeCalledFromChildWindow('my task is over you can proceed');
window.close();
}`;
html += " </head> <body onload='onload()'>' ";
*/
var
html
=
make_tooltip
(
link
.
from
+
'
to
'
+
link
.
to
,
link
);
var
to_adr
=
link
.
to
;
// aggregations don't have *_adr.
...
...
@@ -1620,7 +1644,7 @@ function report_summary(div_id){
new_tab
.
delegate
(
"
span.ui-icon-close
"
,
"
click
"
,
function
()
{
var
panelId
=
$
(
this
).
closest
(
"
li
"
).
remove
().
attr
(
"
aria-controls
"
);
$
(
"
#
"
+
panelId
).
remove
();
tabs
.
tabs
(
"
refresh
"
);
$
(
"
#
tabs
"
)
.
tabs
(
"
refresh
"
);
});
...
...
@@ -1852,11 +1876,15 @@ function hhmmss(d){
$
(
document
).
ready
(
function
(){
parms
=
get_parms
(
);
// OJW 2021-12-09 BEGIN CONFIG FILE LOAD
// Fetch config info and initialize page
$
.
getJSON
(
"
yaml-to-json.cgi?inputfile=mapconfig.yml
"
,
function
(
read_conffile
)
{
// Fetch config info and initialize page
var
conffilename
=
parms
.
conffile
if
(
!
conffilename
)
conffilename
=
'
mapconfig.yml
'
$
.
getJSON
(
"
yaml-to-json.cgi?inputfile=
"
+
conffilename
,
function
(
read_conffile
)
{
if
(
Object
.
keys
(
read_conffile
).
length
>
0
)
{
console
.
log
(
"
Config file non-empty:
"
+
read_conffile
.
msg
);
console
.
log
(
"
Config file
"
+
conffilename
+
"
non-empty:
"
+
read_conffile
.
msg
);
conffile
=
read_conffile
.
config
;
// Remove default measurement variants from select list
$
(
"
#network
"
).
empty
();
...
...
@@ -1864,6 +1892,10 @@ $(document).ready ( function(){
// Add option for measurement variant
$
(
"
#network
"
).
append
(
"
<option value=
"
+
mvar
+
"
>
"
+
conffile
[
mvar
].
title
+
"
</option>
"
);
}
// Sort list alphabetically (from https://stackoverflow.com/questions/667010/sorting-dropdown-list-using-javascript/667198#667198)
$
(
"
#network
"
).
html
(
$
(
"
#network option
"
).
sort
(
function
(
a
,
b
)
{
return
a
.
text
==
b
.
text
?
0
:
a
.
text
<
b
.
text
?
-
1
:
1
}))
//Select first measurement variant in list
$
(
"
#network option:eq(0)
"
).
prop
(
"
selected
"
,
true
);
// $("#network").selectmenu("refresh");
...
...
@@ -1872,22 +1904,14 @@ $(document).ready ( function(){
// OJW 2021-12-09 CONTINUES AT END OF "document ready"
parms
=
get_parms
(
);
update_props
(
parms
.
net
);
if
(
parms
.
net
){
$
(
"
#network
"
).
val
(
parms
.
net
);
}
else
{
parms
.
net
=
$
(
"
#network
"
).
val
();
}
event_names
=
Object
.
keys
(
prop_names_list
);
make_prop_select
(
"
event_type
"
,
event_names
,
event_desc
);
if
(
parms
.
event
)
$
(
"
#event_type
"
).
val
(
parms
.
event
);
if
(
parms
.
period
)
$
(
"
#period
"
).
val
(
parms
.
period
);
prop_names
=
prop_names_list
[
$
(
"
#event_type
"
).
val
()
];
make_prop_select
(
"
prop_select
"
,
prop_names
,
prop_desc
);
// Update properties according to selected measurement network variant
update_props
();
if
(
parms
.
palette
===
"
auto
"
){
colors
=
generate_colors
(
10
,
[
0.8
,
0.2
,
0.2
]);
// 5 colors in red with 50% green and blue
...
...
@@ -1998,7 +2022,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
);
...
...
@@ -2009,10 +2033,9 @@ $(document).ready ( function(){
// event_type parameter change
$
(
"
#event_type
"
).
change
(
function
(){
prop_names
=
prop_names_list
[
$
(
"
#event_type
"
).
val
()
];
parms
.
event
=
$
(
"
#event_type
"
).
val
()
update_props
();
//remove_links();
prop_names
=
prop_names_list
[
$
(
"
#event_type
"
).
val
()
];
make_prop_select
(
"
prop_select
"
,
prop_names
,
prop_desc
);
get_connections
();
update_url
();
$
(
"
#tabs
"
).
tabs
(
"
option
"
,
"
active
"
,
0
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment