diff --git a/Lora-Map/Lora-Map.csproj b/Lora-Map/Lora-Map.csproj index 383781d..96a0d02 100644 --- a/Lora-Map/Lora-Map.csproj +++ b/Lora-Map/Lora-Map.csproj @@ -75,6 +75,9 @@ + + PreserveNewest + PreserveNewest @@ -187,6 +190,10 @@ Utils - + + + PreserveNewest + + \ No newline at end of file diff --git a/Lora-Map/Model/Admin/Adminmodel.cs b/Lora-Map/Model/Admin/Adminmodel.cs index cb3cff5..ad3da9f 100644 --- a/Lora-Map/Model/Admin/Adminmodel.cs +++ b/Lora-Map/Model/Admin/Adminmodel.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; +using System.IO; using System.Net; +using System.Text; using BlubbFish.Utils; using BlubbFish.Utils.IoT.Bots; @@ -14,9 +16,26 @@ namespace Fraunhofer.Fit.IoT.LoraMap.Model.Admin { if(!this.CheckAuth(cont)) { return false; } + if(cont.Request.Url.PathAndQuery.StartsWith("/admin/get_json_")) { + return this.SendJson(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) { Dictionary POST = Webserver.GetPostParams(cont.Request); if(POST.ContainsKey("user") && POST["user"] == "admin" && @@ -56,6 +75,9 @@ namespace Fraunhofer.Fit.IoT.LoraMap.Model.Admin { } private Boolean CheckAuth(HttpListenerContext cont) { + #if DEBUG + return true; + #endif if(cont.Request.Url.PathAndQuery.StartsWith("/admin/login.html")) { return true; } else { diff --git a/Lora-Map/Model/PositionItem.cs b/Lora-Map/Model/PositionItem.cs index a193e6c..0f07098 100644 --- a/Lora-Map/Model/PositionItem.cs +++ b/Lora-Map/Model/PositionItem.cs @@ -65,13 +65,13 @@ namespace Fraunhofer.Fit.IoT.LoraMap.Model { } this.Recievedtime = DateTime.UtcNow; this.Battery = Math.Round((Double)json["BatteryLevel"], 2); - if(this.Battery < 3.59) { + if(this.Battery < 3.44) { this.Batterysimple = 0; - } else if(this.Battery < 3.69) { + } else if(this.Battery < 3.53) { this.Batterysimple = 1; - } else if(this.Battery < 3.77) { + } else if(this.Battery < 3.6525) { this.Batterysimple = 2; - } else if(this.Battery < 3.97) { + } else if(this.Battery < 3.8825) { this.Batterysimple = 3; } else { this.Batterysimple = 4; diff --git a/Lora-Map/resources/admin/css/global.css b/Lora-Map/resources/admin/css/global.css new file mode 100644 index 0000000..ec50778 --- /dev/null +++ b/Lora-Map/resources/admin/css/global.css @@ -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; +} \ No newline at end of file diff --git a/Lora-Map/resources/admin/index.html b/Lora-Map/resources/admin/index.html index 2ac7b38..cbd7b26 100644 --- a/Lora-Map/resources/admin/index.html +++ b/Lora-Map/resources/admin/index.html @@ -2,10 +2,21 @@ - - + + Adminpannel Lora-Map + + - ADMIN + + +
Wilkommen im Adminbereich
\ No newline at end of file diff --git a/Lora-Map/resources/admin/js/menu.js b/Lora-Map/resources/admin/js/menu.js new file mode 100644 index 0000000..bce5b59 --- /dev/null +++ b/Lora-Map/resources/admin/js/menu.js @@ -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 = "
Einträge
"; + for (var id in namesconfig) { + if (namesconfig.hasOwnProperty(id)) { + var nameentry = namesconfig[id]; + html += "
" + + "" + id + "" + + ""+nameentry["name"]+""+ + "
"; + } + } + document.getElementById("content").innerHTML = html; + } +}; \ No newline at end of file