2014-11-16 03:34:00 +08:00
|
|
|
var ZoneMinder = angular.module('ZoneMinder', [
|
2014-11-25 23:25:34 +08:00
|
|
|
'ZoneMinderControllers',
|
2014-11-28 08:20:04 +08:00
|
|
|
'tc.chartjs',
|
2014-12-30 01:15:51 +08:00
|
|
|
'ui.bootstrap',
|
2015-01-21 23:22:25 +08:00
|
|
|
'angularUtils.directives.dirPagination',
|
2015-02-12 03:09:41 +08:00
|
|
|
'ui.bootstrap.datetimepicker',
|
|
|
|
'ngRoute'
|
2014-11-16 03:34:00 +08:00
|
|
|
]);
|
|
|
|
|
2015-02-12 03:09:41 +08:00
|
|
|
ZoneMinder.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
|
2014-11-16 07:50:04 +08:00
|
|
|
$locationProvider.html5Mode(true);
|
2015-02-12 03:09:41 +08:00
|
|
|
|
|
|
|
$routeProvider
|
2015-02-12 03:34:10 +08:00
|
|
|
.when('/', {
|
|
|
|
templateUrl: '/views/console.html'
|
2015-02-12 03:09:41 +08:00
|
|
|
})
|
|
|
|
|
2015-02-12 03:34:10 +08:00
|
|
|
.when('/events', {
|
|
|
|
templateUrl: '/views/events.html'
|
2015-02-12 03:09:41 +08:00
|
|
|
});
|
2014-11-16 07:50:04 +08:00
|
|
|
}]);
|
2014-12-30 01:15:51 +08:00
|
|
|
ZoneMinder.config(function(paginationTemplateProvider) {
|
2015-02-12 03:34:10 +08:00
|
|
|
paginationTemplateProvider.setPath('/js/dirPagination.tpl.html');
|
2014-12-30 01:15:51 +08:00
|
|
|
});
|
2014-11-16 07:50:04 +08:00
|
|
|
|
2014-12-22 10:42:54 +08:00
|
|
|
ZoneMinder.factory('Monitor', function($http) {
|
|
|
|
return {
|
|
|
|
getMonitor: function(mid) {
|
|
|
|
return $http.get('/api/monitors/'+mid+'.json');
|
|
|
|
},
|
|
|
|
saveMonitor: function(monitor) {
|
|
|
|
return $http({
|
|
|
|
method: 'POST',
|
|
|
|
url: '/api/monitors.json',
|
|
|
|
data: $.param(monitor),
|
|
|
|
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2015-01-18 01:25:33 +08:00
|
|
|
ZoneMinder.factory('State', function($http) {
|
|
|
|
return {
|
|
|
|
get: function(callback) {
|
|
|
|
$http.get('/api/states.json').success(callback);
|
|
|
|
},
|
|
|
|
change: function(state) {
|
|
|
|
return $http.post('/api/states/change/'+state+'.json');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2014-11-16 03:34:00 +08:00
|
|
|
ZoneMinder.factory('Header', function($http) {
|
|
|
|
return {
|
|
|
|
getLogState: function(callback) {
|
|
|
|
$http.get('/api/monitors.json').success(callback);
|
2014-11-16 08:35:10 +08:00
|
|
|
},
|
|
|
|
getDaemonStatus: function(callback) {
|
|
|
|
$http.get('/api/host/daemonCheck.json').success(callback);
|
2014-11-16 03:34:00 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
});
|
2014-11-16 07:50:46 +08:00
|
|
|
|
2014-12-02 00:15:12 +08:00
|
|
|
ZoneMinder.factory('Log', function($http) {
|
|
|
|
return {
|
2015-01-09 05:06:13 +08:00
|
|
|
get: function(page) {
|
|
|
|
return $http.get('/api/logs.json?page='+page);
|
2014-12-02 00:15:12 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2014-11-26 00:25:10 +08:00
|
|
|
ZoneMinder.factory('Host', function($http) {
|
2014-11-22 04:06:59 +08:00
|
|
|
return {
|
2014-11-26 00:30:27 +08:00
|
|
|
getDiskPercent: function(callback) {
|
|
|
|
$http.get('/api/host/getDiskPercent.json').success(callback);
|
|
|
|
},
|
2014-11-22 04:06:59 +08:00
|
|
|
getLoad: function(callback) {
|
|
|
|
$http.get('/api/host/getLoad.json').success(callback);
|
2014-11-26 00:25:10 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
ZoneMinder.factory('Footer', function($http) {
|
|
|
|
return {
|
2014-11-24 08:56:20 +08:00
|
|
|
getVersion: function(callback) {
|
|
|
|
$http.get('/api/host/getVersion.json').success(callback);
|
2014-11-22 04:06:59 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2014-12-24 11:38:54 +08:00
|
|
|
ZoneMinder.factory('Events', function($http) {
|
|
|
|
return {
|
2015-01-21 23:22:25 +08:00
|
|
|
get: function(filter, page) {
|
|
|
|
if (filter) {
|
|
|
|
return $http.get('/api/events/index/'+filter+'.json?page='+page);
|
|
|
|
} else {
|
|
|
|
return $http.get('/api/events.json?page='+page);
|
|
|
|
}
|
2014-12-24 11:38:54 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2014-11-16 07:50:46 +08:00
|
|
|
ZoneMinder.factory('Event', function($http) {
|
|
|
|
return {
|
2015-01-07 07:39:04 +08:00
|
|
|
get: function(eventId) {
|
2014-11-16 07:50:46 +08:00
|
|
|
return $http.get('/api/events/'+ eventId +'.json');
|
2015-01-07 07:36:55 +08:00
|
|
|
},
|
|
|
|
delete: function(eventId) {
|
|
|
|
return $http.delete('/api/events/'+ eventId + '.json');
|
2015-01-22 06:25:56 +08:00
|
|
|
},
|
|
|
|
archive: function(eventId) {
|
|
|
|
return $http.post('/api/events/archive/'+ eventId + '.json');
|
2014-11-16 07:50:46 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2014-11-19 23:53:07 +08:00
|
|
|
ZoneMinder.factory('Console', function($http) {
|
|
|
|
return {
|
|
|
|
getConsoleEvents: function(interval) {
|
|
|
|
return $http.get('/api/events/consoleEvents/'+interval+'.json');
|
2014-11-27 22:34:08 +08:00
|
|
|
},
|
2014-11-27 22:35:00 +08:00
|
|
|
getMonitors: function() {
|
|
|
|
return $http.get('/api/monitors.json');
|
|
|
|
},
|
2014-11-27 22:34:08 +08:00
|
|
|
daemonStatus: function(id, daemon) {
|
|
|
|
return $http.get('/api/monitors/daemonStatus/id:'+id+'/daemon:'+daemon+'.json');
|
2015-01-08 05:29:30 +08:00
|
|
|
},
|
|
|
|
delete: function(id) {
|
|
|
|
return $http.delete('/api/monitors/'+id+'.json');
|
2014-11-19 23:53:07 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2014-11-20 12:10:01 +08:00
|
|
|
|
|
|
|
ZoneMinder.factory('Config', function($http) {
|
|
|
|
return {
|
2014-11-20 12:11:33 +08:00
|
|
|
getCategories: function() {
|
|
|
|
return $http.get('/api/configs/categories.json');
|
|
|
|
},
|
|
|
|
getCategory: function(category) {
|
|
|
|
return $http.get('/api/configs/categories/' + category + '.json')
|
|
|
|
},
|
2014-11-20 12:10:01 +08:00
|
|
|
setConfigModel: function() {
|
|
|
|
return $http.get('/api/configs/keyValue.json')
|
|
|
|
},
|
2014-11-20 12:11:33 +08:00
|
|
|
updateOption: function(configId, newValue) {
|
|
|
|
var putData = "Config[Value]=" + newValue;
|
|
|
|
//var postData = {Config[Value]: configValue};
|
|
|
|
|
|
|
|
|
|
|
|
return $http({
|
|
|
|
method: 'POST',
|
|
|
|
url: '/api/configs/' + configId + '.json',
|
|
|
|
data: putData,
|
|
|
|
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
//return $http.post ('/api/configs/' + configId + '.json', postData)
|
2015-01-28 00:14:59 +08:00
|
|
|
},
|
|
|
|
findByName: function(name) {
|
|
|
|
return $http.get('/api/configs/viewByName/'+name+'.json')
|
2014-11-20 12:11:33 +08:00
|
|
|
}
|
2014-11-20 12:10:01 +08:00
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2014-11-20 12:05:22 +08:00
|
|
|
ZoneMinder.directive('angularHtmlBind', function($compile) {
|
|
|
|
return function(scope, elm, attrs) {
|
|
|
|
scope.$watch(attrs.angularHtmlBind, function(newValue, oldValue) {
|
|
|
|
if (newValue && newValue !== oldValue) {
|
|
|
|
elm.html(newValue);
|
|
|
|
$compile(elm.contents())(scope);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
});
|
2014-12-24 11:04:23 +08:00
|
|
|
|
|
|
|
ZoneMinder.filter('DateDiff', function() {
|
|
|
|
return function(StartTime, EndTime, format) {
|
|
|
|
var d1 = new Date(StartTime.replace(/-/g,'/'));
|
|
|
|
var d2 = new Date(EndTime.replace(/-/g,'/'));
|
|
|
|
var miliseconds = d2-d1;
|
|
|
|
var seconds = miliseconds/1000;
|
|
|
|
var minutes = seconds/60;
|
|
|
|
var hours = minutes/60;
|
|
|
|
var days = hours/24;
|
|
|
|
|
|
|
|
switch (format) {
|
|
|
|
case "seconds":
|
|
|
|
return seconds;
|
|
|
|
case "hours":
|
|
|
|
return hours;
|
|
|
|
case "minutes":
|
|
|
|
return minutes;
|
|
|
|
case "pretty":
|
|
|
|
return Math.floor(minutes)+'m ' + seconds+'s';
|
|
|
|
}
|
|
|
|
};
|
|
|
|
});
|
2015-01-28 00:15:10 +08:00
|
|
|
|
|
|
|
ZoneMinder.filter('zpad', function() {
|
|
|
|
return function(input, n) {
|
|
|
|
if(input === undefined)
|
|
|
|
input = ""
|
|
|
|
if(input.length >= n)
|
|
|
|
return input
|
|
|
|
var zeros = "0".repeat(n);
|
|
|
|
return (zeros + input).slice(-1 * n)
|
|
|
|
};
|
|
|
|
});
|