Developing lightweight computation at the DSG edge

Commit c0905f79 authored by Roger Pueyo Centelles's avatar Roger Pueyo Centelles
Browse files

[assign-view] De-hardcode variables



Adjust the graph size to the window size and other automations.
Signed-off-by: Roger Pueyo Centelles's avatarRoger Pueyo Centelles <rpueyo@ac.upc.edu>
parent 36f68768
......@@ -22,49 +22,66 @@ function posItemInArray(theItem, theArray) {
return -1
}
var drawing = SVG("assign").size(1000,1000)
var wwidth = window.innerWidth -15;
if (wwidth < 400) {
wwidth = 400
}
var rwidth = 150
var rheight = 32
var rspace = 3
var rdist = rheight+rspace
var monX = wwidth-rwidth
var wheight = rdist*data.devices.length
var drawing = SVG("assign").size(wwidth,wheight)
var devsRects = new Array()
var devsTexts = new Array()
var monsRects = new Array()
var monsTexts = new Array()
var assignsLines = new Array()
if (data.devices !== null ) {
for (i = 0; i < data.devices.length; i++) {
var rect = drawing.rect(200, 45).attr({
var rect = drawing.rect(rwidth, rheight).attr({
'fill':"#e6ffe6",
'stroke':"gray",
'stroke-width':"2px"
})
rect.y(50*i)
rect.y(rdist*i)
devsRects.push(rect)
var text = drawing.text(data.devices[i]).font({
'anchor':"middle"
})
text.x(100)
text.y(10+50*i)
text.x(rwidth/2)
text.y(rdist/4+rdist*i)
devsTexts.push(text)
}
}
if (data.monitors !== null ) {
for (i = 0; i < data.monitors.length; i++) {
var rect = drawing.rect(200, 45).attr({
var rect = drawing.rect(rwidth, rheight).attr({
'fill':"#e6f2ff",
'stroke':"gray",
'stroke-width':"2px"
})
rect.x(500)
rect.y(50*i)
rect.x(monX)
rect.y(rdist*i)
monsRects.push(rect)
var text = drawing.text(data.monitors[i]).font({
'anchor':"middle"
})
text.x(600)
text.y(10+50*i)
text.x(monX+rwidth/2)
text.y(10+rdist*i)
monsTexts.push(text)
}
}
......@@ -75,24 +92,14 @@ 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(200, 25+devPos*50, 500, 25+monPos*50).stroke({ width: 1 })
var line = drawing.line(rwidth, rdist/2+devPos*rdist, monX, 25+monPos*50).stroke({ width: 1.5 })
assignsLines.push(line)
}
}
}
}
// console.log(i)
// if (data.assignations[i].monitors !== null && data.assignations[i].monitors.length > 0) {
// for (j = 0; j < data.assignations[i].monitors.length; j++) {
// console.log("BBBBBBBB")
// console.log(data.assignations[i].monitors[j])
// var devPos = posItemInArray(data.assignations[i].device, data.devices)
// //var line = drawing.line(200, 25+devPos*50, 500, 25+monPos*50).stroke({ width: 1 })
// }
// }
//
//
// // 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