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:
|
||||
// '/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'
|
||||
})
|
||||
|
||||
////////////////////////////
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue