Avetisyan Karen 5 rokov pred
rodič
commit
dc6b4bdd87

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


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


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


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


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

@@ -95,6 +95,7 @@ function fadeIn(el, display){
 //########## Settings Form ############
 
 function formValidation(){
+  $('validation-box').innerHTML = '';
   var read_community,write_community,managerIP,managerIP2,managerIP3,managerIP4,managerIP5,
     ipaddr, gw, mask, tn_port, wtl_ip1, wtl_ip2, wtl_ip3, wtl_ip4, wtl_ip5, ups_cell_min, ups_cell_max/*, ntpservip*/;
 
@@ -109,6 +110,7 @@ function formValidation(){
   gw              = $('gw');
   mask            = $('mask');
   tn_port         = $('tn_port');
+  ssh_port        = $('ssh_port');
   wtl_ip1         = $('wtl_ip1');
   wtl_ip2         = $('wtl_ip2');
   wtl_ip3         = $('wtl_ip3');
@@ -127,6 +129,17 @@ function formValidation(){
   if ($('tn_enabled').checked) {
     if(!ValidateNumber(tn_port, ' Порт Telnet')) flag = false;
   }
+  if ($('ssh_enabled').checked) {
+    if(!ValidateNumber(ssh_port, ' Порт SSH')) flag = false;
+  }
+  if ($('ssh_enabled').checked && $('tn_enabled').checked) {
+    if (ssh_port.value == tn_port.value) {
+      var warn = document.createElement('li');
+      warn.innerHTML = 'Одинаковые поты Telnet и SSH!';
+      $('validation-box').appendChild(warn);
+      flag = false;
+    }
+  }
   if(ups_cell_min > ups_cell_max) {
     var warn = document.createElement('li');
     warn.innerHTML = 'Минимальное напряжение на ячейке не может быть больше максимального!';
@@ -345,6 +358,13 @@ function telnetState() {
     $('tn_port').removeAttribute('disabled');
   }
 }
+function sshState() {
+  if (!$('ssh_enabled').checked) {
+    $('ssh_port').setAttribute('disabled', 'disabled');
+  } else {
+    $('ssh_port').removeAttribute('disabled');
+  }
+}
 
 //########## Info Form Validation ############
 
@@ -870,6 +890,8 @@ function settingsGET(){
 
     $('tn_enabled').checked   = data.tn_enabled;
     $('tn_port').value        = data.tn_port;
+    $('ssh_enabled').checked  = data.ssh_enabled;
+    $('ssh_port').value       = data.ssh_port;
     $("bat_prod").value       = data.bat_prod;
     ups_max_power = new SpinBox('ups_max_power', {
       'value': data.ups_max_power,

+ 2 - 0
web_interface/src/wui-9/settings.cgi

@@ -50,6 +50,8 @@ JSON = {
   "dhcp":1,
   "tn_enabled": 1,
   "tn_port": 23,
+  "ssh_enabled": 1,
+  "ssh_port": 22,
   "loadvolt_min":43,
   "loadvolt_min_hist":0.5,
   "pps_min":5.0,

+ 12 - 0
web_interface/src/wui-9/settings.html

@@ -164,6 +164,18 @@
         <input type="text" class="form-control" id="tn_port" name="tn_port">
       </div>
     </div>
+    <div class="col span_1_of_2">
+      <h4 class="col span_2_of_2">SSH</h4>
+      <div class="checkbox col span_2_of_2">
+        <label>
+          <input type="checkbox" name="ssh_enabled" id="ssh_enabled" onchange="sshState();">&nbsp;Включить
+        </label>
+      </div>
+      <label for="ssh_port" class="col span_1_of_2">Порт SSH</label>
+      <div class="col span_1_of_2">
+        <input type="text" class="form-control" id="ssh_port" name="ssh_port">
+      </div>
+    </div>
   </div>
 </div>
 <div id="whitelist" class="tabpane">