diff options
Diffstat (limited to 'www')
| -rw-r--r-- | www/js/MomentCtrl.js | 29 | ||||
| -rw-r--r-- | www/templates/moment.html | 4 |
2 files changed, 29 insertions, 4 deletions
diff --git a/www/js/MomentCtrl.js b/www/js/MomentCtrl.js index e6fc34cf..1851dca7 100644 --- a/www/js/MomentCtrl.js +++ b/www/js/MomentCtrl.js @@ -55,6 +55,21 @@ angular.module('zmApp.controllers').controller('zmApp.MomentCtrl', ['$scope', '$ NVRDataModel.debug("Constructed Monitor Filter =" + excludeMonitorsFilter); } + //---------------------------------------------------------------- + // calculates array index from eid + // we can't pass $index as events get collapsed messing up $index + //---------------------------------------------------------------- + + function getIndexFromEID(eid) { + var found = -1; + for (var i=0; i < moments.length; i++) { + if (parseInt(moments[i].Event.Id) == parseInt(eid)) { + found = i; + break; + } + } + return found; // really should never be -1 + } //---------------------------------------------------------------- // Given a payload of raw events from JSON, massages it with more @@ -227,7 +242,12 @@ angular.module('zmApp.controllers').controller('zmApp.MomentCtrl', ['$scope', '$ // down quickly. //---------------------------------------------------------------- - $scope.togglePin = function (ndx) { + $scope.togglePin = function (eid) { + var ndx = getIndexFromEID(eid); + if (ndx == -1) { + NVRDataModel.log ("Uh oh, ndx returned -1, this should never happen. Event passed was "+eid); + return; + } $scope.moments[ndx].Event.pinned = !$scope.moments[ndx].Event.pinned; if ($scope.moments[ndx].Event.pinned) { $scope.moments[ndx].Event.pinnedIcon = " ion-pin assertive"; @@ -249,11 +269,16 @@ angular.module('zmApp.controllers').controller('zmApp.MomentCtrl', ['$scope', '$ // when a user expands back on an eid, all eids after that for the // same monitor should expand, even if they were grouped earlier - $scope.toggleCollapse = function (mid, eid, ndx) { + $scope.toggleCollapse = function (mid, eid) { NVRDataModel.debug("toggling collapse for:" + mid); var collapseCount = 0; var hide = false; + var ndx = getIndexFromEID(eid); + if (ndx == -1) { + NVRDataModel.log ("Uh oh, ndx returned -1, this should never happen. Event passed was "+eid); + return; + } $scope.moments[ndx].Event.hide = false; if ($scope.moments[ndx].Event.icon == 'ion-code-working') { diff --git a/www/templates/moment.html b/www/templates/moment.html index c4d5e25d..081885b5 100644 --- a/www/templates/moment.html +++ b/www/templates/moment.html @@ -87,7 +87,7 @@ <figure class="grid-item grid-item-{{gridSize}}" ng-repeat="moment in moments | onlyEnabledMoments"> <figcaption ng-if="showIcons" class="normal-figheader"> {{moment.Event.monitorName}} <span style="float:right"> - <button class="button button-small button-icon icon {{moment.Event.icon}}" ng-click="toggleCollapse(moment.Event.MonitorId, moment.Event.Id, $index)"></button>{{moment.Event.collapseCount}} </span> + <button class="button button-small button-icon icon {{moment.Event.icon}}" ng-click="toggleCollapse(moment.Event.MonitorId, moment.Event.Id)"></button>{{moment.Event.collapseCount}} </span> </figcaption> <img image-spinner-src="{{moment.Event.baseURL}}/index.php?view=image&fid={{moment.Event.MaxScoreFrameId}}&width={{moment.Event.thumbWidth*2}}&height={{moment.Event.thumbHeight*2}}" img-spinner-w="{{moment.Event.width}}" img-spinner-h="{{moment.Event.height}}" image-spinner-loader="lines" on-tap="playEvent(moment)" @@ -95,7 +95,7 @@ <figcaption ng-if="showIcons" class="normal-subfigcaption"> <span style="float:right"> - <button class="button button-small button-icon icon {{moment.Event.pinnedIcon}}" ng-click="togglePin( $index)"></button> + <button class="button button-small button-icon icon {{moment.Event.pinnedIcon}}" ng-click="togglePin(moment.Event.Id)"></button> </span> </figcaption> <!--on-tap="showThumbnail(moment.Event.baseURL,moment.Event.MaxScoreFrameId)"--> |
