diff options
| author | Pliable Pixels <pliablepixels@gmail.com> | 2020-05-06 16:04:20 -0400 |
|---|---|---|
| committer | Pliable Pixels <pliablepixels@gmail.com> | 2020-05-06 16:04:20 -0400 |
| commit | 0c1a83887147350dfce9c233bc12b6f72eee449a (patch) | |
| tree | 17ec916c38abe1c212adf14ececac0b4eb6383d2 | |
| parent | c0329cd12b864db809937ef7e99e36332260c3e7 (diff) | |
#939 Groups support in montage screen view new API
| -rw-r--r-- | config.xml | 5 | ||||
| -rw-r--r-- | package.json | 6 | ||||
| -rw-r--r-- | www/js/MontageCtrl.js | 93 | ||||
| -rw-r--r-- | www/js/NVR.js | 139 | ||||
| -rw-r--r-- | www/lang/locale-en.json | 1 | ||||
| -rw-r--r-- | www/templates/montage.html | 11 |
6 files changed, 234 insertions, 21 deletions
@@ -1,5 +1,5 @@ <?xml version='1.0' encoding='utf-8'?> -<widget android-packageName="com.pliablepixels.zmninja_pro" id="com.pliablepixels.zmninja_pro" ios-CFBundleIdentifier="com.pliablepixels.zmninja-pro" version="1.4.005" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0"> +<widget android-packageName="com.pliablepixels.zmninja_pro" id="com.pliablepixels.zmninja_pro" ios-CFBundleIdentifier="com.pliablepixels.zmninja-pro" version="1.4.006" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0"> <name>zmNinja</name> <description> High performance ZoneMinder client @@ -186,9 +186,6 @@ <plugin name="cordova-plugin-app-version" spec="0.1.9" /> <plugin name="cordova-plugin-inappbrowser" spec="https://github.com/apache/cordova-plugin-inappbrowser.git" /> <plugin name="cordova-plugin-statusbar" spec="~2.4.4-dev" /> - <plugin name="cordova-plugin-ionic-webview" spec="https://github.com/pliablepixels/cordova-plugin-ionic-webview.git"> - <variable name="ANDROID_SUPPORT_ANNOTATIONS_VERSION" value="27.+" /> - </plugin> <plugin name="cordova-plugin-media-pp-fork" spec="^1.0.2-dev" /> <engine name="android" spec="8.0.0" /> <engine name="ios" spec="5.1.1" /> diff --git a/package.json b/package.json index f78f5c81..42da4ad2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "zmninjapro", "description": "Home security mobile app for ZoneMinder", - "version": "1.4.005", + "version": "1.4.006", "displayName": "zmNinja", "author": "Pliable Pixels", "license": "custom see LICENSE.md", @@ -61,9 +61,6 @@ "cordova-plugin-inappbrowser": {}, "cordova-plugin-app-version": {}, "cordova-plugin-statusbar-pp-fork": {}, - "cordova-plugin-ionic-webview": { - "ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+" - }, "cordova-plugin-media-pp-fork": {} } }, @@ -89,7 +86,6 @@ "cordova-plugin-inappbrowser": "git+https://github.com/apache/cordova-plugin-inappbrowser.git", "cordova-plugin-insomnia": "^4.3.0", "cordova-plugin-ionic-keyboard": "2.2.0", - "cordova-plugin-ionic-webview": "git+https://github.com/pliablepixels/cordova-plugin-ionic-webview.git", "cordova-plugin-media-pp-fork": "^1.0.2-dev", "cordova-plugin-multi-window": "0.0.3", "cordova-plugin-network-information": "^2.0.2", diff --git a/www/js/MontageCtrl.js b/www/js/MontageCtrl.js index 90cfac1c..8663918b 100644 --- a/www/js/MontageCtrl.js +++ b/www/js/MontageCtrl.js @@ -257,7 +257,7 @@ angular.module('zmApp.controllers') NVR.debug ("error parsing profile"); } - NVR.log("found a packery layout"); + // NVR.log("found a packery layout:"+positionsStr); layouttype = false; } @@ -800,6 +800,10 @@ angular.module('zmApp.controllers') $scope.saveReorder = function () { NVR.debug("Saving monitor hide/unhide"); + $scope.currentZMGroupName=''; + var ld = NVR.getLogin(); + ld.currentZMGroupName = ''; + NVR.setLogin(ld); $scope.modal.remove(); $scope.MontageMonitors = $scope.copyMontage; // call finish reorder after modal is gone @@ -960,6 +964,89 @@ angular.module('zmApp.controllers') }; + $scope.selectZMGroup = function() { + + $scope.newGroup = { + val: "" + }; + + + + + $scope.tempZMGroups = angular.copy($scope.zmGroups); + $scope.tempZMGroups.push($translate.instant('kNone')); + + $rootScope.zmPopup = $ionicPopup.show({ + scope: $scope, + template: '<ion-radio-fix ng-if="item" ng-repeat="item in tempZMGroups" ng-value="item" ng-model="newGroup.val" > {{item}} </ion-radio-fix>', + + title: $translate.instant('kSelect'), + subTitle: $translate.instant('kActive') + ': '+ NVR.getLogin().currentZMGroupName, + + buttons: [{ + text: $translate.instant('kButtonCancel'), + onTap: function (e) { + + } + + }, + { + text: $translate.instant('kButtonOk'), + onTap: function (e) { + NVR.log("Group selected:" + $scope.newGroup.val); + var ld = NVR.getLogin(); + if ($scope.newGroup.val == $translate.instant('kNone')) $scope.newGroup.val=''; + + if ($scope.newGroup.val != ld.currentZMGroupName) { + + ld.currentZMGroupName = $scope.newGroup.val; + NVR.setLogin(ld); + $scope.currentZMGroupName = ld.currentZMGroupName; + + if (simulStreaming) currentStreamState = streamState.STOPPED; + + for (var i = 0; i < $scope.MontageMonitors.length; i++) { + if ($scope.MontageMonitors[i].Monitor.listDisplay == 'show' && simulStreaming) NVR.killLiveStream($scope.MontageMonitors[i].Monitor.connKey, $scope.MontageMonitors[i].Monitor.controlURL); + + console.log ('Working on '+$scope.MontageMonitors[i].Monitor.Name+" with ZMG "+ld.currentZMGroupName ); + var isInGroup = !ld.currentZMGroupName ? true: false; + if (ld.currentZMGroupName) { + for (var k=0; k < $scope.MontageMonitors[i].Monitor.Group.length; k++) { + if ($scope.MontageMonitors[i].Monitor.Group[k].name==ld.currentZMGroupName) { + isInGroup = true; + break; + + } + } + } + + $scope.MontageMonitors[i].Monitor.listDisplay = isInGroup? 'show':'noshow'; + // console.log ('----> Setting '+ $scope.MontageMonitors[i].Monitor.Name+' to '+ $scope.MontageMonitors[i].Monitor.listDisplay); + + + } + + $timeout ( function () { + beforeReorderPositions = pckry.getShiftPositions('data-item-id'); + finishReorder(); + $timeout(function () { + pckry.layout(); + },600); + },300); + + } else { + NVR.debug ("No action taken as selection is same as current"); + } + + } + } + ] + }); + + + + }; + $scope.selectUnselectAllToggleReorder = function () { $scope.reorder.selected = !$scope.reorder.selected; @@ -2242,6 +2329,10 @@ angular.module('zmApp.controllers') $scope.eventModalOpen = false; + + $scope.zmGroups = NVR.listOfZMGroups(); + $scope.currentZMGroupName = NVR.getLogin().currentZMGroupName; + $scope.$on ( "process-push", function () { NVR.debug (">> MontageCtrl: push handler"); var s = NVR.evaluateTappedNotification(); diff --git a/www/js/NVR.js b/www/js/NVR.js index e6eadfd8..6fed062b 100644 --- a/www/js/NVR.js +++ b/www/js/NVR.js @@ -21,7 +21,7 @@ angular.module('zmApp.controllers') DO NOT TOUCH zmAppVersion It is changed by sync_version.sh */ - var zmAppVersion = "1.4.005"; + var zmAppVersion = "1.4.006"; var isBackground = false; var justResumed = false; @@ -33,6 +33,7 @@ angular.module('zmApp.controllers') var monitors = []; + var zmgroups = []; var multiservers = []; var migrationComplete = false; @@ -223,6 +224,9 @@ angular.module('zmApp.controllers') 'showAnimation': true, 'montageHideFooter': false, 'httpCordovaNoEncode': false, + 'currentZMGroupName': '', + 'unsupported': {} + }; @@ -301,6 +305,22 @@ angular.module('zmApp.controllers') return true; } + + function clear_unsupported() { + loginData.unsupported = {}; + setLogin(loginData); + } + + function set_unsupported(p) { + loginData.unsupported[p] = true; + debug ('Setting '+p+' to unsupported'); + setLogin(loginData); + } + + function get_unsupported(p) { + return p? loginData.unsupported[p]:loginData.unsupported; + } + function getBandwidth() { // if mode is not on always return high if (loginData.enableLowBandwidth == false) { @@ -370,13 +390,19 @@ angular.module('zmApp.controllers') } function delete_all_caches() { + debug ('Clearing all unsupported flags'); + clear_unsupported(); + debug ('CACHE: Flushing all network API caches...'); return localforage.removeItem('cached_monitors') .then ( function () {return localforage.removeItem('cached_api_version');}) .then ( function () {return localforage.removeItem('cached_multi_servers');}) .then ( function () {return localforage.removeItem('cached_multi_port');}) .then ( function () {return localforage.removeItem('cached_timezone');}) + .then ( function () {return localforage.removeItem('cached_zmgroups');}) .catch ( function (err) {debug ('Error removing all caches: '+JSON.stringify(err));}); + + } @@ -451,7 +477,7 @@ angular.module('zmApp.controllers') return d.promise; }) .catch ( function (err) { - log ('CACHE: error with http get '+err); + log ('CACHE: error with http get '+JSON.stringify(err)); d.reject(err); return d.promise; }); @@ -459,13 +485,67 @@ angular.module('zmApp.controllers') }) .catch ( function (err) { - debug ('cache_or_http error:'+err); - return $http.get(url); + //debug ('cache_or_http error:'+JSON.stringify(err)); + d.reject(err); + return d.promise; + //return $http.get(url); }) ; - debug ('returning promise'); + //debug ('returning promise'); return d.promise; } + function getZMGroups() { + //{"groups":[{"Group":{"Id":"1","Name":"test","ParentId":null}},{"Group":{"Id":"2","Name":"test2","ParentId":null}}]} + var d = $q.defer(); + + if (get_unsupported('groups_associations')) { + debug ('Groups Association API is marked as unsupported, not invoking'); + d.resolve(true); + return d.promise; + } + + var apiurl = loginData.apiurl+'/groups/associations.json?'+$rootScope.authSession; + + for (var m=0; m < monitors.length; m++ ) { + if (!monitors[m].Monitor.Group) monitors[m].Monitor.Group=[]; + } + + cache_or_http(apiurl, 'cached_zmgroups') + .then (function (data) { + data = data.data; +// console.log (JSON.stringify(data)); + + debug ('Groups are:'+JSON.stringify(data)); + if (data && data.groups) { + for (var i=0; i< data.groups.length; i++) { + zmgroups.push(data.groups[i].Group.Name); + //console.log( "Checking Group "+data.groups[i].Group.Name); + for (var j=0; j < data.groups[i].Monitor.length; j++) { + for (var k = 0; k < monitors.length; k++) { + // console.log(k); + if (monitors[k].Monitor.Id == data.groups[i].Monitor[j].Id) { + monitors[k].Monitor.Group.push({'id':data.groups[i].Group.Id, 'name':data.groups[i].Group.Name}); + // console.log ('Monitor: '+ monitors[k].Monitor.Name+" belongs to Group:"+data.groups[i].Group.Name); + } + } // monitors + } // groups monitors + } // groups + d.resolve(true); + return (d.promise); + } else { + debug ('No groups found'); + d.resolve(true); + return (d.promise); + } + }, function (err) { + debug('Error retrieving groups:'+JSON.stringify(err)); + set_unsupported('groups_associations'); + d.resolve(true); + return (d.promise); + }); + return (d.promise); + } + function getZmsMultiPortSupport(forceReload) { var d = $q.defer(); if (configParams.ZM_MIN_STREAMING_PORT == -1 || forceReload) { @@ -1637,13 +1717,24 @@ angular.module('zmApp.controllers') if (typeof loginData.montageHideFooter == 'undefined') { loginData.montageHideFooter = false; } + if (typeof loginData.httpCordovaNoEncode == 'undefined') { loginData.httpCordovaNoEncode = false; } + + if (typeof loginData.currentZMGroupName == 'undefined') { + loginData.currentZMGroupName = ''; + } + + if (typeof loginData.unsupported == 'undefined') { + loginData.unsupported = {}; + } + + loginData.canSwipeMonitors = true; loginData.forceImageModePath = false; @@ -1754,6 +1845,18 @@ angular.module('zmApp.controllers') return { + clear_unsupported: function () { + return clear_unsupported(); + }, + + set_unsupported: function (data) { + return set_unsupported(data); + }, + + get_unsupported: function (data) { + return get_unsupported(data); + }, + encrypt: function(data) { return encrypt(data); }, @@ -2626,6 +2729,9 @@ angular.module('zmApp.controllers') }, + getZMGroups: function () { + return getZMGroups(); + }, //----------------------------------------------------------------------------- // This function returns the numdigits for padding capture images @@ -2735,6 +2841,10 @@ angular.module('zmApp.controllers') return monitors; }, + listOfZMGroups: function () { + return zmgroups; + }, + pauseLiveStream: function (ck, url, name) { if (!url) url = loginData.url; @@ -2811,6 +2921,8 @@ angular.module('zmApp.controllers') return regenConnKeys (mon); }, + + getMonitors: function (forceReload) { //console.log("** Inside ZMData getMonitors with forceReload=" + forceReload); @@ -2832,7 +2944,7 @@ angular.module('zmApp.controllers') var apiurl = loginData.apiurl; var myurl = apiurl + "/monitors"; myurl += "/index/"+"Type !=:WebSite.json" + "?"+$rootScope.authSession; - + getZmsMultiPortSupport() .then(function (zmsPort) { @@ -3069,7 +3181,11 @@ angular.module('zmApp.controllers') } // now get packery hide if applicable reloadMonitorDisplayStatus(); - d.resolve(monitors); + getZMGroups().then ( function (succ) { + d.resolve(monitors); + return d.promise; + }); + return d.promise; }, function (err) { log("multi server list loading error"); @@ -3109,7 +3225,11 @@ angular.module('zmApp.controllers') //debug("API " + $rootScope.apiVersion + ": Monitor " + monitors[i].Monitor.Id + " will use " + monitors[i].Monitor.imageMode + " for direct image access"); } - d.resolve(monitors); + getZMGroups().then ( function (succ) { + d.resolve(monitors); + return d.promise; + }); + return d.promise; }); @@ -3128,9 +3248,10 @@ angular.module('zmApp.controllers') d.resolve(monitors); $ionicLoading.hide(); monitorsLoaded = 0; + return d.promise; }); }); - + return d.promise; } else // monitors are loaded diff --git a/www/lang/locale-en.json b/www/lang/locale-en.json index 4c9211ea..76fcd414 100644 --- a/www/lang/locale-en.json +++ b/www/lang/locale-en.json @@ -273,6 +273,7 @@ "kNoMoreEvents" :"no more events", "kNormalPlay" :"normal play", "kNote" :"Note", + "kNone" :"None", "kNow" :"now", "kObfuscation" : "Data obfuscation", "kObfuscationAES" :"AES (encrypt)", diff --git a/www/templates/montage.html b/www/templates/montage.html index 8c0e3ab8..78ccb87f 100644 --- a/www/templates/montage.html +++ b/www/templates/montage.html @@ -1,5 +1,5 @@ <ion-view cache-view="false" hide-nav-bar="{{minimal}}"> - <ion-nav-title>{{currentProfileName}}</ion-nav-title> + <ion-nav-title>{{currentProfileName}} {{currentZMGroupName}}</ion-nav-title> <ion-nav-buttons side="left"> <button id="montage-move-1" class="button button-icon button-clear ion-navicon" ng-click="openMenu()"></button> @@ -47,8 +47,15 @@ <ul> <!-- <li> <a href="" ng-click="killAllImages()"> <i class="ion-ionic"></i></a> - </li>--> + + </li>--> + + <li ng-if="zmGroups.length"> + <a ng-click="selectZMGroup()"> + <i class="ion-folder"></i> + </a> + </li> <li ng-if="!$root.LoginData.isKiosk"> <a id="montage-move-4" ng-click="sliderChanged(1)"> <i class="ion-plus-circled"></i> |
