Skip to content

Commit c589a96

Browse files
authored
Merge pull request #380 from TheauW/twartel-job-chart
feat: pie chart for Job Monitor
2 parents 31be445 + cf0fec0 commit c589a96

47 files changed

Lines changed: 3788 additions & 1126 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/user/web/monitor_jobs.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818

1919
## Use the table
20+
By default, the jobs are displayed in a table. If you are viewing them in another chart, you can click the table button next to the search bar to switch back to the table view.
2021
The table displays the jobs that match the criteria specified in the search bar. Each row represents a job, and the columns show various attributes of the job, such as its ID, status, type, and submission date.
2122

2223
### Actions on the table
@@ -32,3 +33,5 @@ You can select one or more jobs by clicking on the checkboxes next to each job.
3233
- **Kill**: This button will kill the selected jobs.
3334
- **Delete**: This button will delete the selected jobs.
3435

36+
## Use the Pie Chart
37+
You can change the visualization to use a pie chart with the button next to the search bar. The pie chart provides a hierarchical view of the jobs based on their attributes. The `Columns to plot` component lets you choose your criteria for visualizing the jobs. The chart can display two levels, and you can then click on a section of the chart to zoom into that category and see more details.

package-lock.json

Lines changed: 1469 additions & 757 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/diracx-web-components/.storybook/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const config: StorybookConfig = {
4343
"../stories/mocks/metadata.mock.tsx",
4444
),
4545
"./jobDataService": require.resolve(
46-
"../stories/mocks/jobDataService.mock.ts",
46+
"../stories/mocks/jobDataService.mock.tsx",
4747
),
4848
};
4949
return config;

packages/diracx-web-components/.storybook/preview.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type { Preview } from "@storybook/react";
2-
import React from "react";
32
import { CssBaseline } from "@mui/material";
43
import { ThemeProvider } from "../src/contexts/ThemeProvider";
54

