-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecated old MemoryValuesStore, replaced by DbValuesStore
Added story error on html Added values filtering
- Loading branch information
Showing
7 changed files
with
228 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package ch.mno.copper.data; | ||
|
||
import java.time.Instant; | ||
|
||
/** | ||
* Created by xsicdt on 25/08/17. | ||
*/ | ||
public class InstantValue { | ||
|
||
protected long id; | ||
protected String key; | ||
protected String value; | ||
protected Instant timestamp; | ||
|
||
public String getValue() { | ||
return value; | ||
} | ||
|
||
public long getId() { | ||
return id; | ||
} | ||
|
||
public String getKey() { | ||
return key; | ||
} | ||
|
||
public Instant getTimestamp() { | ||
return timestamp; | ||
} | ||
|
||
|
||
public InstantValue(long id, String key, String value, Instant timestamp) { | ||
this.id = id; | ||
this.key = key; | ||
this.value = value; | ||
this.timestamp = timestamp; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "StoreValue{" + | ||
"key='" + key + '\'' + | ||
", value='" + value + '\'' + | ||
", timestamp=" + timestamp + | ||
'}'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package ch.mno.copper.data; | ||
|
||
import java.time.Instant; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* Created by dutoitc on 30.09.2017. | ||
*/ | ||
public class InstantValues { | ||
|
||
protected Instant timestamp; | ||
protected Map<String, InstantValue> values = new HashMap<>(); | ||
|
||
|
||
|
||
public void put(String key, InstantValue value) { | ||
values.put(key, value); | ||
} | ||
|
||
|
||
public Instant getTimestamp() { | ||
return timestamp; | ||
} | ||
|
||
public void setTimestamp(Instant timestamp) { | ||
this.timestamp = timestamp; | ||
} | ||
|
||
public Map<String, InstantValue> getValues() { | ||
return values; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
'use strict'; | ||
|
||
angular.module('copperApp.history', ['ngRoute']) | ||
.config(['$routeProvider', function($routeProvider) { | ||
$routeProvider.when('/history', { | ||
templateUrl: 'app/views/history.html', | ||
controller: 'historyCtrl' | ||
}); | ||
}]) | ||
|
||
.controller('historyCtrl', ['$http', '$scope', '$routeParams', function($http, $scope, $routeParams) { | ||
var scope = $scope; | ||
var self=this; | ||
var key = $routeParams.key; | ||
|
||
$scope.labels = []; | ||
$scope.series = []; | ||
$scope.data = []; | ||
$scope.onClick = function (points, evt) { | ||
console.log(points, evt); | ||
}; | ||
$scope.datasetOverride = [{ yAxisID: 'y-axis-1' }, { yAxisID: 'y-axis-2' }]; | ||
$scope.options = { | ||
scales: { | ||
yAxes: [ | ||
{ | ||
id: 'y-axis-1', | ||
type: 'linear', | ||
display: true, | ||
position: 'left' | ||
}, | ||
{ | ||
id: 'y-axis-2', | ||
type: 'linear', | ||
display: true, | ||
position: 'right' | ||
} | ||
] | ||
} | ||
}; | ||
|
||
$http.get('ws/instants/query?columns='+key+'&from=2017-09-30T00:00&intervalSeconds=300') | ||
.then(function(response) { | ||
$scope.history=[]; | ||
|
||
// series | ||
var spl = key.split(","); | ||
for (var i=0; i<spl.length; i++) { | ||
$scope.series.push(spl[i]); | ||
$scope.data.push([]); | ||
} | ||
|
||
for (var i=0; i<response.data.length;i++) { | ||
var iv = response.data[i] | ||
$scope.labels.push($scope.toHumanDate(iv.timestamp.seconds)); | ||
for (var j=0; j<$scope.series.length; j++) { | ||
var iv2 = iv.values[$scope.series[j]]; | ||
$scope.data[j].push(iv2.value); | ||
$scope.history.push(iv2); | ||
} | ||
} | ||
}); | ||
|
||
|
||
$scope.toHumanDate = function(ts) { | ||
//var d = new Date(ts*1000); | ||
return moment(ts).format('DD.MM.YYYY, HH:mm:ss'); | ||
}; | ||
|
||
$scope.filter = function(object, field, filter) { | ||
if (!object) return {}; | ||
if (!filter) return object; | ||
|
||
var filteredObject = {}; | ||
Object.keys(object).forEach(function(key) { | ||
if (object[key][field].includes(filter)) { | ||
filteredObject[key] = object[key]; | ||
} | ||
}); | ||
|
||
return filteredObject; | ||
}; | ||
|
||
|
||
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<h1>History</h1> | ||
<div class="row"> | ||
|
||
<canvas id="line" class="chart chart-line" chart-data="data" | ||
chart-labels="labels" chart-series="series" chart-options="options" | ||
chart-dataset-override="datasetOverride" chart-click="onClick"> | ||
</canvas> | ||
(Access from 'values' menu) | ||
|
||
|
||
<br/> | ||
<br/> | ||
|
||
<div ng-show="history.length>0"> | ||
values | ||
|
||
<label>Search: <input ng-model="searchText"></label> | ||
<table class="table-striped" style="width: 80%; margin: auto; border: 1px outset silver"> | ||
<thead> | ||
<th style="text-align:right;padding: 5px">Timestamp</th> | ||
<th style="text-align:right;padding: 5px">Key</th> | ||
<th style="text-align:left; padding-left: 10px">Value</th> | ||
</thead> | ||
<tbody> | ||
<tr ng-repeat="v in history | filter:searchText | orderBy:'-timestamp.seconds'"> | ||
<td style="text-align:center;width: 150px">{{v.timestamp.seconds*1000 | date : 'yyyy-MM-dd HH:mm:ss'}}</td> | ||
<td style="text-align:right;padding: 5px;font-weight:bold">{{v.key}}</td> | ||
<td style="text-align:left; padding-left: 10px">{{v.value}}</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
|
||
</div> |
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.