@milabench/bujang 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +108 -2
- package/dist/api.d.ts +151 -0
- package/dist/components/AutocompleteInput.d.ts +15 -0
- package/dist/components/MonacoEditor.d.ts +11 -0
- package/dist/components/toaster.d.ts +2 -0
- package/dist/components/tooltip.d.ts +11 -0
- package/dist/constants.d.ts +3 -0
- package/dist/context.d.ts +44 -0
- package/dist/hooks/useColorMode.d.ts +4 -0
- package/dist/hooks/usePageTitle.d.ts +2 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +5036 -0
- package/dist/index.js.map +1 -0
- package/dist/paths.d.ts +26 -0
- package/dist/routes.d.ts +22 -0
- package/dist/theme.css +72 -0
- package/dist/toast.d.ts +18 -0
- package/dist/types.d.ts +474 -0
- package/dist/views/AgentActivityView.d.ts +8 -0
- package/dist/views/JobDetails.d.ts +2 -0
- package/dist/views/JobLogs.d.ts +4 -0
- package/dist/views/JobSubmit.d.ts +22 -0
- package/dist/views/JobSubmitView.d.ts +2 -0
- package/dist/views/JobsView.d.ts +4 -0
- package/dist/views/LogDisplay.d.ts +11 -0
- package/dist/views/PipelinesView.d.ts +2 -0
- package/dist/views/ScheduledJobsView.d.ts +2 -0
- package/package.json +70 -4
- package/src/api.ts +602 -0
- package/src/components/AutocompleteInput.tsx +253 -0
- package/src/components/MonacoEditor.tsx +163 -0
- package/src/components/toaster.tsx +38 -0
- package/src/components/tooltip.tsx +52 -0
- package/src/constants.ts +3 -0
- package/src/context.tsx +106 -0
- package/src/hooks/useColorMode.ts +31 -0
- package/src/hooks/usePageTitle.ts +21 -0
- package/src/index.ts +33 -0
- package/src/paths.ts +71 -0
- package/src/routes.tsx +55 -0
- package/src/theme.css +72 -0
- package/src/toast.ts +35 -0
- package/src/types.ts +542 -0
- package/src/views/AgentActivityView.tsx +262 -0
- package/src/views/JobDetails.tsx +675 -0
- package/src/views/JobLogs.tsx +987 -0
- package/src/views/JobSubmit.tsx +1272 -0
- package/src/views/JobSubmitView.tsx +69 -0
- package/src/views/JobsView.tsx +736 -0
- package/src/views/LogDisplay.tsx +171 -0
- package/src/views/PipelinesView.tsx +1318 -0
- package/src/views/ScheduledJobsView.tsx +735 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Views
|
|
2
|
+
export { JobsView } from './views/JobsView';
|
|
3
|
+
export { JobSubmitView } from './views/JobSubmitView';
|
|
4
|
+
export { JobDetailsView } from './views/JobDetails';
|
|
5
|
+
export { JobLogsView } from './views/JobLogs';
|
|
6
|
+
export { PipelinesView } from './views/PipelinesView';
|
|
7
|
+
export { ScheduledJobsView } from './views/ScheduledJobsView';
|
|
8
|
+
export { AgentActivityView, AgentBadge } from './views/AgentActivityView';
|
|
9
|
+
export { JobSubmissionForm } from './views/JobSubmit';
|
|
10
|
+
export type { JobSubmissionInitialData } from './views/JobSubmit';
|
|
11
|
+
export { LogDisplay } from './views/LogDisplay';
|
|
12
|
+
|
|
13
|
+
// Provider, paths, routes
|
|
14
|
+
export { BujangProvider, useBujang, useBujangPaths } from './context';
|
|
15
|
+
export type { BujangProviderProps, BujangContextValue, PushJobDataResult } from './context';
|
|
16
|
+
export { createBujangPaths, defaultRoutePatterns, normalizeBasePath, bujangNavItems } from './paths';
|
|
17
|
+
export type { BujangPaths, BujangView, BujangNavItem } from './paths';
|
|
18
|
+
export { bujangRoutes, bujangRouteElements } from './routes';
|
|
19
|
+
export type { BujangRoutesOptions, BujangRouteObject } from './routes';
|
|
20
|
+
|
|
21
|
+
// Shared pieces
|
|
22
|
+
export { Tooltip } from './components/tooltip';
|
|
23
|
+
export type { TooltipProps } from './components/tooltip';
|
|
24
|
+
export { MonacoEditor } from './components/MonacoEditor';
|
|
25
|
+
export type { MonacoCodeEditor } from './components/MonacoEditor';
|
|
26
|
+
export { BujangToaster } from './components/toaster';
|
|
27
|
+
export { bujangToaster, setBujangToastHandler } from './toast';
|
|
28
|
+
export type { BujangToastOptions, BujangToastHandler } from './toast';
|
|
29
|
+
export { NO_JOB_ID, NO_JOB_STATE, NO_JR_JOB_ID } from './constants';
|
|
30
|
+
|
|
31
|
+
// API client and types
|
|
32
|
+
export * from './api';
|
|
33
|
+
export type * from './types';
|
package/src/paths.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/** Names of the bujang views. */
|
|
2
|
+
export type BujangView =
|
|
3
|
+
| 'jobs'
|
|
4
|
+
| 'submitJob'
|
|
5
|
+
| 'jobDetails'
|
|
6
|
+
| 'jobLogs'
|
|
7
|
+
| 'pipelines'
|
|
8
|
+
| 'scheduled'
|
|
9
|
+
| 'agent';
|
|
10
|
+
|
|
11
|
+
/** URL builders the views use to link to each other. */
|
|
12
|
+
export interface BujangPaths {
|
|
13
|
+
jobs: () => string;
|
|
14
|
+
submitJob: () => string;
|
|
15
|
+
jobDetails: (slurmJobId: string | number, jrJobId: string) => string;
|
|
16
|
+
jobLogs: (slurmJobId: string | number, jrJobId: string) => string;
|
|
17
|
+
pipelines: () => string;
|
|
18
|
+
scheduled: () => string;
|
|
19
|
+
/** Agent activity, optionally filtered on one session. */
|
|
20
|
+
agent: (session?: string) => string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Default URL layout (react-router patterns), relative to the host's basePath. */
|
|
24
|
+
export const defaultRoutePatterns: Record<BujangView, string> = {
|
|
25
|
+
jobs: '/jobs',
|
|
26
|
+
submitJob: '/jobs/submit',
|
|
27
|
+
jobDetails: '/jobrunner/:slurmJobId/:jrJobId',
|
|
28
|
+
jobLogs: '/joblogs/:slurmJobId/:jrJobId',
|
|
29
|
+
pipelines: '/pipelines',
|
|
30
|
+
scheduled: '/scheduled',
|
|
31
|
+
agent: '/agent',
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/** Normalise "", "/", "/x/" to "", "", "/x". */
|
|
35
|
+
export function normalizeBasePath(basePath: string = ''): string {
|
|
36
|
+
const trimmed = basePath.replace(/\/+$/, '');
|
|
37
|
+
if (!trimmed) return '';
|
|
38
|
+
return trimmed.startsWith('/') ? trimmed : `/${trimmed}`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Path builders for the default layout mounted under `basePath`. */
|
|
42
|
+
export function createBujangPaths(basePath: string = ''): BujangPaths {
|
|
43
|
+
const b = normalizeBasePath(basePath);
|
|
44
|
+
const seg = (v: string | number) => encodeURIComponent(String(v));
|
|
45
|
+
return {
|
|
46
|
+
jobs: () => `${b}/jobs`,
|
|
47
|
+
submitJob: () => `${b}/jobs/submit`,
|
|
48
|
+
jobDetails: (slurmJobId, jrJobId) => `${b}/jobrunner/${seg(slurmJobId)}/${seg(jrJobId)}`,
|
|
49
|
+
jobLogs: (slurmJobId, jrJobId) => `${b}/joblogs/${seg(slurmJobId)}/${seg(jrJobId)}`,
|
|
50
|
+
pipelines: () => `${b}/pipelines`,
|
|
51
|
+
scheduled: () => `${b}/scheduled`,
|
|
52
|
+
agent: (session) => (session ? `${b}/agent?session=${encodeURIComponent(session)}` : `${b}/agent`),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface BujangNavItem {
|
|
57
|
+
view: BujangView;
|
|
58
|
+
label: string;
|
|
59
|
+
path: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Sidebar entries for the top-level bujang views. */
|
|
63
|
+
export function bujangNavItems(paths: BujangPaths = createBujangPaths()): BujangNavItem[] {
|
|
64
|
+
return [
|
|
65
|
+
{ view: 'jobs', label: 'Jobs', path: paths.jobs() },
|
|
66
|
+
{ view: 'submitJob', label: 'Submit Job', path: paths.submitJob() },
|
|
67
|
+
{ view: 'scheduled', label: 'Scheduled Jobs', path: paths.scheduled() },
|
|
68
|
+
{ view: 'pipelines', label: 'Pipelines', path: paths.pipelines() },
|
|
69
|
+
{ view: 'agent', label: 'Agent Activity', path: paths.agent() },
|
|
70
|
+
];
|
|
71
|
+
}
|
package/src/routes.tsx
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Route } from 'react-router-dom';
|
|
3
|
+
import { defaultRoutePatterns, normalizeBasePath } from './paths';
|
|
4
|
+
import type { BujangView } from './paths';
|
|
5
|
+
import { JobsView } from './views/JobsView';
|
|
6
|
+
import { JobSubmitView } from './views/JobSubmitView';
|
|
7
|
+
import { JobDetailsView } from './views/JobDetails';
|
|
8
|
+
import { JobLogsView } from './views/JobLogs';
|
|
9
|
+
import { PipelinesView } from './views/PipelinesView';
|
|
10
|
+
import { ScheduledJobsView } from './views/ScheduledJobsView';
|
|
11
|
+
import { AgentActivityView } from './views/AgentActivityView';
|
|
12
|
+
|
|
13
|
+
export interface BujangRoutesOptions {
|
|
14
|
+
/** Prefix the routes are mounted under, e.g. "/slurm". Must match BujangProvider's basePath. Default "". */
|
|
15
|
+
basePath?: string;
|
|
16
|
+
/** Only mount these views (default: all). */
|
|
17
|
+
views?: BujangView[];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** A plain route object, usable with <Route>, useRoutes() or createBrowserRouter(). */
|
|
21
|
+
export interface BujangRouteObject {
|
|
22
|
+
id: BujangView;
|
|
23
|
+
path: string;
|
|
24
|
+
element: React.ReactElement;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const elements: Record<BujangView, () => React.ReactElement> = {
|
|
28
|
+
jobs: () => <JobsView />,
|
|
29
|
+
submitJob: () => <JobSubmitView />,
|
|
30
|
+
jobDetails: () => <JobDetailsView />,
|
|
31
|
+
jobLogs: () => <JobLogsView />,
|
|
32
|
+
pipelines: () => <PipelinesView />,
|
|
33
|
+
scheduled: () => <ScheduledJobsView />,
|
|
34
|
+
agent: () => <AgentActivityView />,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Route objects for the default bujang URL layout under `basePath`:
|
|
39
|
+
* /jobs, /jobs/submit, /jobrunner/:slurmJobId/:jrJobId, /joblogs/:slurmJobId/:jrJobId,
|
|
40
|
+
* /pipelines, /scheduled, /agent.
|
|
41
|
+
*/
|
|
42
|
+
export function bujangRoutes(options: BujangRoutesOptions = {}): BujangRouteObject[] {
|
|
43
|
+
const base = normalizeBasePath(options.basePath);
|
|
44
|
+
const views = options.views ?? (Object.keys(defaultRoutePatterns) as BujangView[]);
|
|
45
|
+
return views.map((id) => ({
|
|
46
|
+
id,
|
|
47
|
+
path: `${base}${defaultRoutePatterns[id]}`,
|
|
48
|
+
element: elements[id](),
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** The same routes as <Route> elements, to drop inside a host's <Routes>. */
|
|
53
|
+
export function bujangRouteElements(options: BujangRoutesOptions = {}): React.ReactElement[] {
|
|
54
|
+
return bujangRoutes(options).map((r) => <Route key={r.id} path={r.path} element={r.element} />);
|
|
55
|
+
}
|
package/src/theme.css
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Default colour tokens for @milabench/bujang (import "@milabench/bujang/theme.css").
|
|
3
|
+
*
|
|
4
|
+
* Every rule uses :where() so it has zero specificity: a host that defines the
|
|
5
|
+
* same --color-* variables (e.g. the theme.css of the host app) always wins.
|
|
6
|
+
* Dark mode follows the `dark` class (next-themes / Chakra) or data-theme="dark" on <html>.
|
|
7
|
+
*/
|
|
8
|
+
:where(:root) {
|
|
9
|
+
--color-bg-page: #f7fafc;
|
|
10
|
+
--color-bg-card: #ffffff;
|
|
11
|
+
--color-bg-header: #f7fafc;
|
|
12
|
+
--color-bg-hover: #edf2f7;
|
|
13
|
+
--color-bg-stripe: #f7fafc;
|
|
14
|
+
--color-border: #e2e8f0;
|
|
15
|
+
--color-text: #2d3748;
|
|
16
|
+
--color-text-muted: #718096;
|
|
17
|
+
--color-primary: #4299e1;
|
|
18
|
+
--color-primary-hover: #3182ce;
|
|
19
|
+
--color-primary-text: #ffffff;
|
|
20
|
+
--color-status-running: #48bb78;
|
|
21
|
+
--color-status-pending: #ecc94b;
|
|
22
|
+
--color-status-completed: #4299e1;
|
|
23
|
+
--color-status-failed: #f56565;
|
|
24
|
+
--color-status-cancelled: #718096;
|
|
25
|
+
--color-log-stdout-bg: #f7fafc;
|
|
26
|
+
--color-log-stderr-bg: #fff5f5;
|
|
27
|
+
--color-log-stdout-text: #1a202c;
|
|
28
|
+
--color-log-stderr-text: #822727;
|
|
29
|
+
--color-input-bg: #ffffff;
|
|
30
|
+
--color-input-border: #cbd5e0;
|
|
31
|
+
--color-freshness-good: #48bb78;
|
|
32
|
+
--color-freshness-stale: #7b341e;
|
|
33
|
+
--color-pipeline-job-bg: #fffaf0;
|
|
34
|
+
--color-pipeline-job-border: #fbd38d;
|
|
35
|
+
--color-pipeline-seq-bg: #f0fff4;
|
|
36
|
+
--color-pipeline-seq-border: #9ae6b4;
|
|
37
|
+
--color-pipeline-par-bg: #ebf8ff;
|
|
38
|
+
--color-pipeline-par-border: #90cdf4;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
:where(html.dark, html[data-theme="dark"]) {
|
|
42
|
+
--color-bg-page: #171923;
|
|
43
|
+
--color-bg-card: #1a202c;
|
|
44
|
+
--color-bg-header: #1a202c;
|
|
45
|
+
--color-bg-hover: #2d3748;
|
|
46
|
+
--color-bg-stripe: #1a202c;
|
|
47
|
+
--color-border: #2d3748;
|
|
48
|
+
--color-text: #cbd5e0;
|
|
49
|
+
--color-text-muted: #a0aec0;
|
|
50
|
+
--color-primary: #63b3ed;
|
|
51
|
+
--color-primary-hover: #90cdf4;
|
|
52
|
+
--color-primary-text: #1a202c;
|
|
53
|
+
--color-status-running: #68d391;
|
|
54
|
+
--color-status-pending: #f6e05e;
|
|
55
|
+
--color-status-completed: #63b3ed;
|
|
56
|
+
--color-status-failed: #fc8181;
|
|
57
|
+
--color-status-cancelled: #a0aec0;
|
|
58
|
+
--color-log-stdout-bg: #171923;
|
|
59
|
+
--color-log-stderr-bg: #63171b;
|
|
60
|
+
--color-log-stdout-text: #edf2f7;
|
|
61
|
+
--color-log-stderr-text: #fed7d7;
|
|
62
|
+
--color-input-bg: #2d3748;
|
|
63
|
+
--color-input-border: #4a5568;
|
|
64
|
+
--color-freshness-good: #68d391;
|
|
65
|
+
--color-freshness-stale: #c05621;
|
|
66
|
+
--color-pipeline-job-bg: #1a202c;
|
|
67
|
+
--color-pipeline-job-border: #4a5568;
|
|
68
|
+
--color-pipeline-seq-bg: #1a202c;
|
|
69
|
+
--color-pipeline-seq-border: #4a5568;
|
|
70
|
+
--color-pipeline-par-bg: #1a202c;
|
|
71
|
+
--color-pipeline-par-border: #4a5568;
|
|
72
|
+
}
|
package/src/toast.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { createToaster } from '@chakra-ui/react';
|
|
3
|
+
import type { CreateToasterReturn } from '@chakra-ui/react';
|
|
4
|
+
|
|
5
|
+
export interface BujangToastOptions {
|
|
6
|
+
title?: ReactNode;
|
|
7
|
+
description?: ReactNode;
|
|
8
|
+
type?: 'success' | 'error' | 'warning' | 'info' | 'loading';
|
|
9
|
+
duration?: number;
|
|
10
|
+
closable?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type BujangToastHandler = (options: BujangToastOptions) => void;
|
|
14
|
+
|
|
15
|
+
/** Toaster rendered by <BujangToaster/> when the host does not provide its own `toast` handler. */
|
|
16
|
+
export const bujangToaster: CreateToasterReturn = createToaster({
|
|
17
|
+
placement: 'bottom-end',
|
|
18
|
+
pauseOnPageIdle: true,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const defaultHandler: BujangToastHandler = (options) => {
|
|
22
|
+
bujangToaster.create(options);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
let currentHandler: BujangToastHandler = defaultHandler;
|
|
26
|
+
|
|
27
|
+
/** Set by BujangProvider. Passing undefined restores the built-in toaster. */
|
|
28
|
+
export function setBujangToastHandler(handler?: BujangToastHandler): void {
|
|
29
|
+
currentHandler = handler ?? defaultHandler;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Internal toaster facade used by the views (same call shape as Chakra's toaster). */
|
|
33
|
+
export const toaster = {
|
|
34
|
+
create: (options: BujangToastOptions) => currentHandler(options),
|
|
35
|
+
};
|