fix(ui): normalize request list fields for jellyfin json
Accept PascalCase or camelCase properties so My requests and Admin queue show title, requester, date, and status correctly. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
97619f1eb5
commit
3957c6ac1d
7 files changed
+78
-28
No files matched your search
@@ -1,7 +1,7 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<Version>1.0.0.7</Version>
|
||||
<AssemblyVersion>1.0.0.7</AssemblyVersion>
|
||||
<FileVersion>1.0.0.7</FileVersion>
|
||||
<Version>1.0.0.8</Version>
|
||||
<AssemblyVersion>1.0.0.8</AssemblyVersion>
|
||||
<FileVersion>1.0.0.8</FileVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -21,7 +21,7 @@ public sealed class WebNavInjector : IHostedService
|
||||
/// <summary>
|
||||
/// Script URL injected into jellyfin-web index.html.
|
||||
/// </summary>
|
||||
public const string LoaderSrc = "/Requests/Assets/nav-loader.js?v=1.0.0.7";
|
||||
public const string LoaderSrc = "/Requests/Assets/nav-loader.js?v=1.0.0.8";
|
||||
|
||||
private const string MarkerStart = "<!-- jellyfin-plugin-request-nav-start -->";
|
||||
private const string MarkerEnd = "<!-- jellyfin-plugin-request-nav-end -->";
|
||||
|
||||
@@ -131,17 +131,62 @@
|
||||
}
|
||||
|
||||
function statusName(value) {
|
||||
if (typeof value === "string") {
|
||||
if (typeof value === "string" && value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
return ["Pending", "Approved", "Rejected", "Fulfilled"][value] || "Unknown";
|
||||
if (typeof value === "number" && value >= 0 && value <= 3) {
|
||||
return ["Pending", "Approved", "Rejected", "Fulfilled"][value];
|
||||
}
|
||||
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
function statusClass(value) {
|
||||
return statusName(value).toLowerCase();
|
||||
}
|
||||
|
||||
function normalizeRequest(item) {
|
||||
if (!item || typeof item !== "object") {
|
||||
return {
|
||||
id: "",
|
||||
mediaType: "",
|
||||
title: "Untitled",
|
||||
year: null,
|
||||
posterPath: null,
|
||||
seasons: [],
|
||||
allSeasons: false,
|
||||
requestedByName: "Unknown",
|
||||
createdAtUtc: null,
|
||||
status: "Unknown",
|
||||
adminNote: null
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
id: item.id ?? item.Id ?? "",
|
||||
mediaType: item.mediaType || item.MediaType || "",
|
||||
title: item.title || item.Title || "Untitled",
|
||||
year: item.year ?? item.Year ?? null,
|
||||
posterPath: item.posterPath || item.PosterPath || null,
|
||||
seasons: item.seasons || item.Seasons || [],
|
||||
allSeasons: !!(item.allSeasons ?? item.AllSeasons),
|
||||
requestedByName: item.requestedByName || item.RequestedByName || "Unknown",
|
||||
createdAtUtc: item.createdAtUtc || item.CreatedAtUtc || null,
|
||||
status: item.status ?? item.Status,
|
||||
adminNote: item.adminNote || item.AdminNote || null
|
||||
};
|
||||
}
|
||||
|
||||
function formatRequestDate(value) {
|
||||
if (!value) {
|
||||
return "Unknown date";
|
||||
}
|
||||
|
||||
const date = new Date(value);
|
||||
return Number.isNaN(date.getTime()) ? "Unknown date" : date.toLocaleString();
|
||||
}
|
||||
|
||||
function escapeHtml(value) {
|
||||
return String(value ?? "")
|
||||
.replaceAll("&", "&")
|
||||
@@ -420,13 +465,16 @@
|
||||
|
||||
async function loadRequests() {
|
||||
try {
|
||||
state.requests = await api("");
|
||||
const raw = await api("");
|
||||
state.requests = (Array.isArray(raw) ? raw : []).map(normalizeRequest);
|
||||
renderRequestList(els.mineList, state.requests, false);
|
||||
if (state.isAdmin) {
|
||||
const pendingFirst = [...state.requests].sort((a, b) => {
|
||||
const aPending = statusName(a.status) === "Pending" ? 0 : 1;
|
||||
const bPending = statusName(b.status) === "Pending" ? 0 : 1;
|
||||
return aPending - bPending || new Date(b.createdAtUtc) - new Date(a.createdAtUtc);
|
||||
const aTime = a.createdAtUtc ? new Date(a.createdAtUtc).getTime() : 0;
|
||||
const bTime = b.createdAtUtc ? new Date(b.createdAtUtc).getTime() : 0;
|
||||
return aPending - bPending || bTime - aTime;
|
||||
});
|
||||
renderRequestList(els.adminList, pendingFirst, true);
|
||||
}
|
||||
@@ -441,21 +489,23 @@
|
||||
return;
|
||||
}
|
||||
|
||||
container.innerHTML = items.map((item) => {
|
||||
container.innerHTML = items.map((raw) => {
|
||||
const item = normalizeRequest(raw);
|
||||
const img = posterUrl(item.posterPath, 185);
|
||||
const seasons = item.allSeasons
|
||||
? "All seasons"
|
||||
: (item.seasons || []).length
|
||||
? `Seasons ${(item.seasons || []).join(", ")}`
|
||||
: item.seasons.length
|
||||
? `Seasons ${item.seasons.join(", ")}`
|
||||
: "";
|
||||
const status = statusName(item.status);
|
||||
const actions = adminMode
|
||||
? `
|
||||
<button type="button" class="req-btn" data-action="approve" data-id="${item.id}">Approve</button>
|
||||
<button type="button" class="req-btn" data-action="reject" data-id="${item.id}">Reject</button>
|
||||
<button type="button" class="req-btn" data-action="fulfill" data-id="${item.id}">Fulfilled</button>
|
||||
<button type="button" class="req-btn danger" data-action="delete" data-id="${item.id}">Delete</button>`
|
||||
: (statusName(item.status) === "Pending"
|
||||
? `<button type="button" class="req-btn danger" data-action="delete" data-id="${item.id}">Cancel</button>`
|
||||
<button type="button" class="req-btn" data-action="approve" data-id="${escapeHtml(item.id)}">Approve</button>
|
||||
<button type="button" class="req-btn" data-action="reject" data-id="${escapeHtml(item.id)}">Reject</button>
|
||||
<button type="button" class="req-btn" data-action="fulfill" data-id="${escapeHtml(item.id)}">Fulfilled</button>
|
||||
<button type="button" class="req-btn danger" data-action="delete" data-id="${escapeHtml(item.id)}">Delete</button>`
|
||||
: (status === "Pending"
|
||||
? `<button type="button" class="req-btn danger" data-action="delete" data-id="${escapeHtml(item.id)}">Cancel</button>`
|
||||
: "");
|
||||
|
||||
return `
|
||||
@@ -463,9 +513,9 @@
|
||||
${img ? `<img src="${escapeHtml(img)}" alt="" />` : "<div></div>"}
|
||||
<div>
|
||||
<p class="req-card-title">${escapeHtml(item.title)}</p>
|
||||
<p class="req-muted">${escapeHtml(item.mediaType)}${item.year ? ` · ${item.year}` : ""}${seasons ? ` · ${escapeHtml(seasons)}` : ""}</p>
|
||||
<p class="req-muted">Requested by ${escapeHtml(item.requestedByName)} · ${new Date(item.createdAtUtc).toLocaleString()}</p>
|
||||
<span class="req-badge ${statusClass(item.status)}">${escapeHtml(statusName(item.status))}</span>
|
||||
<p class="req-muted">${escapeHtml(item.mediaType)}${item.year ? ` · ${escapeHtml(item.year)}` : ""}${seasons ? ` · ${escapeHtml(seasons)}` : ""}</p>
|
||||
<p class="req-muted">Requested by ${escapeHtml(item.requestedByName)} · ${escapeHtml(formatRequestDate(item.createdAtUtc))}</p>
|
||||
<span class="req-badge ${statusClass(item.status)}">${escapeHtml(status)}</span>
|
||||
${item.adminNote ? `<p class="req-muted">${escapeHtml(item.adminNote)}</p>` : ""}
|
||||
</div>
|
||||
<div class="req-list-actions">${actions}</div>
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
---
|
||||
name: "Request"
|
||||
guid: "11c08950-c4bb-484d-89ff-205b3724416b"
|
||||
version: "1.0.0.7"
|
||||
version: "1.0.0.8"
|
||||
targetAbi: "10.11.11.0"
|
||||
framework: "net9.0"
|
||||
overview: "Request movies and TV shows from a local admin review queue"
|
||||
|
||||
+5
-5
@@ -9,12 +9,12 @@
|
||||
"repositoryUrl": "https://git.masengr.com/Michael-A-Sloan/Jellyfin_Request_tvandmovies",
|
||||
"versions": [
|
||||
{
|
||||
"version": "1.0.0.7",
|
||||
"changelog": "Fix request submit errors with clearer validation and ApiClient base URL",
|
||||
"version": "1.0.0.8",
|
||||
"changelog": "Fix My requests/Admin queue showing Unknown status and Invalid Date",
|
||||
"targetAbi": "10.11.11.0",
|
||||
"sourceUrl": "https://git.masengr.com/Michael-A-Sloan/Jellyfin_Request_tvandmovies/raw/branch/main/release/Jellyfin.Plugin.Request_1.0.0.7.zip",
|
||||
"checksum": "55DBF64784413920B09287802EE25732",
|
||||
"timestamp": "2026-08-02T21:32:22.2192886Z",
|
||||
"sourceUrl": "https://git.masengr.com/Michael-A-Sloan/Jellyfin_Request_tvandmovies/raw/branch/main/release/Jellyfin.Plugin.Request_1.0.0.8.zip",
|
||||
"checksum": "50A8114FF61E2E4C440C332E1AEF3D01",
|
||||
"timestamp": "2026-08-02T21:38:10.7513883Z",
|
||||
"dependencies": []
|
||||
}
|
||||
]
|
||||
|
||||
Binary file not shown.
@@ -1,5 +1,5 @@
|
||||
param(
|
||||
[string]$Version = "1.0.0.7",
|
||||
[string]$Version = "1.0.0.8",
|
||||
[string]$TargetAbi = "10.11.11.0",
|
||||
[string]$RepoRawBase = "https://git.masengr.com/Michael-A-Sloan/Jellyfin_Request_tvandmovies/raw/branch/main"
|
||||
)
|
||||
@@ -17,7 +17,7 @@ $dllPath = Join-Path $root "Jellyfin.Plugin.Request\bin\Release\net9.0\Jellyfin.
|
||||
$zipPath = Join-Path $releaseDir $zipFileName
|
||||
$manifestPath = Join-Path $root "manifest.json"
|
||||
$timestamp = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ")
|
||||
$changelog = "Fix request submit errors with clearer validation and ApiClient base URL"
|
||||
$changelog = "Fix My requests/Admin queue showing Unknown status and Invalid Date"
|
||||
|
||||
Write-Host "Building plugin..."
|
||||
dotnet build (Join-Path $root "Jellyfin.Plugin.Request.sln") -c Release
|
||||
|
||||
Reference in new issue
Block a user