misc. changes
This commit is contained in:
@@ -24,12 +24,12 @@ namespace pointMaster.Controllers
|
|||||||
vm.links.Add(new NavUrl("Patruljer", "/Patrulje"));
|
vm.links.Add(new NavUrl("Patruljer", "/Patrulje"));
|
||||||
vm.links.Add(new NavUrl("Point", "/Point"));
|
vm.links.Add(new NavUrl("Point", "/Point"));
|
||||||
vm.links.Add(new NavUrl("Poster", "/Poster"));
|
vm.links.Add(new NavUrl("Poster", "/Poster"));
|
||||||
vm.links.Add(new NavUrl("Statistikker", "/stats"));
|
vm.links.Add(new NavUrl("Statistikker", "/Stats"));
|
||||||
}
|
}
|
||||||
if (User.Identity != null && User.Identity.IsAuthenticated)
|
if (User.Identity != null && User.Identity.IsAuthenticated)
|
||||||
{
|
{
|
||||||
vm.links.Add(new NavUrl("Giv point", "/point/givpoint"));
|
vm.links.Add(new NavUrl("Giv point", "/Point/GivPoint"));
|
||||||
vm.links.Add(new NavUrl("Vælg post", "/point/skiftpost"));
|
vm.links.Add(new NavUrl("Vælg post", "/Point/SkiftPost"));
|
||||||
vm.links.Add(new NavUrl("Log ud", "/account/signout"));
|
vm.links.Add(new NavUrl("Log ud", "/account/signout"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ using pointMaster.Models;
|
|||||||
|
|
||||||
namespace pointMaster.Controllers
|
namespace pointMaster.Controllers
|
||||||
{
|
{
|
||||||
[Authorize(Policy = Roles.Postmaster)]
|
|
||||||
public class PointController : Controller
|
public class PointController : Controller
|
||||||
{
|
{
|
||||||
private readonly DataContext context;
|
private readonly DataContext context;
|
||||||
@@ -15,7 +14,7 @@ namespace pointMaster.Controllers
|
|||||||
{
|
{
|
||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
[Authorize(Policy = Roles.Postmaster)]
|
||||||
public async Task<IActionResult> Index()
|
public async Task<IActionResult> Index()
|
||||||
{
|
{
|
||||||
var vm = new PointViewModel();
|
var vm = new PointViewModel();
|
||||||
@@ -31,7 +30,7 @@ namespace pointMaster.Controllers
|
|||||||
|
|
||||||
return View(vm);
|
return View(vm);
|
||||||
}
|
}
|
||||||
|
[Authorize(Policy = Roles.Postmaster)]
|
||||||
public async Task<IActionResult> SkiftPatrulje()
|
public async Task<IActionResult> SkiftPatrulje()
|
||||||
{
|
{
|
||||||
var vm = new SkiftPatruljeViewModel();
|
var vm = new SkiftPatruljeViewModel();
|
||||||
@@ -52,6 +51,28 @@ namespace pointMaster.Controllers
|
|||||||
|
|
||||||
public async Task<IActionResult> GivPoint(int id = 0)
|
public async Task<IActionResult> GivPoint(int id = 0)
|
||||||
{
|
{
|
||||||
|
if (!HttpContext.User.Identity.IsAuthenticated)
|
||||||
|
{
|
||||||
|
var patruljeData = new PatruljeInfoModel();
|
||||||
|
|
||||||
|
var data = await context.Patruljer.Include(x => x.Points).ThenInclude(x => x.Poster).FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
|
||||||
|
if (data != null)
|
||||||
|
{
|
||||||
|
patruljeData.patrulje = data;
|
||||||
|
|
||||||
|
patruljeData.totalPoints = data.Points.Sum(x => x.Points);
|
||||||
|
|
||||||
|
patruljeData.totalTurnout = data.Points.Sum(x => x.Turnout);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
return View("PatruljeInfo", patruljeData);
|
||||||
|
}
|
||||||
|
|
||||||
if (id == 0)
|
if (id == 0)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(Request.Cookies["Post"]))
|
if (string.IsNullOrEmpty(Request.Cookies["Post"]))
|
||||||
@@ -98,6 +119,7 @@ namespace pointMaster.Controllers
|
|||||||
return View(vm);
|
return View(vm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Authorize(Policy = Roles.Postmaster)]
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<IActionResult> GivPoint(int id, GivPointViewModel point)
|
public async Task<IActionResult> GivPoint(int id, GivPointViewModel point)
|
||||||
{
|
{
|
||||||
@@ -129,6 +151,7 @@ namespace pointMaster.Controllers
|
|||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Authorize(Policy = Roles.Postmaster)]
|
||||||
public async Task<IActionResult> SkiftPost()
|
public async Task<IActionResult> SkiftPost()
|
||||||
{
|
{
|
||||||
var vm = new SelectPostViewModel();
|
var vm = new SelectPostViewModel();
|
||||||
@@ -138,6 +161,7 @@ namespace pointMaster.Controllers
|
|||||||
return View(vm);
|
return View(vm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Authorize(Policy = Roles.Postmaster)]
|
||||||
public IActionResult SelectPost(int id)
|
public IActionResult SelectPost(int id)
|
||||||
{
|
{
|
||||||
var cookieOptions = new CookieOptions();
|
var cookieOptions = new CookieOptions();
|
||||||
@@ -150,6 +174,7 @@ namespace pointMaster.Controllers
|
|||||||
return Redirect("/");
|
return Redirect("/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Authorize(Policy = Roles.Editor)]
|
||||||
public ActionResult DeletePoint(int id)
|
public ActionResult DeletePoint(int id)
|
||||||
{
|
{
|
||||||
var point = context.Points.FirstOrDefault(p => p.Id == id);
|
var point = context.Points.FirstOrDefault(p => p.Id == id);
|
||||||
@@ -183,4 +208,10 @@ namespace pointMaster.Controllers
|
|||||||
public List<Point> points { get; set; } = null!;
|
public List<Point> points { get; set; } = null!;
|
||||||
public bool AllowedToDelete { get; set; } = false;
|
public bool AllowedToDelete { get; set; } = false;
|
||||||
}
|
}
|
||||||
|
public class PatruljeInfoModel
|
||||||
|
{
|
||||||
|
public Patrulje patrulje { get; set; } = null!;
|
||||||
|
public int totalPoints { get; set; }
|
||||||
|
public int totalTurnout { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using pointMaster.Data;
|
|||||||
|
|
||||||
namespace pointMaster.Controllers
|
namespace pointMaster.Controllers
|
||||||
{
|
{
|
||||||
|
[Authorize(Policy = Roles.Editor)]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("api")]
|
[Route("api")]
|
||||||
public class StatsApiController : ControllerBase
|
public class StatsApiController : ControllerBase
|
||||||
@@ -17,7 +18,6 @@ namespace pointMaster.Controllers
|
|||||||
this.dataContext = dataContext;
|
this.dataContext = dataContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Authorize(Policy = Roles.Editor)]
|
|
||||||
[HttpGet("GetPointsOverTime")]
|
[HttpGet("GetPointsOverTime")]
|
||||||
public async Task<object> GetList()
|
public async Task<object> GetList()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
{
|
{
|
||||||
<div class="border m-4 p-4 rounded">
|
<div class="border m-4 p-4 rounded">
|
||||||
<div class="d-flex flex-row justify-content-between">
|
<div class="d-flex flex-row justify-content-between">
|
||||||
<h2>@patrulje.Name</h2>
|
<h2><span>@patrulje.Id</span> @patrulje.Name</h2>
|
||||||
<p>Points: @Model.patruljePoints[patrulje.Id]</p>
|
<p>Points: @Model.patruljePoints[patrulje.Id]</p>
|
||||||
<p>Turnout: @Model.patruljeTurnout[patrulje.Id]</p>
|
<p>Turnout: @Model.patruljeTurnout[patrulje.Id]</p>
|
||||||
<div class="my-auto">
|
<div class="my-auto">
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Point";
|
ViewData["Title"] = "Point";
|
||||||
}
|
}
|
||||||
|
<h1>Point</h1>
|
||||||
<a asp-action="GivPoint" asp-controller="Point" class="btn btn-primary">Giv point</a>
|
<a asp-action="GivPoint" asp-controller="Point" class="btn btn-primary">Giv point</a>
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
|
|||||||
34
pointMaster/Views/Point/PatruljeInfo.cshtml
Normal file
34
pointMaster/Views/Point/PatruljeInfo.cshtml
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
@model pointMaster.Controllers.PatruljeInfoModel
|
||||||
|
|
||||||
|
<h1>@Model.patrulje.Name</h1>
|
||||||
|
|
||||||
|
<p>Total points: @Model.totalPoints</p>
|
||||||
|
<p>total turnout: @Model.totalTurnout</p>
|
||||||
|
<table class="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col">Post navn</th>
|
||||||
|
<th scope="col">Points</th>
|
||||||
|
<th scope="col">Turnout</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@if (Model.patrulje.Points.Any())
|
||||||
|
{
|
||||||
|
@foreach (var point in Model.patrulje.Points)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td scope="row">@point.Poster.Name</td>
|
||||||
|
<td scope="row">@point.Turnout</td>
|
||||||
|
<td scope="row">@point.Points</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td colspan="3">Ingen point givet</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
@@ -10,6 +10,6 @@
|
|||||||
<ul class="list-group">
|
<ul class="list-group">
|
||||||
@foreach (var patrulje in Model.Patruljer)
|
@foreach (var patrulje in Model.Patruljer)
|
||||||
{
|
{
|
||||||
<a asp-action="GivPoint" asp-controller="Point" asp-route-id="@patrulje.Id" class="btn btn-primary mb-2">@patrulje.Name</a>
|
<a asp-action="GivPoint" asp-controller="Point" asp-route-id="@patrulje.Id" class="list-group-item">@patrulje.Name</a>
|
||||||
}
|
}
|
||||||
</ul>
|
</ul>
|
||||||
@@ -6,6 +6,6 @@
|
|||||||
<ul class="list-group">
|
<ul class="list-group">
|
||||||
@foreach(var item in Model.Poster)
|
@foreach(var item in Model.Poster)
|
||||||
{
|
{
|
||||||
<a asp-action="SelectPost" asp-route-id="@item.Id" class="btn btn-primary">@item.Name</a>
|
<a asp-action="SelectPost" asp-route-id="@item.Id" class="list-group-item">@item.Name</a>
|
||||||
}
|
}
|
||||||
</ul>
|
</ul>
|
||||||
@@ -15,7 +15,10 @@
|
|||||||
<header>
|
<header>
|
||||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
|
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">pointMaster</a>
|
<div class="navbar-brand">
|
||||||
|
<img src="~/favicon.svg" class="pe-2" />
|
||||||
|
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">pointMaster</a>
|
||||||
|
</div>
|
||||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
|
||||||
aria-expanded="false" aria-label="Toggle navigation">
|
aria-expanded="false" aria-label="Toggle navigation">
|
||||||
<span class="navbar-toggler-icon"></span>
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
|||||||
@@ -4,4 +4,4 @@
|
|||||||
@{
|
@{
|
||||||
ViewData["title"] = "Stats";
|
ViewData["title"] = "Stats";
|
||||||
}
|
}
|
||||||
<hello-world></hello-world>
|
<stats></stats>
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
import { createApp } from "vue";
|
import { createApp } from "vue";
|
||||||
import HelloWorld from "./components/HelloWorld.vue";
|
import HelloWorld from "./components/HelloWorld.vue";
|
||||||
import Stats from "./components/Stats.vue";
|
import Stats from "./components/Stats.vue";
|
||||||
|
import Test from "./components/Test.vue";
|
||||||
|
|
||||||
const app = createApp({});
|
const app = createApp({});
|
||||||
|
|
||||||
app.component("hello-world", Stats);
|
app.component("stats", Stats);
|
||||||
|
|
||||||
(window as any).app = app;
|
(window as any).app = app;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user