diff --git a/web/skins/bootstrap/js/app.js b/web/skins/bootstrap/js/app.js index f01f943e7..dac90f048 100644 --- a/web/skins/bootstrap/js/app.js +++ b/web/skins/bootstrap/js/app.js @@ -78,6 +78,9 @@ ZoneMinder.factory('Event', function($http) { return { getEvent: function(eventId) { return $http.get('/api/events/'+ eventId +'.json'); + }, + delete: function(eventId) { + return $http.delete('/api/events/'+ eventId + '.json'); } }; }); diff --git a/web/skins/bootstrap/js/controllers.js b/web/skins/bootstrap/js/controllers.js index a629e0618..4e5b046e1 100644 --- a/web/skins/bootstrap/js/controllers.js +++ b/web/skins/bootstrap/js/controllers.js @@ -23,13 +23,19 @@ ZoneMinder.controller('LogController', function($scope, Log) { }); }); -ZoneMinder.controller('EventsController', function($scope, Events) { +ZoneMinder.controller('EventsController', function($scope, Events, $modal) { + // First thing, get page 1 of the events. getEventsPage(1); + // If the page is changed, get the new page of events $scope.pageChanged = function(newPage) { getEventsPage(newPage); }; + // Call Events.get and pass it the page number + // Set the appropriate scope values with the results. + // The events.php file takes over and iterates over events + // and the painator uses totalEvents and eventPerPage function getEventsPage(pageNumber) { Events.get(pageNumber).then(function(results) { $scope.events = results.data.events; @@ -37,11 +43,28 @@ ZoneMinder.controller('EventsController', function($scope, Events) { $scope.eventsPerPage = results.data.pagination.limit; }); } + + // This is called when a user clicks on an event. + // It fires up a modal and passes it the EventId of the clicked event + // EventController takes over from there. + $scope.displayEvent = function (eventId) { + $scope.eventId = eventId; + + var modalInstance = $modal.open({ + templateUrl: '/?view=event&skin=bootstrap', + controller: 'EventController', + resolve: { eventId: function () { return $scope.eventId; } } + }); + + modalInstance.result.then(function (selectedItem) { + }, function () { + console.log('Modal dismissed at: ' + new Date()); + } + ); + }; }); -ZoneMinder.controller('EventController', function($scope, $location, Event) { - - var eventId = $location.search().eid; +ZoneMinder.controller('EventController', function($scope, Event, $modalInstance, eventId) { Event.getEvent(eventId).then(function(results) { $scope.eventId = eventId; @@ -57,9 +80,17 @@ ZoneMinder.controller('EventController', function($scope, $location, Event) { $scope.avgScore = results.data.event.Event.AvgScore; $scope.maxScore = results.data.event.Event.MaxScore; $scope.notes = results.data.event.Event.Notes; - - }); + + $scope.cancel = function () { + $modalInstance.dismiss('cancel'); + }; + + $scope.deleteEvent = function() { + Event.delete(eventId).then(function(results) { + console.log(results); + }); + }; }); ZoneMinder.controller('MonitorController', function($scope, $http, $location, Monitor) { diff --git a/web/skins/bootstrap/views/event.php b/web/skins/bootstrap/views/event.php index bb9d1f1ed..73e5a5fc4 100644 --- a/web/skins/bootstrap/views/event.php +++ b/web/skins/bootstrap/views/event.php @@ -1,224 +1,26 @@ - + + Event {{eventId}} + -if ( !canView( 'Events' ) ) -{ - $view = "error"; - return; -} + -$sql = 'SELECT E.*,M.Name AS MonitorName,M.DefaultRate,M.DefaultScale FROM Events AS E INNER JOIN Monitors AS M ON E.MonitorId = M.Id WHERE E.Id = ?'.$midSql; -$event = dbFetchOne( $sql, NULL, array($eid) ); - -if ( isset( $_REQUEST['rate'] ) ) - $rate = validInt($_REQUEST['rate']); -else - $rate = reScale( RATE_BASE, $event['DefaultRate'], ZM_WEB_DEFAULT_RATE ); -if ( isset( $_REQUEST['scale'] ) ) - $scale = validInt($_REQUEST['scale']); -else - $scale = reScale( SCALE_BASE, $event['DefaultScale'], ZM_WEB_DEFAULT_SCALE ); - -$replayModes = array( - 'single' => $SLANG['ReplaySingle'], - 'all' => $SLANG['ReplayAll'], - 'gapless' => $SLANG['ReplayGapless'], -); - -if ( isset( $_REQUEST['streamMode'] ) ) - $streamMode = validHtmlStr($_REQUEST['streamMode']); -else - $streamMode = canStream()?'stream':'stills'; - -if ( isset( $_REQUEST['replayMode'] ) ) - $replayMode = validHtmlStr($_REQUEST['replayMode']); -if ( isset( $_COOKIE['replayMode']) && preg_match('#^[a-z]+$#', $_COOKIE['replayMode']) ) - $replayMode = validHtmlStr($_COOKIE['replayMode']); -else { - $keys = array_keys( $replayModes ); - $replayMode = array_shift( $keys ); -} - -parseSort(); -parseFilter( $_REQUEST['filter'] ); -$filterQuery = $_REQUEST['filter']['query']; - -$panelSections = 40; -$panelSectionWidth = (int)ceil(reScale($event['Width'],$scale)/$panelSections); -$panelWidth = ($panelSections*$panelSectionWidth-1); - -$connkey = generateConnKey(); - -$focusWindow = true; - -xhtmlHeaders(__FILE__, $SLANG['Event'] ); -?> - -
-
-
- - - - - - - - - -
s{{ frames }} / {{ alarmFrames }}{{ totScore }} / {{ avgScore }} / {{ maxScore }}
-
- - -
-
- -
-

- - - - - - - - - -

-
- Mode:   - Rate: x - Progress: s - Zoom: x -
- -
- -
-
- - + diff --git a/web/skins/bootstrap/views/events.php b/web/skins/bootstrap/views/events.php index 50b072db1..915376e9e 100644 --- a/web/skins/bootstrap/views/events.php +++ b/web/skins/bootstrap/views/events.php @@ -18,25 +18,23 @@ -
-
- - ... -
-
- Monitor {{event.Event.MonitorId}} - {{ event.Event.StartTime | DateDiff:event.Event.EndTime:'pretty' }} - Event {{event.Event.Id}} -
-
-
+
+
+ ... +
+
+ Monitor {{event.Event.MonitorId}} + {{ event.Event.StartTime | DateDiff:event.Event.EndTime:'pretty' }} + Event {{event.Event.Id}} +
+
-
-
+ +