소스 검색

cleanup web interface

Andrew Tridgell 3 년 전
부모
커밋
b068d31c8f
5개의 변경된 파일87개의 추가작업 그리고 45개의 파일을 삭제
  1. 2 2
      RemoteIDModule/Makefile
  2. 17 6
      RemoteIDModule/web/index.html
  3. 1 0
      RemoteIDModule/web/js/jquery.min.js
  4. 51 35
      RemoteIDModule/web/uploader.html
  5. 16 2
      RemoteIDModule/webinterface.cpp

+ 2 - 2
RemoteIDModule/Makefile

@@ -38,8 +38,8 @@ headers:
 	@../scripts/git-version.sh
 	@cd .. && scripts/regen_headers.sh
 
-romfs_files.h: web/*.html web/js/*.js
-	@../scripts/make_romfs.py romfs_files.h web/*.html web/js/*.js
+romfs_files.h: web/*.html web/js/*.js web/styles/*css web/images/*.jpg
+	@../scripts/make_romfs.py romfs_files.h web/*.html web/js/*.js web/styles/*css web/images/*.jpg
 
 ArduRemoteID-%.bin: *.cpp *.ino *.h romfs_files.h
 	@echo "Building $* on $(CHIP)"

+ 17 - 6
RemoteIDModule/web/index.html

@@ -1,3 +1,14 @@
+<!doctype html>
+<html lang="en">
+
+<head>
+    <meta charset="utf-8">
+    <title>ArduRemoteID</title>
+    <meta name="description" content="ArduPilot RemoteID Module.">
+    <link rel="stylesheet" type="text/css" href="styles/main.css">
+</head>
+
+<body>
 <form name='loginForm'>
   <table width='20%' bgcolor='A09F9F' align='center'>
     <tr>
@@ -8,10 +19,6 @@
       <br>
       <br>
     </tr>
-    <tr>
-      <td>Username:</td>
-      <td><input type='text' size=25 name='userid'><br></td>
-    </tr>
     <br>
     <br>
     <tr>
@@ -25,12 +32,16 @@
     </tr>
   </table>
 </form>
+
 <script>
   function check(form) {
-      if(form.userid.value=='admin' && form.pwd.value=='admin') {
+      if (form.pwd.value=='admin') {
           window.open('/uploader.html')
       } else {
-          alert('Error Password or Username')/*displays error message*/
+          alert('Incorrect Password')
       }
   }
 </script>
+
+</body>
+</html>

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 1 - 0
RemoteIDModule/web/js/jquery.min.js


+ 51 - 35
RemoteIDModule/web/uploader.html

@@ -1,36 +1,52 @@
-<script src='js/jquery.min.js'></script>
-<form method='POST' action='#' enctype='multipart/form-data' id='upload_form'>
-  <input type='file' name='update'>
-  <input type='submit' value='Update'>
-</form>
-<div id='prg'>upload progress: 0%</div>
-<script>
-  $('form').submit(function(e) {
-      e.preventDefault();
-      var form = $('#upload_form')[0];
-      var data = new FormData(form);
-      $.ajax({
-          url: '/update',
-          type: 'POST',
-          data: data,
-          contentType: false,
-          processData:false,
-          xhr: function() {
-              var xhr = new window.XMLHttpRequest();
-              xhr.upload.addEventListener('progress', function(evt) {
-                  if (evt.lengthComputable) {
-                      var per = evt.loaded / evt.total;
-                      $('#prg').html('progress: ' + Math.round(per*100) + '%');
-                  }
-              }, false);
-              return xhr;
-          },
-          success:function(d, s) {
-              console.log('success!')
-          },
-          error: function (a, b, c) {
-          }
-      });
-  });
-</script>
+<!doctype html>
+<html lang="en">
 
+<head>
+    <meta charset="utf-8">
+    <title>ArduRemoteID Firmware Update</title>
+    <meta name="description" content="ArduPilot RemoteID Module.">
+    <link rel="stylesheet" type="text/css" href="styles/main.css">
+    <script src='js/jquery.min.js'></script>
+</head>
+
+<body>
+  <h1>ArduRemoteID Firmware Update</h1>
+
+  <form method='POST' action='#' enctype='multipart/form-data' id='upload_form'>
+    <input type='file' name='update'>
+    <input type='submit' value='Update'>
+  </form>
+  <div id='progress'>upload progress: 0%</div>
+
+  <script>
+    $('form').submit(function(e) {
+        e.preventDefault();
+        var form = $('#upload_form')[0];
+        var data = new FormData(form);
+        $.ajax({
+            url: '/update',
+            type: 'POST',
+            data: data,
+            contentType: false,
+            processData:false,
+            xhr: function() {
+                var xhr = new window.XMLHttpRequest();
+                xhr.upload.addEventListener('progress', function(evt) {
+                    if (evt.lengthComputable) {
+                        var per = evt.loaded / evt.total;
+                        $('#progress').html('progress: ' + Math.round(per*100) + '%');
+                    }
+                }, false);
+                return xhr;
+            },
+            success:function(d, s) {
+                console.log('success!')
+            },
+            error: function (a, b, c) {
+            }
+        });
+    });
+  </script>
+
+</body>
+</html>

+ 16 - 2
RemoteIDModule/webinterface.cpp

@@ -34,10 +34,24 @@ class ROMFS_Handler : public RequestHandler
         }
         String uri = "web" + requestUri;
         Serial.printf("handle: '%s'\n", requestUri.c_str());
+
+        // work out content type
         const char *content_type = "text/html";
-        if (uri.endsWith(".js")) {
-            content_type = "text/javascript";
+        const struct {
+            const char *extension;
+            const char *content_type;
+        } extensions[] = {
+            { ".js", "text/javascript" },
+            { ".jpg", "image/jpeg" },
+            { ".css", "text/css" },
+        };
+        for (const auto &e : extensions) {
+            if (uri.endsWith(e.extension)) {
+                content_type = e.content_type;
+                break;
+            }
         }
+
         auto *f = ROMFS::find_stream(uri.c_str());
         if (f != nullptr) {
             server.sendHeader("Content-Encoding", "gzip");

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.