ソースを参照

Merge branch 'new_lwip' of https://192.168.14.200:3000/dtelenkov/bt-670x into new_lwip

TelenkovDmitry 7 年 前
コミット
ceac38ce04

BIN
modules/HTTP_Server/fs/main.css


BIN
modules/HTTP_Server/fs/main.js


BIN
modules/HTTP_Server/fs/settings.html


ファイルの差分が大きいため隠しています
+ 631 - 623
modules/HTTP_Server/fsdata.c


+ 11 - 7
web_interface/src/wui/main.css

@@ -400,11 +400,11 @@ input[type="search"]::-webkit-search-decoration {
 }
 
 /* Main style */
-* {
-  -webkit-box-sizing: border-box;
-  -moz-box-sizing: border-box;
-  box-sizing: border-box;
-}
+// * {
+//   -webkit-box-sizing: border-box;
+//   -moz-box-sizing: border-box;
+//   box-sizing: border-box;
+// }
 *:before,
 *:after {
   -webkit-box-sizing: border-box;
@@ -2097,7 +2097,11 @@ fieldset[disabled] .checkbox label {
   z-index:102;
   overflow: auto;
 }
-#checkUpdatePass, #changePassword, #uploadSettings, #rectifiersConfig{
+#checkUpdatePass,
+#changePassword,
+#uploadSettings,
+#uploadCertificate,
+#rectifiersConfig{
   display: none;
   position: relative;
   text-align: center;
@@ -2114,7 +2118,7 @@ fieldset[disabled] .checkbox label {
 #checkUpdatePass{
   border: 5px solid #5cb85c;
 }
-#changePassword, #uploadSettings{
+#changePassword, #uploadSettings, #uploadCertificate{
   border: 5px solid #337ab7;
 }
 

+ 35 - 1
web_interface/src/wui/main.js

@@ -161,6 +161,17 @@ function ValidateAlphanumeric(uadd, z) {
   return false;
 }
 
+function validateUpload(oForm) {
+  var file = oForm.elements.datafile.files[0];
+  var fnmreg = /^.{1,}\.crt$/g;
+
+  if (file && fnmreg.test(file.name) ) {
+    upload(file);
+  } else {
+    alert('Файл сертификата не указан или не валиден!');
+  }
+  return false;
+}
 
 function submitForms() {
   if (confirm('Вы уверены что хотите применить настройки?')) {
@@ -175,7 +186,30 @@ function submitForms() {
     }
   }
 }
-
+function upload(file) {
+  var fl = new FormData();
+  fl.append('file', file);
+  var xhr = new XMLHttpRequest();
+  xhr.open('POST', '/srv_crt_upload.cgi', true);
+  // обработчик для закачки
+  xhr.upload.onprogress = function(event) {
+    var progress = Math.floor((event.loaded / event.total) * 100);
+    console.log(progress + '%');
+  };
+  xhr.onload = xhr.onerror = function() {
+    if (this.status == 200) {
+      if (+xhr.responseText == '1') {
+        alert('Успешно');
+        window.location.reload();
+      } else {
+        alert('Ошибка установки сертификата');
+      }
+    } else {
+      alert('Ошибка ' + this.status);
+    }
+  };
+  xhr.send(fl);
+}
 function checkPWD(){
   // $('checkUpdatePass').style.display = 'none';
   $('count-wrap').style.display = 'block';

+ 30 - 1
web_interface/src/wui/settings.html

@@ -28,6 +28,20 @@
       <input type="submit" class="btn btn-success-inverted" onclick="checkChangePWD(); return false;" value="Отправить">
     </form>
   </div>
+  <div id='uploadCertificate'>
+    <form name="upload" onsubmit="return validateUpload(this);">
+      <p>Загрузка сертификата.</p>
+      <div class="upload-wrapper">
+        <input id="uploadFile" placeholder="Файл" disabled="disabled" class="file-name" />
+        <div class="fileUpload btn btn-primary">
+          <span>Выбор файла</span>
+          <input id="uploadBtn" type="file" class="upload" name="datafile"/>
+        </div>
+      </div>
+      <input type="button" id="close-cert" class="btn btn-danger-inverted" value="Отмена">
+      <input class="btn btn-success-inverted" type="submit" value="Загрузить">
+    </form>
+  </div>
 </div>
 <div class="navbar navbar-default navbar-fixed-top">
   <div class="navbar-header">
@@ -246,7 +260,9 @@
           <input type="checkbox" name="swauth" id="swauth" onchange="authState()"> Включить авторизацию
         </label>
       </div>
-
+      <div class="col span_2_of_2">
+        <a href="javascript:void(0)" id="set-cert">Загрузить сертификат</a>
+      </div>
     </div>
   </div>
 </div>
@@ -350,6 +366,19 @@ $('dev-update').onclick = function(){
   };
 };
 
+$('set-cert').onclick = function(){
+  $('count-wrap').style.display = 'block';
+  $('uploadCertificate').style.display = 'block';
+};
+$('uploadBtn').onchange = function(){
+  $('uploadFile').value = this.files[0].name;
+};
+$('close-cert').onclick = function() {
+  $('count-wrap').style.display = 'none';
+  $('uploadCertificate').style.display = 'none';
+  $('uploadBtn').innerHTML = $('uploadBtn').innerHTML;
+  $('uploadFile').value = '';
+};
 $('change_pass').onclick = function(){
   $('count-wrap').style.display = 'block';
   $('changePassword').style.display = 'block';

この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません