@@ -56,10 +56,26 @@ function Loadtostore() {
56
56
checkConf ( 'serviceListattr' ) ;
57
57
checkConf ( 'serviceListattrnest' ) ;
58
58
}
59
+ let processData = processData_old ;
59
60
60
61
//***********************
61
62
Loadtostore ( ) ;
62
63
//***********************
64
+ // START: loader spinner settings ****************************
65
+ var opts = {
66
+ lines : 25 , // The number of lines to draw
67
+ length : 15 , // The length of each line
68
+ width : 5 , // The line thickness
69
+ radius : 25 , // The radius of the inner circle
70
+ color : '#f00' , // #rgb or #rrggbb or array of colors
71
+ speed : 2 , // Rounds per second
72
+ trail : 50 , // Afterglow percentage
73
+ className : 'spinner' , // The CSS class to assign to the spinner
74
+ } ;
75
+ var target = document . getElementById ( 'loadingSpinner' ) ;
76
+ var spinner ;
77
+ // END: loader spinner settings ****************************
78
+
63
79
var undefinedValue = undefined ;
64
80
var undefinedColor = "#666" ;
65
81
var colorscale = d3 . scaleOrdinal ( d3 . schemeCategory10 ) ;
@@ -70,7 +86,7 @@ let legendw= 80;
70
86
let legendh = 20 ;
71
87
let barw = 300 ;
72
88
let barScale = d3 . scaleLinear ( ) ;
73
-
89
+ let db = 'nagios' ;
74
90
const collator = new Intl . Collator ( undefined , { numeric : true , sensitivity : 'base' } ) ;
75
91
Array . prototype . naturalSort = function ( _ ) {
76
92
if ( arguments . length ) {
@@ -125,7 +141,6 @@ $( document ).ready(function() {
125
141
} ) . on ( 'change' , function ( d ) {
126
142
const pdata = d3 . select ( this . parentElement . parentElement ) . datum ( ) ;
127
143
d . value = this . checked ;
128
- console . log ( pdata . arr )
129
144
if ( this . checked ) {
130
145
add_axis ( pdata . arr , g ) ;
131
146
d3 . select ( this . parentElement . parentElement ) . classed ( 'disable' , false ) ;
@@ -221,8 +236,74 @@ $( document ).ready(function() {
221
236
// _.bind(dragged,chosenAxis.node(),chosenAxis.datum(),'table')();
222
237
// }));
223
238
d3 . select ( "#DarkTheme" ) . on ( "click" , switchTheme ) ;
224
- init ( ) ;
239
+
240
+ // data
241
+ d3 . select ( '#datacom' ) . on ( "change" , function ( ) {
242
+ d3 . select ( '.cover' ) . classed ( 'hidden' , false ) ;
243
+ spinner . spin ( target ) ;
244
+ const choice = this . value ;
245
+ const choicetext = d3 . select ( '#datacom' ) . node ( ) . selectedOptions [ 0 ] . text ;
246
+ setTimeout ( ( ) => {
247
+ if ( choice !== "nagios" && choice !== "influxdb" )
248
+ d3 . json ( "../HiperView/data/" + choice + ".json" ) . then ( function ( data ) {
249
+ sampleS = data ;
250
+ if ( choice . includes ( 'influxdb' ) ) {
251
+ // processResult = processResult_influxdb;
252
+ db = "influxdb" ;
253
+ realTimesetting ( false , "influxdb" ) ;
254
+ } else {
255
+ // processResult = processResult_old;
256
+ realTimesetting ( false ) ;
257
+ }
258
+ d3 . select ( ".currentDate" )
259
+ . text ( "" + d3 . timeParse ( "%d %b %Y" ) ( choicetext ) . toDateString ( ) ) ;
260
+ resetRequest ( ) ;
261
+ d3 . select ( '.cover' ) . classed ( 'hidden' , true ) ;
262
+ spinner . stop ( ) ;
263
+ } ) ;
264
+ else {
265
+ realTimesetting ( true , choice ) ;
266
+ db = choice ;
267
+ requestService = eval ( 'requestService' + choice ) ;
268
+ processResult = eval ( 'processResult_' + choice ) ;
269
+ d3 . select ( '.cover' ) . classed ( 'hidden' , true ) ;
270
+ spinner . stop ( ) ;
271
+ }
272
+ } , 0 ) ;
273
+ } ) ;
274
+ spinner = new Spinner ( opts ) . spin ( target ) ;
275
+
276
+
277
+ setTimeout ( ( ) => {
278
+ d3 . json ( "../HiperView/data/" + d3 . select ( '#datacom' ) . node ( ) . value + ".json" ) . then ( function ( data ) {
279
+ d3 . select ( ".cover" ) . select ( 'h5' ) . text ( 'drawLegend...' ) ;
280
+ d3 . select ( ".currentDate" )
281
+ . text ( "" + d3 . timeParse ( "%d %b %Y" ) ( d3 . select ( '#datacom' ) . select ( '[selected="selected"]' ) . text ( ) ) . toDateString ( ) ) ;
282
+ // drawLegend(initialService, arrThresholds, arrColor, dif);
283
+ sampleS = data ;
284
+ init ( ) ;
285
+ d3 . select ( ".cover" ) . select ( 'h5' ) . text ( 'loading data...' ) ;
286
+ // addDatasetsOptions(); // Add these dataset to the select dropdown, at the end of this files
287
+ d3 . select ( '.cover' ) . classed ( 'hidden' , true ) ;
288
+ spinner . stop ( ) ;
289
+ } ) ;
290
+ } , 0 ) ;
291
+ // Spinner Stop ********************************************************************
292
+
293
+ // init();
225
294
} ) ;
295
+
296
+ function realTimesetting ( option , db ) {
297
+ isRealtime = option ;
298
+ // getDataWorker.postMessage({action:'isRealtime',value:option,db: db});
299
+ if ( option ) {
300
+ processData = eval ( 'processData_' + db ) ;
301
+ } else {
302
+ processData = db ?eval ( 'processData_' + db ) :processData_old ;
303
+ }
304
+ resetRequest ( ) ;
305
+ }
306
+
226
307
function getBrush ( d ) {
227
308
return d3 . brushY ( yscale [ d ] )
228
309
. extent ( [ [ - 10 , 0 ] , [ 10 , h ] ] )
@@ -287,7 +368,6 @@ function dragend(d) {
287
368
var extent = d3 . brushSelection ( this ) ;
288
369
if ( extent )
289
370
extent = extent . map ( yscale [ d ] . invert ) . sort ( ( a , b ) => a - b ) ;
290
- console . log ( extent )
291
371
}
292
372
293
373
// remove axis if dragged all the way left
@@ -444,6 +524,22 @@ function init() {
444
524
brush ( ) ;
445
525
}
446
526
527
+ function resetRequest ( ) {
528
+ // Convert quantitative scales to floats
529
+ data = object2DataPrallel ( readData ( ) ) ;
530
+ d3 . keys ( data [ 0 ] ) . filter ( function ( k ) {
531
+ return ( ( ( _ . isDate ( data [ 0 ] [ k ] ) ) && ( yscale [ k ] = d3 . scaleTime ( )
532
+ . domain ( d3 . extent ( data , function ( d ) {
533
+ return d [ k ] ;
534
+ } ) )
535
+ . range ( [ h , 0 ] ) ) || ( _ . isNumber ( data [ 0 ] [ k ] ) ) && ( yscale [ k ] = d3 . scaleLinear ( )
536
+ . domain ( d3 . extent ( data , function ( d ) {
537
+ return + d [ k ] ;
538
+ } ) )
539
+ . range ( [ h , 0 ] ) ) ) ) ;
540
+ } ) ;
541
+ brush ( ) ;
542
+ }
447
543
function setColorsAndThresholds ( s ) {
448
544
for ( var i = 0 ; i < serviceList . length ; i ++ ) {
449
545
if ( s == serviceList [ i ] ) {
@@ -660,8 +756,6 @@ function highlight(d) {
660
756
const val = d [ selectedService ] ;
661
757
const gourpBeloing = orderLegend . find ( dv => val >= dv . minvalue && val < dv . value ) || { text :undefined } ;
662
758
663
- console . log ( val ) ;
664
- console . log ( gourpBeloing ) ;
665
759
d3 . select ( "#colorContinuos" ) . selectAll ( ".row" ) . style ( "opacity" , function ( p ) { return ( gourpBeloing . text === p ) ? null : "0.3" } ) ;
666
760
} else {
667
761
d3 . select ( "#legend" ) . selectAll ( ".row" ) . style ( "opacity" , function ( p ) {
@@ -696,7 +790,8 @@ function invert_axis(d) {
696
790
// Get extents of brush along each active selection axis (the Y axes)
697
791
extent = d3 . brushSelection ( this ) . map ( yscale [ d ] . invert ) ;
698
792
} ) ;
699
- console . log ( extent )
793
+
794
+
700
795
if ( yscale [ d ] . inverted == true ) {
701
796
yscale [ d ] . range ( [ h , 0 ] ) ;
702
797
d3 . selectAll ( '.label' )
@@ -743,7 +838,6 @@ function path(d, ctx, color) {
743
838
var x = xscale ( p ) ,
744
839
y = yscale [ p ] ( d [ p ] ) ;
745
840
if ( y === undefined ) {
746
- console . log ( p )
747
841
if ( valid ) {
748
842
ctx . stroke ( ) ;
749
843
ctx . beginPath ( ) ;
0 commit comments