Ver Fonte

OP task #649 | improve battest time setting

Avetisyan Karen há 5 anos atrás
pai
commit
ed09f78e78

BIN
web_interface/dist/wui-3/main.js


BIN
web_interface/dist/wui-3/settings.html


BIN
web_interface/dist/wui-7/main.js


BIN
web_interface/dist/wui-7/settings.html


BIN
web_interface/dist/wui-9/main.js


BIN
web_interface/dist/wui-9/settings.html


+ 6 - 0
web_interface/src/wui-3/main.js

@@ -1112,6 +1112,7 @@ function SpinBox(container, options) {
   this.addEventListener(this.input, 'keydown',        this.handleKeyDown, [], true);
   this.addEventListener(this.input, 'keydown',        this.handleKeyDown, [], true);
   this.addEventListener(this.input, 'keypress',       this.handleKeyPress, [], true);
   this.addEventListener(this.input, 'keypress',       this.handleKeyPress, [], true);
   this.addEventListener(this.input, 'keyup',          this.stop);
   this.addEventListener(this.input, 'keyup',          this.stop);
+  this.addEventListener(this.input, 'blur',           this.loseFocus);
   this.addEventListener(upButton,   'mousedown',      this.start, [true]);
   this.addEventListener(upButton,   'mousedown',      this.start, [true]);
   this.addEventListener(upButton,   'mouseup',        this.stop);
   this.addEventListener(upButton,   'mouseup',        this.stop);
   this.addEventListener(upButton,   'mouseout',       this.stop);
   this.addEventListener(upButton,   'mouseout',       this.stop);
@@ -1129,6 +1130,11 @@ SpinBox.prototype.getValue = function () {
   // parse and return the value
   // parse and return the value
   return parseFloat(this.input.value);
   return parseFloat(this.input.value);
 
 
+};
+SpinBox.prototype.loseFocus = function () {
+  if ('minimum' in this.options && this.input.value < this.options.minimum) this.input.value = this.options.minimum.toFixed(this.options.decimals ? this.options.decimals : 0);
+  if ('maximum' in this.options && this.input.value > this.options.maximum) this.input.value = this.options.maximum.toFixed(this.options.decimals ? this.options.decimals : 0);
+
 };
 };
 
 
 SpinBox.prototype.setName = function (name) {
 SpinBox.prototype.setName = function (name) {

+ 25 - 5
web_interface/src/wui-3/settings.html

@@ -252,10 +252,29 @@
   <div class="panel-body section group">
   <div class="panel-body section group">
     <div class="col span_1_of_3">
     <div class="col span_1_of_3">
       <h4 class="col span_2_of_2">Аккумуляторные батареи</h4>
       <h4 class="col span_2_of_2">Аккумуляторные батареи</h4>
-      <div class="form-group">
+      <div class="form-group col span_2_of_2">
         <label for="" class="col span_1_of_2">Время теста (мин)</label>
         <label for="" class="col span_1_of_2">Время теста (мин)</label>
         <div class="col span_1_of_2">
         <div class="col span_1_of_2">
-          <input type="text" class="form-control" value="10" maxlength="6" id="test_time">
+          <select class="form-control" id="test_time">
+            <option value="0.2">0.2</option>
+            <option value="0.3">0.3</option>
+            <option value="0.4">0.4</option>
+            <option value="0.5">0.5</option>
+            <option value="0.6">0.6</option>
+            <option value="0.7">0.7</option>
+            <option value="0.8">0.8</option>
+            <option value="0.9">0.9</option>
+            <option value="1">1</option>
+            <option value="2">2</option>
+            <option value="3">3</option>
+            <option value="4">4</option>
+            <option value="5">5</option>
+            <option value="6">6</option>
+            <option value="7">7</option>
+            <option value="8">8</option>
+            <option value="9">9</option>
+            <option value="10">10</option>
+          </select>
         </div>
         </div>
       </div>
       </div>
       <button type="button" class="btn btn-default" onclick="batTest({ 'func': 'time', 'time': $('test_time').value });">Запуск теста</button>
       <button type="button" class="btn btn-default" onclick="batTest({ 'func': 'time', 'time': $('test_time').value });">Запуск теста</button>
@@ -271,11 +290,11 @@
     <div class="col span_1_of_3">
     <div class="col span_1_of_3">
       <h4 class="col span_2_of_2">Нагрузка</h4>
       <h4 class="col span_2_of_2">Нагрузка</h4>
       <button type="button" class="btn btn-default" onclick="UPSPowerOff({'func': 'reboot'})">Отмена отключения</button>
       <button type="button" class="btn btn-default" onclick="UPSPowerOff({'func': 'reboot'})">Отмена отключения</button>
-      <button type="button" class="btn btn-default" onclick="UPSPowerOff({'func': 'off', 'after': $('upspo_after').value})">Отключить</button>
+      <button type="button" class="btn btn-default" onclick="UPSPowerOff({'func': 'off', 'after': $('upspo_after').children[0].value})">Отключить</button>
       <div class="form-group">
       <div class="form-group">
-        <label for="" class="col span_1_of_2">Откл. через (мин)</label>
+        <label for="" class="col span_1_of_2">Откл. через (1-99 мин)</label>
         <div class="col span_1_of_2">
         <div class="col span_1_of_2">
-          <input type="text" class="form-control" value="10" maxlength="6" id="upspo_after">
+          <span id="upspo_after"></span>
         </div>
         </div>
       </div>
       </div>
     </div>
     </div>
@@ -418,6 +437,7 @@ var ups_cell_min  = new SpinBox('ups_cell_min', {'name':'ups_cell_min','minimum'
 var ups_cell_max  = new SpinBox('ups_cell_max', {'name':'ups_cell_max','minimum':0,'maximum':3,'step':0.01});
 var ups_cell_max  = new SpinBox('ups_cell_max', {'name':'ups_cell_max','minimum':0,'maximum':3,'step':0.01});
 var temp_hist     = new SpinBox('temp_hist', {'name':'temp_hist','minimum':0.5,'maximum':2.0,'step':0.1,'decimals':1, 'value': 0.5});
 var temp_hist     = new SpinBox('temp_hist', {'name':'temp_hist','minimum':0.5,'maximum':2.0,'step':0.1,'decimals':1, 'value': 0.5});
 var loadvolt_hist = new SpinBox('loadvolt_hist', {'name':'loadvolt_hist','minimum':0.5,'maximum':2.0,'step':0.1,'decimals':1, 'value': 0.5});
 var loadvolt_hist = new SpinBox('loadvolt_hist', {'name':'loadvolt_hist','minimum':0.5,'maximum':2.0,'step':0.1,'decimals':1, 'value': 0.5});
+var upspo_after   = new SpinBox('upspo_after', {'minimum':1,'maximum':99,'step':1, 'value': 1});
 settingsGET();
 settingsGET();
 // $('dev-update').onclick = function(){
 // $('dev-update').onclick = function(){
 //   $('count-wrap').style.display = 'block';
 //   $('count-wrap').style.display = 'block';

+ 6 - 0
web_interface/src/wui-7/main.js

@@ -1098,6 +1098,7 @@ function SpinBox(container, options) {
   this.addEventListener(this.input, 'keydown',        this.handleKeyDown, [], true);
   this.addEventListener(this.input, 'keydown',        this.handleKeyDown, [], true);
   this.addEventListener(this.input, 'keypress',       this.handleKeyPress, [], true);
   this.addEventListener(this.input, 'keypress',       this.handleKeyPress, [], true);
   this.addEventListener(this.input, 'keyup',          this.stop);
   this.addEventListener(this.input, 'keyup',          this.stop);
+  this.addEventListener(this.input, 'blur',           this.loseFocus);
   this.addEventListener(upButton,   'mousedown',      this.start, [true]);
   this.addEventListener(upButton,   'mousedown',      this.start, [true]);
   this.addEventListener(upButton,   'mouseup',        this.stop);
   this.addEventListener(upButton,   'mouseup',        this.stop);
   this.addEventListener(upButton,   'mouseout',       this.stop);
   this.addEventListener(upButton,   'mouseout',       this.stop);
@@ -1115,6 +1116,11 @@ SpinBox.prototype.getValue = function () {
   // parse and return the value
   // parse and return the value
   return parseFloat(this.input.value);
   return parseFloat(this.input.value);
 
 
+};
+SpinBox.prototype.loseFocus = function () {
+  if ('minimum' in this.options && this.input.value < this.options.minimum) this.input.value = this.options.minimum.toFixed(this.options.decimals ? this.options.decimals : 0);
+  if ('maximum' in this.options && this.input.value > this.options.maximum) this.input.value = this.options.maximum.toFixed(this.options.decimals ? this.options.decimals : 0);
+
 };
 };
 
 
 SpinBox.prototype.setName = function (name) {
 SpinBox.prototype.setName = function (name) {

+ 25 - 5
web_interface/src/wui-7/settings.html

@@ -287,10 +287,29 @@
   <div class="panel-body section group">
   <div class="panel-body section group">
     <div class="col span_1_of_3">
     <div class="col span_1_of_3">
       <h4 class="col span_2_of_2">Аккумуляторные батареи</h4>
       <h4 class="col span_2_of_2">Аккумуляторные батареи</h4>
-      <div class="form-group">
+      <div class="form-group col span_2_of_2">
         <label for="" class="col span_1_of_2">Время теста (мин)</label>
         <label for="" class="col span_1_of_2">Время теста (мин)</label>
         <div class="col span_1_of_2">
         <div class="col span_1_of_2">
-          <input type="text" class="form-control" value="10" maxlength="6" id="test_time">
+          <select class="form-control" id="test_time">
+            <option value="0.2">0.2</option>
+            <option value="0.3">0.3</option>
+            <option value="0.4">0.4</option>
+            <option value="0.5">0.5</option>
+            <option value="0.6">0.6</option>
+            <option value="0.7">0.7</option>
+            <option value="0.8">0.8</option>
+            <option value="0.9">0.9</option>
+            <option value="1">1</option>
+            <option value="2">2</option>
+            <option value="3">3</option>
+            <option value="4">4</option>
+            <option value="5">5</option>
+            <option value="6">6</option>
+            <option value="7">7</option>
+            <option value="8">8</option>
+            <option value="9">9</option>
+            <option value="10">10</option>
+          </select>
         </div>
         </div>
       </div>
       </div>
       <button type="button" class="btn btn-default" onclick="batTest({ 'func': 'time', 'time': $('test_time').value });">Запуск теста</button>
       <button type="button" class="btn btn-default" onclick="batTest({ 'func': 'time', 'time': $('test_time').value });">Запуск теста</button>
@@ -306,11 +325,11 @@
     <div class="col span_1_of_3">
     <div class="col span_1_of_3">
       <h4 class="col span_2_of_2">Нагрузка</h4>
       <h4 class="col span_2_of_2">Нагрузка</h4>
       <button type="button" class="btn btn-default" onclick="UPSPowerOff({'func': 'reboot'})">Отмена отключения</button>
       <button type="button" class="btn btn-default" onclick="UPSPowerOff({'func': 'reboot'})">Отмена отключения</button>
-      <button type="button" class="btn btn-default" onclick="UPSPowerOff({'func': 'off', 'after': $('upspo_after').value})">Отключить</button>
+      <button type="button" class="btn btn-default" onclick="UPSPowerOff({'func': 'off', 'after': $('upspo_after').children[0].value})">Отключить</button>
       <div class="form-group">
       <div class="form-group">
-        <label for="" class="col span_1_of_2">Откл. через (мин)</label>
+        <label for="" class="col span_1_of_2">Откл. через (1-99 мин)</label>
         <div class="col span_1_of_2">
         <div class="col span_1_of_2">
-          <input type="text" class="form-control" value="10" maxlength="6" id="upspo_after">
+          <span id="upspo_after"></span>
         </div>
         </div>
       </div>
       </div>
     </div>
     </div>
@@ -408,6 +427,7 @@ var ups_cell_max  = new SpinBox('ups_cell_max', {'name':'ups_cell_max','minimum'
 var temp_hist     = new SpinBox('temp_hist', {'name':'temp_hist','minimum':0.5,'maximum':2.0,'step':0.1,'decimals':1, 'value': 0.5});
 var temp_hist     = new SpinBox('temp_hist', {'name':'temp_hist','minimum':0.5,'maximum':2.0,'step':0.1,'decimals':1, 'value': 0.5});
 var loadvolt_hist = new SpinBox('loadvolt_hist', {'name':'loadvolt_hist','minimum':0.5,'maximum':2.0,'step':0.1,'decimals':1, 'value': 0.5});
 var loadvolt_hist = new SpinBox('loadvolt_hist', {'name':'loadvolt_hist','minimum':0.5,'maximum':2.0,'step':0.1,'decimals':1, 'value': 0.5});
 var mainvolt_hist = new SpinBox('mainvolt_hist', {'name':'mainvolt_hist','minimum':10,'maximum':30,'step':1});
 var mainvolt_hist = new SpinBox('mainvolt_hist', {'name':'mainvolt_hist','minimum':10,'maximum':30,'step':1});
+var upspo_after   = new SpinBox('upspo_after', {'minimum':1,'maximum':99,'step':1, 'value': 1});
 settingsGET();
 settingsGET();
 // $('dev-update').onclick = function(){
 // $('dev-update').onclick = function(){
 //   $('count-wrap').style.display = 'block';
 //   $('count-wrap').style.display = 'block';

+ 6 - 0
web_interface/src/wui-9/main.js

@@ -1161,6 +1161,7 @@ function SpinBox(container, options) {
   this.addEventListener(this.input, 'keydown',        this.handleKeyDown, [], true);
   this.addEventListener(this.input, 'keydown',        this.handleKeyDown, [], true);
   this.addEventListener(this.input, 'keypress',       this.handleKeyPress, [], true);
   this.addEventListener(this.input, 'keypress',       this.handleKeyPress, [], true);
   this.addEventListener(this.input, 'keyup',          this.stop);
   this.addEventListener(this.input, 'keyup',          this.stop);
+  this.addEventListener(this.input, 'blur',           this.loseFocus);
   this.addEventListener(upButton,   'mousedown',      this.start, [true]);
   this.addEventListener(upButton,   'mousedown',      this.start, [true]);
   this.addEventListener(upButton,   'mouseup',        this.stop);
   this.addEventListener(upButton,   'mouseup',        this.stop);
   this.addEventListener(upButton,   'mouseout',       this.stop);
   this.addEventListener(upButton,   'mouseout',       this.stop);
@@ -1178,6 +1179,11 @@ SpinBox.prototype.getValue = function () {
   // parse and return the value
   // parse and return the value
   return parseFloat(this.input.value);
   return parseFloat(this.input.value);
 
 
+};
+SpinBox.prototype.loseFocus = function () {
+  if ('minimum' in this.options && this.input.value < this.options.minimum) this.input.value = this.options.minimum.toFixed(this.options.decimals ? this.options.decimals : 0);
+  if ('maximum' in this.options && this.input.value > this.options.maximum) this.input.value = this.options.maximum.toFixed(this.options.decimals ? this.options.decimals : 0);
+
 };
 };
 
 
 SpinBox.prototype.setName = function (name) {
 SpinBox.prototype.setName = function (name) {

+ 25 - 5
web_interface/src/wui-9/settings.html

@@ -260,10 +260,29 @@
   <div class="panel-body section group">
   <div class="panel-body section group">
     <div class="col span_1_of_3">
     <div class="col span_1_of_3">
       <h4 class="col span_2_of_2">Аккумуляторные батареи</h4>
       <h4 class="col span_2_of_2">Аккумуляторные батареи</h4>
-      <div class="form-group">
+      <div class="form-group col span_2_of_2">
         <label for="" class="col span_1_of_2">Время теста (мин)</label>
         <label for="" class="col span_1_of_2">Время теста (мин)</label>
         <div class="col span_1_of_2">
         <div class="col span_1_of_2">
-          <input type="text" class="form-control" value="10" maxlength="6" id="test_time">
+          <select class="form-control" id="test_time">
+            <option value="0.2">0.2</option>
+            <option value="0.3">0.3</option>
+            <option value="0.4">0.4</option>
+            <option value="0.5">0.5</option>
+            <option value="0.6">0.6</option>
+            <option value="0.7">0.7</option>
+            <option value="0.8">0.8</option>
+            <option value="0.9">0.9</option>
+            <option value="1">1</option>
+            <option value="2">2</option>
+            <option value="3">3</option>
+            <option value="4">4</option>
+            <option value="5">5</option>
+            <option value="6">6</option>
+            <option value="7">7</option>
+            <option value="8">8</option>
+            <option value="9">9</option>
+            <option value="10">10</option>
+          </select>
         </div>
         </div>
       </div>
       </div>
       <button type="button" class="btn btn-default" onclick="batTest({ 'func': 'time', 'time': $('test_time').value });">Запуск теста</button>
       <button type="button" class="btn btn-default" onclick="batTest({ 'func': 'time', 'time': $('test_time').value });">Запуск теста</button>
@@ -279,11 +298,11 @@
     <div class="col span_1_of_3">
     <div class="col span_1_of_3">
       <h4 class="col span_2_of_2">Нагрузка</h4>
       <h4 class="col span_2_of_2">Нагрузка</h4>
       <button type="button" class="btn btn-default" onclick="UPSPowerOff({'func': 'reboot'})">Отмена отключения</button>
       <button type="button" class="btn btn-default" onclick="UPSPowerOff({'func': 'reboot'})">Отмена отключения</button>
-      <button type="button" class="btn btn-default" onclick="UPSPowerOff({'func': 'off', 'after': $('upspo_after').value})">Отключить</button>
+      <button type="button" class="btn btn-default" onclick="UPSPowerOff({'func': 'off', 'after': $('upspo_after').children[0].value})">Отключить</button>
       <div class="form-group">
       <div class="form-group">
-        <label for="" class="col span_1_of_2">Откл. через (мин)</label>
+        <label for="" class="col span_1_of_2">Откл. через (1-99 мин)</label>
         <div class="col span_1_of_2">
         <div class="col span_1_of_2">
-          <input type="text" class="form-control" value="10" maxlength="6" id="upspo_after">
+          <span id="upspo_after"></span>
         </div>
         </div>
       </div>
       </div>
     </div>
     </div>
@@ -386,6 +405,7 @@ var bat_charge    = new SpinBox('bat_charge', {'name':'bat_charge','minimum':12,
 var temp_hist     = new SpinBox('temp_hist', {'name':'temp_hist','minimum':0.5,'maximum':2.0,'step':0.1,'decimals':1, 'value': 0.5});
 var temp_hist     = new SpinBox('temp_hist', {'name':'temp_hist','minimum':0.5,'maximum':2.0,'step':0.1,'decimals':1, 'value': 0.5});
 var loadvolt_hist = new SpinBox('loadvolt_hist', {'name':'loadvolt_hist','minimum':0.5,'maximum':2.0,'step':0.1,'decimals':1, 'value': 0.5});
 var loadvolt_hist = new SpinBox('loadvolt_hist', {'name':'loadvolt_hist','minimum':0.5,'maximum':2.0,'step':0.1,'decimals':1, 'value': 0.5});
 var mainvolt_hist = new SpinBox('mainvolt_hist', {'name':'mainvolt_hist','minimum':10,'maximum':30,'step':1});
 var mainvolt_hist = new SpinBox('mainvolt_hist', {'name':'mainvolt_hist','minimum':10,'maximum':30,'step':1});
+var upspo_after   = new SpinBox('upspo_after', {'minimum':1,'maximum':99,'step':1, 'value': 1});
 
 
 settingsGET();
 settingsGET();
 // $('dev-update').onclick = function(){
 // $('dev-update').onclick = function(){