t2
This commit is contained in:
+20
-13
@@ -8,29 +8,36 @@
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>MAX - System Error</title>
|
||||
<title>MAX - @Model.Title</title>
|
||||
<link rel="stylesheet" href="~/css/max_error.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div class="header">MAX</div>
|
||||
<div class="center-box-vertically" style="margin-bottom: -224px;"></div>
|
||||
<div class="box">
|
||||
<div class="title"><img src="~/favicon.ico" alt="" /><h1>System Error</h1></div>
|
||||
<div class="title"><img src="~/favicon.ico" alt="" /><h1>@Model.Title</h1></div>
|
||||
<div class="description">
|
||||
<h2>A system error has occurred. Please contact MAX Support.</h2>
|
||||
<h2>@Model.Description</h2>
|
||||
</div>
|
||||
<div class="support">
|
||||
<h2>MAX Support:</h2>
|
||||
<br />
|
||||
<h3>Email: <a href="mailto:maxsupport@max.gov">maxsupport@max.gov</a></h3>
|
||||
<h4><span>Available<br /> </span> <span>8:00AM - 8:00PM Weekdays,<br />9:00AM - 6:00PM Weekends (2 hour response time)</span></h4>
|
||||
<br />
|
||||
<h3>Phone: 202-395-6860</h3>
|
||||
<h4>Available 8:00AM - 6:30PM Weekdays</h4>
|
||||
<br />
|
||||
<h4>All hours in Eastern Time (ET)</h4>
|
||||
@if (!string.IsNullOrWhiteSpace(Model.SupportContactBlock))
|
||||
{
|
||||
@Html.Raw(Model.SupportContactBlock)
|
||||
}
|
||||
else
|
||||
{
|
||||
<h2>MAX Support:</h2>
|
||||
<br />
|
||||
<h3>Email: <a href="mailto:maxsupport@max.gov">maxsupport@max.gov</a></h3>
|
||||
<h4><span>Available<br /> </span> <span>8:00AM - 8:00PM Weekdays,<br />9:00AM - 6:00PM Weekends (2 hour response time)</span></h4>
|
||||
<br />
|
||||
<h3>Phone: 202-395-6860</h3>
|
||||
<h4>Available 8:00AM - 6:30PM Weekdays</h4>
|
||||
<br />
|
||||
<h4>All hours in Eastern Time (ET)</h4>
|
||||
}
|
||||
</div>
|
||||
<div class="code"><h4>(Error Code: eag)</h4></div>
|
||||
<div class="code"><h4>(Error Code: @Model.ErrorCode)</h4></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,10 +1,32 @@
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using maintenance.Services.Templates;
|
||||
|
||||
namespace maintenance.Pages.Errors;
|
||||
|
||||
public sealed class GenericModel : PageModel
|
||||
{
|
||||
public void OnGet()
|
||||
private readonly ITemplateService _templateService;
|
||||
|
||||
public GenericModel(ITemplateService templateService)
|
||||
{
|
||||
_templateService = templateService;
|
||||
}
|
||||
|
||||
public string Title { get; private set; } = "System Error";
|
||||
public string Description { get; private set; } = "A system error has occurred. Please contact MAX Support.";
|
||||
public string ErrorCode { get; private set; } = "eag";
|
||||
public string? SupportContactBlock { get; private set; }
|
||||
|
||||
public async Task OnGetAsync()
|
||||
{
|
||||
var template = await _templateService.GetByNameAsync("generic", HttpContext.RequestAborted);
|
||||
if (template is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Title = string.IsNullOrWhiteSpace(template.Title) ? Title : template.Title;
|
||||
Description = string.IsNullOrWhiteSpace(template.Body) ? Description : template.Body;
|
||||
SupportContactBlock = template.SupportContactBlock;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,15 +47,22 @@
|
||||
@if (Model.ShowSupport)
|
||||
{
|
||||
<div class="support">
|
||||
<h2>MAX Support:</h2>
|
||||
<br />
|
||||
<h3>Email: <a href="mailto:maxsupport@max.gov">maxsupport@max.gov</a></h3>
|
||||
<h4><span>Available<br /> </span> <span>8:00AM - 8:00PM Weekdays,<br />9:00AM - 6:00PM Weekends (2 hour response time)</span></h4>
|
||||
<br />
|
||||
<h3>Phone: 202-395-6860</h3>
|
||||
<h4>Available 8:00AM - 6:30PM Weekdays</h4>
|
||||
<br />
|
||||
<h4>All hours in Eastern Time (ET)</h4>
|
||||
@if (!string.IsNullOrWhiteSpace(Model.SupportContactBlock))
|
||||
{
|
||||
@Html.Raw(Model.SupportContactBlock)
|
||||
}
|
||||
else
|
||||
{
|
||||
<h2>MAX Support:</h2>
|
||||
<br />
|
||||
<h3>Email: <a href="mailto:maxsupport@max.gov">maxsupport@max.gov</a></h3>
|
||||
<h4><span>Available<br /> </span> <span>8:00AM - 8:00PM Weekdays,<br />9:00AM - 6:00PM Weekends (2 hour response time)</span></h4>
|
||||
<br />
|
||||
<h3>Phone: 202-395-6860</h3>
|
||||
<h4>Available 8:00AM - 6:30PM Weekdays</h4>
|
||||
<br />
|
||||
<h4>All hours in Eastern Time (ET)</h4>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
<div class="code"><h4>(Error Code: @Model.ErrorCode)</h4></div>
|
||||
|
||||
@@ -1,10 +1,21 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using maintenance.Services.Templates;
|
||||
|
||||
namespace maintenance.Pages.Errors;
|
||||
|
||||
public sealed class TemplateModel : PageModel
|
||||
{
|
||||
private readonly ITemplateService _templateService;
|
||||
|
||||
public TemplateModel(ITemplateService templateService)
|
||||
{
|
||||
_templateService = templateService;
|
||||
}
|
||||
|
||||
[FromQuery(Name = "template")]
|
||||
public string TemplateName { get; set; } = "template";
|
||||
|
||||
[FromQuery(Name = "errorName")]
|
||||
public string ErrorName { get; set; } = "Error Name";
|
||||
|
||||
@@ -29,13 +40,36 @@ public sealed class TemplateModel : PageModel
|
||||
[FromQuery(Name = "code")]
|
||||
public string ErrorCode { get; set; } = "eaX";
|
||||
|
||||
public string? SupportContactBlock { get; private set; }
|
||||
|
||||
public IReadOnlyList<string> InstructionSteps { get; private set; } = new List<string>
|
||||
{
|
||||
"Change some setting"
|
||||
};
|
||||
|
||||
public void OnGet()
|
||||
public async Task OnGetAsync()
|
||||
{
|
||||
var template = await _templateService.GetByNameAsync(TemplateName, HttpContext.RequestAborted);
|
||||
if (template is not null)
|
||||
{
|
||||
if (!Request.Query.ContainsKey("errorName") && !string.IsNullOrWhiteSpace(template.Title))
|
||||
{
|
||||
ErrorName = template.Title;
|
||||
}
|
||||
|
||||
if (!Request.Query.ContainsKey("desc") && !string.IsNullOrWhiteSpace(template.Body))
|
||||
{
|
||||
Description = template.Body;
|
||||
}
|
||||
|
||||
SupportContactBlock = template.SupportContactBlock;
|
||||
|
||||
if (!Request.Query.ContainsKey("showSupport") && string.IsNullOrWhiteSpace(SupportContactBlock))
|
||||
{
|
||||
ShowSupport = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(StepsCsv))
|
||||
{
|
||||
InstructionSteps = StepsCsv
|
||||
|
||||
@@ -8,30 +8,37 @@
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>MAX - Application Unavailable</title>
|
||||
<title>MAX - @Model.Title</title>
|
||||
<link rel="stylesheet" href="~/css/max_error.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div class="header">MAX</div>
|
||||
<div class="center-box-vertically" style="margin-bottom: -232px;"></div>
|
||||
<div class="box">
|
||||
<div class="title"><img src="~/favicon.ico" alt="" /><h1>Application Unavailable</h1></div>
|
||||
<div class="title"><img src="~/favicon.ico" alt="" /><h1>@Model.Title</h1></div>
|
||||
<div class="description">
|
||||
<h2 style="font-size: 13px;">MAX applications may be down for scheduled maintenance <b>2AM-8AM Sunday</b> morning.</h2>
|
||||
<h2 style="font-size: 13px;">If you are receiving this message at any other time, please contact MAX Support.</h2>
|
||||
<h2 style="font-size: 13px;">@Model.DescriptionLine1</h2>
|
||||
<h2 style="font-size: 13px;">@Model.DescriptionLine2</h2>
|
||||
</div>
|
||||
<div class="support">
|
||||
<h2>MAX Support:</h2>
|
||||
<br />
|
||||
<h3>Email: <a href="mailto:maxsupport@max.gov">maxsupport@max.gov</a></h3>
|
||||
<h4><span>Available<br /> </span> <span>8:00AM - 8:00PM Weekdays,<br />9:00AM - 6:00PM Weekends (2 hour response time)</span></h4>
|
||||
<br />
|
||||
<h3>Phone: 202-395-6860</h3>
|
||||
<h4>Available 8:00AM - 6:30PM Weekdays</h4>
|
||||
<br />
|
||||
<h4>All hours in Eastern Time (ET)</h4>
|
||||
@if (!string.IsNullOrWhiteSpace(Model.SupportContactBlock))
|
||||
{
|
||||
@Html.Raw(Model.SupportContactBlock)
|
||||
}
|
||||
else
|
||||
{
|
||||
<h2>MAX Support:</h2>
|
||||
<br />
|
||||
<h3>Email: <a href="mailto:maxsupport@max.gov">maxsupport@max.gov</a></h3>
|
||||
<h4><span>Available<br /> </span> <span>8:00AM - 8:00PM Weekdays,<br />9:00AM - 6:00PM Weekends (2 hour response time)</span></h4>
|
||||
<br />
|
||||
<h3>Phone: 202-395-6860</h3>
|
||||
<h4>Available 8:00AM - 6:30PM Weekdays</h4>
|
||||
<br />
|
||||
<h4>All hours in Eastern Time (ET)</h4>
|
||||
}
|
||||
</div>
|
||||
<div class="code"><h4>(Error Code: eau)</h4></div>
|
||||
<div class="code"><h4>(Error Code: @Model.ErrorCode)</h4></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,10 +1,51 @@
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using maintenance.Services.Templates;
|
||||
|
||||
namespace maintenance.Pages.Errors;
|
||||
|
||||
public sealed class UnavailableModel : PageModel
|
||||
{
|
||||
public void OnGet()
|
||||
private readonly ITemplateService _templateService;
|
||||
|
||||
public UnavailableModel(ITemplateService templateService)
|
||||
{
|
||||
_templateService = templateService;
|
||||
}
|
||||
|
||||
public string Title { get; private set; } = "Application Unavailable";
|
||||
public string DescriptionLine1 { get; private set; } =
|
||||
"MAX applications may be down for scheduled maintenance 2AM-8AM Sunday morning.";
|
||||
public string DescriptionLine2 { get; private set; } =
|
||||
"If you are receiving this message at any other time, please contact MAX Support.";
|
||||
public string ErrorCode { get; private set; } = "eau";
|
||||
public string? SupportContactBlock { get; private set; }
|
||||
|
||||
public async Task OnGetAsync()
|
||||
{
|
||||
var template = await _templateService.GetByNameAsync("unavailable", HttpContext.RequestAborted);
|
||||
if (template is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Title = string.IsNullOrWhiteSpace(template.Title) ? Title : template.Title;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(template.Body))
|
||||
{
|
||||
var lines = template.Body
|
||||
.Split('\n', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
if (lines.Length > 0)
|
||||
{
|
||||
DescriptionLine1 = lines[0];
|
||||
}
|
||||
|
||||
if (lines.Length > 1)
|
||||
{
|
||||
DescriptionLine2 = lines[1];
|
||||
}
|
||||
}
|
||||
|
||||
SupportContactBlock = template.SupportContactBlock;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ using maintenance.Authentication.Core;
|
||||
using maintenance.Authentication.Providers.AdfsWsFed;
|
||||
using maintenance.Authentication.Providers.Oidc;
|
||||
using maintenance.Data;
|
||||
using maintenance.Services.Templates;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
@@ -40,6 +41,7 @@ builder.Services.AddDbContext<GroupLookupDbContext>(options =>
|
||||
options.UseSqlServer(groupLookupDbConnection);
|
||||
options.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking);
|
||||
});
|
||||
builder.Services.AddScoped<ITemplateService, TemplateService>();
|
||||
|
||||
builder.Services.AddRazorPages(options =>
|
||||
{
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
using maintenance.Data.Entities;
|
||||
|
||||
namespace maintenance.Services.Templates;
|
||||
|
||||
public interface ITemplateService
|
||||
{
|
||||
Task<TemplateEntity?> GetByNameAsync(string name, CancellationToken cancellationToken = default);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using maintenance.Data;
|
||||
using maintenance.Data.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace maintenance.Services.Templates;
|
||||
|
||||
public sealed class TemplateService : ITemplateService
|
||||
{
|
||||
private readonly AppDbContext _dbContext;
|
||||
|
||||
public TemplateService(AppDbContext dbContext)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
}
|
||||
|
||||
public Task<TemplateEntity?> GetByNameAsync(string name, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return _dbContext.Templates
|
||||
.AsNoTracking()
|
||||
.FirstOrDefaultAsync(t => t.Name == name, cancellationToken);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user