From 667f6540773b6a556171c20a16996b32d334fc05 Mon Sep 17 00:00:00 2001 From: Patrick McDonagh Date: Wed, 13 Apr 2016 17:17:15 -0500 Subject: [PATCH] Able to switch back and forth between MySQL and SQLite --- python/tag_mysql.py | 2 +- python/tag_sqlite.py | 15 +- python/tagserver_MySQL.py | 2 +- python/tagserver_SQLite.py | 152 +++++++----------- www/app.coffee | 2 + www/functions_MySQL.coffee | 38 ++++- www/functions_SQLite.coffee | 81 +++++++--- www/public/css/app.css | 14 ++ www/public/js/controller.js | 54 +++++++ www/public/partials/tagVals.html | 24 ++- www/public/partials/tags.html | 257 +++++++++++++++++++------------ 11 files changed, 405 insertions(+), 236 deletions(-) diff --git a/python/tag_mysql.py b/python/tag_mysql.py index 3dab869..ed468d2 100644 --- a/python/tag_mysql.py +++ b/python/tag_mysql.py @@ -8,7 +8,7 @@ import micro800 as u800 import traceback import pickle -with open('mysql_cfg.pickle', 'rb') as cfgFile: +with open('/root/tagserver/python/mysql_cfg.pickle', 'rb') as cfgFile: mysql_cfg = pickle.load(cfgFile) con = mysqlcon.connect(**mysql_cfg) diff --git a/python/tag_sqlite.py b/python/tag_sqlite.py index a6dbabd..74eb046 100644 --- a/python/tag_sqlite.py +++ b/python/tag_sqlite.py @@ -19,7 +19,7 @@ def readTag(addr, tag): v = c.read_tag(tag) return v except Exception: - print("ERROR RETRIEVING TAG: {}".format(tag)) + print("ERROR RETRIEVING TAG: {} at {}".format(tag, addr)) err = c.get_status() c.close() print err @@ -49,7 +49,7 @@ class Tag(): def read(self, forceSend): writeToDB = False if self.tag: - v = readFn(self.plc_ip_address, self.tag) + v = self.readFn(str(self.plc_ip_address), str(self.tag)) if v: if self.data_type == 'BOOL' or self.data_type == 'STRING': val = v[0] @@ -73,9 +73,10 @@ class Tag(): def sendToDB(self): query = "INSERT INTO tag_vals (dtime, tagID, val) VALUES ({}, '{}', {})".format(time.time(), self.db_id, self.value) + self.last_send_time = time.time() print query - # TODO: CHECK ON THIS LOGIC -- with con: - cur = con.cursor() - cur.execute(query) - con.commit() - cur.close() + with con: + cur = con.cursor() + cur.execute(query) + con.commit() + cur.close() diff --git a/python/tagserver_MySQL.py b/python/tagserver_MySQL.py index 8767645..f85a9b5 100644 --- a/python/tagserver_MySQL.py +++ b/python/tagserver_MySQL.py @@ -12,7 +12,7 @@ from tag_mysql import Tag import traceback import time -with open('mysql_cfg.pickle', 'rb') as pickleconfig: +with open('/root/tagserver/python/mysql_cfg.pickle', 'rb') as pickleconfig: mysql_cfg = pickle.load(pickleconfig) if mysql_cfg: diff --git a/python/tagserver_SQLite.py b/python/tagserver_SQLite.py index 4989455..20a3628 100644 --- a/python/tagserver_SQLite.py +++ b/python/tagserver_SQLite.py @@ -8,125 +8,87 @@ Created on Dec 8, 2015 import time import sqlite3 as lite -from pycomm.ab_comm.clx import Driver as ClxDriver -import micro800 as u800 -import logging +from tag_sqlite import Tag +import traceback # con = lite.connect("/usr/db/data.db") con = lite.connect('/mnt/usb/data.db') configProperties = {} -def readTag(addr, tag): - # logging.basicConfig( - # filename="ClxDriver.log", - # format="%(levelname)-10s %(asctime)s %(message)s", - # level=logging.DEBUG - # ) - c = ClxDriver() - - if c.open(addr): - try: - v = c.read_tag(tag) - # print(v) - return v - except Exception as e: - err = c.get_status() - c.close() - print err - print e - pass - c.close() def main(): - with con: - cur = con.cursor() - query = "SELECT * FROM tags WHERE deleted = 0;" - cur.execute(query) - tags = cur.fetchall() + with con: + cur = con.cursor() + query = "SELECT * FROM tags WHERE deleted = 0;" + cur.execute(query) + tags = cur.fetchall() - configObj = {} + configObj = {} - with con: - cur = con.cursor() - query = "SELECT parameter, val FROM config GROUP BY parameter;" - cur.execute(query) - config = cur.fetchall() - for x in config: - configObj[x[0]] = x[1] + with con: + cur = con.cursor() + query = "SELECT parameter, val FROM config GROUP BY parameter;" + cur.execute(query) + config = cur.fetchall() + for x in config: + configObj[x[0]] = x[1] - try: - configProperties['PLC_IP_ADDRESS'] = str(configObj['ip_address']) - print("FYI, using PLC IP Address from the database {0}".format(configProperties['PLC_IP_ADDRESS'])) - except KeyError: - print("FYI, there is no PLC IP Address stored in the database, defaulting to 192.168.1.10") - configProperties['PLC_IP_ADDRESS'] = "192.168.1.10" + try: + configProperties['PLC_IP_ADDRESS'] = str(configObj['ip_address']) + print("FYI, using PLC IP Address from the database {0}".format(configProperties['PLC_IP_ADDRESS'])) + except KeyError: + print("FYI, there is no PLC IP Address stored in the database, defaulting to 192.168.1.10") + configProperties['PLC_IP_ADDRESS'] = "192.168.1.10" - try: - configProperties['plc_type'] = str(configObj['plc_type']) - print("FYI, using PLC Type from the database {0}".format(configProperties['plc_type'])) - except KeyError: - print("FYI, there is no PLC Type stored in the database, defaulting to CLX") - configProperties['plc_type'] = "CLX" + try: + configProperties['plc_type'] = str(configObj['plc_type']) + print("FYI, using PLC Type from the database {0}".format(configProperties['plc_type'])) + except KeyError: + print("FYI, there is no PLC Type stored in the database, defaulting to CLX") + configProperties['plc_type'] = "CLX" - try: - configProperties['scan_rate'] = int(configObj['scan_rate']) - print("FYI, using Scan Rate from the database {0}".format(configProperties['scan_rate'])) - except KeyError: - print("FYI, there is no Scan Rate stored in the database, defaulting to 10 seconds") - configProperties['scan_rate'] = 10 + try: + configProperties['scan_rate'] = int(configObj['scan_rate']) + print("FYI, using Scan Rate from the database {0}".format(configProperties['scan_rate'])) + except KeyError: + print("FYI, there is no Scan Rate stored in the database, defaulting to 10 seconds") + configProperties['scan_rate'] = 10 - try: - sa_test = str(configObj['save_all']) - if sa_test == "true": - configProperties['save_all'] = True - else: - configProperties['save_all'] = False - print("FYI, value for save_all is {0}".format(configProperties['save_all'])) - except KeyError: - print("FYI, there is no save_all value stored in the database, using False") - configProperties['save_all'] = False + try: + sa_test = str(configObj['save_all']) + if sa_test == "true": + configProperties['save_all'] = True + else: + configProperties['save_all'] = False + print("FYI, value for save_all is {0}".format(configProperties['save_all'])) + except KeyError: + print("FYI, there is no save_all value stored in the database, using False") + configProperties['save_all'] = False - tagList = [] - print("\nScan List\n--------------") - if len(tags) > 0: - for t in tags: - tagList.append({"id": int(t[0]), "name": t[1], "val": None, "lastVal": None}) - print(t[1]) - print("--------------\n") + tag_store = {} - while True: - try: - for r in tagList: - r['val'] = 0 - if configProperties['plc_type'] == "u800": - r["val"] = u800.readMicroTag(configProperties['PLC_IP_ADDRESS'], str(r['name']))[0] - else: - r["val"] = readTag(configProperties['PLC_IP_ADDRESS'], str(r['name']))[0] + if len(tags) > 0: + for t in tags: + # (1, u'Pump Intake Pressure', u'5', u'Pump_Intake_Pressure', u'Pressure at the Intake of the Pump', None, 100.0, 3600, u'PSI', 0.0, 3000.0, u'2016-04-13 21:27:01', 0) + tag_store[t[1]] = Tag(t[1], t[3], t[0], t[5], t[6], t[7], mapFn=t[8], plc_type=configProperties['plc_type'], plc_ip_address=configProperties['PLC_IP_ADDRESS']) - print("{0} - {1}".format(r["name"], r["val"])) - if (not configProperties['save_all'] and not r["val"] == r["lastVal"]) or configProperties['save_all']: - with con: - cur = con.cursor() - aQuery = """INSERT INTO vals (tagID, val) VALUES ('%d', '%f');""" % (r["id"], float(r["val"])) - # print(aQuery) - cur.execute(aQuery) - con.commit() - print("") - r["lastVal"] = r["val"] - print("-----------") - time.sleep(configProperties['scan_rate']) - except Exception as err: - print err - main() + while True: + for tag in tag_store: + try: + tag_store[tag].read(configProperties['save_all']) + except: + print("ERROR EVALUATING {}".format(tag)) + traceback.print_exc() + time.sleep(configProperties['scan_rate']) if __name__ == '__main__': - main() + main() diff --git a/www/app.coffee b/www/app.coffee index d6c4920..8ad43f6 100644 --- a/www/app.coffee +++ b/www/app.coffee @@ -83,6 +83,8 @@ app.get '/json/config', fns.getSetup # Gets the contents of the config table app.post '/json/config', fns.updateSetup # Adds a new parameter to the config table app.get '/json/logger/status', fns.checkLoggerStatus # Gets the status of the data logger app.get '/json/logger/restart', fns.restartLogger # Restarts the data logger +app.get '/json/clearDatabase/all', fns.clearValues # Removes all tag values from the database +app.get '/json/clearDatabase/:id', fns.clearValues # Removes tag values from the database app.get '*', angular ###* diff --git a/www/functions_MySQL.coffee b/www/functions_MySQL.coffee index 59eff3b..9f3d5cd 100644 --- a/www/functions_MySQL.coffee +++ b/www/functions_MySQL.coffee @@ -66,8 +66,8 @@ exports.getAllTags = (req, res) -> exports.createTag = (req, res) -> req.app.locals.pool.getConnection (err, db) -> - query = 'INSERT INTO tags (tag, units, minExpected, maxExpected, name, description, class) VALUES (?, ?, ?, ?, ?, ?, 5)' - db.query query, [req.body.tag, req.body.units, req.body.minExpected, req.body.maxExpected, req.body.name, req.body.description], (err, results) -> + query = 'INSERT INTO tags (tag, units, minExpected, maxExpected, name, description, class, guarantee_sec, change_threshold) VALUES (?, ?, ?, ?, ?, ?, 5, ?, ?)' + db.query query, [req.body.tag, req.body.units, req.body.minExpected, req.body.maxExpected, req.body.name, req.body.description, req.body.guarantee_sec, req.body.change_threshold], (err, results) -> if err res.json status: 'error' @@ -96,9 +96,10 @@ exports.getTag = (req, res) -> exports.updateTag = (req, res) -> + console.log(req.body) req.app.locals.pool.getConnection (err, db) -> - query = 'UPDATE tags set tag = ?, units = ?, minExpected = ?, maxExpected = ?, name = ?, description = ? WHERE id = ?' - db.query query, [req.body.tag, req.body.units, req.body.minExpected, req.body.maxExpected, req.body.name, req.body.description, req.body.id], (err, results) -> + query = 'UPDATE tags set tag = ?, units = ?, minExpected = ?, maxExpected = ?, name = ?, description = ?, guarantee_sec = ?, change_threshold = ? WHERE id = ?' + db.query query, [req.body.tag, req.body.units, req.body.minExpected, req.body.maxExpected, req.body.name, req.body.description, req.body.guarantee_sec, req.body.change_threshold, req.body.id], (err, results) -> db.release() if err res.json @@ -386,3 +387,32 @@ exports.updateSetup = (req, res) -> query: query ), 5000 undefined + +exports.clearValues = (req, res) -> + if req.params.id + req.app.locals.pool.getConnection (err, db) -> + query = 'DELETE FROM tag_vals WHERE tagID = ?;'; + db.query query, [req.params.id], (err) -> + db.release() + if err + res.json + status: 'error' + message: err + console.log err + else + res.json + status: 'OK' + else + req.app.locals.pool.getConnection (err, db) -> + query = 'DELETE FROM tag_vals WHERE id >= 0;'; + db.query query, (err) -> + db.release() + if err + res.json + status: 'error' + message: err + console.log err + else + res.json + status: 'OK' + undefined diff --git a/www/functions_SQLite.coffee b/www/functions_SQLite.coffee index 7c42f13..2a3576d 100644 --- a/www/functions_SQLite.coffee +++ b/www/functions_SQLite.coffee @@ -81,9 +81,9 @@ exports.createTag = (req, res) -> sqlite3 = require('sqlite3').verbose() db = new (sqlite3.Database)(dbFile) db.serialize -> - query = 'INSERT INTO tags (tagName, units, minExpected, maxExpected, vanityName, description) VALUES (?, ?, ?, ?, ?, ?)' + query = 'INSERT INTO tags (tag, units, minExpected, maxExpected, name, description, class, guarantee_sec, change_threshold) VALUES (?, ?, ?, ?, ?, ?, 5, ?, ?)' prepQuery = db.prepare(query) - prepQuery.run req.body.tagName, req.body.units, req.body.minExpected, req.body.maxExpected, req.body.vanityName, req.body.description, (err) -> + prepQuery.run req.body.tag, req.body.units, req.body.minExpected, req.body.maxExpected, req.body.name, req.body.description, req.body.guarantee_sec, req.body.change_threshold, (err) -> prepQuery.finalize() db.close() if err @@ -125,9 +125,9 @@ exports.updateTag = (req, res) -> sqlite3 = require('sqlite3').verbose() db = new (sqlite3.Database)(dbFile) db.serialize -> - query = 'UPDATE tags set tagName = ?, units = ?, minExpected = ?, maxExpected = ?, vanityName = ?, description = ? WHERE id = ?' + query = 'UPDATE tags set tag = ?, units = ?, minExpected = ?, maxExpected = ?, name = ?, description = ?, guarantee_sec = ?, change_threshold = ? WHERE id = ?' prepQuery = db.prepare(query) - prepQuery.run req.body.tagName, req.body.units, req.body.minExpected, req.body.maxExpected, req.body.vanityName, req.body.description, req.body.id, (err) -> + prepQuery.run req.body.tag, req.body.units, req.body.minExpected, req.body.maxExpected, req.body.name, req.body.description, req.body.guarantee_sec, req.body.change_threshold, req.body.id, (err) -> prepQuery.finalize() db.close() if err @@ -167,7 +167,7 @@ exports.seriesTagValues = (req, res) -> sqlite3 = require('sqlite3').verbose() db = new (sqlite3.Database)(dbFile) db.serialize -> - query = 'SELECT * FROM vals WHERE tagID = ? AND dateAdded > DATETIME(\'now\', \'-1 HOUR\')' + query = 'SELECT * FROM tag_vals WHERE tagID = ? AND dtime > DATETIME(\'now\', \'-1 HOUR\')' prepQuery = db.prepare(query) prepQuery.all parseInt(req.params.tag), (err, rows) -> prepQuery.finalize() @@ -191,7 +191,7 @@ exports.seriesTagValuesBetween = (req, res) -> sqlite3 = require('sqlite3').verbose() db = new (sqlite3.Database)(dbFile) db.serialize -> - query = 'SELECT * FROM vals WHERE tagID = ? AND dateAdded >= DATETIME(?) AND dateAdded <= DATETIME(?)' + query = 'SELECT * FROM tag_vals WHERE tagID = ? AND dtime >= DATETIME(?) AND dtime <= DATETIME(?)' prepQuery = db.prepare(query) prepQuery.all parseInt(req.params.tag), dString_to_sqlite(req.params.startDatetime), dString_to_sqlite(req.params.endDatetime), (err, rows) -> prepQuery.finalize() @@ -214,8 +214,8 @@ exports.seriesTagValuesBetween = (req, res) -> return createCSVrow = (header, dataRow) -> - i = header.indexOf(dataRow.vanityName) - csvRow = dataRow.id.toString() + ',' + dataRow.dateAdded + ',' + i = header.indexOf(dataRow.name) + csvRow = dataRow.id.toString() + ',' + dataRow.dtime + ',' if i >= 0 j = 2 while j < header.length @@ -232,7 +232,7 @@ exports.allDataCSV = (req, res) -> sqlite3 = require('sqlite3').verbose() db = new (sqlite3.Database)(dbFile) db.serialize -> - query = 'SELECT v.id, t.vanityName, v.val, v.dateAdded FROM tags t JOIN vals v ON t.id = v.tagID' + query = 'SELECT v.id, t.name, v.val, v.dtime FROM tags t JOIN tag_vals v ON t.id = v.tagID' prepQuery = db.prepare(query) prepQuery.all (err, rows) -> prepQuery.finalize() @@ -251,12 +251,12 @@ exports.allDataCSV = (req, res) -> csvString = '' da = [ 'id' - 'DateAdded' + 'dtime' ] - tagVanityNames = tags.map((t) -> - t.vanityName + tagnames = tags.map((t) -> + t.name ) - h = da.concat(tagVanityNames) + h = da.concat(tagnames) console.log h csvString = csvString + h.join(',') + '\u000d' i = 0 @@ -275,7 +275,7 @@ exports.seriesCSV = (req, res) -> sqlite3 = require('sqlite3').verbose() db = new (sqlite3.Database)(dbFile) db.serialize -> - query = 'SELECT v.id, t.vanityName, v.val, v.dateAdded FROM tags t JOIN vals v ON t.id = v.tagID WHERE tagID = ? AND v.dateAdded > DATETIME(\'now\', \'-1 HOUR\')' + query = 'SELECT v.id, t.name, v.val, v.dtime FROM tags t JOIN tag_vals v ON t.id = v.tagID WHERE tagID = ? AND v.dtime > DATETIME(\'now\', \'-1 HOUR\')' prepQuery = db.prepare(query) prepQuery.all parseInt(req.params.tag), (err, rows) -> prepQuery.finalize() @@ -290,15 +290,15 @@ exports.seriesCSV = (req, res) -> csvString = '' h = [ 'id' - 'DateAdded' - rows[0].vanityName + 'dtime' + rows[0].name ] csvString = csvString + h.join(',') + '\u000d' i = 0 while i < rows.length csvString = csvString + [ rows[i].id - rows[i].dateAdded + rows[i].dtime rows[i].val ].join(',') + '\u000d' i++ @@ -313,7 +313,7 @@ exports.seriesCSVBetween = (req, res) -> sqlite3 = require('sqlite3').verbose() db = new (sqlite3.Database)(dbFile) db.serialize -> - query = 'SELECT v.id, t.vanityName, v.val, v.dateAdded FROM tags t JOIN vals v ON t.id = v.tagID WHERE tagID = ? AND dateAdded >= DATETIME(?) AND dateAdded <= DATETIME(?)' + query = 'SELECT v.id, t.name, v.val, v.dtime FROM tags t JOIN tag_vals v ON t.id = v.tagID WHERE tagID = ? AND dtime >= DATETIME(?) AND dtime <= DATETIME(?)' prepQuery = db.prepare(query) prepQuery.all parseInt(req.params.tag), dString_to_sqlite(req.params.startDatetime), dString_to_sqlite(req.params.endDatetime), (err, rows) -> prepQuery.finalize() @@ -328,15 +328,15 @@ exports.seriesCSVBetween = (req, res) -> csvString = '' h = [ 'id' - 'DateAdded' - rows[0].vanityName + 'dtime' + rows[0].name ] csvString = csvString + h.join(',') + '\u000d' i = 0 while i < rows.length csvString = csvString + [ rows[i].id - rows[i].dateAdded + rows[i].dtime rows[i].val ].join(',') + '\u000d' i++ @@ -351,7 +351,7 @@ exports.latestValueSingleTag = (req, res) -> sqlite3 = require('sqlite3').verbose() db = new (sqlite3.Database)(dbFile) db.serialize -> - query = 'SELECT * FROM vals WHERE id = (SELECT MAX(id) FROM vals WHERE tagID = ?)' + query = 'SELECT * FROM tag_vals WHERE id = (SELECT MAX(id) FROM tag_vals WHERE tagID = ?)' prepQuery = db.prepare(query) prepQuery.all req.params.tag, (err, rows) -> console.log rows @@ -374,7 +374,7 @@ exports.latestValueAllTags = (req, res) -> sqlite3 = require('sqlite3').verbose() db = new (sqlite3.Database)(dbFile) db.serialize -> - query = 'SELECT t.tagName as tagName, t.vanityName as vanityName, t.description as description, t.units as units, t.id as t_id, t.minExpected as min, t.maxExpected as max, MAX(v.id) as v_id, v.val as val, v.dateAdded as dtime FROM vals v JOIN tags t ON v.tagID = t.id WHERE t.deleted = 0 GROUP BY v.tagID' + query = 'SELECT t.tag as tag, t.name as name, t.description as description, t.units as units, t.id as t_id, t.minExpected as min, t.maxExpected as max, MAX(v.id) as v_id, v.val as val, v.dtime as dtime FROM tag_vals v JOIN tags t ON v.tagID = t.id WHERE t.deleted = 0 GROUP BY v.tagID' prepQuery = db.prepare(query) prepQuery.all req.params.id, (err, rows) -> prepQuery.finalize() @@ -480,3 +480,38 @@ exports.updateSetup = (req, res) -> return return return + +exports.clearValues = (req, res) -> + sqlite3 = require('sqlite3').verbose() + db = new (sqlite3.Database)(dbFile) + if req.params.id + db.serialize () -> + query = 'DELETE FROM tag_vals WHERE tagID = ?;'; + prepQuery = db.prepare(query) + prepQuery.run req.params.id, (err) -> + prepQuery.finalize() + db.close() + if err + res.json + status: 'error' + message: err + console.log err + else + res.json + status: 'OK' + else + db.serialize () -> + query = 'DELETE FROM tag_vals WHERE id >= 0;'; + prepQuery = db.prepare(query) + prepQuery.run req.params.id, (err) -> + prepQuery.finalize() + db.close() + if err + res.json + status: 'error' + message: err + console.log err + else + res.json + status: 'OK' + undefined diff --git a/www/public/css/app.css b/www/public/css/app.css index 8b13789..4e87a3a 100644 --- a/www/public/css/app.css +++ b/www/public/css/app.css @@ -1 +1,15 @@ +.topMargin40 { + margin-top: 40px; +} +.row-flex { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + flex-wrap: wrap; +} +.row-flex > [class*='col-'] { + display: flex; + flex-direction: column; +} diff --git a/www/public/js/controller.js b/www/public/js/controller.js index aa9024e..9174494 100644 --- a/www/public/js/controller.js +++ b/www/public/js/controller.js @@ -200,6 +200,8 @@ tsCtrlrs.factory('tags',function($q, $http, $log){ units: tag.units, minExpected: tag.minExpected, maxExpected: tag.maxExpected, + guarantee_sec: tag.guarantee_sec, + change_threshold: tag.change_threshold, description: tag.description }).success(function(data){ return data; @@ -215,6 +217,8 @@ tsCtrlrs.factory('tags',function($q, $http, $log){ units: tag.units, minExpected: tag.minExpected, maxExpected: tag.maxExpected, + guarantee_sec: tag.guarantee_sec, + change_threshold: tag.change_threshold, description: tag.description }).success(function(data){ return data; @@ -234,6 +238,28 @@ tsCtrlrs.factory('tags',function($q, $http, $log){ return deferred.promise; }; + var clearSingleTagData = function(id){ + var deferred = $q.defer(); + var url = '/json/clearDatabase/' + id; + $http.get(url).success(function(data) { + deferred.resolve({ + status: data.status + }); + }); + return deferred.promise; + }; + + var clearAllTagData = function(){ + var deferred = $q.defer(); + var url = '/json/clearDatabase/all'; + $http.get(url).success(function(data) { + deferred.resolve({ + status: data.status + }); + }); + return deferred.promise; + }; + return { getTag: getTag, getTagList: getTagList, @@ -243,6 +269,8 @@ tsCtrlrs.factory('tags',function($q, $http, $log){ createTag: createTag, updateTag: updateTag, deleteTag: deleteTag, + clearSingleTagData: clearSingleTagData, + clearAllTagData: clearAllTagData }; }); @@ -396,6 +424,32 @@ tsCtrlrs.controller('tagsCtrl', function($scope, $route, $http, $routeParams, Pa }); }; + $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.deleteTagValues = function(id){ + 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.openEditTag = function(id){ var getTag = tags.getTag(id); getTag.then(function(data){ diff --git a/www/public/partials/tagVals.html b/www/public/partials/tagVals.html index 042eb8a..9b4d876 100644 --- a/www/public/partials/tagVals.html +++ b/www/public/partials/tagVals.html @@ -32,19 +32,31 @@
-

{{tag.vanityName}}

- From: To: +

{{tag.name}}

+
+
+ From: +
+
+ To: +
+
+ +
+
- - Download Data -
+
-
+
+ +
+
+ Download Data diff --git a/www/public/partials/tags.html b/www/public/partials/tags.html index 9bc1303..416bdf8 100644 --- a/www/public/partials/tags.html +++ b/www/public/partials/tags.html @@ -1,109 +1,166 @@ + + + + @@ -140,6 +197,7 @@ + @@ -151,6 +209,7 @@ +
Max Expected Value Units
{{tag.maxExpected}} {{tag.units}}