- Add Detail endpoint to LessonsController (GET /Plugins/Lessons/Detail?id=...) - Update lessonsPage.html with detail view, click handlers, and back navigation - Media cards fetch Jellyfin item details and render thumbnails & durations - Clicking media card launches Jellyfin native player via appRouter.showItem - Compiled Typst HTML rendered via innerHTML with dark theme styling - Works on web and Fire TV Silk browser Closes #6
65 lines
1.7 KiB
C#
65 lines
1.7 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using Jellyfin.Plugin.Lessons.Data;
|
|
|
|
namespace Jellyfin.Plugin.Lessons.Api;
|
|
|
|
[ApiController]
|
|
[Route("Plugins/Lessons")]
|
|
public class LessonsController : ControllerBase
|
|
{
|
|
private readonly LessonStore _store;
|
|
|
|
public LessonsController(LessonStore store)
|
|
{
|
|
_store = store;
|
|
}
|
|
|
|
[HttpGet("List")]
|
|
public IActionResult List()
|
|
{
|
|
var lessons = _store.GetAllLessons();
|
|
|
|
var summaries = lessons.Select(l => new
|
|
{
|
|
id = l.Id,
|
|
title = l.Title,
|
|
grade = l.Grade,
|
|
subject = l.Subject,
|
|
lessonDate = l.LessonDate,
|
|
description = l.Description
|
|
});
|
|
|
|
return Ok(summaries);
|
|
}
|
|
|
|
[HttpGet("Detail")]
|
|
public IActionResult Detail([FromQuery] string id)
|
|
{
|
|
if (string.IsNullOrEmpty(id))
|
|
return BadRequest("Lesson id is required.");
|
|
|
|
var lesson = _store.GetLessonById(id);
|
|
if (lesson == null)
|
|
return NotFound();
|
|
|
|
return Ok(new
|
|
{
|
|
id = lesson.Id,
|
|
title = lesson.Title,
|
|
grade = lesson.Grade,
|
|
subject = lesson.Subject,
|
|
lessonDate = lesson.LessonDate,
|
|
description = lesson.Description,
|
|
sourcePath = lesson.SourcePath,
|
|
compiledHtml = lesson.CompiledHtml,
|
|
createdAt = lesson.CreatedAt,
|
|
updatedAt = lesson.UpdatedAt,
|
|
mediaItems = lesson.MediaItems.Select(m => new
|
|
{
|
|
lessonId = m.LessonId,
|
|
jellyfinItemId = m.JellyfinItemId,
|
|
sortOrder = m.SortOrder
|
|
})
|
|
});
|
|
}
|
|
}
|