Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V1.3.3 #193

Merged
merged 12 commits into from
Feb 12, 2019
2 changes: 1 addition & 1 deletion module.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name" : "Dashboard",
"version" : "1.3.2"
"version" : "1.3.3"
}
60 changes: 45 additions & 15 deletions widget/battery/battery_render.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,22 @@ function battery_widgetlist(){
[0, _Tr("Without colour gradients")]
];

addOption(widgets["battery"], "feedid", "feedid", _Tr("Feed"), _Tr("Feed value"), []);
addOption(widgets["battery"], "battery_title", "value", _Tr("Battery title"), _Tr("Battery title"), []);
addOption(widgets["battery"], "max", "value", _Tr("Max value"), _Tr("Max value to show"), []);
addOption(widgets["battery"], "min", "value", _Tr("Min value"), _Tr("Min value to show"), []); //TT
addOption(widgets["battery"], "scale", "value", _Tr("Scale"), _Tr("Value is multiplied by scale before display"), []);
addOption(widgets["battery"], "units", "dropbox_other", _Tr("Units"), _Tr("Units to show"), _SI);
addOption(widgets["battery"], "unitend", "dropbox", _Tr("Unit position"), _Tr("Where should the unit be shown"), unitEndOptions);
addOption(widgets["battery"], "decimals", "dropbox", _Tr("Decimals"), _Tr("Decimals to show"), decimalsDropBoxOptions);
addOption(widgets["battery"], "offset", "value", _Tr("Offset"), _Tr("Static offset. Subtracted from value before computing"), []);
addOption(widgets["battery"], "colour", "colour_picker", _Tr("Colour label"), _Tr("Color of the label"), []);
addOption(widgets["battery"], "font", "dropbox", _Tr("Font"), _Tr("Label font"), fontoptions);
addOption(widgets["battery"], "fstyle", "dropbox", _Tr("Font style"), _Tr("Font style used for display"), fstyleoptions);
addOption(widgets["battery"], "fweight", "dropbox", _Tr("Font weight"), _Tr("Font weight used for display"), fweightoptions);
addOption(widgets["battery"], "battery_style", "dropbox", _Tr("Style"), _Tr("Display style"), StyleOptions);
addOption(widgets["battery"], "feedid", "feedid", _Tr("Feed"), _Tr("Feed value"), []);
addOption(widgets["battery"], "battery_title", "value", _Tr("Battery title"), _Tr("Battery title"), []);
addOption(widgets["battery"], "max", "value", _Tr("Max value"), _Tr("Max value to show"), []);
addOption(widgets["battery"], "min", "value", _Tr("Min value"), _Tr("Min value to show"), []); //TT
addOption(widgets["battery"], "scale", "value", _Tr("Scale"), _Tr("Value is multiplied by scale before display"), []);
addOption(widgets["battery"], "units", "dropbox_other", _Tr("Units"), _Tr("Units to show"), _SI);
addOption(widgets["battery"], "unitend", "dropbox", _Tr("Unit position"), _Tr("Where should the unit be shown"), unitEndOptions);
addOption(widgets["battery"], "decimals", "dropbox", _Tr("Decimals"), _Tr("Decimals to show"), decimalsDropBoxOptions);
addOption(widgets["battery"], "offset", "value", _Tr("Offset"), _Tr("Static offset. Subtracted from value before computing"), []);
addOption(widgets["battery"], "colour", "colour_picker", _Tr("Colour label"), _Tr("Color of the label"), []);
addOption(widgets["battery"], "font", "dropbox", _Tr("Font"), _Tr("Label font"), fontoptions);
addOption(widgets["battery"], "fstyle", "dropbox", _Tr("Font style"), _Tr("Font style used for display"), fstyleoptions);
addOption(widgets["battery"], "fweight", "dropbox", _Tr("Font weight"), _Tr("Font weight used for display"), fweightoptions);
addOption(widgets["battery"], "battery_style", "dropbox", _Tr("Style"), _Tr("Display style"), StyleOptions);
addOption(widgets["battery"], "timeout", "value", _Tr("Timeout"), _Tr("Timeout without feed update in seconds (empty is never)"), []);
addOption(widgets["battery"], "errormessagedisplayed", "value", _Tr("Error Message"), _Tr("Error message displayed when timeout is reached"), []);

