v0.3.7-pre.008
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<!-- file: crates/ksp-app-backfill-desk/frontend/main.html -->
|
||||
<!-- version: 3 -->
|
||||
<!-- version: 4 -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
|
||||
@@ -121,10 +121,13 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex align-items-center gap-3 flex-wrap mt-4">
|
||||
<button id="validateBackfillRequest" class="btn btn-primary" type="submit" disabled>
|
||||
<button id="validateBackfillRequest" class="btn btn-outline-primary" type="submit" disabled>
|
||||
<i class="fa-solid fa-shield-halved me-2" aria-hidden="true"></i>Valider la requête
|
||||
</button>
|
||||
<span class="text-body-secondary small">Cette tranche ne démarre aucun job.</span>
|
||||
<button id="startBackfillRequest" class="btn btn-primary" type="button" disabled>
|
||||
<i class="fa-solid fa-play me-2" aria-hidden="true"></i>Démarrer le backfill
|
||||
</button>
|
||||
<span class="text-body-secondary small">Un seul run peut être actif ; monitoring détaillé en pre.009.</span>
|
||||
</div>
|
||||
</form>
|
||||
<div id="backfillRequestValidation" class="alert alert-secondary mt-4 mb-0" role="status" aria-live="polite" hidden></div>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// file: crates/ksp-app-backfill-desk/frontend/ts/main.ts
|
||||
// version: 3
|
||||
// version: 4
|
||||
|
||||
import "bootstrap";
|
||||
import ResizeObserver from "resize-observer-polyfill";
|
||||
@@ -7,6 +7,7 @@ import "simplebar";
|
||||
import { getCurrentWindow } from "@tauri-apps/api/window";
|
||||
import type { BackfillRequestPreviewDto } from "./bindings/ksp_app_backfill_desk/dto_backfill/BackfillRequestPreviewDto.ts";
|
||||
import type { BackfillStartRequestDto } from "./bindings/ksp_app_backfill_desk/dto_backfill/BackfillStartRequestDto.ts";
|
||||
import type { BackfillStartResponseDto } from "./bindings/ksp_app_backfill_desk/dto_backfill/BackfillStartResponseDto.ts";
|
||||
import type { BackfillDeskOptionsDto } from "./bindings/ksp_app_backfill_desk/dto_common/BackfillDeskOptionsDto.ts";
|
||||
import type { BackfillHttpRouteOptionDto } from "./bindings/ksp_app_backfill_desk/dto_common/BackfillHttpRouteOptionDto.ts";
|
||||
import type { ShellStatusDto } from "./bindings/ksp_app_backfill_desk/dto_common/ShellStatusDto.ts";
|
||||
@@ -35,6 +36,9 @@ const scopeLabels: Record<string, string> = {
|
||||
explicit_signatures: "Signatures explicites",
|
||||
};
|
||||
|
||||
let compositionReadyForStart = false;
|
||||
let runStartAccepted = false;
|
||||
|
||||
|
||||
function isViewId(value: string | undefined): value is ViewId {
|
||||
return value === "backfill" || value === "diagnostics";
|
||||
@@ -125,6 +129,13 @@ function applyNumberInputContract(inputId: string, maximum: number, defaultValue
|
||||
}
|
||||
}
|
||||
|
||||
function refreshStartButton(): void {
|
||||
const startButton = document.querySelector<HTMLButtonElement>("#startBackfillRequest");
|
||||
if (startButton) {
|
||||
startButton.disabled = !compositionReadyForStart || runStartAccepted;
|
||||
}
|
||||
}
|
||||
|
||||
function renderCampaignContract(options: BackfillDeskOptionsDto): void {
|
||||
populateCodeSelect("backfillScopeKind", options.scopeKinds, scopeLabels);
|
||||
populateCodeSelect("backfillCommitment", options.commitments, commitmentLabels);
|
||||
@@ -293,6 +304,31 @@ function renderRequestValidationError(caughtError: unknown): void {
|
||||
status.textContent = message;
|
||||
}
|
||||
|
||||
async function startBackfillRequest(): Promise<void> {
|
||||
const request = buildBackfillStartRequest();
|
||||
frontendDebug("main", "Backfill Desk campaign Start requested", {
|
||||
commitment: request.commitment,
|
||||
httpRole: request.httpRole,
|
||||
scopeKind: request.scopeKind,
|
||||
});
|
||||
try {
|
||||
const started = await invokeKsp<BackfillStartResponseDto>("main", "backfill_start", { request });
|
||||
runStartAccepted = true;
|
||||
refreshStartButton();
|
||||
const status = document.querySelector<HTMLElement>("#backfillRequestValidation");
|
||||
if (status) {
|
||||
status.hidden = false;
|
||||
status.classList.remove("alert-secondary", "alert-danger");
|
||||
status.classList.add("alert-success");
|
||||
status.textContent = `Job ${started.jobId} démarré (${started.state}). Le monitoring détaillé arrive en pre.009.`;
|
||||
}
|
||||
frontendInfo("main", "Backfill Desk campaign Start accepted", { jobId: started.jobId, state: started.state });
|
||||
} catch (caughtError) {
|
||||
renderRequestValidationError(caughtError);
|
||||
frontendWarn("main", "Backfill Desk campaign Start failed");
|
||||
}
|
||||
}
|
||||
|
||||
async function validateBackfillRequest(): Promise<void> {
|
||||
const request = buildBackfillStartRequest();
|
||||
frontendDebug("main", "Backfill Desk campaign validation requested", {
|
||||
@@ -331,6 +367,12 @@ function bindCampaignForm(): void {
|
||||
void validateBackfillRequest();
|
||||
});
|
||||
}
|
||||
const startButton = document.querySelector<HTMLButtonElement>("#startBackfillRequest");
|
||||
if (startButton) {
|
||||
startButton.addEventListener("click", () => {
|
||||
void startBackfillRequest();
|
||||
});
|
||||
}
|
||||
frontendTrace("main", "Backfill Desk campaign form handlers installed");
|
||||
}
|
||||
|
||||
@@ -342,7 +384,9 @@ function routeLabel(route: BackfillHttpRouteOptionDto): string {
|
||||
}
|
||||
|
||||
function renderBackfillOptions(options: BackfillDeskOptionsDto): void {
|
||||
compositionReadyForStart = options.compositionReady;
|
||||
renderCampaignContract(options);
|
||||
refreshStartButton();
|
||||
const select = document.querySelector<HTMLSelectElement>("#backfillHttpRoute");
|
||||
if (select) {
|
||||
const previous = select.value;
|
||||
|
||||
Reference in New Issue
Block a user