summaryrefslogtreecommitdiff
path: root/www
diff options
context:
space:
mode:
authorArjun Roychowdhury <pliablepixels@gmail.com>2015-10-23 07:25:36 -0400
committerArjun Roychowdhury <pliablepixels@gmail.com>2015-10-23 07:25:36 -0400
commitdc29a463418d49e02c71493ca7d3e13b6b65e650 (patch)
tree5083f3a8f66e9a55e8f5c44134090fd336764872 /www
parentb5cbc97a8b555d73d102d7742ae1f014e7349492 (diff)
You can now specify a minimum reporting interval per monitor for notifications
Diffstat (limited to 'www')
-rw-r--r--www/.DS_Storebin6148 -> 6148 bytes
-rw-r--r--www/css/style.css21
-rw-r--r--www/js/DataModel.js4
-rw-r--r--www/js/EventServer.js3
-rw-r--r--www/js/EventServerSettingsCtrl.js239
-rw-r--r--www/sounds/.DS_Storebin0 -> 6148 bytes
-rw-r--r--www/templates/eventserversettings.html78
7 files changed, 246 insertions, 99 deletions
diff --git a/www/.DS_Store b/www/.DS_Store
index 1d01a7a1..c21f88ea 100644
--- a/www/.DS_Store
+++ b/www/.DS_Store
Binary files differ
diff --git a/www/css/style.css b/www/css/style.css
index 29243005..7ca94150 100644
--- a/www/css/style.css
+++ b/www/css/style.css
@@ -492,6 +492,27 @@ input[type=range]::-webkit-slider-thumb {
}
+/*
+ * http://docs.angularjs.org/api/ng/directive/ngShow#usage_animations
+ */
+.list .item.item-accordion {
+ line-height: 45px;
+ padding-top: 0;
+ padding-bottom: 0;
+ transition: 0.09s all linear;
+}
+.list .item.item-accordion.ng-hide {
+ line-height: 0px;
+}
+.list .item.item-accordion.ng-hide-add,
+.list .item.item-accordion.ng-hide-remove {
+ display: block !important;
+}
+
+.custom-list i {
+ float: right;
+}
+
/*.mySliderClass.jslider.sliderCSS div.jslider-pointer
{top:-10px;left:15px;width:60px;height:60px;margin-left:-5px;background-color:silver;background-color:#615959;border-radius:50%
}*/
diff --git a/www/js/DataModel.js b/www/js/DataModel.js
index 3c0765c2..b8a5e53b 100644
--- a/www/js/DataModel.js
+++ b/www/js/DataModel.js
@@ -39,8 +39,8 @@ angular.module('zmApp.controllers')
'keepAwake':true, // don't dim/dim during live view
'isUseAuth':true, // true if user wants ZM auth
'isUseEventServer':false, // true if you configure the websocket event server
- 'eventServerMonitors':'',
- 'eventServerInterval':0,
+ 'eventServerMonitors':'', // list of monitors to notify from ES
+ 'eventServerInterval':'', // list of intervals for all monitors
'refreshSec':"2", // timer value for frame change in sec
'enableDebug':false, // if enabled with log messages with "debug"
'usePin':false,
diff --git a/www/js/EventServer.js b/www/js/EventServer.js
index e47ca109..77922f0e 100644
--- a/www/js/EventServer.js
+++ b/www/js/EventServer.js
@@ -20,9 +20,6 @@ angular.module('zmApp.controllers')
var localNotificationId = 0;
-
-
-
//--------------------------------------------------------------------------
// used to compare versions of event server
//--------------------------------------------------------------------------
diff --git a/www/js/EventServerSettingsCtrl.js b/www/js/EventServerSettingsCtrl.js
index 2156f169..3763973a 100644
--- a/www/js/EventServerSettingsCtrl.js
+++ b/www/js/EventServerSettingsCtrl.js
@@ -2,71 +2,157 @@
/* jslint browser: true*/
/* global cordova,StatusBar,angular,console */
-angular.module('zmApp.controllers').controller('zmApp.EventServerSettingsCtrl', ['$scope','$ionicSideMenuDelegate', 'zm', '$stateParams','EventServer', '$ionicHistory', '$rootScope', '$state', 'message', 'ZMDataModel', function ($scope,$ionicSideMenuDelegate,zm, $stateParams, EventServer, $ionicHistory, $rootScope, $state, message, ZMDataModel) {
-$scope.openMenu = function () {
- $ionicSideMenuDelegate.toggleLeft();
- };
+angular.module('zmApp.controllers').controller('zmApp.EventServerSettingsCtrl', ['$scope', '$ionicSideMenuDelegate', 'zm', '$stateParams', 'EventServer', '$ionicHistory', '$rootScope', '$state', 'message', 'ZMDataModel', function ($scope, $ionicSideMenuDelegate, zm, $stateParams, EventServer, $ionicHistory, $rootScope, $state, message, ZMDataModel) {
+ $scope.openMenu = function () {
+ $ionicSideMenuDelegate.toggleLeft();
+ };
- $scope.openMenu = function () {
+ $scope.openMenu = function () {
$ionicSideMenuDelegate.toggleLeft();
};
-
- //----------------------------------------------------------------
+
+ //----------------------------------------------------------------
// Alarm notification handling
//----------------------------------------------------------------
- $scope.handleAlarms = function()
- {
- $rootScope.isAlarm=!$rootScope.isAlarm;
- if (!$rootScope.isAlarm)
- {
- $rootScope.alarmCount="0";
- $ionicHistory.nextViewOptions({disableBack: true});
-
-
- $state.go("events", {"id": 0}, { reload: true });
- }
- };
+ $scope.handleAlarms = function () {
+ $rootScope.isAlarm = !$rootScope.isAlarm;
+ if (!$rootScope.isAlarm) {
+ $rootScope.alarmCount = "0";
+ $ionicHistory.nextViewOptions({
+ disableBack: true
+ });
+
+ $state.go("events", {
+ "id": 0
+ }, {
+ reload: true
+ });
+ }
+ };
+
+ //----------------------------------------------------------------
+ // Save anyway when you exit
+ //----------------------------------------------------------------
$scope.$on('$ionicView.beforeLeave', function () {
- ZMDataModel.zmDebug("Saving Event Server data");
- var monstring="";
- for (var i=0; i < $scope.monitors.length; i++)
- {
- if ($scope.monitors[i].Monitor.isChecked)
- {
- monstring = monstring + $scope.monitors[i].Monitor.Id+",";
- }
- }
-
- if (monstring.charAt(monstring.length - 1) == ',')
+ saveItems();
+
+
+ });
+
+ //----------------------------------------------------------------
+ // Accordion list show/hide
+ //----------------------------------------------------------------
+
+ $scope.toggleGroup = function (group) {
+ if ($scope.isGroupShown(group)) {
+ $scope.shownGroup = null;
+ } else {
+ $scope.shownGroup = group;
+ }
+ };
+ $scope.isGroupShown = function (group) {
+ return $scope.shownGroup === group;
+ };
+
+ $scope.saveItems = function () {
+ saveItems();
+ };
+
+ //----------------------------------------------------------------
+ // Saves ES data
+ //----------------------------------------------------------------
+
+ function saveItems() {
+ ZMDataModel.zmDebug("Saving Event Server data");
+ var monstring = "";
+ var intervalstring = "";
+ for (var i = 0; i < $scope.monitors.length; i++) {
+ if (isNaN($scope.monitors[i].Monitor.reportingInterval)) {
+ $scope.monitors[i].Monitor.reportingInterval = 0;
+ }
+ if ($scope.monitors[i].Monitor.isChecked) {
+ monstring = monstring + $scope.monitors[i].Monitor.Id + ",";
+ var tint = isNaN($scope.monitors[i].Monitor.reportingInterval) ? 0 : parseInt($scope.monitors[i].Monitor.reportingInterval);
+ intervalstring = intervalstring + tint + ",";
+ }
+
+ }
+
+ if (monstring.charAt(monstring.length - 1) == ',')
monstring = monstring.substr(0, monstring.length - 1);
-
- $scope.loginData.eventServerMonitors = monstring;
-
- $scope.loginData.isUseEventServer = ($scope.check.isUseEventServer) ? "1" : "0";
-
- ZMDataModel.setLogin($scope.loginData);
- console.log ("**** EVENT MONSTRING " + monstring);
-
- if ($scope.loginData.isUseEventServer)
- {
+
+ if (intervalstring.charAt(intervalstring.length - 1) == ',')
+ intervalstring = intervalstring.substr(0, intervalstring.length - 1);
+
+ $scope.loginData.eventServerMonitors = monstring;
+ $scope.loginData.eventServerInterval = intervalstring;
+
+ $scope.loginData.isUseEventServer = ($scope.check.isUseEventServer) ? "1" : "0";
+
+ ZMDataModel.setLogin($scope.loginData);
+ console.log("**** EVENT MONSTRING " + monstring);
+ console.log("**** EVENT INTERVALSTRING " + intervalstring);
+
+ if ($scope.loginData.isUseEventServer) {
EventServer.init()
- .then(function(data) {
- console.log ("Sending control filter");
- EventServer.sendMessage ("control", { type:'filter',monlist:monstring});
- });
+ .then(function (data) {
+ console.log("Sending control filter");
+ EventServer.sendMessage("control", {
+ type: 'filter',
+ monlist: monstring,
+ intervalist: intervalstring
+ });
+ });
}
-
- });
+ }
+
+
+ //----------------------------------------------------------------
+ // returns reporting interval for monitor ID
+ //----------------------------------------------------------------
+ function getInterval(id) {
+ // means no interval, should only happen one time
+ // till we save
+ if ($scope.loginData.eventServerInterval == "")
+ return 0;
+ var retval = 0;
+ for (var i = 0; i < res.length; i++) {
+ if (res[i] == id) {
+ retval = parseInt(minterval[i]);
+ break;
+ }
+ }
+ return retval;
+ }
+
+ //----------------------------------------------------------------
+ // Returns true/false if monitor ID is in event monitor list
+ //----------------------------------------------------------------
+ function isEnabled(id) {
+ if ($scope.loginData.eventServerMonitors == "")
+ return true;
+
+ var isThere = false;
+ for (var i = 0; i < res.length; i++) {
+ if (res[i] == id) {
+ isThere = true;
+ console.log("isRes found: " + id);
+ break;
+ }
+ }
+ return isThere;
+ }
+
//-------------------------------------------------------------------------
// Controller Main
//------------------------------------------------------------------------
$scope.monitors = [];
$scope.monitors = message;
-
+
$scope.loginData = ZMDataModel.getLogin();
$scope.check = {
@@ -75,45 +161,28 @@ $scope.openMenu = function () {
$scope.check.isUseEventServer = ($scope.loginData.isUseEventServer == '1') ? true : false;
var res = $scope.loginData.eventServerMonitors.split(",");
-
- function isEnabled(id)
- {
- if ($scope.loginData.eventServerMonitors=="")
- return true;
-
- var isThere = false;
- for (var i=0; i<res.length; i++)
- {
- if (res[i]==id)
- {
- isThere = true;
- console.log ("isRes found: " + id);
- break;
- }
- }
- return isThere;
- }
-
-
-
- for (var i=0; i < $scope.monitors.length; i++)
- {
- if (!isEnabled($scope.monitors[i].Monitor.Id))
- {
+ var minterval = $scope.loginData.eventServerInterval.split(",");
+
+
+ for (var i = 0; i < $scope.monitors.length; i++) {
+
+
+ if (!isEnabled($scope.monitors[i].Monitor.Id)) {
// if the filter list has IDs and this is not part of it, uncheck it
- $scope.monitors[i].Monitor.isChecked = false;
- console.log ("Marking false");
- }
- else
- {
- console.log ("Marking true");
- $scope.monitors[i].Monitor.isChecked = true;
+ $scope.monitors[i].Monitor.isChecked = false;
+ console.log("Marking false");
+ $scope.monitors[i].Monitor.reportingInterval = 0;
+ } else {
+ console.log("Marking true");
+ $scope.monitors[i].Monitor.isChecked = true;
+ $scope.monitors[i].Monitor.reportingInterval = getInterval($scope.monitors[i].Monitor.Id);
}
+
}
-
-
-
-
-
-}]);
+
+
+
+
+
+}]); \ No newline at end of file
diff --git a/www/sounds/.DS_Store b/www/sounds/.DS_Store
new file mode 100644
index 00000000..a6356cd9
--- /dev/null
+++ b/www/sounds/.DS_Store
Binary files differ
diff --git a/www/templates/eventserversettings.html b/www/templates/eventserversettings.html
index a3ed37aa..74c05b20 100644
--- a/www/templates/eventserversettings.html
+++ b/www/templates/eventserversettings.html
@@ -4,6 +4,12 @@
<button class="button button-icon button-clear ion-navicon" ng-click="openMenu()"></button>
<button data-badge="{{$root.alarmCount}}" class="animated infinite tada button button-icon button-clear ion-ios-bell notification-badge" ng-click="handleAlarms();" ng-if="$root.isAlarm"></button>
</ion-nav-buttons>
+
+
+ <ion-nav-buttons side="right">
+ <button class="button button-clear" ng-click="saveItems()">Save</button>
+ </ion-nav-buttons>
+
<ion-content>
<ion-checkbox ng-model="check.isUseEventServer">use event server</ion-checkbox>
@@ -14,18 +20,72 @@
</label>
+
+ <ion-list>
+ <div ng-repeat="monitor in monitors">
+
+ <ion-item class="custom-list"
+ ng-click="toggleGroup(monitor)"
+ ng-class="{active: isGroupShown(monitor)}">
+ <i class="icon" ng-class="isGroupShown(monitor) ? 'ion-minus' : 'ion-plus'"></i>
+ &nbsp;
- <ul class="list" ng-if="check.isUseEventServer">
+ {{monitor.Monitor.Name}}
+ </ion-item>
+
+ <ion-item class="item-accordion"
+ ng-show="isGroupShown(monitor)">
+ <span class="item-checkbox">
+
+ report events
+ <label class="checkbox">
+ <input type="checkbox" ng-model="monitor.Monitor.isChecked" ng-checked="monitor.Monitor.isChecked">
+ </label>
+ </span>
+ </ion-item>
+
+ <ion-item class="item-accordion"
+ ng-show="isGroupShown(monitor)">
+ <div class=" item-input-inset">
+ <label class="item-input-wrapper">
+ <input type="tel" placeholder="sec." ng-model="monitor.Monitor.reportingInterval">
+ </label>
+ &nbsp;min. reporting interval
+
+
+ </div>
+ </ion-item>
+
+
+ </div>
+
+ </ion-list>
+
+
- <li class="item item-checkbox" ng-repeat="monitor in monitors">
- <label class="checkbox">
- <input type="checkbox" ng-model="monitor.Monitor.isChecked" ng-checked="monitor.Monitor.isChecked">
- </label>
- {{monitor.Monitor.Name}}
- </li>
+ <!-- <ul class="list" ng-if="check.isUseEventServer">
+http://codepen.io/anon/pen/QbVveV
+ <div class="item-icon-right">
+ <li class="item item-checkbox" ng-repeat="monitor in monitors">
+ <label class="checkbox">
+ <input type="checkbox" ng-model="monitor.Monitor.isChecked" ng-checked="monitor.Monitor.isChecked">
+ </label>
+ {{monitor.Monitor.Name}}
+ <i class="icon ion-ios-arrow-down"></i>
+ </li>
+ </div>
- </ul>
+
+ </ul>-->
</ion-content>
-</ion-view> \ No newline at end of file
+</ion-view>
+
+
+
+<!--
+ <label class="checkbox">
+ <input type="checkbox" ng-model="monitor.Monitor.isChecked" ng-checked="monitor.Monitor.isChecked">
+ </label>
+ {{monitor.Monitor.Name}}--> \ No newline at end of file