new battery levels
begin of adminpannel and names editor
This commit is contained in:
parent
925e30e086
commit
e41e6ddabc
@ -75,6 +75,9 @@
|
|||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Content Include="resources\admin\css\global.css">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<Content Include="resources\admin\index.html">
|
<Content Include="resources\admin\index.html">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
@ -187,6 +190,10 @@
|
|||||||
<Name>Utils</Name>
|
<Name>Utils</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup />
|
<ItemGroup>
|
||||||
|
<Content Include="resources\admin\js\menu.js">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
@ -1,6 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
using System.Text;
|
||||||
using BlubbFish.Utils;
|
using BlubbFish.Utils;
|
||||||
using BlubbFish.Utils.IoT.Bots;
|
using BlubbFish.Utils.IoT.Bots;
|
||||||
|
|
||||||
@ -14,9 +16,26 @@ namespace Fraunhofer.Fit.IoT.LoraMap.Model.Admin {
|
|||||||
if(!this.CheckAuth(cont)) {
|
if(!this.CheckAuth(cont)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if(cont.Request.Url.PathAndQuery.StartsWith("/admin/get_json_")) {
|
||||||
|
return this.SendJson(cont);
|
||||||
|
}
|
||||||
return Webserver.SendFileResponse(cont);
|
return Webserver.SendFileResponse(cont);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Boolean SendJson(HttpListenerContext cont) {
|
||||||
|
if(cont.Request.Url.PathAndQuery == "/admin/get_json_names") {
|
||||||
|
String file = File.ReadAllText("names.json");
|
||||||
|
Byte[] buf = Encoding.UTF8.GetBytes(file);
|
||||||
|
cont.Response.ContentLength64 = buf.Length;
|
||||||
|
cont.Response.OutputStream.Write(buf, 0, buf.Length);
|
||||||
|
Console.WriteLine("200 - Send names.json " + cont.Request.Url.PathAndQuery);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Helper.WriteError("404 - Section in get_json not found " + cont.Request.Url.PathAndQuery + "!");
|
||||||
|
cont.Response.StatusCode = 404;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private Boolean Login(HttpListenerContext cont) {
|
private Boolean Login(HttpListenerContext cont) {
|
||||||
Dictionary<String, String> POST = Webserver.GetPostParams(cont.Request);
|
Dictionary<String, String> POST = Webserver.GetPostParams(cont.Request);
|
||||||
if(POST.ContainsKey("user") && POST["user"] == "admin" &&
|
if(POST.ContainsKey("user") && POST["user"] == "admin" &&
|
||||||
@ -56,6 +75,9 @@ namespace Fraunhofer.Fit.IoT.LoraMap.Model.Admin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Boolean CheckAuth(HttpListenerContext cont) {
|
private Boolean CheckAuth(HttpListenerContext cont) {
|
||||||
|
#if DEBUG
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
if(cont.Request.Url.PathAndQuery.StartsWith("/admin/login.html")) {
|
if(cont.Request.Url.PathAndQuery.StartsWith("/admin/login.html")) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -65,13 +65,13 @@ namespace Fraunhofer.Fit.IoT.LoraMap.Model {
|
|||||||
}
|
}
|
||||||
this.Recievedtime = DateTime.UtcNow;
|
this.Recievedtime = DateTime.UtcNow;
|
||||||
this.Battery = Math.Round((Double)json["BatteryLevel"], 2);
|
this.Battery = Math.Round((Double)json["BatteryLevel"], 2);
|
||||||
if(this.Battery < 3.59) {
|
if(this.Battery < 3.44) {
|
||||||
this.Batterysimple = 0;
|
this.Batterysimple = 0;
|
||||||
} else if(this.Battery < 3.69) {
|
} else if(this.Battery < 3.53) {
|
||||||
this.Batterysimple = 1;
|
this.Batterysimple = 1;
|
||||||
} else if(this.Battery < 3.77) {
|
} else if(this.Battery < 3.6525) {
|
||||||
this.Batterysimple = 2;
|
this.Batterysimple = 2;
|
||||||
} else if(this.Battery < 3.97) {
|
} else if(this.Battery < 3.8825) {
|
||||||
this.Batterysimple = 3;
|
this.Batterysimple = 3;
|
||||||
} else {
|
} else {
|
||||||
this.Batterysimple = 4;
|
this.Batterysimple = 4;
|
||||||
|
31
Lora-Map/resources/admin/css/global.css
Normal file
31
Lora-Map/resources/admin/css/global.css
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
html, body {
|
||||||
|
height: 100%;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
font-family: Verdana;
|
||||||
|
}
|
||||||
|
|
||||||
|
#header {
|
||||||
|
font-size: 20px;
|
||||||
|
font-weight: bold;
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#menu {
|
||||||
|
width: 200px;
|
||||||
|
font-size: 12px;
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
#menu ul {
|
||||||
|
padding-left: 20px;
|
||||||
|
}
|
||||||
|
#menu ul li a {
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
#menu ul li a:hover {
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#content {
|
||||||
|
margin-left: 210px;
|
||||||
|
}
|
@ -3,9 +3,20 @@
|
|||||||
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
|
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<title></title>
|
<title>Adminpannel Lora-Map</title>
|
||||||
|
<link rel="stylesheet" type="text/css" href="css/global.css" />
|
||||||
|
<script type="text/javascript" src="js/menu.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
ADMIN
|
<div id="header">Adminpannel Lora-Map</div>
|
||||||
|
<div id="menu">
|
||||||
|
<ul>
|
||||||
|
<li><a onclick="menu_names(); return false;" href="#">Namen und Icons</a></li>
|
||||||
|
<li><a onclick="menu_overlay(); return false;" href="#">Karteneditor</a></li>
|
||||||
|
<li><a onclick="menu_export(); return false;" href="#">Einstellungen Exportieren</a></li>
|
||||||
|
<li><a onclick="menu_import(); return false;" href="#">Einstellungen Importieren</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div id="content">Wilkommen im Adminbereich</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
40
Lora-Map/resources/admin/js/menu.js
Normal file
40
Lora-Map/resources/admin/js/menu.js
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
function menu_names() {
|
||||||
|
var parsenames = new XMLHttpRequest();
|
||||||
|
parsenames.onreadystatechange = function() {
|
||||||
|
if(parsenames.readyState === 4 && parsenames.status === 200) {
|
||||||
|
NamesEditor.parseJson(parsenames.responseText);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
parsenames.open("GET", "http://{%REQUEST_URL_HOST%}:8080/admin/get_json_names", true);
|
||||||
|
parsenames.send();
|
||||||
|
}
|
||||||
|
|
||||||
|
function menu_overlay() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function menu_export() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function menu_import() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
var NamesEditor = {
|
||||||
|
parseJson: function (jsontext) {
|
||||||
|
document.getElementById("content").innerHTML = "";
|
||||||
|
var namesconfig = JSON.parse(jsontext);
|
||||||
|
var html = "<div>Einträge</div>";
|
||||||
|
for (var id in namesconfig) {
|
||||||
|
if (namesconfig.hasOwnProperty(id)) {
|
||||||
|
var nameentry = namesconfig[id];
|
||||||
|
html += "<div>" +
|
||||||
|
"<span>" + id + "</span>" +
|
||||||
|
"<span>"+nameentry["name"]+"</span>"+
|
||||||
|
"</div>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
document.getElementById("content").innerHTML = html;
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user