From 6316fb267ee310114b4f0772d81e073b373cbe39 Mon Sep 17 00:00:00 2001 From: Patrick McDonagh Date: Wed, 27 Jan 2016 15:06:08 -0600 Subject: [PATCH] Added line graph to tag vals --- python/tagserver_SQLite.py | 4 +-- www/app.js | 1 + www/functions_SQLite.js | 3 ++- www/package.json | 3 ++- www/public/js/controller.js | 24 +++++++++++++++-- www/public/partials/tagVals.html | 45 +++++++++++++++++++++++++------- www/public/partials/tags.html | 43 +++++++++++++++++++++++++++--- www/views/angularIndex.html | 3 +++ 8 files changed, 106 insertions(+), 20 deletions(-) diff --git a/python/tagserver_SQLite.py b/python/tagserver_SQLite.py index dfb0959..22c76fb 100644 --- a/python/tagserver_SQLite.py +++ b/python/tagserver_SQLite.py @@ -11,8 +11,8 @@ import sqlite3 as lite from pycomm.ab_comm.clx import Driver as ClxDriver import logging -con = lite.connect("/usr/db/data.db") -# con = lite.connect('/Users/patrickjmcd/data.db') +# con = lite.connect("/usr/db/data.db") +con = lite.connect('/home/pi/data.db') def readTag(addr, tag): diff --git a/www/app.js b/www/app.js index e77d842..91f45ff 100644 --- a/www/app.js +++ b/www/app.js @@ -56,6 +56,7 @@ app.use(bodyParser.urlencoded({extended: true})); //app.use(express["static"](path.join(__dirname, 'public'))); app.use(express.static(__dirname + '/public')); app.use('/bower_components', express.static(__dirname + '/bower_components')); +app.use('/node_modules', express.static(__dirname + '/node_modules')); /** * Routes diff --git a/www/functions_SQLite.js b/www/functions_SQLite.js index 94e67c2..08b7194 100644 --- a/www/functions_SQLite.js +++ b/www/functions_SQLite.js @@ -1,4 +1,5 @@ -var dbFile = "/usr/db/data.db" +// var dbFile = "/usr/db/data.db"; +var dbFile = "/home/pi/data.db"; // var dbFile = '/Users/patrickjmcd/data.db'; // app.get('/json/add/:tag', fns.addTag); // Adds a tag to the scan list // app.get('/json/remove/:tag', fns.removeTag); // Removes a tag from the scan list diff --git a/www/package.json b/www/package.json index a6a29b4..1a29e40 100644 --- a/www/package.json +++ b/www/package.json @@ -12,7 +12,8 @@ "morgan": "*", "mysql": "*", "serve-favicon": "*", - "sqlite3": "*" + "sqlite3": "*", + "n3-charts": "*" }, "devDependencies": {}, "scripts": { diff --git a/www/public/js/controller.js b/www/public/js/controller.js index e46bc73..2cb050e 100644 --- a/www/public/js/controller.js +++ b/www/public/js/controller.js @@ -1,4 +1,4 @@ -var tsCtrlrs = angular.module('tsCtrlrs', ['ngJustGage']); +var tsCtrlrs = angular.module('tsCtrlrs', ['ngJustGage', 'n3-line-chart']); tsCtrlrs.factory('Page', function($log) { var title = 'default'; @@ -168,8 +168,28 @@ tsCtrlrs.controller('tagValsCtrl', function($scope, $route, $http, $routeParams, getTagHistory.then(function(data) { $scope.loading = false; if (data.status == "OK"){ - $scope.vals = data.vals; + $scope.data = data; $scope.error = false; + + $scope.options = { + series: [ + { + axis: "y", + dataset: "vals", + key: "val", + label: "Tag Value", + color: "#1f77b4", + type: ['line'], + id: 'tagChart' + } + ], + axes: { + x: { + key: "id", + // type: "date" + } + } + }; } else { $scope.error = data.message; } diff --git a/www/public/partials/tagVals.html b/www/public/partials/tagVals.html index 3fc3e0d..39540b4 100644 --- a/www/public/partials/tagVals.html +++ b/www/public/partials/tagVals.html @@ -1,12 +1,37 @@ -
-
{{message}}
+
+
+
+

Error Caught!

+
{{message}}
+
+
-
- -

{{tag.tagName}}

-
    -
  • {{val.id}} @ {{val.dateAdded}} - {{val.val}} {{tag.units}}
  • -
-
{{vals}}
-
\ No newline at end of file +
+
+
+
+ +
+
+
+

{{tag.tagName}}

+ + + + + + + + + + + + + + + +
IDValueDate Added
{{val.id}}{{val.val}} {{tag.units}}{{val.dateAdded}}
+
+
+
diff --git a/www/public/partials/tags.html b/www/public/partials/tags.html index 98a6714..d1cb55e 100644 --- a/www/public/partials/tags.html +++ b/www/public/partials/tags.html @@ -1,4 +1,39 @@ -
{{tags}}
- \ No newline at end of file +
+
+
+

Error Caught!

+
{{message}}
+
+
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
IDNameMin Expected ValueMax Expected ValueUnits
{{tag.id}}{{tag.tagName}}{{tag.minExpected}}{{tag.maxExpected}}{{tag.units}}
+
+
+
\ No newline at end of file diff --git a/www/views/angularIndex.html b/www/views/angularIndex.html index e6a1d66..115be5c 100644 --- a/www/views/angularIndex.html +++ b/www/views/angularIndex.html @@ -17,6 +17,9 @@ + + +