From: Calin Crisan <ccrisan@gmail.com>
Date: Sat, 8 Mar 2014 10:40:31 +0000 (+0200)
Subject: added custom lifetime for movies and pictures
X-Git-Url: http://www.vanbest.org/gitweb/?a=commitdiff_plain;h=9bbe5028465f24c516f33e01e12b0842682e4cd8;p=motioneye-debian

added custom lifetime for movies and pictures
---

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 @@
                                 <option value="30">For One Month</option>
                                 <option value="365">For One Year</option>
                                 <option value="0">Forever</option>
+                                <option value="-1">Custom</option>
                             </select>
                         </td>
                         <td><span class="help-mark" title="images older than the specified duration are automatically deleted to free storage space">?</span></td>
                     </tr>
+                    <tr class="settings-item">
+                        <td class="settings-item-label"><span class="settings-item-label">Pictures Lifetime</span></td>
+                        <td class="settings-item-value"><input type="text" class="styled number still-images" id="picturesLifetime"><span class="settings-item-unit">days</span></td>
+                        <td><span class="help-mark" title="sets the number of days after which the pictures will be deleted automatically">?</span></td>
+                    </tr>
                 </table>
                 
                 <div class="settings-section-title"><input type="checkbox" class="styled section motion-movies" id="motionMoviesSwitch">Motion Movies</div>
@@ -336,10 +342,16 @@
                                 <option value="30">For One Month</option>
                                 <option value="365">For One Year</option>
                                 <option value="0">Forever</option>
+                                <option value="-1">Custom</option>
                             </select>
                         </td>
                         <td><span class="help-mark" title="movies older than the specified duration are automatically deleted to free storage space">?</span></td>
                     </tr>
+                    <tr class="settings-item">
+                        <td class="settings-item-label"><span class="settings-item-label">Movies Lifetime</span></td>
+                        <td class="settings-item-value"><input type="text" class="styled number still-images" id="moviesLifetime"><span class="settings-item-unit">days</span></td>
+                        <td><span class="help-mark" title="sets the number of days after which the movies will be deleted automatically">?</span></td>
+                    </tr>
                 </table>
                 
                 <div class="settings-section-title advanced-setting">Motion Detection</div>