From 036231b5d292665b5696373186d03b5cd5e6d4c7 Mon Sep 17 00:00:00 2001 From: Kyle Johnson Date: Wed, 18 Feb 2015 12:11:55 -0500 Subject: [PATCH] Fix bug: 'mid' was not properly set Since migrating to ui-router, the monitor's ID was not properly set when trying to edit an existing monitor. This caused existing monitors to not load properly when in the edit / detail page. Now, the monitor id (mid) is set as a state parameter, and is accessed from $state.params.mid --- web/js/app.js | 5 +++-- web/js/controllers.js | 8 +++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/web/js/app.js b/web/js/app.js index ddef820ca..c0a190150 100644 --- a/web/js/app.js +++ b/web/js/app.js @@ -50,8 +50,9 @@ ZoneMinder.config(function($stateProvider, $urlRouterProvider) { // This state is a child of 'monitor'. The URL will end up being like: // '/monitor/{mid:[0-9]{1,4}}'. When the URL becomes something like '/monitor/7', // this state will become active. - url: '/{mid:[0-9]{1,4}}', - templateUrl: '/views/monitor.detail.html' + url: '/detail/{mid:[0-9]{1,4}}', + templateUrl: '/views/monitor.detail.html', + controller: 'MonitorController' }) //////////////////////////// diff --git a/web/js/controllers.js b/web/js/controllers.js index 5f1483080..8f0b07bf8 100644 --- a/web/js/controllers.js +++ b/web/js/controllers.js @@ -203,11 +203,9 @@ ZoneMinder.controller('EventController', function($scope, Event, $modalInstance, }; }); -ZoneMinder.controller('MonitorController', function($scope, $http, $location, Monitor, Console) { - // If mid is set, we're editing a monitor. Else, we're adding one. - var mid = $location.search().mid; - if (mid) { - Monitor.getMonitor(mid).then(function(results) { +ZoneMinder.controller('MonitorController', function($scope, $state, $http, Monitor, Console) { + if ($state.params.mid) { + Monitor.getMonitor($state.params.mid).then(function(results) { $scope.monitor = results.data.monitor.Monitor; }); } else {