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
This commit is contained in:
Kyle Johnson 2015-02-18 12:11:55 -05:00
parent 29bcbb2af9
commit 036231b5d2
2 changed files with 6 additions and 7 deletions

View File

@ -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'
})
////////////////////////////

View File

@ -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 {