浏览代码

fix auto-restart bug; add tooltips in UI

Chris Mullins 8 年之前
父节点
当前提交
1ebc6f81d2
共有 2 个文件被更改,包括 33 次插入3 次删除
  1. 32 2
      data/web/index.html
  2. 1 1
      lib/Settings/Settings.cpp

+ 32 - 2
data/web/index.html

@@ -19,7 +19,6 @@
   
   <style>
     .header-row { border-bottom: 1px solid #ccc; }
-    label { display: block; }
     .radio-option { padding: 0 5px; cursor: pointer; }
     .command-buttons { list-style: none; margin: 0; padding: 0; }
     .command-buttons li { display: inline-block; margin-right: 1em; }
@@ -90,6 +89,11 @@
       float: left;
       display: block;
     }
+    .field-help {
+      display: inline-block;
+      font-size: 1.25em;
+      margin-left: 0.5em;
+    }
   </style>
 </head>
 
@@ -104,9 +108,18 @@
   <script lang="text/javascript">
     var FORM_SETTINGS = [
       "admin_username", "admin_password", "ce_pin", "csn_pin", "packet_repeats",
-      "http_repeat_factor"
+      "http_repeat_factor", "auto_restart_period"
     ];
     
+    var FORM_SETTINGS_HELP = {
+      packet_repeats : "The number of times to repeat RF packets sent to bulbs",
+      http_repeat_factor : "Multiplicative factor on packet_repeats for " +
+        "requests initiated by the HTTP API. UDP API typically receives " +
+        "duplicate packets, so more repeats should be used for HTTP.",
+      auto_restart_period : "Automatically restart the device every number of " +
+        "minutes specified. Use 0 for disabled."
+    }
+    
     var UDP_PROTOCOL_VERSIONS = [ 5, 6 ];
     var DEFAULT_UDP_PROTOCL_VERSION = 5;
     
@@ -395,8 +408,14 @@
       FORM_SETTINGS.forEach(function(k) {
         var elmt = '<div class="form-entry">';
         elmt += '<label for="' + k + '">' + k + '</label>';
+        
+        if (FORM_SETTINGS_HELP[k]) {
+          elmt += '<div class="field-help" data-help-text="' + FORM_SETTINGS_HELP[k] + '"></div>';
+        }
+        
         elmt += '<input type="text" class="form-control" name="' + k + '"/>';
         elmt += '</div>';
+        
         settings += elmt;
       });
         
@@ -435,6 +454,17 @@
         return false;
       });
       
+      $('.field-help').each(function() {
+        var elmt = $('<i></i>')
+          .addClass('glyphicon glyphicon-question-sign')
+          .tooltip({
+            placement: 'top',
+            title: $(this).data('help-text'),
+            container: 'body'
+          });
+        $(this).append(elmt);
+      });
+      
       loadSettings();
       updateModeOptions();
     });

+ 1 - 1
lib/Settings/Settings.cpp

@@ -17,7 +17,7 @@ size_t Settings::getAutoRestartPeriod() {
     return 0;
   }
   
-  return std::min(_autoRestartPeriod, static_cast<size_t>(MINIMUM_RESTART_PERIOD));
+  return std::max(_autoRestartPeriod, static_cast<size_t>(MINIMUM_RESTART_PERIOD));
 }
 
 void Settings::deserialize(Settings& settings, String json) {