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>
|
<Project>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Version>1.0.0.7</Version>
|
<Version>1.0.0.8</Version>
|
||||||
<AssemblyVersion>1.0.0.7</AssemblyVersion>
|
<AssemblyVersion>1.0.0.8</AssemblyVersion>
|
||||||
<FileVersion>1.0.0.7</FileVersion>
|
<FileVersion>1.0.0.8</FileVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@@ -21,7 +21,7 @@ public sealed class WebNavInjector : IHostedService
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Script URL injected into jellyfin-web index.html.
|
/// Script URL injected into jellyfin-web index.html.
|
||||||
/// </summary>
|
/// </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 MarkerStart = "<!-- jellyfin-plugin-request-nav-start -->";
|
||||||
private const string MarkerEnd = "<!-- jellyfin-plugin-request-nav-end -->";
|
private const string MarkerEnd = "<!-- jellyfin-plugin-request-nav-end -->";
|
||||||
|
|||||||
@@ -131,17 +131,62 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function statusName(value) {
|
function statusName(value) {
|
||||||
if (typeof value === "string") {
|
if (typeof value === "string" && value) {
|
||||||
return 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) {
|
function statusClass(value) {
|
||||||
return statusName(value).toLowerCase();
|
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) {
|
function escapeHtml(value) {
|
||||||
return String(value ?? "")
|
return String(value ?? "")
|
||||||
.replaceAll("&", "&")
|
.replaceAll("&", "&")
|
||||||
@@ -420,13 +465,16 @@
|
|||||||
|
|
||||||
async function loadRequests() {
|
async function loadRequests() {
|
||||||
try {
|
try {
|
||||||
state.requests = await api("");
|
const raw = await api("");
|
||||||
|
state.requests = (Array.isArray(raw) ? raw : []).map(normalizeRequest);
|
||||||
renderRequestList(els.mineList, state.requests, false);
|
renderRequestList(els.mineList, state.requests, false);
|
||||||
if (state.isAdmin) {
|
if (state.isAdmin) {
|
||||||
const pendingFirst = [...state.requests].sort((a, b) => {
|
const pendingFirst = [...state.requests].sort((a, b) => {
|
||||||
const aPending = statusName(a.status) === "Pending" ? 0 : 1;
|
const aPending = statusName(a.status) === "Pending" ? 0 : 1;
|
||||||
const bPending = statusName(b.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);
|
renderRequestList(els.adminList, pendingFirst, true);
|
||||||
}
|
}
|
||||||
@@ -441,21 +489,23 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
container.innerHTML = items.map((item) => {
|
container.innerHTML = items.map((raw) => {
|
||||||
|
const item = normalizeRequest(raw);
|
||||||
const img = posterUrl(item.posterPath, 185);
|
const img = posterUrl(item.posterPath, 185);
|
||||||
const seasons = item.allSeasons
|
const seasons = item.allSeasons
|
||||||
? "All seasons"
|
? "All seasons"
|
||||||
: (item.seasons || []).length
|
: item.seasons.length
|
||||||
? `Seasons ${(item.seasons || []).join(", ")}`
|
? `Seasons ${item.seasons.join(", ")}`
|
||||||
: "";
|
: "";
|
||||||
|
const status = statusName(item.status);
|
||||||
const actions = adminMode
|
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="approve" data-id="${escapeHtml(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="reject" data-id="${escapeHtml(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" data-action="fulfill" data-id="${escapeHtml(item.id)}">Fulfilled</button>
|
||||||
<button type="button" class="req-btn danger" data-action="delete" data-id="${item.id}">Delete</button>`
|
<button type="button" class="req-btn danger" data-action="delete" data-id="${escapeHtml(item.id)}">Delete</button>`
|
||||||
: (statusName(item.status) === "Pending"
|
: (status === "Pending"
|
||||||
? `<button type="button" class="req-btn danger" data-action="delete" data-id="${item.id}">Cancel</button>`
|
? `<button type="button" class="req-btn danger" data-action="delete" data-id="${escapeHtml(item.id)}">Cancel</button>`
|
||||||
: "");
|
: "");
|
||||||
|
|
||||||
return `
|
return `
|
||||||
@@ -463,9 +513,9 @@
|
|||||||
${img ? `<img src="${escapeHtml(img)}" alt="" />` : "<div></div>"}
|
${img ? `<img src="${escapeHtml(img)}" alt="" />` : "<div></div>"}
|
||||||
<div>
|
<div>
|
||||||
<p class="req-card-title">${escapeHtml(item.title)}</p>
|
<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">${escapeHtml(item.mediaType)}${item.year ? ` · ${escapeHtml(item.year)}` : ""}${seasons ? ` · ${escapeHtml(seasons)}` : ""}</p>
|
||||||
<p class="req-muted">Requested by ${escapeHtml(item.requestedByName)} · ${new Date(item.createdAtUtc).toLocaleString()}</p>
|
<p class="req-muted">Requested by ${escapeHtml(item.requestedByName)} · ${escapeHtml(formatRequestDate(item.createdAtUtc))}</p>
|
||||||
<span class="req-badge ${statusClass(item.status)}">${escapeHtml(statusName(item.status))}</span>
|
<span class="req-badge ${statusClass(item.status)}">${escapeHtml(status)}</span>
|
||||||
${item.adminNote ? `<p class="req-muted">${escapeHtml(item.adminNote)}</p>` : ""}
|
${item.adminNote ? `<p class="req-muted">${escapeHtml(item.adminNote)}</p>` : ""}
|
||||||
</div>
|
</div>
|
||||||
<div class="req-list-actions">${actions}</div>
|
<div class="req-list-actions">${actions}</div>
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
name: "Request"
|
name: "Request"
|
||||||
guid: "11c08950-c4bb-484d-89ff-205b3724416b"
|
guid: "11c08950-c4bb-484d-89ff-205b3724416b"
|
||||||
version: "1.0.0.7"
|
version: "1.0.0.8"
|
||||||
targetAbi: "10.11.11.0"
|
targetAbi: "10.11.11.0"
|
||||||
framework: "net9.0"
|
framework: "net9.0"
|
||||||
overview: "Request movies and TV shows from a local admin review queue"
|
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",
|
"repositoryUrl": "https://git.masengr.com/Michael-A-Sloan/Jellyfin_Request_tvandmovies",
|
||||||
"versions": [
|
"versions": [
|
||||||
{
|
{
|
||||||
"version": "1.0.0.7",
|
"version": "1.0.0.8",
|
||||||
"changelog": "Fix request submit errors with clearer validation and ApiClient base URL",
|
"changelog": "Fix My requests/Admin queue showing Unknown status and Invalid Date",
|
||||||
"targetAbi": "10.11.11.0",
|
"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",
|
"sourceUrl": "https://git.masengr.com/Michael-A-Sloan/Jellyfin_Request_tvandmovies/raw/branch/main/release/Jellyfin.Plugin.Request_1.0.0.8.zip",
|
||||||
"checksum": "55DBF64784413920B09287802EE25732",
|
"checksum": "50A8114FF61E2E4C440C332E1AEF3D01",
|
||||||
"timestamp": "2026-08-02T21:32:22.2192886Z",
|
"timestamp": "2026-08-02T21:38:10.7513883Z",
|
||||||
"dependencies": []
|
"dependencies": []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
Binary file not shown.
@@ -1,5 +1,5 @@
|
|||||||
param(
|
param(
|
||||||
[string]$Version = "1.0.0.7",
|
[string]$Version = "1.0.0.8",
|
||||||
[string]$TargetAbi = "10.11.11.0",
|
[string]$TargetAbi = "10.11.11.0",
|
||||||
[string]$RepoRawBase = "https://git.masengr.com/Michael-A-Sloan/Jellyfin_Request_tvandmovies/raw/branch/main"
|
[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
|
$zipPath = Join-Path $releaseDir $zipFileName
|
||||||
$manifestPath = Join-Path $root "manifest.json"
|
$manifestPath = Join-Path $root "manifest.json"
|
||||||
$timestamp = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ")
|
$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..."
|
Write-Host "Building plugin..."
|
||||||
dotnet build (Join-Path $root "Jellyfin.Plugin.Request.sln") -c Release
|
dotnet build (Join-Path $root "Jellyfin.Plugin.Request.sln") -c Release
|
||||||
|
|||||||
Reference in new issue
Block a user