]> www.vanbest.org Git - motioneye-debian/commitdiff
don't actually enable working schedule unless at least one day is
authorCalin Crisan <ccrisan@gmail.com>
Fri, 16 Oct 2015 11:56:11 +0000 (14:56 +0300)
committerCalin Crisan <ccrisan@gmail.com>
Fri, 16 Oct 2015 11:56:26 +0000 (14:56 +0300)
enabled

motioneye/__init__.py
motioneye/static/js/main.js

index 0c7df6ecd7726d6fd4a67692cc1b7555f82f2482..dcb5b41f7b136aa5a6e69105b26ab1872f6ca41a 100644 (file)
@@ -1,2 +1,2 @@
 
-VERSION = "0.28.1"
+VERSION = "0.28.1-git"
index d6187fc988bc75965a8e670cc8f772fdd7c05a94..ac361fd78b054697d73c23ac03ed3074a09c989f 100644 (file)
@@ -332,6 +332,16 @@ Array.prototype.every = Array.prototype.every || function (callback, thisArg) {
     return true;
 };
 
+Array.prototype.some = Array.prototype.some || function (callback, thisArg) {
+    for (var i = 0; i < this.length; i++) {
+        if (callback.call(thisArg, this[i], i, this)) {
+            return true;
+        }
+    }
+    
+    return false;
+};
+
 Array.prototype.unique = function (callback, thisArg) {
     var uniqueElements = [];
     this.forEach(function (element) {
@@ -1385,6 +1395,16 @@ function cameraUi2Dict() {
         'sunday_to': $('#sundayEnabledSwitch')[0].checked ? $('#sundayToEntry').val() : '',
         'working_schedule_type': $('#workingScheduleTypeSelect').val(),
     };
+    
+    /* if all working schedule days are disabled,
+     * also disable the global working schedule */
+    var hasWS = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'].some(function (day) {
+        return $('#' + day + 'EnabledSwitch')[0].checked;
+    });
+    
+    if (!hasWS) {
+        dict['working_schedule'] = false;
+    }
 
     if ($('#resolutionSelect')[0].selectedIndex != -1) {
         dict.resolution = $('#resolutionSelect').val();