diff --git a/MyWebsite/Controllers/AdminController.cs b/MyWebsite/Controllers/AdminController.cs new file mode 100644 index 0000000..d204192 --- /dev/null +++ b/MyWebsite/Controllers/AdminController.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.Http; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using MyWebsite.Models; +using Newtonsoft.Json; + +namespace MyWebsite.Controllers +{ + public class AdminController : Controller + { + public IActionResult Index() + { + return View(); + } + + public async Task Projects(int? id) + { + if (id == null) + return View(); + else + { + Project[] projects = JsonConvert.DeserializeObject(await new HttpClient().GetStringAsync($"{Request.Scheme}://{Request.Host}/Projects.json")); + + ViewData["Project"] = projects[id.Value]; + ViewData["Badges"] = new Dictionary + { + { "csharp", "C# Programming language" }, + { "dotnet", ".NET Framework" }, + { "xamarin", "Xamarin Framework" }, + { "unity", "Unity Engine" }, + { "uwp", "Universal Windows Platform" }, + { "windows", "Windows Platform" }, + { "win32", "Windows Platform (Win32)" }, + { "android", "Android Platform" }, + { "ios", "iOS Platform" } + }; + + return View("Views/Admin/ProjectEditor.cshtml"); + } + } + } +} \ No newline at end of file diff --git a/MyWebsite/Views/Admin/Index.cshtml b/MyWebsite/Views/Admin/Index.cshtml new file mode 100644 index 0000000..65c9845 --- /dev/null +++ b/MyWebsite/Views/Admin/Index.cshtml @@ -0,0 +1,27 @@ + +@{ + ViewData["Title"] = "Admin panel"; +} + +
+

Administration

+

Note: Any write/read operations in this section will require an admin password

+
+ +
+
+
+
+
+ +
+ +
+
+ + \ No newline at end of file diff --git a/MyWebsite/Views/Admin/ProjectEditor.cshtml b/MyWebsite/Views/Admin/ProjectEditor.cshtml new file mode 100644 index 0000000..0556214 --- /dev/null +++ b/MyWebsite/Views/Admin/ProjectEditor.cshtml @@ -0,0 +1,35 @@ + +@{ + ViewData["Title"] = "Project editor"; + Project project = ViewData["Project"] as Project; +} + +
+

Project editor

+

@project.Title

+
+ +
+
+ +
+ +
+ + + + + + + + + + + +
+
+ + \ No newline at end of file diff --git a/MyWebsite/Views/Admin/Projects.cshtml b/MyWebsite/Views/Admin/Projects.cshtml new file mode 100644 index 0000000..5bcbf33 --- /dev/null +++ b/MyWebsite/Views/Admin/Projects.cshtml @@ -0,0 +1,7 @@ + +@{ + ViewData["Title"] = "Projects list"; +} + +

Projects

+ diff --git a/MyWebsite/wwwroot/css/Admin.css b/MyWebsite/wwwroot/css/Admin.css new file mode 100644 index 0000000..de3f343 --- /dev/null +++ b/MyWebsite/wwwroot/css/Admin.css @@ -0,0 +1,62 @@ +input { + padding: 10px; + border-radius: 10px; + border: 1px solid black; + width: 100%; + box-sizing: border-box; +} + +select { + padding: 10px; + border: 1px solid black; + border-radius: 10px; + width: 100%; + -moz-appearance: none; /* Firefox */ + -webkit-appearance: none; /* Safari and Chrome */ +} + +button { + margin: 10px; + border-radius: 10px; + border: 0px; + padding: 10px 20px; + background-color: #343434; + color: white; +} + +textarea { + resize: none; + width: 100%; + border-radius: 10px; + border: 1px solid black; + padding: 10px; + box-sizing: border-box; + height: 200px; + font-family: Consolas; +} + +.select-container::after { + content: '>'; + transform: rotate(90deg); + -webkit-transform: rotate(90deg); + -moz-transform: rotate(90deg); + -ms-transform: rotate(90deg); + right: 11px; + top: 11px; + position: absolute; + pointer-events: none; +} + +.select-container { + position: relative; +} + +form { + max-width: 50%; +} + +@media only screen and (max-width: 700px) { + form { + max-width: initial; + } +}