return widgets;
}
Expand All @@ -103,12 +105,31 @@ function battery_init(){

function battery_draw(){
$(".battery").each(function(index) {
var errorMessage = $(this).attr("errormessagedisplayed");
if (errorMessage === "" || errorMessage === undefined){ //Error Message parameter is empty
errorMessage = "TO Error";
}
var errorTimeout = $(this).attr("timeout");
if (errorTimeout === "" || errorTimeout === undefined){ //Timeout parameter is empty
errorTimeout = 0;
}

var errorCode = "0";

var feedid = $(this).attr("feedid");
if (assocfeed[feedid]!=undefined) feedid = assocfeed[feedid]; // convert tag:name to feedid
if (associd[feedid] === undefined) { console.log("Review config for feed id of " + $(this).attr("class")); return; }
var val = curve_value(feedid,dialrate).toFixed(3);

if (errorTimeout !== 0)
{
if (((new Date()).getTime() / 1000 - offsetofTime - (associd[feedid]["time"] * 1)) > errorTimeout)
{
errorCode = "1";
}
}
// ONLY UPDATE ON CHANGE
if (val != (associd[feedid]["value"] * 1).toFixed(3) || redraw == 1)
if (val != (associd[feedid]["value"] * 1).toFixed(3) || redraw == 1 || errorTimeout != 0)
{
var id = "can-"+$(this).attr("id");
var scale = 1*$(this).attr("scale") || 1;
Expand Down Expand Up @@ -208,6 +229,7 @@ function battery_draw(){


var red_val = 255 - green_val;
if (errorCode !== "1"){
if (battery_style ==="1"){
var linearGradient1 = context.createLinearGradient(start_x + line_width*2 + margin,
start_y + cap_height + line_width*2 + margin,
Expand All @@ -225,6 +247,7 @@ function battery_draw(){
linearGradient1.addColorStop(0, "rgb("+red_val+", "+green_val+", 0)");
linearGradient1.addColorStop(1, "rgb("+red_val+","+green_val+", 0)");
}
}
for(var i=1;i <= last_block; i++)
{
var y_pos = start_y + block_start_y - i*(block_height + margin);
Expand All @@ -235,6 +258,10 @@ function battery_draw(){

var size = ((battery_width<battery_height)?battery_width:battery_height)/2;
var unitsandval = raw_value + units;
if(errorCode == "1")
{
unitsandval = errorMessage;
}
var valsize;
if (unitsandval.length >4){ valsize = (size / (unitsandval.length+2)) * 5.5;}
else {valsize = (size / 6) * 5.5;}
Expand All @@ -244,8 +271,11 @@ function battery_draw(){
context.fillStyle = color;
context.textAlign = "center";
context.font = (fontstyle+ " "+ fontweight+ " "+(valsize*0.5)+"px "+ fontname);
if (errorCode === "1"){context.fillText(errorMessage, start_x + battery_width/2, start_y + battery_height*0.6);}
else{
if (unitend ==="0"){context.fillText(raw_value + units, start_x + battery_width/2, start_y + battery_height*0.6);}
if (unitend ==="1"){context.fillText(units + raw_value, start_x + battery_width/2, start_y + battery_height*0.6);}
}

if(title)
{
Expand Down
41 changes: 34 additions & 7 deletions widget/jgauge/jgauge_render.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ function jgauge_widgetlist()
{
"offsetx":-80,"offsety":-80,"width":160,"height":160,
"menu":"Widgets",
"options":["feedid", "scale", "max", "min", "units"],
"optionstype":["feedid","value","value","value","value"],
"optionsname":[_Tr("Feed"),_Tr("Scale"),_Tr("Max value"),_Tr("Min value"),_Tr("Units")],
"optionshint":[_Tr("Feed"),_Tr("Scale applied to value"),_Tr("Max value to show"),_Tr("Min value to show"),_Tr("Units to show")]
"options":["feedid", "scale", "max", "min", "units","timeout","errormessagedisplayed"],
"optionstype":["feedid","value","value","value","value","value","value"],
"optionsname":[_Tr("Feed"),_Tr("Scale"),_Tr("Max value"),_Tr("Min value"),_Tr("Units"),_Tr("Timeout"),_Tr("Error Message")],
"optionshint":[_Tr("Feed"),_Tr("Scale applied to value"),_Tr("Max value to show"),_Tr("Min value to show"),_Tr("Units to show"),_Tr("Timeout without feed update in seconds (empty is never)"),_Tr("Error message displayed when timeout is reached")]

}
}
Expand All @@ -43,16 +43,35 @@ function jgauge_draw()
{
$('.jgauge').each(function(index)
{
var errorMessage = $(this).attr("errormessagedisplayed");
if (errorMessage === "" || errorMessage === undefined){ //Error Message parameter is empty
errorMessage = "TO Error";
}
var errorTimeout = $(this).attr("timeout");
if (errorTimeout === "" || errorTimeout === undefined){ //Timeout parameter is empty
errorTimeout = 0;
}

var errorCode = "0";

var feedid = $(this).attr("feedid");
if (assocfeed[feedid]!=undefined) feedid = assocfeed[feedid]; // convert tag:name to feedid
if (associd[feedid] === undefined) { console.log("Review config for feed id of " + $(this).attr("class")); return; }
var val = curve_value(feedid,dialrate).toFixed(3);

if (errorTimeout !== 0)
{
if (((new Date()).getTime() / 1000 - offsetofTime - (associd[feedid]["time"] * 1)) > errorTimeout)
{
errorCode = "1";
}
}
// ONLY UPDATE ON CHANGE
if (val != (associd[feedid]['value'] * 1).toFixed(3) || redraw == 1)
if (val != (associd[feedid]['value'] * 1).toFixed(3) || redraw == 1 || errorTimeout != 0)
{
var id = "can-"+$(this).attr("id");
var scale = 1*$(this).attr("scale") || 1;
draw_jgauge(widgetcanvas[id],0,0,$(this).width(),$(this).height(),val*scale,$(this).attr("max"),$(this).attr("min"),$(this).attr("units"));
draw_jgauge(widgetcanvas[id],0,0,$(this).width(),$(this).height(),val*scale,$(this).attr("max"),$(this).attr("min"),$(this).attr("units"),errorCode,errorMessage);
}
});
}
Expand All @@ -67,7 +86,7 @@ function jgauge_fastupdate()
jgauge_draw();
}

function draw_jgauge(ctx,x,y,width,height,value,max,min,units)
function draw_jgauge(ctx,x,y,width,height,value,max,min,units,errorCode,errorMessage)
{
if (!max) max = 1000;
if (!min) min = 0;
Expand Down Expand Up @@ -125,8 +144,14 @@ function draw_jgauge(ctx,x,y,width,height,value,max,min,units)
ctx.font = "14pt Calibri,Geneva,Arial";
ctx.strokeStyle = "rgb(255,255,255)";
ctx.fillStyle = "rgb(255,255,255)";
if (errorCode!= "1"){
value = Number(value.toFixed(decimalPlaces));
ctx.fillText(value+units, 50*(size/100), 85*(size/100));
}
else
{
ctx.fillText(errorMessage, 50*(size/100), 85*(size/100));
}

// Save the current drawing state
ctx.save();
Expand All @@ -135,7 +160,9 @@ function draw_jgauge(ctx,x,y,width,height,value,max,min,units)
// Rotate around this point
ctx.rotate((position + offset) * (Math.PI / 180));
// Draw the image back and up
if (errorCode!= "1"){
ctx.drawImage(needle, -(size/2), -(size/2), size, size);
}

// Restore the previous drawing state
ctx.restore();
Expand Down
42 changes: 34 additions & 8 deletions widget/jgauge2/jgauge2_render.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ function jgauge2_widgetlist()
{
"offsetx":-80,"offsety":-80,"width":160,"height":160,
"menu":"Widgets",
"options":["feedid", "feedid2", "scale", "max", "min", "units"],
"optionstype":["feedid","feedid","value","value","value"],
"optionsname":[_Tr("Feed 1"),_Tr("Feed 2"),_Tr("Scale"),_Tr("Max value"),_Tr("Min value"),_Tr("Units")],
"optionshint":[_Tr("Feed 1"),_Tr("Feed 2 (Min/Max for example)"),_Tr("Scale applied to value"),_Tr("Max value to show"),_Tr("Min value to show"),_Tr("Units to show")]
"options":["feedid", "feedid2", "scale", "max", "min", "units","timeout","errormessagedisplayed"],
"optionstype":["feedid","feedid","value","value","value","value","value"],
"optionsname":[_Tr("Feed 1"),_Tr("Feed 2"),_Tr("Scale"),_Tr("Max value"),_Tr("Min value"),_Tr("Units"),_Tr("Timeout"),_Tr("Error Message")],
"optionshint":[_Tr("Feed 1"),_Tr("Feed 2 (Min/Max for example)"),_Tr("Scale applied to value"),_Tr("Max value to show"),_Tr("Min value to show"),_Tr("Units to show"),_Tr("Timeout without feed update in seconds (empty is never)"),_Tr("Error message displayed when timeout is reached")]

}
}
Expand All @@ -47,6 +47,17 @@ function jgauge2_draw()
{
$('.jgauge2').each(function(index)
{
var errorMessage = $(this).attr("errormessagedisplayed");
if (errorMessage === "" || errorMessage === undefined){ //Error Message parameter is empty
errorMessage = "TO Error";
}
var errorTimeout = $(this).attr("timeout");
if (errorTimeout === "" || errorTimeout === undefined){ //Timeout parameter is empty
errorTimeout = 0;
}

var errorCode = "0";

var feedid = $(this).attr("feedid");
if (assocfeed[feedid]!=undefined) feedid = assocfeed[feedid]; // convert tag:name to feedid
var feedid2 = $(this).attr("feedid2");
Expand All @@ -55,14 +66,22 @@ function jgauge2_draw()
if (associd[feedid2] === undefined) { console.log("Review config for feed id of " + $(this).attr("class")); return; }
var val = curve_value(feedid,dialrate).toFixed(3);
var val2 = curve_value(feedid2, dialrate).toFixed(3);

if (errorTimeout !== 0)
{
if (((new Date()).getTime() / 1000 - offsetofTime - (associd[feedid]["time"] * 1)) > errorTimeout)
{
errorCode = "1";
}
}
// ONLY UPDATE ON CHANGE
if (val != (associd[feedid]['value'] * 1).toFixed(3) ||
val2 != (associd[feedid2]['value'] * 1).toFixed(3) ||
redraw == 1)
redraw == 1 || errorTimeout != 0)
{
var id = "can-"+$(this).attr("id");
var scale = 1*$(this).attr("scale") || 1;
draw_jgauge2(widgetcanvas[id],0,0,$(this).width(),$(this).height(),val*scale,val2*scale,$(this).attr("max"),$(this).attr("min"),$(this).attr("units"));
draw_jgauge2(widgetcanvas[id],0,0,$(this).width(),$(this).height(),val*scale,val2*scale,$(this).attr("max"),$(this).attr("min"),$(this).attr("units"),errorCode,errorMessage);
}
});
}
Expand All @@ -77,7 +96,7 @@ function jgauge2_fastupdate()
jgauge2_draw();
}

function draw_jgauge2(ctx,x,y,width,height,value,value2,max,min,units)
function draw_jgauge2(ctx,x,y,width,height,value,value2,max,min,units,errorCode,errorMessage)
{
if (!max) max = 1000;
if (!min) min = 0;
Expand Down Expand Up @@ -145,9 +164,14 @@ function draw_jgauge2(ctx,x,y,width,height,value,value2,max,min,units)
ctx.font = "14pt Calibri,Geneva,Arial";
ctx.strokeStyle = "rgb(255,255,255)";
ctx.fillStyle = "rgb(255,255,255)";
if (errorCode!= "1"){
value = Number(value.toFixed(decimalPlaces));
ctx.fillText(value+units, 50*(size/100), 88*(size/100));

}
else
{
ctx.fillText(errorMessage, 50*(size/100), 85*(size/100));
}
// max label
ctx.font = "10pt Calibri,Geneva,Arial";
ctx.strokeStyle = "rgb(255,255,255)";
Expand All @@ -163,7 +187,9 @@ function draw_jgauge2(ctx,x,y,width,height,value,value2,max,min,units)
// Rotate around this point
ctx.rotate((position + offset) * (Math.PI / 180));
// Draw the image back and up
if (errorCode!= "1"){
ctx.drawImage(needle_jgauge2, -(size/2), -(size/2), size, size);
}
// Restore the previous drawing state
ctx.restore();

Expand Down
Loading