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:
parent
29bcbb2af9
commit
036231b5d2
|
@ -50,8 +50,9 @@ ZoneMinder.config(function($stateProvider, $urlRouterProvider) {
|
||||||
// This state is a child of 'monitor'. The URL will end up being like:
|
// 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',
|
// '/monitor/{mid:[0-9]{1,4}}'. When the URL becomes something like '/monitor/7',
|
||||||
// this state will become active.
|
// this state will become active.
|
||||||
url: '/{mid:[0-9]{1,4}}',
|
url: '/detail/{mid:[0-9]{1,4}}',
|
||||||
templateUrl: '/views/monitor.detail.html'
|
templateUrl: '/views/monitor.detail.html',
|
||||||
|
controller: 'MonitorController'
|
||||||
})
|
})
|
||||||
|
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
|
|
|
@ -203,11 +203,9 @@ ZoneMinder.controller('EventController', function($scope, Event, $modalInstance,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
ZoneMinder.controller('MonitorController', function($scope, $http, $location, Monitor, Console) {
|
ZoneMinder.controller('MonitorController', function($scope, $state, $http, Monitor, Console) {
|
||||||
// If mid is set, we're editing a monitor. Else, we're adding one.
|
if ($state.params.mid) {
|
||||||
var mid = $location.search().mid;
|
Monitor.getMonitor($state.params.mid).then(function(results) {
|
||||||
if (mid) {
|
|
||||||
Monitor.getMonitor(mid).then(function(results) {
|
|
||||||
$scope.monitor = results.data.monitor.Monitor;
|
$scope.monitor = results.data.monitor.Monitor;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue