diff --git a/Lora-Map/Lora-Map.csproj b/Lora-Map/Lora-Map.csproj
index 1858338..cc670b3 100644
--- a/Lora-Map/Lora-Map.csproj
+++ b/Lora-Map/Lora-Map.csproj
@@ -45,6 +45,7 @@
+
@@ -179,5 +180,8 @@
Utils
+
+
+
\ No newline at end of file
diff --git a/Lora-Map/Model/Admin/Adminmodel.cs b/Lora-Map/Model/Admin/Adminmodel.cs
new file mode 100644
index 0000000..3777591
--- /dev/null
+++ b/Lora-Map/Model/Admin/Adminmodel.cs
@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Text;
+using System.Threading.Tasks;
+using BlubbFish.Utils.IoT.Bots;
+
+namespace Fraunhofer.Fit.IoT.LoraMap.Model.Admin {
+ class AdminModel {
+ public Boolean ParseReuqest(HttpListenerContext cont) {
+ //cont.Request.Url.PathAndQuery =
+ if(!this.CheckAuth(cont)) {
+ return false;
+ }
+ return Webserver.SendFileResponse(cont, "admin");
+ }
+
+ private Boolean CheckAuth(HttpListenerContext cont) {
+ if(cont.Request.Url.PathAndQuery.StartsWith("/admin/login")) {
+ return true;
+ } else if(cont.Request.Url.PathAndQuery.StartsWith("/admin/logout")) {
+ } else {
+ cont.Response.StatusCode = 403;
+ }
+ return false;
+ }
+ }
+}
diff --git a/Lora-Map/Server.cs b/Lora-Map/Server.cs
index b958344..e814281 100644
--- a/Lora-Map/Server.cs
+++ b/Lora-Map/Server.cs
@@ -8,6 +8,7 @@ using BlubbFish.Utils.IoT.Bots;
using BlubbFish.Utils.IoT.Connector;
using BlubbFish.Utils.IoT.Events;
using Fraunhofer.Fit.IoT.LoraMap.Model;
+using Fraunhofer.Fit.IoT.LoraMap.Model.Admin;
using LitJson;
namespace Fraunhofer.Fit.IoT.LoraMap {
@@ -17,6 +18,7 @@ namespace Fraunhofer.Fit.IoT.LoraMap {
private readonly SortedDictionary alarms = new SortedDictionary();
private readonly JsonData marker;
private readonly Dictionary markertable = new Dictionary();
+ private readonly AdminModel admin = new AdminModel();
public Server(ADataBackend backend, Dictionary settings, InIReader requests) : base(backend, settings, requests) => this.marker = JsonMapper.ToObject(File.ReadAllText("names.json"));
@@ -45,14 +47,12 @@ namespace Fraunhofer.Fit.IoT.LoraMap {
}
}
- protected override void SendResponse(HttpListenerContext cont) {
+ protected override Boolean SendWebserverResponse(HttpListenerContext cont) {
try {
if (cont.Request.Url.PathAndQuery.StartsWith("/loc")) {
- this.SendJsonResponse(this.positions, cont);
- return;
+ return SendJsonResponse(this.positions, cont);
} else if(cont.Request.Url.PathAndQuery.StartsWith("/panic")) {
- this.SendJsonResponse(this.alarms, cont);
- return;
+ return SendJsonResponse(this.alarms, cont);
} else if (cont.Request.Url.PathAndQuery.StartsWith("/icons/marker/Marker.svg") && cont.Request.Url.PathAndQuery.Contains("?")) {
String hash = cont.Request.Url.PathAndQuery.Substring(cont.Request.Url.PathAndQuery.IndexOf('?') + 1);
if (!this.markertable.ContainsKey(hash)) {
@@ -63,17 +63,18 @@ namespace Fraunhofer.Fit.IoT.LoraMap {
cont.Response.ContentLength64 = buf.Length;
cont.Response.OutputStream.Write(buf, 0, buf.Length);
Console.WriteLine("200 - " + cont.Request.Url.PathAndQuery);
- return;
+ return true;
} else if(cont.Request.Url.PathAndQuery.StartsWith("/currenttime")) {
- this.SendJsonResponse(new Dictionary() { { "utc", DateTime.UtcNow } }, cont);
- return;
+ return SendJsonResponse(new Dictionary() { { "utc", DateTime.UtcNow } }, cont);
+ } else if(cont.Request.Url.PathAndQuery.StartsWith("/admin")) {
+ return this.admin.ParseReuqest(cont);
}
} catch (Exception e) {
Helper.WriteError("500 - " + e.Message);
cont.Response.StatusCode = 500;
- return;
+ return false;
}
- base.SendResponse(cont);
+ return SendFileResponse(cont, "resources");
}
}
}
\ No newline at end of file