remote.del_media_group(camera_config, group=group, media_type='movie', callback=on_response)
+class LogHandler(BaseHandler):
+ LOGS = {
+ 'motion': (os.path.join(settings.LOG_PATH, 'motion.log'), 'motion.log')
+ }
+
+ @BaseHandler.auth(admin=True)
+ def get(self, name):
+ log = self.LOGS.get(name)
+ if log is None:
+ raise HTTPError(404, 'no such log')
+
+ (path, filename) = log
+ logging.debug('serving log file %s from %s' % (filename, path))
+
+ self.set_header('Content-Type', 'text/plain')
+ self.set_header('Content-Disposition', 'attachment; filename=' + filename + ';')
+
+ with open(path) as f:
+ self.finish(f.read())
+
+
class UpdateHandler(BaseHandler):
@BaseHandler.auth(admin=True)
def get(self):
(r'^/movie/(?P<camera_id>\d+)/(?P<op>list)/?$', handlers.MovieHandler),
(r'^/movie/(?P<camera_id>\d+)/(?P<op>download|preview|delete)/(?P<filename>.+?)/?$', handlers.MovieHandler),
(r'^/movie/(?P<camera_id>\d+)/(?P<op>delete_all)/(?P<group>.+?)/?$', handlers.MovieHandler),
+ (r'^/log/(?P<name>\w+)/?$', handlers.LogHandler),
(r'^/update/?$', handlers.UpdateHandler),
(r'^/power/(?P<op>shutdown|reboot)/?$', handlers.PowerHandler),
(r'^/version/?$', handlers.VersionHandler),
var refreshInterval = 50; /* milliseconds */
var username = '';
var password = '';
+var baseUri = null;
/* utils */
/* additional configs */
$('tr.additional-config').each(function () {
var $this = $(this);
- var control = $this.find('input, select');
+ var control = $this.find('input, select, div.html');
if (!control.hasClass('main-config')) {
return;
name = id.substring(0, id.length - 6);
control[0].checked = dict['_' + name];
}
+ else if (id.endsWith('Html')) {
+ name = id.substring(0, id.length - 4);
+ control.html(dict['_' + name]);
+ }
});
updateConfigUi();
/* additional configs */
$('tr.additional-config').each(function () {
var $this = $(this);
- var control = $this.find('input, select');
+ var control = $this.find('input, select, div.html');
if (!control.hasClass('camera-config')) {
return;
name = id.substring(0, id.length - 6);
control[0].checked = dict['_' + name];
}
+ else if (id.endsWith('Html')) {
+ name = id.substring(0, id.length - 4);
+ control.html(dict['_' + name]);
+ }
});
updateConfigUi();
}
function downloadFile(uri) {
+ uri = baseUri + uri;
+
var url = window.location.href;
var parts = url.split('/');
url = parts.slice(0, 3).join('/') + uri;
}
function doBackup() {
- downloadFile(baseUri + 'config/backup/');
+ downloadFile('config/backup/');
}
function doRestore() {
}
else {
hideModalDialog(); /* progress */
- downloadFile(baseUri + 'picture/' + cameraId + '/zipped/' + groupKey + '/?key=' + data.key);
+ downloadFile('picture/' + cameraId + '/zipped/' + groupKey + '/?key=' + data.key);
}
});
}
{caption: 'Close'},
{caption: 'Download', isDefault: true, click: function () {
var entry = entries[pos];
- downloadFile(baseUri + mediaType + '/' + entry.cameraId + '/download' + entry.path);
+ downloadFile(mediaType + '/' + entry.cameraId + '/download' + entry.path);
return false;
}}
setTimeout(function () {
hideModalDialog(); /* progress */
hideModalDialog(); /* timelapse dialog */
- downloadFile(baseUri + 'picture/' + cameraId + '/timelapse/' + groupKey + '/?key=' + data.key);
+ downloadFile('picture/' + cameraId + '/timelapse/' + groupKey + '/?key=' + data.key);
}, 500);
}
else {
entryDiv.append(detailsDiv);
downloadButton.click(function () {
- downloadFile(baseUri + mediaType + '/' + cameraId + '/download' + entry.path);
+ downloadFile(mediaType + '/' + cameraId + '/download' + entry.path);
return false;
});