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
|
||||
- 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
|
||||
|
||||
|
|
|
@ -16,7 +16,28 @@
|
|||
<h1 class="title is-2">Urls Administration</h1>
|
||||
</div>
|
||||
|
||||
<form class="column is-half-desktop is-two-thirds-tablet is-full-mobile" method="post">
|
||||
<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>
|
||||
|
||||
<div class="field has-addons">
|
||||
<div class="control">
|
||||
<label class="button is-static">ID</label>
|
||||
</div>
|
||||
<div class="control is-expanded">
|
||||
<input required type="text" class="input" name="Inspect_Id"/>
|
||||
</div>
|
||||
<div class="control">
|
||||
<button class="button is-primary" type="submit">Inspect</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<span class="help is-danger">@ModelState["Inspect_Id"]?.Errors.FirstOrDefault()?.ErrorMessage</span>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<form method="post">
|
||||
<h2 class="title is-3">New URL</h2>
|
||||
|
||||
<div class="field">
|
||||
|
@ -60,4 +81,5 @@
|
|||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Web;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.Extensions.Caching.Distributed;
|
||||
|
||||
namespace JustShortIt.Pages;
|
||||
|
@ -28,7 +29,20 @@ public class UrlsModel : PageModel {
|
|||
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() {
|
||||
if (!ModelState.IsValid) return Page();
|
||||
|
|
Loading…
Reference in a new issue