Can see tags and values now
This commit is contained in:
@@ -6,6 +6,12 @@
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
|
||||
latest: function(req, res){
|
||||
var query = "SELECT v1.id as id, v1.createdAt as dtime, t.id as t_id, t.name as name, t.tag as tag, v1.val as val, t.units as units, t.description as description, t.minExpected as minExpected, t.maxExpected as maxExpected FROM tag_vals v1 LEFT JOIN tags t ON t.id = v1.tagID WHERE v1.id = (SELECT v2.id FROM tag_vals v2 WHERE v2.tagID = v1.tagID ORDER BY v2.id DESC LIMIT 1)";
|
||||
console.log(query);
|
||||
Tag_val.query(query, function(err, results){
|
||||
if (err) return res.serverError(err);
|
||||
return res.ok(results);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -103,92 +103,41 @@ tsCtrlrs.factory('Alerts', function($log) {
|
||||
tsCtrlrs.factory('tags',function($q, $http, $log){
|
||||
var getTag = function(id) {
|
||||
var deferred = $q.defer();
|
||||
$http.get('/json/tag/' + id).success(function(data) {
|
||||
if(data.status == "OK"){
|
||||
deferred.resolve({
|
||||
tag:data.tags[0],
|
||||
status: data.status
|
||||
});
|
||||
} else {
|
||||
deferred.resolve({
|
||||
status:data.status,
|
||||
message: data.message
|
||||
});
|
||||
}
|
||||
$http.get('/tag/' + id).success(function(data) {
|
||||
deferred.resolve({
|
||||
tag:data
|
||||
});
|
||||
});
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
var getTagList = function() {
|
||||
var deferred = $q.defer();
|
||||
$http.get('/json/tag/').success(function(data) {
|
||||
if(data.status == "OK"){
|
||||
deferred.resolve({
|
||||
tags:data.tags,
|
||||
status: data.status
|
||||
});
|
||||
} else {
|
||||
deferred.resolve({
|
||||
status:data.status,
|
||||
message: data.message
|
||||
});
|
||||
}
|
||||
});
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
var getTagHistory = function(id){
|
||||
var deferred = $q.defer();
|
||||
$http.get('/json/series/'+ id + "/24").success(function(data) {
|
||||
if(data.status == "OK"){
|
||||
deferred.resolve({
|
||||
vals:data.vals,
|
||||
status: data.status
|
||||
});
|
||||
} else {
|
||||
deferred.resolve({
|
||||
status:data.status,
|
||||
message: data.message
|
||||
});
|
||||
}
|
||||
$http.get('/tag/').success(function(data) {
|
||||
deferred.resolve({
|
||||
tags:data
|
||||
});
|
||||
});
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
var getTagHistoryBetween = function(id, start, end){
|
||||
var deferred = $q.defer();
|
||||
var url = '/json/valBetween/'+ id + "/" + date_to_dString(start) + "/" + date_to_dString(end);
|
||||
$log.info("getting value for: " + url);
|
||||
$http.get(url).success(function(data) {
|
||||
if(data.status == "OK"){
|
||||
deferred.resolve({
|
||||
vals:data.vals,
|
||||
status: data.status
|
||||
});
|
||||
} else {
|
||||
deferred.resolve({
|
||||
status:data.status,
|
||||
message: data.message
|
||||
});
|
||||
}
|
||||
var w = {'where':{'tagID': id, 'createdAt': {">=":0, "<=":end}}};
|
||||
$http.get("/tag_val", {params:w}).success(function(data) {
|
||||
deferred.resolve({
|
||||
vals:data
|
||||
});
|
||||
});
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
var getCurrentValues = function(){
|
||||
var deferred = $q.defer();
|
||||
$http.get('/json/all').success(function(data) {
|
||||
if(data.status == "OK"){
|
||||
deferred.resolve({
|
||||
vals:data.vals,
|
||||
status: data.status
|
||||
});
|
||||
} else {
|
||||
deferred.resolve({
|
||||
status:data.status,
|
||||
message: data.message
|
||||
});
|
||||
}
|
||||
$http.get('/tag_val/latest').success(function(data) {
|
||||
deferred.resolve({
|
||||
vals:data
|
||||
});
|
||||
});
|
||||
return deferred.promise;
|
||||
};
|
||||
@@ -265,7 +214,6 @@ tsCtrlrs.factory('tags',function($q, $http, $log){
|
||||
return {
|
||||
getTag: getTag,
|
||||
getTagList: getTagList,
|
||||
getTagHistory: getTagHistory,
|
||||
getTagHistoryBetween: getTagHistoryBetween,
|
||||
getCurrentValues: getCurrentValues,
|
||||
createTag: createTag,
|
||||
@@ -365,12 +313,7 @@ tsCtrlrs.controller('dashboardCtrl', function($scope, $route, $http, $routeParam
|
||||
var getCurrentValues = tags.getCurrentValues();
|
||||
getCurrentValues.then(function(data) {
|
||||
$scope.loading = false;
|
||||
if (data.status == "OK"){
|
||||
$scope.vals = data.vals;
|
||||
$scope.error = false;
|
||||
} else {
|
||||
$scope.error = data.message;
|
||||
}
|
||||
$scope.vals = data.vals;
|
||||
});
|
||||
};
|
||||
$scope.loadDashboard();
|
||||
@@ -384,12 +327,7 @@ tsCtrlrs.controller('tagsCtrl', function($scope, $route, $http, $routeParams, Pa
|
||||
var getTagList = tags.getTagList();
|
||||
getTagList.then(function(data) {
|
||||
$scope.loading = false;
|
||||
if (data.status == "OK"){
|
||||
$scope.tags = data.tags;
|
||||
$scope.error = false;
|
||||
} else {
|
||||
$scope.error = data.message;
|
||||
}
|
||||
$scope.tags = data.tags;
|
||||
});
|
||||
};
|
||||
$scope.loadTagList();
|
||||
@@ -403,13 +341,9 @@ tsCtrlrs.controller('tagsCtrl', function($scope, $route, $http, $routeParams, Pa
|
||||
$scope.openDeleteTag = function(id){
|
||||
var getTag = tags.getTag(id);
|
||||
getTag.then(function(data){
|
||||
if (data.status == "OK"){
|
||||
$scope.error = false;
|
||||
$scope.dTag = data.tag;
|
||||
$log.info("Thinking about deleting tag with parameters: "+ JSON.stringify($scope.dTag));
|
||||
} else {
|
||||
$scope.error = data.message;
|
||||
}
|
||||
$scope.error = false;
|
||||
$scope.dTag = data.tag;
|
||||
$log.info("Thinking about deleting tag with parameters: "+ JSON.stringify($scope.dTag));
|
||||
});
|
||||
};
|
||||
|
||||
@@ -417,25 +351,17 @@ tsCtrlrs.controller('tagsCtrl', function($scope, $route, $http, $routeParams, Pa
|
||||
var deleteTag = tags.deleteTag(id);
|
||||
deleteTag.then(function(data){
|
||||
$log.info("deleting tag "+ id + " status: " + data.status);
|
||||
if (data.status == "OK"){
|
||||
$scope.error = false;
|
||||
$scope.loadTagList();
|
||||
} else {
|
||||
$scope.error = data.message;
|
||||
}
|
||||
$scope.error = false;
|
||||
$scope.loadTagList();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.openClearTagData = function(id){
|
||||
var getTag = tags.getTag(id);
|
||||
getTag.then(function(data){
|
||||
if (data.status == "OK"){
|
||||
$scope.error = false;
|
||||
$scope.dTagValues = data.tag;
|
||||
$log.info("Thinking about deleting tag data with parameters: "+ JSON.stringify($scope.dTagValues));
|
||||
} else {
|
||||
$scope.error = data.message;
|
||||
}
|
||||
$scope.error = false;
|
||||
$scope.dTagValues = data.tag;
|
||||
$log.info("Thinking about deleting tag data with parameters: "+ JSON.stringify($scope.dTagValues));
|
||||
});
|
||||
};
|
||||
|
||||
@@ -443,25 +369,17 @@ tsCtrlrs.controller('tagsCtrl', function($scope, $route, $http, $routeParams, Pa
|
||||
var clearSingleTagData = tags.clearSingleTagData(id);
|
||||
clearSingleTagData.then(function(data){
|
||||
$log.info("deleting tag "+ id + " status: " + data.status);
|
||||
if (data.status == "OK"){
|
||||
$scope.error = false;
|
||||
$scope.loadTagList();
|
||||
} else {
|
||||
$scope.error = data.message;
|
||||
}
|
||||
$scope.error = false;
|
||||
$scope.loadTagList();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.openEditTag = function(id){
|
||||
var getTag = tags.getTag(id);
|
||||
getTag.then(function(data){
|
||||
if (data.status == "OK"){
|
||||
$scope.error = false;
|
||||
$scope.editTag = data.tag;
|
||||
$log.info("Started editing tag with parameters: "+ JSON.stringify($scope.editTag));
|
||||
} else {
|
||||
$scope.error = data.message;
|
||||
}
|
||||
$scope.error = false;
|
||||
$scope.editTag = data.tag;
|
||||
$log.info("Started editing tag with parameters: "+ JSON.stringify($scope.editTag));
|
||||
});
|
||||
};
|
||||
|
||||
@@ -495,46 +413,38 @@ tsCtrlrs.controller('tagValsCtrl', function($scope, $route, $http, $routeParams,
|
||||
$scope.loading = true;
|
||||
var getTag = tags.getTag($routeParams.tagID);
|
||||
getTag.then(function(tagData){
|
||||
if (tagData.status == "OK"){
|
||||
$scope.tag = tagData.tag;
|
||||
Page.setTitle('Tag Series: '+ tagData.tag.tagName);
|
||||
var getTagHistoryBetween = tags.getTagHistoryBetween($routeParams.tagID, sDTime, eDTime);
|
||||
getTagHistoryBetween.then(function(data) {
|
||||
$scope.loading = false;
|
||||
if (data.status == "OK"){
|
||||
$scope.data = data;
|
||||
$scope.data.vals = $scope.data.vals.map(function(x){
|
||||
return {id: x.id, tagID: x.tagID, val: x.val, dtime: new Date(x.dtime)};
|
||||
});
|
||||
$scope.error = false;
|
||||
$scope.tag = tagData.tag;
|
||||
Page.setTitle('Tag Series: '+ tagData.tag.tagName);
|
||||
var getTagHistoryBetween = tags.getTagHistoryBetween($routeParams.tagID, sDTime, eDTime);
|
||||
getTagHistoryBetween.then(function(data) {
|
||||
$log.info(data);
|
||||
$scope.loading = false;
|
||||
$scope.data = data;
|
||||
$scope.data.vals = $scope.data.vals.map(function(x){
|
||||
return {id: x.id, tagID: x.tagID, val: x.val, dtime: new Date(x.createdAt)};
|
||||
});
|
||||
$scope.error = false;
|
||||
|
||||
$scope.options = {
|
||||
series: [
|
||||
{
|
||||
axis: "y",
|
||||
dataset: "vals",
|
||||
key: "val",
|
||||
label: "Tag Value",
|
||||
color: "#1f77b4",
|
||||
type: ['line'],
|
||||
id: 'tagChart'
|
||||
}
|
||||
],
|
||||
axes: {
|
||||
x: {
|
||||
key: "dtime",
|
||||
type: "date"
|
||||
}
|
||||
}
|
||||
};
|
||||
} else {
|
||||
$scope.error = data.message;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$scope.loading = false;
|
||||
$scope.error = data.message;
|
||||
}
|
||||
$scope.options = {
|
||||
series: [
|
||||
{
|
||||
axis: "y",
|
||||
dataset: "vals",
|
||||
key: "val",
|
||||
label: "Tag Value",
|
||||
color: "#1f77b4",
|
||||
type: ['line'],
|
||||
id: 'tagChart'
|
||||
}
|
||||
],
|
||||
axes: {
|
||||
x: {
|
||||
key: "dtime",
|
||||
type: "date"
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
};
|
||||
$scope.loadTagVals($scope.startDatetime, $scope.endDatetime);
|
||||
|
||||
@@ -93,10 +93,10 @@
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="data_type">Data Type</label>
|
||||
<select ng-model="editTag.data_type" class="form-control" id="data_type">
|
||||
<option value="REAL">Floating Point</option>
|
||||
<option value="DINT">Integer</option>
|
||||
<option value="BOOL">Boolean</option>
|
||||
<select ng-model="editTag.data_type.id" class="form-control" id="data_type">
|
||||
<option value=1>Floating Point</option>
|
||||
<option value=2>Integer</option>
|
||||
<option value=3>Boolean</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
|
||||
@@ -34,7 +34,7 @@ module.exports.routes = {
|
||||
|
||||
'/': {
|
||||
view: 'homepage'
|
||||
}
|
||||
},
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
@@ -45,5 +45,5 @@ module.exports.routes = {
|
||||
* for configuration options and examples. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
"/tag_val/latest": "Tag_valController.latest"
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user