mirror of
https://github.com/miawinter98/just-short-it.git
synced 2024-11-22 08:19:54 +00:00
Implemented Inspect on Urls
This commit is contained in:
parent
89cce362f6
commit
2290099f45
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
- Page Titles to Login, Logout and Urls Page
|
- Page Titles to Login, Logout and Urls Page
|
||||||
- Added Inspect Page, which displays information about a URL and allows to delete it
|
- Added Inspect Page, which displays information about a URL and allows to delete it
|
||||||
|
- Added Inspect Form group to Urls that redirects to Inspect Page
|
||||||
|
|
||||||
## [1.1.0] - 2023-04-17
|
## [1.1.0] - 2023-04-17
|
||||||
|
|
||||||
|
|
|
@ -15,49 +15,71 @@
|
||||||
<div class="column is-full has-text-centered">
|
<div class="column is-full has-text-centered">
|
||||||
<h1 class="title is-2">Urls Administration</h1>
|
<h1 class="title is-2">Urls Administration</h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="column is-half-desktop is-two-thirds-tablet is-full-mobile">
|
||||||
|
<form class="mb-6" method="post" asp-page="Urls" asp-page-handler="Inspect">
|
||||||
|
<h2 class="title is-3">Inspect URL</h2>
|
||||||
|
|
||||||
<form class="column is-half-desktop is-two-thirds-tablet is-full-mobile" method="post">
|
<div class="field has-addons">
|
||||||
<h2 class="title is-3">New URL</h2>
|
<div class="control">
|
||||||
|
<label class="button is-static">ID</label>
|
||||||
<div class="field">
|
</div>
|
||||||
<label class="label" asp-for="Model!.Id">ID</label>
|
<div class="control is-expanded">
|
||||||
<div class="control">
|
<input required type="text" class="input" name="Inspect_Id"/>
|
||||||
<input required class="input" type="text" asp-for="Model!.Id" />
|
</div>
|
||||||
</div>
|
<div class="control">
|
||||||
<span class="help is-danger" asp-validation-for="Model!.Id"></span>
|
<button class="button is-primary" type="submit">Inspect</button>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="field">
|
|
||||||
<label class="label" asp-for="Model!.Target">Target</label>
|
|
||||||
<div class="control">
|
|
||||||
<input required class="input" type="text" asp-for="Model!.Target" />
|
|
||||||
</div>
|
|
||||||
<span class="help is-danger" asp-validation-for="Model!.Target"></span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="field">
|
|
||||||
<label class="label" asp-for="Model!.ExpirationDate">Expiration</label>
|
|
||||||
<div class="control">
|
|
||||||
<div class="select">
|
|
||||||
@Html.DropDownListFor(m => m.Model!.ExpirationDate, new List<SelectListItem> {
|
|
||||||
new("1 Day", DateTime.UtcNow.AddDays(1).ToBinary().ToString()),
|
|
||||||
new("1 Week", DateTime.UtcNow.AddDays(7).ToBinary().ToString()),
|
|
||||||
new("4 Weeks", DateTime.UtcNow.AddDays(4 * 7).ToBinary().ToString()),
|
|
||||||
new("1 Year", DateTime.UtcNow.AddYears(1).ToBinary().ToString()),
|
|
||||||
new("Never", DateTime.UtcNow.AddYears(1000).ToBinary().ToString())
|
|
||||||
}, "Select Expiration")
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<span class="help is-danger" asp-validation-for="Model!.ExpirationDate"></span>
|
|
||||||
</div>
|
<div class="field">
|
||||||
|
<span class="help is-danger">@ModelState["Inspect_Id"]?.Errors.FirstOrDefault()?.ErrorMessage</span>
|
||||||
<div class="has-text-danger" asp-validation-summary="ModelOnly"></div>
|
|
||||||
|
|
||||||
<div class="field is-grouped is-grouped-right">
|
|
||||||
<div class="control">
|
|
||||||
<button class="button is-primary" type="submit">Create</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</form>
|
||||||
</form>
|
|
||||||
|
<form method="post">
|
||||||
|
<h2 class="title is-3">New URL</h2>
|
||||||
|
|
||||||
|
<div class="field">
|
||||||
|
<label class="label" asp-for="Model!.Id">ID</label>
|
||||||
|
<div class="control">
|
||||||
|
<input required class="input" type="text" asp-for="Model!.Id" />
|
||||||
|
</div>
|
||||||
|
<span class="help is-danger" asp-validation-for="Model!.Id"></span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="field">
|
||||||
|
<label class="label" asp-for="Model!.Target">Target</label>
|
||||||
|
<div class="control">
|
||||||
|
<input required class="input" type="text" asp-for="Model!.Target" />
|
||||||
|
</div>
|
||||||
|
<span class="help is-danger" asp-validation-for="Model!.Target"></span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="field">
|
||||||
|
<label class="label" asp-for="Model!.ExpirationDate">Expiration</label>
|
||||||
|
<div class="control">
|
||||||
|
<div class="select">
|
||||||
|
@Html.DropDownListFor(m => m.Model!.ExpirationDate, new List<SelectListItem> {
|
||||||
|
new("1 Day", DateTime.UtcNow.AddDays(1).ToBinary().ToString()),
|
||||||
|
new("1 Week", DateTime.UtcNow.AddDays(7).ToBinary().ToString()),
|
||||||
|
new("4 Weeks", DateTime.UtcNow.AddDays(4 * 7).ToBinary().ToString()),
|
||||||
|
new("1 Year", DateTime.UtcNow.AddYears(1).ToBinary().ToString()),
|
||||||
|
new("Never", DateTime.UtcNow.AddYears(1000).ToBinary().ToString())
|
||||||
|
}, "Select Expiration")
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<span class="help is-danger" asp-validation-for="Model!.ExpirationDate"></span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="has-text-danger" asp-validation-summary="ModelOnly"></div>
|
||||||
|
|
||||||
|
<div class="field is-grouped is-grouped-right">
|
||||||
|
<div class="control">
|
||||||
|
<button class="button is-primary" type="submit">Create</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
|
using Microsoft.AspNetCore.Components;
|
||||||
using Microsoft.Extensions.Caching.Distributed;
|
using Microsoft.Extensions.Caching.Distributed;
|
||||||
|
|
||||||
namespace JustShortIt.Pages;
|
namespace JustShortIt.Pages;
|
||||||
|
@ -27,8 +28,21 @@ public class UrlsModel : PageModel {
|
||||||
#endif
|
#endif
|
||||||
Db = db;
|
Db = db;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public async Task<IActionResult> OnPostInspectAsync() {
|
||||||
|
string? id = Request.Form["Inspect_Id"];
|
||||||
|
if (id is null || string.IsNullOrEmpty(id)) {
|
||||||
|
ModelState.AddModelError("Inspect_Id", "ID is a required field");
|
||||||
|
return Page();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (await Db.GetAsync(id) is null) {
|
||||||
|
ModelState.AddModelError("Inspect_Id", "ID does not exist");
|
||||||
|
return Page();
|
||||||
|
}
|
||||||
|
|
||||||
|
return RedirectToPage("Inspect", new { Id = id });
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<IActionResult> OnPostAsync() {
|
public async Task<IActionResult> OnPostAsync() {
|
||||||
if (!ModelState.IsValid) return Page();
|
if (!ModelState.IsValid) return Page();
|
||||||
|
|
Loading…
Reference in a new issue