Skip to content

Commit

Permalink
fix(Job): add id in JobHistoryDialog and more fields in JobDataTable
Browse files Browse the repository at this point in the history
  • Loading branch information
aldbr committed Oct 25, 2024
1 parent dcfc88f commit f3e2e44
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
RowSelectionState,
useReactTable,
getCoreRowModel,
VisibilityState,
} from "@tanstack/react-table";
import { useOIDCContext } from "../../hooks/oidcConfiguration";
import { DataTable, MenuItem } from "../shared/DataTable";
Expand Down Expand Up @@ -67,7 +68,17 @@ export function JobDataTable() {
});

// States for table settings
const [columnVisibility, setColumnVisibility] = React.useState({});
const [columnVisibility, setColumnVisibility] =
React.useState<VisibilityState>({
JobGroup: false,
JobType: false,
Owner: false,
OwnerGroup: false,
VO: false,
StartExecTime: false,
EndExecTime: false,
UserPriority: false,
});
const [columnPinning, setColumnPinning] = React.useState<ColumnPinningState>({
left: ["JobID"], // Pin JobID column by default
});
Expand All @@ -81,6 +92,10 @@ export function JobDataTable() {
const [searchBody, setSearchBody] = React.useState<SearchBody>({
sort: [{ parameter: "JobID", direction: "asc" }],
});

// State for selected job
const [selectedJobId, setSelectedJobId] = React.useState<number | null>(null);

// State for job history
const [isHistoryDialogOpen, setIsHistoryDialogOpen] = React.useState(false);
const [jobHistoryData, setJobHistoryData] = React.useState<JobHistory[]>([]);
Expand Down Expand Up @@ -144,12 +159,6 @@ export function JobDataTable() {
header: "ID",
meta: { type: "number" },
}),
columnHelper.accessor("JobName", {
header: "Name",
}),
columnHelper.accessor("Site", {
header: "Site",
}),
columnHelper.accessor("Status", {
header: "Status",
cell: (info) => renderStatusCell(info.getValue()),
Expand All @@ -158,10 +167,54 @@ export function JobDataTable() {
columnHelper.accessor("MinorStatus", {
header: "Minor Status",
}),
columnHelper.accessor("ApplicationStatus", {
header: "Application Status",
}),
columnHelper.accessor("Site", {
header: "Site",
}),
columnHelper.accessor("JobName", {
header: "Name",
}),
columnHelper.accessor("JobGroup", {
header: "Job Group",
}),
columnHelper.accessor("JobType", {
header: "Type",
}),
columnHelper.accessor("LastUpdateTime", {
header: "Last Update Time",
meta: { type: "date" },
}),
columnHelper.accessor("HeartBeatTime", {
header: "Last Sign of Life",
meta: { type: "date" },
}),
columnHelper.accessor("SubmissionTime", {
header: "Submission Time",
meta: { type: "date" },
}),
columnHelper.accessor("Owner", {
header: "Owner",
}),
columnHelper.accessor("OwnerGroup", {
header: "Owner Group",
}),
columnHelper.accessor("VO", {
header: "VO",
}),
columnHelper.accessor("StartExecTime", {
header: "Start Execution Time",
meta: { type: "date" },
}),
columnHelper.accessor("EndExecTime", {
header: "End Execution Time",
meta: { type: "date" },
}),
columnHelper.accessor("UserPriority", {
header: "User Priority",
meta: { type: "number" },
}),
],
[columnHelper, renderStatusCell, statusColors],
);
Expand Down Expand Up @@ -330,6 +383,7 @@ export function JobDataTable() {
async (selectedId: number | null) => {
if (!selectedId) return;
setBackdropOpen(true);
setSelectedJobId(selectedId);
try {
const { data } = await getJobHistory(selectedId, accessToken);
setBackdropOpen(false);
Expand Down Expand Up @@ -468,6 +522,7 @@ export function JobDataTable() {
open={isHistoryDialogOpen}
onClose={handleHistoryClose}
historyData={jobHistoryData}
jobId={selectedJobId ?? 0}
/>
</Box>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ interface JobHistoryDialogProps {
* The data for the job history dialog
*/
historyData: JobHistory[];
/** The job ID */
jobId: number;
}

/**
Expand All @@ -29,10 +31,10 @@ interface JobHistoryDialogProps {
* @returns The rendered JobHistoryDialog component.
*/
export function JobHistoryDialog(props: JobHistoryDialogProps) {
const { open, onClose, historyData } = props;
const { open, onClose, historyData, jobId } = props;
return (
<Dialog open={open} onClose={onClose} aria-labelledby="job-history-title">
<DialogTitle id="job-history-title">Job History</DialogTitle>
<DialogTitle id="job-history-title">Job History: {jobId}</DialogTitle>

<IconButton
aria-label="close"
Expand Down
7 changes: 3 additions & 4 deletions packages/diracx-web-components/contexts/ThemeProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
darken,
alpha,
PaletteMode,
useMediaQuery,
} from "@mui/material";
import { cyan, grey, lightGreen } from "@mui/material/colors";
import { createContext, useEffect, useMemo, useState } from "react";
Expand Down Expand Up @@ -41,15 +42,13 @@ export const ThemeContext = createContext<ThemeContextType | undefined>(
*/
export const ThemeProvider = ({ children }: ThemeProviderProps) => {
const [theme, setTheme] = useState<string>("light");
const prefersDarkMode = useMediaQuery("(prefers-color-scheme: dark)");

useEffect(() => {
const prefersDarkMode = window.matchMedia(
"(prefers-color-scheme: dark)",
).matches;
const storedTheme = localStorage.getItem("theme");
const defaultTheme = storedTheme || (prefersDarkMode ? "dark" : "light");
setTheme(defaultTheme);
}, []);
}, [prefersDarkMode]);

// Update localStorage when the theme changes
useEffect(() => {
Expand Down
7 changes: 6 additions & 1 deletion packages/diracx-web-components/types/Job.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
export interface Job {
JobID: number;
JobName: string;
JobGroup: string;
JobType: string;
Owner: string;
OwnerGroup: string;
VO: string;
Site: string;
Status: string;
MinorStatus: string;
ApplicationStatus: string;
SubmissionTime: Date;
RescheduleTime: Date | null;
LastUpdateTime: Date;
StartExecTime: Date | null;
HeartBeatTime: Date | null;
EndExecTime: Date | null;
ApplicationStatus: string;
UserPriority: number;
RescheduleCounter: number;
VerifiedFlag: boolean;
Expand Down

0 comments on commit f3e2e44

Please sign in to comment.