1
1
<!DOCTYPE html>
2
2
< html >
3
3
< head >
4
+ < meta name ="viewport " content ="width=device-width, initial-scale=1 ">
4
5
< title > Js connection check GRAPHS</ title >
5
6
< script src ="https://cdn.jsdelivr.net/npm/vue/dist/vue.js "> </ script >
6
7
< script src ="https://unpkg.com/fusioncharts@3.15.0-sr.1/fusioncharts.js "> </ script >
11
12
< style type ="text/css ">
12
13
.source_wrapper {
13
14
display : flex;
14
- flex-flow : row wrap;
15
+ flex-wrap : wrap;
15
16
}
16
17
.source_box {
17
- border : 1px solid black;
18
- width : 45% ;
19
- margin : 1% ;
20
- padding : 1% ;
18
+ flex : 0 0 33% ;
19
+ }
20
+ .source_box_content {
21
+ border : 1px solid gray;
22
+ padding : 10px ;
23
+ margin : 10px ;
24
+ }
25
+ .text-color-green {color : green;}
26
+ .text-color-red {color : red;}
27
+ @media (max-width : 1024px ) {
28
+ .source_box {
29
+ flex : 0 0 50% ;
30
+ }
31
+ }
32
+ @media (max-width : 720px ) {
33
+ .source_box {
34
+ flex : 0 0 100% ;
35
+ }
21
36
}
22
37
</ style >
23
38
</ head >
24
39
< body >
25
40
< div id ="app ">
26
41
< div class ="source_wrapper ">
27
42
< div v-for ="(source, index) in sources " v-bind:key ="index " class ="source_box ">
28
- < h2 >
29
- Source: {{ source.name }} < small > {{ source.url }}</ small >
30
- < button @click ="delete_source(index) "> Delete source</ button >
31
- </ h2 >
32
- < h3 v-if ="source.data ">
33
- Connection: {{ source.data.currentStatus ? 'true' : 'false' }} ||
34
- Last disconnect: {{ source.data.lastTs }} sec
35
- < span v-if ="source.data.updatedDiff "> || Last updated: {{ source.data.updatedDiff }} sec</ span >
36
- </ h3 >
37
- < fusioncharts v-if ="source.data && source.data.chart " type ="column2d " width ="100% " height ="350 " :dataSource ="source.data.chart "> </ fusioncharts >
43
+ < div class ="source_box_content ">
44
+ < h2 >
45
+ Source: {{ source.name }} < small > {{ source.url }}</ small >
46
+ < button @click ="delete_source(index) "> Delete source</ button >
47
+ </ h2 >
48
+ < h4 v-if ="source.data ">
49
+ < span :class ="[source.data.currentStatus ? 'text-color-green' : 'text-color-red'] "> {{ source.data.currentStatus ? 'Connected' : 'Disconnected'}}</ span > |
50
+ Last disconnect: {{ diffFormatted( source.data.lastTs ) }}
51
+ < span v-if ="source.data.updatedDiff "> | Last updated: {{ diffFormatted( source.data.updatedDiff ) }}</ span >
52
+ </ h4 >
53
+ < fusioncharts v-if ="source.data && source.data.chart " type ="column2d " width ="100% " height ="350 " :dataSource ="source.data.chart "> </ fusioncharts >
54
+ </ div >
38
55
</ div >
39
56
</ div >
40
57
@@ -86,11 +103,7 @@ <h3 v-if="source.data">
86
103
87
104
let chart = [ ]
88
105
data . archive . forEach ( ( item ) => {
89
- let diff = data . serverTS - item . start
90
- if ( diff > 60 * 60 * 24 ) diff = ( diff / ( 60 * 60 * 24 ) ) . toFixed ( 1 ) + 'd'
91
- else if ( diff > 60 * 60 ) diff = ( diff / ( 60 * 60 ) ) . toFixed ( 1 ) + 'h'
92
- else if ( diff > 60 ) diff = ( diff / 60 ) . toFixed ( 1 ) + 'm'
93
- else diff = diff + 's'
106
+ let diff = this . diffFormatted ( data . serverTS - item . start )
94
107
95
108
chart . push ( {
96
109
"label" : diff ,
@@ -115,6 +128,12 @@ <h3 v-if="source.data">
115
128
116
129
this . save_state ( )
117
130
} ,
131
+ diffFormatted ( diff ) {
132
+ if ( diff > 60 * 60 * 24 ) return ( diff / ( 60 * 60 * 24 ) ) . toFixed ( 1 ) + 'd'
133
+ else if ( diff > 60 * 60 ) return ( diff / ( 60 * 60 ) ) . toFixed ( 1 ) + 'h'
134
+ else if ( diff > 60 ) return ( diff / 60 ) . toFixed ( 1 ) + 'm'
135
+ else return diff + 's'
136
+ } ,
118
137
add_source ( ) {
119
138
if ( ! this . form . source || this . form . source . length == 0 ) return alert ( 'Enter source' )
120
139
this . sources . push ( { url : this . form . source , name : this . form . name , data : null } )
0 commit comments