From 82cec8eece4b30af1cc4afe1fc8c5da4439888ba Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Mon, 12 Jul 2021 02:17:26 +0100 Subject: [PATCH] Api Key view --- src/isnd/Data/ApiKeys/ApiKey.cs | 2 ++ src/isnd/Views/ApiKeys/Details.cshtml | 14 +++++++++++++- src/isnd/Views/ApiKeys/Index.cshtml | 6 +++++- src/isnd/wwwroot/css/site.css | 28 +++++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 2 deletions(-) diff --git a/src/isnd/Data/ApiKeys/ApiKey.cs b/src/isnd/Data/ApiKeys/ApiKey.cs index 9e320e7..7e3c8bb 100644 --- a/src/isnd/Data/ApiKeys/ApiKey.cs +++ b/src/isnd/Data/ApiKeys/ApiKey.cs @@ -19,5 +19,7 @@ namespace isn.Data.ApiKeys public int ValidityPeriodInDays{ get; set; } public DateTime CreationDate { get; set; } + + public bool IsValid => CreationDate.AddDays(ValidityPeriodInDays) > DateTime.Now; } } \ No newline at end of file diff --git a/src/isnd/Views/ApiKeys/Details.cshtml b/src/isnd/Views/ApiKeys/Details.cshtml index 6934f56..5ed503a 100644 --- a/src/isnd/Views/ApiKeys/Details.cshtml +++ b/src/isnd/Views/ApiKeys/Details.cshtml @@ -37,9 +37,21 @@
@Html.DisplayNameFor(model => model.ProtectedValue) +
- @Html.DisplayFor(model => model.ProtectedValue) + + + +
+
+ @Html.DisplayNameFor(model => model.ApiKey.IsValid) +
+
+ @Html.DisplayFor(model => model.ApiKey.IsValid)
diff --git a/src/isnd/Views/ApiKeys/Index.cshtml b/src/isnd/Views/ApiKeys/Index.cshtml index b93292b..ee3e28f 100644 --- a/src/isnd/Views/ApiKeys/Index.cshtml +++ b/src/isnd/Views/ApiKeys/Index.cshtml @@ -30,7 +30,11 @@ @foreach (var item in Model.ApiKey) { - + var rcsscl = item.IsValid ? + item.CreationDate.AddDays(item.ValidityPeriodInDays-30) > DateTime.Now ? + "ok" : "nomoretam" : "expired"; + + @Html.DisplayFor(modelItem => item.User.Id) diff --git a/src/isnd/wwwroot/css/site.css b/src/isnd/wwwroot/css/site.css index 6dc1c4f..4f1d690 100644 --- a/src/isnd/wwwroot/css/site.css +++ b/src/isnd/wwwroot/css/site.css @@ -22,3 +22,31 @@ height: 100px; } .grants-page .card label { font-weight: bold; } + +.expired { + color: white; + background-color: red; +} + +.ok { + font-weight: bolder; + color: white; + background-color: black; +} + + +.nomoretam { + font-weight: bolder; + color: black; + background-color: orange; +} + +.ok a { + color: rgb(47, 228, 228); + background-color: black; +} + +.ok a:hover { + color: rgb(119, 255, 255); + background-color: black; +} \ No newline at end of file