]> www.vanbest.org Git - motioneye-debian/commitdiff
added custom lifetime for movies and pictures
authorCalin Crisan <ccrisan@gmail.com>
Sat, 8 Mar 2014 10:40:31 +0000 (12:40 +0200)
committerCalin Crisan <ccrisan@gmail.com>
Sat, 8 Mar 2014 10:40:31 +0000 (12:40 +0200)
static/js/main.js
templates/main.html

index 76b563d0c49efbece145f3283115cce987c1b534..8ce14e9b6ecbd53934ea876a7bc7b8b49018e066 100644 (file)
@@ -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'];
index 7bdf83c108de118da4dd9e75df15db1bc33d7087..3d5594ebe11744f5324b01b607ef373e10803030 100644 (file)
                                 <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>
                                 <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>