Files
2026-03-11 11:05:06 -04:00

240 lines
9.2 KiB
Plaintext

@page "{id:guid}"
@model maintenance.Pages.Admin.Templates.EditModel
@{
ViewData["Title"] = "Edit Page";
}
<h1>Edit Page</h1>
<p><a href="@Model.PreviewUrl" target="_blank" rel="noopener">Preview this page</a></p>
<form method="post">
<input asp-for="Input.Id" type="hidden" />
<div class="row">
<div class="col-md-4 mb-3">
<label asp-for="Input.Key" class="form-label"></label>
<input asp-for="Input.Key" class="form-control" readonly />
</div>
<div class="col-md-4 mb-3">
<label asp-for="Input.DisplayName" class="form-label"></label>
<input asp-for="Input.DisplayName" class="form-control" />
</div>
<div class="col-md-4 mb-3">
<label asp-for="Input.Stub" class="form-label"></label>
<input asp-for="Input.Stub" class="form-control" placeholder="team-a-maintenance" />
<span asp-validation-for="Input.Stub" class="text-danger"></span>
</div>
</div>
<div class="row">
<div class="col-md-4 mb-3">
<label asp-for="Input.PageKind" class="form-label"></label>
<select asp-for="Input.PageKind" class="form-select">
<option value="maintenance">maintenance</option>
<option value="error">error</option>
</select>
</div>
<div class="col-md-4 mb-3">
<label asp-for="Input.Priority" class="form-label"></label>
<input asp-for="Input.Priority" class="form-control" type="number" />
</div>
<div class="col-md-4 mb-3">
<label asp-for="Input.RecurrenceRule" class="form-label"></label>
<input asp-for="Input.RecurrenceRule" class="form-control" placeholder="cron-like (future)" />
</div>
</div>
<div class="row">
<div class="col-md-3 form-check mb-3">
<input asp-for="Input.IsEnabled" class="form-check-input" />
<label asp-for="Input.IsEnabled" class="form-check-label"></label>
</div>
<div class="col-md-3 form-check mb-3">
<input asp-for="Input.IsDefaultFallback" class="form-check-input" />
<label asp-for="Input.IsDefaultFallback" class="form-check-label"></label>
</div>
<div class="col-md-3 form-check mb-3">
<input asp-for="Input.OverrideWindow" class="form-check-input" />
<label asp-for="Input.OverrideWindow" class="form-check-label"></label>
</div>
</div>
<div class="row">
<div class="col-md-6 mb-3">
<label asp-for="Input.StartUtc" class="form-label"></label>
<input asp-for="Input.StartUtc" class="form-control" type="datetime-local" />
<span asp-validation-for="Input.StartUtc" class="text-danger"></span>
<div id="startUtcDisplay" class="form-text"></div>
</div>
<div class="col-md-6 mb-3">
<label asp-for="Input.EndUtc" class="form-label"></label>
<input asp-for="Input.EndUtc" class="form-control" type="datetime-local" />
<span asp-validation-for="Input.EndUtc" class="text-danger"></span>
<div id="endUtcDisplay" class="form-text"></div>
</div>
</div>
<hr />
<h4>Page Content (Template Slots)</h4>
<div class="mb-3">
<label asp-for="Input.ErrorName" class="form-label"></label>
<input asp-for="Input.ErrorName" class="form-control" />
</div>
<div class="mb-3">
<label asp-for="Input.ShortDescription" class="form-label"></label>
<input asp-for="Input.ShortDescription" class="form-control" />
</div>
<div class="mb-3">
<label asp-for="Input.Description" class="form-label"></label>
<textarea asp-for="Input.Description" class="form-control" rows="3"></textarea>
</div>
<div class="mb-3">
<label asp-for="Input.InstructionsHeader" class="form-label"></label>
<input asp-for="Input.InstructionsHeader" class="form-control" />
</div>
<div class="mb-3">
<label asp-for="Input.InstructionSteps" class="form-label"></label>
<input asp-for="Input.InstructionSteps" class="form-control" placeholder="step 1|step 2|step 3" />
</div>
<div class="row">
<div class="col-md-3 form-check mb-3">
<input asp-for="Input.ShowInstructions" class="form-check-input" />
<label asp-for="Input.ShowInstructions" class="form-check-label"></label>
</div>
<div class="col-md-3 form-check mb-3">
<input asp-for="Input.ShowSupport" class="form-check-input" />
<label asp-for="Input.ShowSupport" class="form-check-label"></label>
</div>
</div>
<div class="row">
<div class="col-md-4 mb-3">
<label asp-for="Input.SupportEmail" class="form-label"></label>
<input asp-for="Input.SupportEmail" class="form-control" />
</div>
<div class="col-md-4 mb-3">
<label asp-for="Input.SupportPhone" class="form-label"></label>
<input asp-for="Input.SupportPhone" class="form-control" />
</div>
<div class="col-md-4 mb-3">
<label asp-for="Input.ErrorCode" class="form-label"></label>
<input asp-for="Input.ErrorCode" class="form-control" />
</div>
</div>
<div class="mb-3">
<label asp-for="Input.SupportHours" class="form-label"></label>
<input asp-for="Input.SupportHours" class="form-control" />
</div>
<button type="submit" class="btn btn-primary">Save</button>
<a asp-page="./Index" class="btn btn-secondary">Cancel</a>
</form>
<partial name="_ValidationScriptsPartial" />
<script>
(function () {
const startInput = document.getElementById("Input_StartUtc");
const endInput = document.getElementById("Input_EndUtc");
const startUtcDisplay = document.getElementById("startUtcDisplay");
const endUtcDisplay = document.getElementById("endUtcDisplay");
function getOffsetMinutes(timeZone, instant) {
const offsetPart = new Intl.DateTimeFormat("en-US", {
timeZone: timeZone,
timeZoneName: "shortOffset"
})
.formatToParts(instant)
.find(function (part) { return part.type === "timeZoneName"; });
if (!offsetPart) {
return null;
}
const match = offsetPart.value.match(/GMT([+-]\d{1,2})(?::(\d{2}))?/);
if (!match) {
return null;
}
const hours = parseInt(match[1], 10);
const minutes = match[2] ? parseInt(match[2], 10) : 0;
const sign = hours < 0 ? -1 : 1;
return (Math.abs(hours) * 60 + minutes) * sign;
}
function easternLocalToUtcInstant(localValue) {
const match = localValue.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})/);
if (!match) {
return null;
}
const year = Number(match[1]);
const monthIndex = Number(match[2]) - 1;
const day = Number(match[3]);
const hour = Number(match[4]);
const minute = Number(match[5]);
const naiveUtcMillis = Date.UTC(year, monthIndex, day, hour, minute, 0, 0);
let guess = new Date(naiveUtcMillis);
const offsetOne = getOffsetMinutes("America/New_York", guess);
if (offsetOne === null) {
return null;
}
let utcMillis = naiveUtcMillis - (offsetOne * 60 * 1000);
guess = new Date(utcMillis);
const offsetTwo = getOffsetMinutes("America/New_York", guess);
if (offsetTwo !== null && offsetTwo !== offsetOne) {
utcMillis = naiveUtcMillis - (offsetTwo * 60 * 1000);
}
return new Date(utcMillis);
}
function toUtcText(easternLocalValue) {
if (!easternLocalValue) {
return "UTC: not set";
}
const utcInstant = easternLocalToUtcInstant(easternLocalValue);
if (!utcInstant || Number.isNaN(utcInstant.getTime())) {
return "UTC: invalid ET value";
}
const formatted = new Intl.DateTimeFormat("en-US", {
timeZone: "UTC",
year: "numeric",
month: "2-digit",
day: "2-digit",
hour: "2-digit",
minute: "2-digit",
hour12: false,
timeZoneName: "short"
}).format(utcInstant);
return "UTC: " + formatted;
}
function refreshDisplays() {
if (startUtcDisplay && startInput) {
startUtcDisplay.textContent = toUtcText(startInput.value);
}
if (endUtcDisplay && endInput) {
endUtcDisplay.textContent = toUtcText(endInput.value);
}
}
if (startInput) {
startInput.addEventListener("input", refreshDisplays);
startInput.addEventListener("change", refreshDisplays);
}
if (endInput) {
endInput.addEventListener("input", refreshDisplays);
endInput.addEventListener("change", refreshDisplays);
}
refreshDisplays();
})();
</script>