Add support for editing an existing monitor

Saving and editing of monitors now works.  Tested only with
Type = Remote.

There is a bug where when editing a monitor, Orientation is not
set properly.  Due to number vs. string and mysql enum.
0 != '0'
This commit is contained in:
Kyle Johnson 2014-12-21 21:44:18 -05:00
parent 44a44580b7
commit 1fadbff72d
1 changed files with 49 additions and 31 deletions

View File

@ -46,39 +46,57 @@ ZoneMinder.controller('EventController', function($scope, $location, Event) {
}); });
}); });
ZoneMinder.controller('MonitorController', function($scope, $http) { ZoneMinder.controller('MonitorController', function($scope, $http, $location, Monitor) {
$scope.monitor = {}; // If mid is set, we're editing a monitor. Else, we're adding one.
$scope.monitor.Type = 'Remote'; var mid = $location.search().mid;
$scope.monitor.RefBlendPerc = 6; if (mid) {
$scope.monitor.AlarmRefBlendPerc = 6; Monitor.getMonitor(mid).then(function(results) {
$scope.monitor.Function = 'Monitor'; $scope.monitor = results.data.monitor.Monitor;
$scope.monitor.ImageBufferCount = 100; });
$scope.monitor.WarmupCount = 25; } else {
$scope.monitor.PreEventCount = 50; // Assign each monitor a random color, as opposed to them all being 'red'
$scope.monitor.PostEventCount = 50; var color = '#' + (Math.random() * 0xFFFFFF << 0).toString(16);
$scope.monitor.StreamReplayBuffer = 1000;
$scope.monitor.AlarmFrameCount = 1; // This is where the monitor's 'form data' is saved
$scope.monitor.LabelFormat = '%N - %d/%m/%y %H:%M:%S'; // It is sent to saveMonitor when the save button is clicked
$scope.monitor.LabelX = 0; $scope.monitor = {
$scope.monitor.LabelY = 0; // Set default values for a monitor
$scope.monitor.Colours = 3; 'Type' : 'Remote',
$scope.monitor.Orientation = 0; 'RefBlendPerc' : 6,
$scope.monitor.Enabled = true; 'AlarmRefBlendPerc' : 6,
$scope.monitor.Protocol = 'http'; 'Function' : 'Monitor',
$scope.monitor.SectionLength = 600; 'ImageBufferCount' : 100,
$scope.monitor.EventPrefix = 'Event-'; 'WarmupCount' : 25,
$scope.monitor.FrameSkip = 0; 'PreEventCount' : 50,
$scope.monitor.MotionFrameSkip = 0; 'PostEventCount' : 50,
$scope.monitor.FPSReportInterval = 1000; 'StreamReplayBuffer' : 1000,
$scope.monitor.DefaultView = 'Events'; 'AlarmFrameCount' : 1,
$scope.monitor.DefaultRate = 100; 'LabelFormat' : '%N - %d/%m/%y %H:%M:%S',
$scope.monitor.DefaultScale = 100; 'LabelX' : 0,
$scope.monitor.SignalCheckColour = '#0000c0'; 'LabelY' : 0,
$scope.monitor.Method = 'simple'; 'Colours' : 3,
var color = '#' + (Math.random() * 0xFFFFFF << 0).toString(16); // Here be a bug!
$scope.monitor.WebColour = color; // When retrieving 'Orientation', it comes back and is set a a number
// But it mustbe saved as a string (due to mysql enum)
'Orientation' : '0',
'Enabled' : true,
'Protocol' : 'http',
'SectionLength' : 600,
'EventPrefix' : 'Event-',
'FrameSkip' : 0,
'MotionFrameSkip' : 0,
'FPSReportInterval' : 1000,
'DefaultView' : 'Events',
'DefaultRate' : 100,
'DefaultScale' : 100,
'SignalCheckColour' : '#0000c0',
'Method' : 'simple',
'WebColour' : color
};
}
// Call Monitor.saveMonitor when the save button is clicked. Pass along $scope.monitor
$scope.submitMonitor = function() { $scope.submitMonitor = function() {
$http({ $http({
method : 'POST', method : 'POST',