packages/diracx-web-components/babel.config.cjs renamed to packages/diracx-web-components/babel.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = {
1+
export default {
22
presets: [
33
"@babel/preset-env",
44
["@babel/preset-react", { runtime: "automatic" }],

packages/diracx-web-components/jest.config.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,20 @@ const config = {
1313
moduleNameMapper: {
1414
"^@axa-fr/react-oidc$": "<rootDir>/stories/mocks/react-oidc.mock.tsx",
1515
"^../../hooks/metadata$": "<rootDir>/stories/mocks/metadata.mock.tsx",
16-
"^./jobDataService$": "<rootDir>/stories/mocks/jobDataService.mock.ts",
16+
"^./jobDataService$": "<rootDir>/stories/mocks/jobDataService.mock.tsx",
17+
"\\.css$": "<rootDir>/stories/mocks/style.mock.ts",
18+
},
19+
20+
// To support ESM modules in Jest
21+
transformIgnorePatterns: [
22+
"/node_modules/(?!d3|d3-[^/]+|internmap|delaunator|robust-predicates)",
23+
],
24+
25+
// Tell Jest how to transform files
26+
// Use ts-jest for TypeScript files and babel-jest for JavaScript files
27+
transform: {
28+
"^.+\\.(ts|tsx)$": "ts-jest",
29+
"^.+\\.(js|jsx)$": "babel-jest",
1730
},
1831
};
1932

packages/diracx-web-components/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,21 @@
3131
"@mui/utils": "^6.1.6",
3232
"@mui/x-date-pickers": "^7.28.3",
3333
"@tanstack/react-table": "^8.20.5",
34+
"@types/d3": "^7.4.3",
3435
"@types/node": "^20.17.6",
3536
"@types/react": "^18.3.12",
3637
"@types/react-dom": "^18.3.1",
38+
"d3": "^7.9.0",
39+
"d3-hierarchy": "^3.1.2",
3740
"dayjs": "^1.11.13",
3841
"react": "^18.3.1",
3942
"react-dom": "^18.3.1",
4043
"react-virtuoso": "^4.12.3",
4144
"swr": "^2.2.5"
4245
},
4346
"devDependencies": {
44-
"@babel/preset-env": "^7.26.9",
47+
"@babel/core": "^7.28.0",
48+
"@babel/preset-env": "^7.28.0",
4549
"@babel/preset-react": "^7.24.7",
4650
"@babel/preset-typescript": "^7.24.7",
4751
"@chromatic-com/storybook": "^3.2.4",

packages/diracx-web-components/src/components/JobMonitor/JobDataTable.tsx

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import {
3232
deleteJobs,
3333
getJobHistory,
3434
killJobs,
35-
refreshJobs,
3635
rescheduleJobs,
3736
useJobs,
3837
} from "./jobDataService";
@@ -109,21 +108,22 @@ export function JobDataTable({
109108
// State for job history
110109
const [isHistoryDialogOpen, setIsHistoryDialogOpen] = useState(false);
111110
const [jobHistoryData, setJobHistoryData] = useState<JobHistory[]>([]);
112-
113111
/**
114112
* Fetches the jobs from the /api/jobs/search endpoint
115113
*/
116-
const { data, error, isLoading, isValidating } = useJobs(
114+
const {
115+
data: results,
116+
headers: dataHeader,
117+
error: dataError,
118+
isLoading,
119+
} = useJobs(
117120
diracxUrl,
118121
accessToken,
119122
searchBody,
120123
pagination.pageIndex,
121124
pagination.pageSize,
122125
);
123126

124-
const dataHeader = data?.headers;
125-
const results = useMemo(() => data?.data || [], [data?.data]);
126-
127127
// Parse the headers to get the first item, last item and number of items
128128
const contentRange = dataHeader?.get("content-range");
129129
let totalJobs = 0;
@@ -148,13 +148,10 @@ export function JobDataTable({
148148
const selectedIds = Object.keys(rowSelection).map(Number);
149149
await deleteJobs(diracxUrl, selectedIds, accessToken, accessTokenPayload);
150150
setBackdropOpen(false);
151-
refreshJobs(
152-
diracxUrl,
153-
accessToken,
154-
searchBody,
155-
pagination.pageIndex,
156-
pagination.pageSize,
157-
);
151+
// Refresh the data manually
152+
setSearchBody((prev) => {
153+
return { ...prev };
154+
});
158155
clearSelected();
159156
setSnackbarInfo({
160157
open: true,
@@ -206,13 +203,12 @@ export function JobDataTable({
206203
);
207204

208205
setBackdropOpen(false);
209-
refreshJobs(
210-
diracxUrl,
211-
accessToken,
212-
searchBody,
213-
pagination.pageIndex,
214-
pagination.pageSize,
215-
);
206+
207+
// Refresh the data manually
208+
setSearchBody((prev) => {
209+
return { ...prev };
210+
});
211+
216212
clearSelected();
217213
// Handle Snackbar Messaging
218214
if (successfulJobs.length > 0 && failedJobs.length > 0) {
@@ -278,13 +274,10 @@ export function JobDataTable({
278274
);
279275

280276
setBackdropOpen(false);
281-
refreshJobs(
282-
diracxUrl,
283-
accessToken,
284-
searchBody,
285-
pagination.pageIndex,
286-
pagination.pageSize,
287-
);
277+
// Refresh the data manually
278+
setSearchBody((prev) => {
279+
return { ...prev };
280+
});
288281
clearSelected();
289282
// Handle Snackbar Messaging
290283
if (successfulJobs.length > 0 && failedJobs.length > 0) {
@@ -412,7 +405,7 @@ export function JobDataTable({
412405
* Table instance
413406
*/
414407
const table = useReactTable({
415-
data: results,
408+
data: useMemo(() => results || [], [results]),
416409
columns,
417410
state: {
418411
columnVisibility,
@@ -450,9 +443,8 @@ export function JobDataTable({
450443
totalRows={totalJobs}
451444
searchBody={searchBody}
452445
setSearchBody={setSearchBody}
453-
error={error}
446+
error={dataError}
454447
isLoading={isLoading}
455-
isValidating={isValidating}
456448
toolbarComponents={toolbarComponents}
457449
menuItems={menuItems}
458450
/>

0 commit comments

Comments
 (0)