Skip to content

Commit 714c191

Browse files
authored
Merge pull request #386 from TheauW/twartel-fix-job-monitor
Use the new API and fix the dataTable component
2 parents c589a96 + f402641 commit 714c191

6 files changed

Lines changed: 201 additions & 138 deletions

File tree

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

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,7 @@ export function JobDataTable({
198198
const failedJobs = Object.entries(data.failed).map(
199199
([jobId, error]) => `Job ${jobId}: ${error.detail}`,
200200
);
201-
const successfulJobs = Object.keys(data.success).map(
202-
(jobId) => `Job ${jobId}`,
203-
);
201+
const areSucceedJobs = Object.keys(data.success).length > 0;
204202

205203
setBackdropOpen(false);
206204

@@ -211,22 +209,22 @@ export function JobDataTable({
211209

212210
clearSelected();
213211
// Handle Snackbar Messaging
214-
if (successfulJobs.length > 0 && failedJobs.length > 0) {
212+
if (areSucceedJobs && failedJobs.length > 0) {
215213
setSnackbarInfo({
216214
open: true,
217-
message: `Kill operation summary. Success: ${successfulJobs.join(", ")}. Failed: ${failedJobs.join("; ")}`,
215+
message: `Kill operation summary. Failed: ${failedJobs.join("; ")}, Success for the rest`,
218216
severity: "warning",
219217
});
220-
} else if (successfulJobs.length > 0) {
218+
} else if (areSucceedJobs) {
221219
setSnackbarInfo({
222220
open: true,
223-
message: `Kill operation summary. Success: ${successfulJobs.join(", ")}`,
221+
message: `Kill operation summary. Success for all selected jobs.`,
224222
severity: "success",
225223
});
226224
} else {
227225
setSnackbarInfo({
228226
open: true,
229-
message: `Kill operation summary. Failed: ${failedJobs.join("; ")}`,
227+
message: `Kill operation summary. Failure for all selected jobs.`,
230228
severity: "error",
231229
});
232230
}
@@ -269,9 +267,7 @@ export function JobDataTable({
269267
const failedJobs = Object.entries(data.failed).map(
270268
([jobId, error]) => `Job ${jobId}: ${error.detail}`,
271269
);
272-
const successfulJobs = Object.keys(data.success).map(
273-
(jobId) => `Job ${jobId}`,
274-
);
270+
const areSucceedJobs = Object.keys(data.success).length > 0;
275271

276272
setBackdropOpen(false);
277273
// Refresh the data manually
@@ -280,22 +276,22 @@ export function JobDataTable({
280276
});
281277
clearSelected();
282278
// Handle Snackbar Messaging
283-
if (successfulJobs.length > 0 && failedJobs.length > 0) {
279+
if (areSucceedJobs && failedJobs.length > 0) {
284280
setSnackbarInfo({
285281
open: true,
286-
message: `Reschedule operation summary. Success: ${successfulJobs.join(", ")}. Failed: ${failedJobs.join("; ")}`,
282+
message: `Reschedule operation summary. Failed: ${failedJobs.join("; ")}, Success for the rest`,
287283
severity: "warning",
288284
});
289-
} else if (successfulJobs.length > 0) {
285+
} else if (areSucceedJobs) {
290286
setSnackbarInfo({
291287
open: true,
292-
message: `Reschedule operation summary. Success: ${successfulJobs.join(", ")}`,
288+
message: `Reschedule operation summary. Success for all selected jobs.`,
293289
severity: "success",
294290
});
295291
} else {
296292
setSnackbarInfo({
297293
open: true,
298-
message: `Reschedule operation summary. Failed: ${failedJobs.join("; ")}`,
294+
message: `Reschedule operation summary. Failure for all selected jobs.`,
299295
severity: "error",
300296
});
301297
}
@@ -395,7 +391,7 @@ export function JobDataTable({
395391
() => [
396392
{
397393
label: "Get history",
398-
onClick: (id: number | null) => handleHistory(id),
394+
onClick: (id: string | null) => handleHistory(Number(id)),
399395
},
400396
],
401397
[handleHistory],

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
blueGrey,
1313
lime,
1414
amber,
15+
brown,
1516
} from "@mui/material/colors";
1617

1718
import { lighten, darken, useTheme, Box } from "@mui/material";
@@ -161,6 +162,7 @@ export default function JobMonitor() {
161162
*/
162163
const renderStatusCell = useCallback(
163164
(status: string) => {
165+
const defaultColor = brown[500];
164166
return (
165167
<Box
166168
sx={{
@@ -169,8 +171,8 @@ export default function JobMonitor() {
169171
padding: "3px 10px",
170172
backgroundColor:
171173
theme.palette.mode === "light"
172-
? lighten(statusColors[status] ?? "default", 0.1)
173-
: darken(statusColors[status] ?? "default", 0.3),
174+
? lighten(statusColors[status] ?? defaultColor, 0.1)
175+
: darken(statusColors[status] ?? defaultColor, 0.3),
174176
color: "white",
175177
fontWeight: "bold",
176178
}}

packages/diracx-web-components/src/components/JobMonitor/jobDataService.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,7 @@ export function deleteJobs(
6868

6969
const deleteUrl = `${diracxUrl}/api/jobs/status`;
7070

71-
const currentDate = dayjs()
72-
.utc()
73-
.format("YYYY-MM-DDTHH:mm:ss.SSSSSS[Z]")
74-
.toString();
71+
const currentDate = dayjs().toISOString();
7572

7673
const body = selectedIds.reduce((acc: StatusBody, jobId) => {
7774
acc[jobId] = {
@@ -158,9 +155,12 @@ export function rescheduleJobs(
158155
if (!diracxUrl) {
159156
throw new Error("Invalid URL generated for rescheduling jobs.");
160157
}
161-
const queryString = selectedIds.map((id) => `job_ids=${id}`).join("&");
162-
const rescheduleUrl = `${diracxUrl}/api/jobs/reschedule?${queryString}`;
163-
return fetcher([rescheduleUrl, accessToken, "POST"]);
158+
const body = {
159+
job_ids: selectedIds,
160+
};
161+
162+
const rescheduleUrl = `${diracxUrl}/api/jobs/reschedule`;
163+
return fetcher([rescheduleUrl, accessToken, "POST", body]);
164164
}
165165

166166
/**

0 commit comments

Comments
 (0)