Skip to content

Commit

Permalink
save sensor data outside of panel to sovle 'unsaved changes' prompt p…
Browse files Browse the repository at this point in the history
…roblem
  • Loading branch information
Mengman committed Sep 5, 2017
1 parent 2d56fe8 commit 36e4786
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/module.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<div ng-if="sensor.visible">
<div ng-style="{position: 'relative', left:sensor.xlocationStr, top:sensor.ylocationStr, 'font-size':sensor.sizeStr,color:sensor.color}">
<div ng-style="{position: 'absolute', top: 0, left: 0,'background-color': sensor.bgcolor,'border-style':'solid','border-color':sensor.bordercolor,'border-width':'1px',padding:'5px'}">
<a href="{{sensor.link_url}}" bs-tooltip="sensor.link_hover" style="color: {{sensor.color}}">
{{sensor.valueFormatted}} {{sensor.valueUnit}}
<a ng-if="ctrl.sensorValues[sensor.name]" href="{{sensor.link_url}}" bs-tooltip="sensor.link_hover" style="color: {{sensor.color}}">
{{ctrl.sensorValues[sensor.name]}} {{sensor.valueUnit}}
</a>
</div>
</div>
Expand Down
18 changes: 9 additions & 9 deletions src/pictureit_ctrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class PictureItCtrl extends MetricsPanelCtrl {
constructor($scope, $injector) {
super($scope, $injector);
_.defaults(this.panel, panelDefaults);

this.sensorValues = new Object();
this.unitFormats = kbn.getUnitFormats();

this.events.on('init-edit-mode', this.onInitEditMode.bind(this));
Expand All @@ -30,10 +30,11 @@ export class PictureItCtrl extends MetricsPanelCtrl {
}

onDataReceived(dataList) {
this.sensorValues = new Object();
var dataListLength = dataList.length;
this.panel.valueMaps=[];
for (var series=0;series<dataListLength;series++) {
this.panel.valueMaps.push({name:dataList[series].target,value:dataList[series].datapoints[dataList[series].datapoints.length-1][0]});
var data = dataList[series];
this.sensorValues[data.target] = data.datapoints[data.datapoints.length-1][0];
}

this.render();
Expand All @@ -54,7 +55,7 @@ export class PictureItCtrl extends MetricsPanelCtrl {
}

setUnitFormat(subItem, index) {
this.panel.sensors[index].format = subItem.value;
this.panel.sensors[index].format = subItem.value;
}

onInitEditMode() {
Expand Down Expand Up @@ -88,11 +89,10 @@ export class PictureItCtrl extends MetricsPanelCtrl {
sensors[sensor].ylocationStr=sensors[sensor].ylocation.toString()+"px";
sensors[sensor].xlocationStr=sensors[sensor].xlocation.toString()+"px";
sensors[sensor].sizeStr=sensors[sensor].size.toString()+"px";
for (var valueMap=0;valueMap<valueMapsLength;valueMap++) {
if (sensors[sensor].name==valueMaps[valueMap].name) {
sensors[sensor].valueFormatted = kbn.valueFormats[sensors[sensor].format](valueMaps[valueMap].value,sensors[sensor].decimals, null);
break;
}
var name = sensors[sensor].name;
if(ctrl.sensorValues.hasOwnProperty(name)) {
var value = ctrl.sensorValues[name];
ctrl.sensorValues[name] = kbn.valueFormats[sensors[sensor].format](value, sensors[sensor].decimals, null);
}
}
}
Expand Down

1 comment on commit 36e4786

@kjetilmjos
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! Looking forward to getting it merged :)

Please sign in to comment.