-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: display docs generation jobs in admin pages (#8)
- Loading branch information
Showing
11 changed files
with
243 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 Cénotélie Opérations SAS (cenotelie.fr) | ||
******************************************************************************/ | ||
|
||
//! Data types around documentation generation | ||
|
||
use chrono::NaiveDateTime; | ||
use serde_derive::{Deserialize, Serialize}; | ||
|
||
use super::JobCrate; | ||
|
||
/// The state of a documentation generation job | ||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)] | ||
pub enum DocGenJobState { | ||
/// The job is queued | ||
Queued, | ||
/// The worker is working on this job | ||
Working, | ||
/// The job is finished and succeeded | ||
Success, | ||
/// The worker failed to complete this job | ||
Failure, | ||
} | ||
|
||
/// A documentation generation job | ||
#[derive(Debug, Clone, Serialize, Deserialize)] | ||
pub struct DocGenJob { | ||
/// The specification for the job | ||
pub spec: JobCrate, | ||
/// The state of the job | ||
pub state: DocGenJobState, | ||
/// Timestamp the last time this job was touched | ||
#[serde(rename = "lastUpdate")] | ||
pub last_update: NaiveDateTime, | ||
/// The output log, if any | ||
pub output: String, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
<!DOCTYPE html> | ||
<html lang="en" class="dark"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="description" content=""> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link rel="icon" type="image/png" href="/webapp/favicon.png"> | ||
<title> | ||
Cratery -- Documentation generation jobs | ||
</title> | ||
<script src="https://cdn.tailwindcss.com"></script> | ||
</head> | ||
|
||
<header style="position: sticky; top: 0;"> | ||
<nav class="bg-white border-gray-200 px-4 lg:px-6 py-2.5 dark:bg-gray-800"> | ||
<div class="flex flex-wrap justify-between items-center mx-auto max-w-screen-xl"> | ||
<a href="/webapp/index.html" class="flex items-center"> | ||
<img src="./logo-white.svg" class="mr-3 h-6 sm:h-9" style="min-width: 200px;" alt="Cratery Logo" /> | ||
</a> | ||
<div class="flex items-center lg:order-2"> | ||
<a id="link-admin" href="/webapp/admin.html" style="cursor: pointer;" class="text-gray-800 dark:text-white hover:bg-gray-50 focus:ring-4 focus:ring-gray-300 font-medium rounded-lg text-sm px-4 lg:px-5 py-2 lg:py-2.5 mr-2 dark:hover:bg-gray-700 focus:outline-none dark:focus:ring-gray-800">Admin</a> | ||
<a id="link-account" href="/webapp/account.html" style="cursor: pointer;" class="text-gray-800 dark:text-white hover:bg-gray-50 focus:ring-4 focus:ring-gray-300 font-medium rounded-lg text-sm px-4 lg:px-5 py-2 lg:py-2.5 mr-2 dark:hover:bg-gray-700 focus:outline-none dark:focus:ring-gray-800">My Account</a> | ||
<a onclick="doLogout()" style="cursor: pointer;" class="text-gray-800 dark:text-white hover:bg-gray-50 focus:ring-4 focus:ring-gray-300 font-medium rounded-lg text-sm px-4 lg:px-5 py-2 lg:py-2.5 mr-2 dark:hover:bg-gray-700 focus:outline-none dark:focus:ring-gray-800">Logout</a> | ||
</div> | ||
</div> | ||
</nav> | ||
</header> | ||
<body onload="doPageLoad()" class="bg-white dark:bg-gray-800"> | ||
<section class="bg-white dark:bg-gray-900"> | ||
<div class="p-2 flex flex-row flex-wrap"> | ||
<a href="/webapp/admin.html" class="font-medium text-blue-600 dark:text-blue-500 hover:underline"> | ||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6" style="display: inline-block;"> | ||
<path stroke-linecap="round" stroke-linejoin="round" d="M10.5 19.5 3 12m0 0 7.5-7.5M3 12h18" /> | ||
</svg> | ||
Back to admin | ||
</a> | ||
</div> | ||
<div class="py-4 lg:py-4 px-4 mx-auto max-w-screen-xxl"> | ||
<h2 class="mb-4 text-4xl tracking-tight font-extrabold text-center text-gray-900 dark:text-white">Documentation generation jobs</h2> | ||
<div class="relative overflow-x-auto space-y-8"> | ||
<table class="w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400"> | ||
<thead class="text-xs text-gray-700 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400"> | ||
<tr> | ||
<th scope="col" class="px-6 py-3"> | ||
Crate | ||
</th> | ||
<th scope="col" class="px-6 py-3"> | ||
Version | ||
</th> | ||
<th scope="col" class="px-6 py-3"> | ||
Status | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody id="jobs"> | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</section> | ||
</body> | ||
<footer class="p-4 bg-white md:p-8 lg:p-10 dark:bg-gray-800"> | ||
<div class="mx-auto max-w-screen-xl text-center"> | ||
<span class="text-sm text-gray-500 sm:text-center dark:text-gray-400">Version <span id="version"></span>, Copyright © <span id="year"></span> <a href="https://cenotelie.fr/" target="_blank" class="hover:underline">Cénotélie</a>. All Rights Reserved.</span> | ||
</div> | ||
</footer> | ||
|
||
<link href="/webapp/index.css" rel="stylesheet" /> | ||
<script src="/webapp/api.js"></script> | ||
<script src="/webapp/index.js"></script> | ||
<script> | ||
function doPageLoad() { | ||
onPageLoad().then((_user) => { | ||
apiGetDocGenJobs().then(jobs => { | ||
const jobsEl = document.getElementById("jobs"); | ||
for (const job of jobs) { | ||
// jobsEl.appendChild(renderJob(job)); | ||
} | ||
}) | ||
}); | ||
} | ||
|
||
function renderJob(job) { | ||
const inputLoginEl = document.createElement("input"); | ||
inputLoginEl.setAttribute("type", "text"); | ||
inputLoginEl.className = "block p-3 w-full text-sm text-gray-900 bg-gray-50 rounded-lg border border-gray-300 shadow-sm focus:ring-primary-500 focus:border-primary-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500 dark:shadow-sm-light"; | ||
inputLoginEl.value = user.login; | ||
const inputNameEl = document.createElement("input"); | ||
inputNameEl.setAttribute("type", "text"); | ||
inputNameEl.className = "block p-3 w-full text-sm text-gray-900 bg-gray-50 rounded-lg border border-gray-300 shadow-sm focus:ring-primary-500 focus:border-primary-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500 dark:shadow-sm-light"; | ||
inputNameEl.value = user.name; | ||
const inputRolesEl = document.createElement("input"); | ||
inputRolesEl.setAttribute("type", "text"); | ||
inputRolesEl.className = "block p-3 w-full text-sm text-gray-900 bg-gray-50 rounded-lg border border-gray-300 shadow-sm focus:ring-primary-500 focus:border-primary-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500 dark:shadow-sm-light"; | ||
inputRolesEl.value = user.roles; | ||
|
||
const row = document.createElement("tr"); | ||
const cell1 = document.createElement("th"); | ||
cell1.setAttribute("scope", "row"); | ||
cell1.className = "px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white"; | ||
cell1.appendChild(document.createTextNode(user.email)); | ||
const cell2 = document.createElement("td"); | ||
cell2.className = "px-6 py-4"; | ||
cell2.appendChild(inputLoginEl); | ||
const cell3 = document.createElement("td"); | ||
cell3.className = "px-6 py-4"; | ||
cell3.appendChild(inputNameEl); | ||
|
||
row.appendChild(cell1); | ||
row.appendChild(cell2); | ||
row.appendChild(cell3); | ||
return row; | ||
} | ||
</script> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters