Developing lightweight computation at the DSG edge

Commit 6c350832 authored by Roger Pueyo Centelles's avatar Roger Pueyo Centelles
Browse files

[assign-view] Get rid of hardcoded values


Signed-off-by: Roger Pueyo Centelles's avatarRoger Pueyo Centelles <rpueyo@ac.upc.edu>
parent 7c81ec6a
......@@ -4,14 +4,16 @@
<script src="/tmp/out.json"></script>
<script>
// data={"devices":["35578","35580","41236","52800","53410","55625","58266","66287","67954","69514","74780","74943","75036","75038","75651","92844"],"monitors":["1","2","3","444"],"assignations":[{"device":"35578","monitors":["2"]},{"device":"35580","monitors":["1"]},{"device":"41236","monitors":["1"]},{"device":"52800","monitors":["1","2"]},{"device":"53410","monitors":["2"]},{"device":"55625","monitors":["1","2"]},{"device":"58266","monitors":["2"]},{"device":"66287","monitors":null},{"device":"67954","monitors":["1","2"]},{"device":"69514","monitors":["1","2"]},{"device":"74780","monitors":["1"]},{"device":"74943","monitors":["1","2"]},{"device":"75036","monitors":["1","2"]},{"device":"75038","monitors":null},{"device":"75651","monitors":["2"]},{"device":"92844","monitors":["1"]}]}
setTimeout(function(){
window.location.reload(true);
}, 2000);
// data={"devices":["35578","35580","41236","52800","53410","55625","58266","66287","67954","69514","74780","74943","75036","75038","75651","92844"],"monitors":["1","2","3","444"],"assignations":[{"device":"35578","monitors":["2"]},{"device":"35580","monitors":["1"]},{"device":"41236","monitors":["1"]},{"device":"52800","monitors":["1","2"]},{"device":"53410","monitors":["2"]},{"device":"55625","monitors":["1","2"]},{"device":"58266","monitors":["2"]},{"device":"66287","monitors":null},{"device":"67954","monitors":["1","2"]},{"device":"69514","monitors":["1","2"]},{"device":"74780","monitors":["1"]},{"device":"74943","monitors":["1","2"]},{"device":"75036","monitors":["1","2"]},{"device":"75038","monitors":null},{"device":"75651","monitors":["2"]},{"device":"92844","monitors":["1"]}]}
//
// dsata={"devices":["35578","35580","41236","52800","53410","55625","58266","66287","67954","69514","74780","74943","75036","75038","75651","92844"],"monitors":["1","2"],"assignations":[{"device":"35578","monitors":["2"]},{"device":"35580","monitors":["1"]},{"device":"92844","monitors":["1"]}]}
function posItemInArray(theItem, theArray) {
console.log("theItem " + theItem)
console.log("theArray " + theArray)
if (theItem !== null && theArray !== null && theArray.length > 0) {
for (k=0; k<theArray.length; k++) {
if (theItem == theArray[k]) {
......@@ -44,7 +46,7 @@ var monX = wwidth-rwidth
var fontsize ="12px"
var dheight = rdist*data.devices.length
var dheight = rdist*Math.max(data.devices.length, data.monitors.length)
var drawing = SVG("assign").size(wwidth,dheight)
var devsRects = new Array()
......@@ -81,7 +83,7 @@ if (data.monitors !== null ) {
'stroke-width':"2px"
})
rect.x(monX)
rect.y((dheight/data.monitors.length)*i+rdist*i/2)
rect.y((dheight/Math.max(1,data.monitors.length+1))*i+rdist*i/2)
monsRects.push(rect)
var text = drawing.text(data.monitors[i]).font({
......@@ -90,7 +92,7 @@ if (data.monitors !== null ) {
})
text.x(monX+rwidth/2)
text.y((dheight/data.monitors.length)*i+rdist*i/2+rdist/4)
text.y((dheight/Math.max(1,data.monitors.length+1))*i+rdist*i/2+rdist/4)
monsTexts.push(text)
}
}
......@@ -101,14 +103,11 @@ if (data.assignations !== null) {
for (j = 0; j < data.assignations[i].monitors.length; j++) {
var devPos = posItemInArray(data.assignations[i].device, data.devices)
var monPos = posItemInArray(data.assignations[i].monitors[j], data.monitors)
var line = drawing.line(rwidth, rdist/2+devPos*rdist, monX, (dheight/Math.max(1,data.monitors.length))*monPos+rdist*monPos/2+rdist/2).stroke({ width: 1.5 })
var line = drawing.line(rwidth, rdist/2+devPos*rdist, monX, (dheight/Math.max(1,data.monitors.length+1))*monPos+rdist*monPos/2+rdist/2 ).stroke({ width: 1.5 })
assignsLines.push(line)
}
}
}
}
setTimeout(function(){
window.location.reload(true);
}, 2000);
</script>
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