Skip to content

Commit 9b14f13

Browse files
committed
update dataset choices #20
1 parent 2504ff6 commit 9b14f13

File tree

7 files changed

+201
-162
lines changed

7 files changed

+201
-162
lines changed

HiperView/css/main.css

-28
Original file line numberDiff line numberDiff line change
@@ -673,34 +673,6 @@ p.divider {
673673
margin-left: 1em !important;
674674
}
675675

676-
.cover {
677-
position: fixed;
678-
margin: 0;
679-
width:100%;
680-
height:100%;
681-
background: #485563; /* fallback for old browsers */
682-
background: -webkit-linear-gradient(to top, #29323cc4, #485563); /* Chrome 10-25, Safari 5.1-6 */
683-
background: linear-gradient(to top, #29323cc4, #485563); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
684-
z-index: 10;
685-
}
686-
687-
.light .cover {
688-
background: #f3f3f3; /* fallback for old browsers */
689-
background: -webkit-linear-gradient(to right, #f3f3f3c4, #ececec); /* Chrome 10-25, Safari 5.1-6 */
690-
background: linear-gradient(to right, #f3f3f3c4, #ececec); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
691-
}
692-
.cover .spinnerC {
693-
position: fixed;
694-
margin: 0;
695-
/* position: absolute; */
696-
top: 50%;
697-
left: 50%;
698-
transform: translate(-50%, -50%);
699-
}
700-
701-
.cover.hidden {
702-
display: none;
703-
}
704676

705677
#datasetsSelectTrigger img{
706678
width: 30px;

HiperView/css/theme.css

+29
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,33 @@
103103
}
104104
}
105105

106+
107+
.cover {
108+
position: fixed;
109+
margin: 0;
110+
width:100%;
111+
height:100%;
112+
background: #485563; /* fallback for old browsers */
113+
background: -webkit-linear-gradient(to top, #29323cc4, #485563); /* Chrome 10-25, Safari 5.1-6 */
114+
background: linear-gradient(to top, #29323cc4, #485563); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
115+
z-index: 10;
116+
}
117+
118+
.light .cover {
119+
background: #f3f3f3; /* fallback for old browsers */
120+
background: -webkit-linear-gradient(to right, #f3f3f3c4, #ececec); /* Chrome 10-25, Safari 5.1-6 */
121+
background: linear-gradient(to right, #f3f3f3c4, #ececec); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
122+
}
123+
.cover .spinnerC {
124+
position: fixed;
125+
margin: 0;
126+
/* position: absolute; */
127+
top: 50%;
128+
left: 50%;
129+
transform: translate(-50%, -50%);
130+
}
131+
132+
.cover.hidden {
133+
display: none;
134+
}
106135
/*

HiperView/myscripts/main.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1674,7 +1674,7 @@ $( document ).ready(function() {
16741674
drawsummary(i);
16751675
}
16761676
break;
1677-
}
1677+
}ta
16781678
});
16791679
d3.select('#datacom').on("change", function () {
16801680
d3.select('.cover').classed('hidden', false);

HiperView/myscripts/setting.js

+53
Original file line numberDiff line numberDiff line change
@@ -244,4 +244,57 @@ function processData_old(str, serviceName) {
244244
}
245245
return a;
246246
}
247+
}
248+
249+
function simulateResults2(hostname,iter, s){
250+
var newService;
251+
if (s == serviceList[0])
252+
newService = sampleS[hostname].arrTemperature[iter];
253+
else if (s == serviceList[1])
254+
newService = sampleS[hostname].arrCPU_load[iter];
255+
else if (s == serviceList[2])
256+
newService = sampleS[hostname].arrMemory_usage[iter];
257+
else if (s == serviceList[3])
258+
newService = sampleS[hostname].arrFans_health[iter];
259+
else if (s == serviceList[4]) {
260+
if (sampleS[hostname]["arrPower_usage"]== undefined && db!="influxdb") {
261+
var simisval = handlemissingdata(hostname,iter);
262+
sampleS[hostname]["arrPower_usage"] = [simisval];
263+
}else if (sampleS[hostname]["arrPower_usage"][iter]== undefined && db!="influxdb"){
264+
var simisval = handlemissingdata(hostname,iter);
265+
sampleS[hostname]["arrPower_usage"][iter] = simisval;
266+
}
267+
newService = sampleS[hostname]["arrPower_usage"][iter];
268+
}
269+
if (newService === undefined){
270+
newService ={}
271+
newService.result = {};
272+
newService.result.query_time = query_time;
273+
newService.data = {};
274+
newService.data.service={};
275+
newService.data.service.host_name = hostname;
276+
newService.data.service.plugin_output = undefined;
277+
}else {
278+
if (db == "influxdb")
279+
try {
280+
newService.result.query_time = d3.timeParse("%Y-%m-%dT%H:%M:%S.%LZ")(newService.result.query_time).getTime();
281+
}catch(e){
282+
283+
}
284+
}
285+
return newService;
286+
}
287+
288+
function handlemissingdata(hostname,iter){
289+
var simisval = jQuery.extend(true, {}, sampleS[hostname]["arrTemperature"][iter]);
290+
var simval = processData(simisval.data.service.plugin_output, serviceList[0]);
291+
// simval = (simval[0]+simval[1])/2;
292+
simval = (simval[0]+simval[1]+20);
293+
var tempscale = d3.scaleLinear().domain([thresholds[0][0],thresholds[0][1]]).range([thresholds[4][0],thresholds[4][1]]);
294+
if (simval!==undefinedValue && !isNaN(simval) )
295+
//simisval.data.service.plugin_output = "OK - The average power consumed in the last one minute = "+Math.round(tempscale(simval)*3.2)+" W";
296+
simisval.data.service.plugin_output = "OK - The average power consumed in the last one minute = "+Math.floor(simval*3.2)+" W";
297+
else
298+
simisval.data.service.plugin_output = "UNKNOWN";
299+
return simisval;
247300
}

ParallelCoordinates/index.html

+14-5
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,22 @@
1515

1616

1717
<link rel="stylesheet" type="text/css" href="parallel.css" />
18+
<link rel="stylesheet" type="text/css" href="../HiperView/css/theme.css" />
1819
<link rel="stylesheet" type="text/css" href="theme.css" />
1920
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
2021
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
2122
<script src="src/lib/d3.v5.min.js"></script>
2223
<script src="https://d3js.org/d3-selection-multi.v1.min.js"></script>
2324
<script src="src/lib/underscore-min.js"></script>
24-
</head>
25-
<body>
25+
<script src='https://cdnjs.cloudflare.com/ajax/libs/spin.js/2.0.1/spin.min.js'></script> <!-- Spinner when loading -->
2626

27+
</head>
28+
<body text="black" id="mainBody">
29+
<div class="cover">
30+
<h5 class="spinnerC center" style="top: 60%;" >loading data...</h5>
31+
<div class="spinnerC center" id="loadingSpinner" >
32+
</div>
33+
</div>
2734
<nav class="pushpin-demo-nav" data-target="blue">
2835

2936
<div class="nav-wrapper" id="header">
@@ -78,8 +85,9 @@ <h5></h5>
7885
<option value="serviceWed04Oct" >04 Oct 2018</option>
7986
<option value="service15Oct">15 Oct 2018</option>
8087
<option value="service17Oct">17 Oct 2018</option>
81-
<option value="influxdb">Real-time Influxdb</option>
82-
<option value="nagios">Real-time Nagios</option>
88+
<option value="influxdbThus21Mar_1520">21 Mar 2019</option>
89+
<!--<option value="influxdb">Real-time Influxdb</option>-->
90+
<!--<option value="nagios">Real-time Nagios</option>-->
8391
</select>
8492
</div>
8593
<table class="table table-striped table-hover row s12" id = "axisSetting">
@@ -193,7 +201,8 @@ <h5>Credits &amp; License</h5>
193201

194202
</body>
195203
<!--data load-->
196-
<script src="src/data/serviceWed26Sep.js"></script>
204+
<script src="../HiperView/myscripts/setting.js"></script>
205+
<!--<script src="src/data/serviceWed26Sep.js"></script>-->
197206
<!--<script src="http://mbostock.github.com/d3/d3.v2.js"></script>-->
198207
<script src="src/js/ulti.js"></script>
199208
<script src="src/js/readData.js"></script>

ParallelCoordinates/src/js/main.js

+102-8
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,26 @@ function Loadtostore() {
5656
checkConf('serviceListattr');
5757
checkConf('serviceListattrnest');
5858
}
59+
let processData = processData_old;
5960

6061
//***********************
6162
Loadtostore();
6263
//***********************
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+
6379
var undefinedValue = undefined;
6480
var undefinedColor = "#666";
6581
var colorscale = d3.scaleOrdinal(d3.schemeCategory10);
@@ -70,7 +86,7 @@ let legendw= 80;
7086
let legendh= 20;
7187
let barw = 300;
7288
let barScale = d3.scaleLinear();
73-
89+
let db = 'nagios';
7490
const collator = new Intl.Collator(undefined, {numeric: true, sensitivity: 'base'});
7591
Array.prototype.naturalSort= function(_){
7692
if (arguments.length) {
@@ -125,7 +141,6 @@ $( document ).ready(function() {
125141
}).on('change',function (d){
126142
const pdata = d3.select(this.parentElement.parentElement).datum();
127143
d.value = this.checked;
128-
console.log(pdata.arr)
129144
if(this.checked) {
130145
add_axis(pdata.arr, g);
131146
d3.select(this.parentElement.parentElement).classed('disable', false);
@@ -221,8 +236,74 @@ $( document ).ready(function() {
221236
// _.bind(dragged,chosenAxis.node(),chosenAxis.datum(),'table')();
222237
// }));
223238
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();
225294
});
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+
226307
function getBrush(d) {
227308
return d3.brushY(yscale[d])
228309
.extent([[-10, 0], [10, h]])
@@ -287,7 +368,6 @@ function dragend(d) {
287368
var extent = d3.brushSelection(this);
288369
if (extent)
289370
extent = extent.map(yscale[d].invert).sort((a,b)=>a-b);
290-
console.log(extent)
291371
}
292372

293373
// remove axis if dragged all the way left
@@ -444,6 +524,22 @@ function init() {
444524
brush();
445525
}
446526

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+
}
447543
function setColorsAndThresholds(s) {
448544
for (var i=0; i<serviceList.length;i++){
449545
if (s == serviceList[i]){
@@ -660,8 +756,6 @@ function highlight(d) {
660756
const val = d[selectedService];
661757
const gourpBeloing = orderLegend.find(dv=>val>=dv.minvalue && val<dv.value)||{text:undefined};
662758

663-
console.log(val);
664-
console.log(gourpBeloing);
665759
d3.select("#colorContinuos").selectAll(".row").style("opacity", function(p) { return (gourpBeloing.text === p) ? null : "0.3" });
666760
}else {
667761
d3.select("#legend").selectAll(".row").style("opacity", function (p) {
@@ -696,7 +790,8 @@ function invert_axis(d) {
696790
// Get extents of brush along each active selection axis (the Y axes)
697791
extent = d3.brushSelection(this).map(yscale[d].invert);
698792
});
699-
console.log(extent)
793+
794+
700795
if (yscale[d].inverted == true) {
701796
yscale[d].range([h, 0]);
702797
d3.selectAll('.label')
@@ -743,7 +838,6 @@ function path(d, ctx, color) {
743838
var x = xscale(p),
744839
y = yscale[p](d[p]);
745840
if (y===undefined) {
746-
console.log(p)
747841
if (valid) {
748842
ctx.stroke();
749843
ctx.beginPath();

0 commit comments

Comments
 (0)