From 9bbe5028465f24c516f33e01e12b0842682e4cd8 Mon Sep 17 00:00:00 2001 From: Calin Crisan Date: Sat, 8 Mar 2014 12:40:31 +0200 Subject: [PATCH] added custom lifetime for movies and pictures --- static/js/main.js | 26 ++++++++++++++++++++++++-- templates/main.html | 12 ++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/static/js/main.js b/static/js/main.js index 76b563d..8ce14e9 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -209,6 +209,8 @@ function initUI() { /* number validators */ makeNumberValidator($('#streamingPortEntry'), 1024, 65535, false, false, true); makeNumberValidator($('#snapshotIntervalEntry'), 1, 86400, false, false, true); + makeNumberValidator($('#picturesLifetime'), 1, 3650, false, false, true); + makeNumberValidator($('#moviesLifetime'), 1, 3650, false, false, true); makeNumberValidator($('#gapEntry'), 1, 86400, false, false, true); makeNumberValidator($('#preCaptureEntry'), 0, 100, false, false, true); makeNumberValidator($('#postCaptureEntry'), 0, 100, false, false, true); @@ -244,7 +246,9 @@ function initUI() { $('#videoStreamingSwitch').change(updateConfigUi); $('#streamingServerResizeSwitch').change(updateConfigUi); $('#stillImagesSwitch').change(updateConfigUi); + $('#preservePicturesSelect').change(updateConfigUi); $('#motionMoviesSwitch').change(updateConfigUi); + $('#preserveMoviesSelect').change(updateConfigUi); $('#motionNotificationsSwitch').change(updateConfigUi); $('#workingScheduleSwitch').change(updateConfigUi); @@ -424,11 +428,21 @@ function updateConfigUi() { $('#stillImagesSwitch').parent().next('table.settings').find('tr.settings-item').each(markHide); } + /* preserve pictures */ + if ($('#preservePicturesSelect').val() != '-1') { + $('#picturesLifetime').parents('tr:eq(0)').each(markHide); + } + /* motion movies switch */ if (!$('#motionMoviesSwitch').get(0).checked) { $('#motionMoviesSwitch').parent().next('table.settings').find('tr.settings-item').each(markHide); } + /* preserve movies */ + if ($('#preserveMoviesSelect').val() != '-1') { + $('#moviesLifetime').parents('tr:eq(0)').each(markHide); + } + /* motion notifications switch */ if (!$('#motionNotificationsSwitch').get(0).checked) { $('#motionNotificationsSwitch').parent().next('table.settings').find('tr.settings-item').each(markHide); @@ -566,13 +580,13 @@ function cameraUi2Dict() { 'image_quality': $('#imageQualitySlider').val(), 'capture_mode': $('#captureModeSelect').val(), 'snapshot_interval': $('#snapshotIntervalEntry').val(), - 'preserve_pictures': $('#preservePicturesSelect').val(), + 'preserve_pictures': $('#preservePicturesSelect').val() >= 0 ? $('#preservePicturesSelect').val() : $('#picturesLifetime').val(), /* motion movies */ 'motion_movies': $('#motionMoviesSwitch')[0].checked, 'movie_file_name': $('#movieFileNameEntry').val(), 'movie_quality': $('#movieQualitySlider').val(), - 'preserve_movies': $('#preserveMoviesSelect').val(), + 'preserve_movies': $('#preserveMoviesSelect').val() >= 0 ? $('#preserveMoviesSelect').val() : $('#moviesLifetime').val(), /* motion detection */ 'show_frame_changes': $('#showFrameChangesSwitch')[0].checked, @@ -699,12 +713,20 @@ function dict2CameraUi(dict) { $('#captureModeSelect').val(dict['capture_mode']); $('#snapshotIntervalEntry').val(dict['snapshot_interval']); $('#preservePicturesSelect').val(dict['preserve_pictures']); + if ($('#preservePicturesSelect').val() == null) { + $('#preservePicturesSelect').val('-1'); + } + $('#picturesLifetime').val(dict['preserve_pictures']); /* motion movies */ $('#motionMoviesSwitch')[0].checked = dict['motion_movies']; $('#movieFileNameEntry').val(dict['movie_file_name']); $('#movieQualitySlider').val(dict['movie_quality']); $('#preserveMoviesSelect').val(dict['preserve_movies']); + if ($('#preserveMoviesSelect').val() == null) { + $('#preserveMoviesSelect').val('-1'); + } + $('#moviesLifetime').val(dict['preserve_movies']); /* motion detection */ $('#showFrameChangesSwitch')[0].checked = dict['show_frame_changes']; diff --git a/templates/main.html b/templates/main.html index 7bdf83c..3d5594e 100644 --- a/templates/main.html +++ b/templates/main.html @@ -309,10 +309,16 @@ + ? + + Pictures Lifetime + days + ? +
Motion Movies
@@ -336,10 +342,16 @@ + ? + + Movies Lifetime + days + ? +
Motion Detection
-- 2.39.5