PlotDirector/PlotLine/Views/Onboarding/StoryIntelligenceProgress.cshtml

171 lines
7.2 KiB
Plaintext

@model StoryIntelligenceProgressViewModel
@{
ViewData["Title"] = "Review scenes";
}
<section class="onboarding-shell" aria-labelledby="story-progress-title">
<div class="onboarding-panel onboarding-review-panel">
@if (Model.HasActiveRuns)
{
<meta http-equiv="refresh" content="10" />
}
<div class="onboarding-copy">
<p class="eyebrow">@Model.BookTitle</p>
<h1 id="story-progress-title">Review scenes</h1>
<p>PlotDirector is analysing the approved chapters. When a chapter is ready, you can create its scenes in PlotDirector.</p>
</div>
@if (TempData["OnboardingStoryIntelligenceError"] is string error)
{
<div class="alert alert-danger">@error</div>
}
@if (TempData["OnboardingStoryIntelligenceMessage"] is string message)
{
<div class="alert alert-success">@message</div>
}
<div class="onboarding-scan-counts onboarding-review-counts">
<div>
<span>Chapters</span>
<strong>@Model.CompletedChapterCount / @Model.ChapterCount</strong>
</div>
<div>
<span>Scenes detected</span>
<strong>@Model.TotalDetectedScenes</strong>
</div>
<div>
<span>Scenes analysed</span>
<strong>@Model.TotalCompletedScenes</strong>
</div>
<div>
<span>Failures</span>
<strong>@(Model.FailedChapterCount + Model.TotalFailedScenes)</strong>
</div>
</div>
<section class="onboarding-review-grid" aria-label="Chapter analysis progress">
<div class="onboarding-review-section">
<h2>Chapters</h2>
<div class="onboarding-review-chapters">
@foreach (var chapter in Model.Chapters.OrderBy(chapter => chapter.ChapterNumber))
{
<details class="onboarding-review-chapter" open>
<summary>
<span>@chapter.ChapterNumber. @chapter.ChapterTitle</span>
<strong>@ChapterStatusLabel(chapter)</strong>
</summary>
<div class="onboarding-scan-counts onboarding-review-counts">
<div>
<span>Status</span>
<strong>@chapter.Status</strong>
</div>
<div>
<span>Scenes</span>
<strong>@((chapter.CompletedScenes ?? 0).ToString("N0")) / @((chapter.TotalDetectedScenes ?? 0).ToString("N0"))</strong>
</div>
<div>
<span>Failed</span>
<strong>@((chapter.FailedScenes ?? 0).ToString("N0"))</strong>
</div>
<div>
<span>Tokens</span>
<strong>@(chapter.TotalTokens?.ToString("N0") ?? "-")</strong>
</div>
</div>
@if (!string.IsNullOrWhiteSpace(chapter.CurrentMessage))
{
<p>@chapter.CurrentMessage</p>
}
@if (!string.IsNullOrWhiteSpace(chapter.ErrorMessage))
{
<p class="text-danger">@chapter.ErrorMessage</p>
}
@if (chapter.Warnings.Any())
{
<ul>
@foreach (var warning in chapter.Warnings)
{
<li>@warning</li>
}
</ul>
}
@if (chapter.Blockers.Any())
{
<ul>
@foreach (var blocker in chapter.Blockers)
{
<li class="text-danger">@blocker</li>
}
</ul>
}
<div class="onboarding-actions">
@if (chapter.HasCompletedCommit)
{
<span class="btn btn-outline-secondary disabled">@chapter.ScenesCreated scene(s) created</span>
}
else if (chapter.CanCommit && Model.BatchID.HasValue)
{
<form asp-action="CommitStoryIntelligence" method="post">
<input type="hidden" name="batchId" value="@Model.BatchID" />
<input type="hidden" name="runId" value="@chapter.RunID" />
<button class="btn btn-primary" type="submit">Create scenes</button>
</form>
}
else if (chapter.IsRunComplete)
{
<span class="btn btn-outline-secondary disabled">Review needed</span>
}
</div>
</details>
}
</div>
</div>
</section>
<div class="onboarding-actions">
@if (Model.BatchID.HasValue)
{
<form asp-action="CancelStoryIntelligence" method="post">
<input type="hidden" name="batchId" value="@Model.BatchID" />
<button class="btn btn-outline-secondary" type="submit" disabled="@(!Model.HasActiveRuns)">Cancel analysis</button>
</form>
<a class="btn btn-outline-secondary" asp-action="StoryIntelligenceProgress" asp-route-batchId="@Model.BatchID">Refresh</a>
<a class="btn btn-primary @(Model.AllCommitted ? string.Empty : "disabled")"
asp-action="StoryIntelligenceComplete"
asp-route-batchId="@Model.BatchID"
aria-disabled="@(!Model.AllCommitted)">Continue</a>
}
</div>
</div>
</section>
@functions {
private static string ChapterStatusLabel(StoryIntelligenceOnboardingChapterViewModel chapter)
{
if (chapter.HasCompletedCommit)
{
return "Scenes created";
}
if (chapter.CanCommit)
{
return "Ready to create";
}
if (chapter.IsActive)
{
return "Analysing";
}
if (chapter.IsFailed)
{
return "Needs attention";
}
return "Reviewing";
}
}