diff --git a/cueweb/app/jobs/data-table.tsx b/cueweb/app/jobs/data-table.tsx index c66c47ee4..604e2dcbf 100644 --- a/cueweb/app/jobs/data-table.tsx +++ b/cueweb/app/jobs/data-table.tsx @@ -122,22 +122,24 @@ const initialColumnVisibility = { maxRss: false, } -// Initial state -const initialState: State = { - autoloadMine: getItemFromLocalStorage("autoloadMine", "true"), - tableData: getItemFromLocalStorage("tableData", "[]"), - tableDataUnfiltered: getItemFromLocalStorage("tableDataUnfiltered", "[]"), - sorting: getItemFromLocalStorage("sorting", "[]"), - columnFilters: getItemFromLocalStorage("columnFilters", "[]"), - stateSelectValue: getItemFromLocalStorage("stateSelectValue", JSON.stringify("All States")), - jobSearchResults: [], - filteredJobSearchResults: [], - searchQuery: "", - apiQuery: "", - rowSelection: {}, - columnVisibility: getItemFromLocalStorage("columnVisibility", JSON.stringify(initialColumnVisibility)), - error: null, - username: UNKNOWN_USER, +// The initial state of the data table on remount using local storage to preserve states +function getInitialState(): State { + return { + autoloadMine: getItemFromLocalStorage("autoloadMine", "true"), + tableData: getItemFromLocalStorage("tableData", "[]"), + tableDataUnfiltered: getItemFromLocalStorage("tableDataUnfiltered", "[]"), + sorting: getItemFromLocalStorage("sorting", "[]"), + columnFilters: getItemFromLocalStorage("columnFilters", "[]"), + stateSelectValue: getItemFromLocalStorage("stateSelectValue", JSON.stringify("All States")), + jobSearchResults: [], + filteredJobSearchResults: [], + searchQuery: "", + apiQuery: "", + rowSelection: {}, + columnVisibility: getItemFromLocalStorage("columnVisibility", JSON.stringify(initialColumnVisibility)), + error: null, + username: UNKNOWN_USER, + } }; // Reducer function @@ -174,10 +176,10 @@ function reducer(state: State, action: Action): State { case "RESET_COLUMN_VISIBILITY": return { ...state, - columnVisibility: initialState.columnVisibility, + columnVisibility: initialColumnVisibility, }; case "RESET_STATE": - return initialState; + return getInitialState(); default: return state; } @@ -215,7 +217,11 @@ export function DataTable({ columns, username }: DataTableProps) { const { theme, setTheme } = useTheme(); // useReducer hook to manage state - const [state, dispatch] = useReducer(reducer, initialState); + const [state, dispatch] = useReducer(reducer, getInitialState()); + + useEffect(() => { + dispatch({ type: "RESET_STATE"}); + }, []); useEffect(() => { addUsersJobs(); @@ -380,7 +386,6 @@ export function DataTable({ columns, username }: DataTableProps) { // Filter out any of the old data in the data table which no longer exists (has been finished for over 48 hours) updatedTableDataUnfiltered = updatedTableDataUnfiltered.filter((oldJob: Job) => newData.some((newJob: Job) => oldJob.id === newJob.id)); updatedTableData = updatedTableData.filter((oldJob: Job) => newData.some((newJob: Job) => oldJob.id === newJob.id)); - // Update table data as both a variable and in local storage dispatch({ type: "SET_TABLE_DATA_UNFILTERED", payload: updatedTableDataUnfiltered }); dispatch({ type: "SET_TABLE_DATA", payload: updatedTableData }); @@ -388,9 +393,9 @@ export function DataTable({ columns, username }: DataTableProps) { }; // Trigger table updates every 5000ms - interval = setInterval(() => { + interval = setInterval(async () => { updateData(); - addUsersJobs(); + await addUsersJobs(); }, 5000); } catch (error) { handleError(error, "Error updating table"); @@ -633,9 +638,14 @@ export function DataTable({ columns, username }: DataTableProps) { const jobsToAdd = userJobs.filter(userJob => { return !state.tableData.some(existingJob => existingJob.name === userJob.name) }); - - dispatch({ type: "SET_TABLE_DATA", payload: [...state.tableDataUnfiltered, ...jobsToAddUnfiltered] }); - dispatch({ type: "SET_TABLE_DATA_UNFILTERED", payload: [...state.tableData, ...jobsToAdd] }); + + if (jobsToAddUnfiltered.length > 0) { + dispatch({ type: "SET_TABLE_DATA", payload: [...state.tableDataUnfiltered, ...jobsToAddUnfiltered] }); + } + + if (jobsToAdd.length > 0) { + dispatch({ type: "SET_TABLE_DATA_UNFILTERED", payload: [...state.tableData, ...jobsToAdd] }); + } }; const handleStateFiltering = (stateFilter: string) => { diff --git a/cueweb/app/utils/get_utils.ts b/cueweb/app/utils/get_utils.ts index 653460c6a..5d1194ff3 100644 --- a/cueweb/app/utils/get_utils.ts +++ b/cueweb/app/utils/get_utils.ts @@ -45,7 +45,7 @@ export async function getLayers(body: string): Promise { // Fetch jobs for a specific user, including finished jobs export async function getJobsForUser(user: string): Promise { - const body = { r: { include_finished: true, users: [`${user}`] } }; + const body = { r: { include_finished: false, users: [`${user}`] } }; return await getJobs(JSON.stringify(body)); } diff --git a/cueweb/package-lock.json b/cueweb/package-lock.json index f280ea834..3a484e378 100644 --- a/cueweb/package-lock.json +++ b/cueweb/package-lock.json @@ -35,7 +35,7 @@ "lodash": "^4.17.21", "lodash.debounce": "^4.0.8", "lucide-react": "^0.304.0", - "next": "^14.2.3", + "next": "^14.2.20", "next-auth": "^4.24.10", "next-themes": "^0.2.1", "prom-client": "^15.1.2", @@ -3232,9 +3232,9 @@ } }, "node_modules/@next/env": { - "version": "14.2.14", - "resolved": "https://registry.npmjs.org/@next/env/-/env-14.2.14.tgz", - "integrity": "sha512-/0hWQfiaD5//LvGNgc8PjvyqV50vGK0cADYzaoOOGN8fxzBn3iAiaq3S0tCRnFBldq0LVveLcxCTi41ZoYgAgg==" + "version": "14.2.20", + "resolved": "https://registry.npmjs.org/@next/env/-/env-14.2.20.tgz", + "integrity": "sha512-JfDpuOCB0UBKlEgEy/H6qcBSzHimn/YWjUHzKl1jMeUO+QVRdzmTTl8gFJaNO87c8DXmVKhFCtwxQ9acqB3+Pw==" }, "node_modules/@next/eslint-plugin-next": { "version": "14.0.4", @@ -3267,9 +3267,9 @@ } }, "node_modules/@next/swc-darwin-arm64": { - "version": "14.2.14", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-14.2.14.tgz", - "integrity": "sha512-bsxbSAUodM1cjYeA4o6y7sp9wslvwjSkWw57t8DtC8Zig8aG8V6r+Yc05/9mDzLKcybb6EN85k1rJDnMKBd9Gw==", + "version": "14.2.20", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-14.2.20.tgz", + "integrity": "sha512-WDfq7bmROa5cIlk6ZNonNdVhKmbCv38XteVFYsxea1vDJt3SnYGgxLGMTXQNfs5OkFvAhmfKKrwe7Y0Hs+rWOg==", "cpu": [ "arm64" ], @@ -3282,9 +3282,9 @@ } }, "node_modules/@next/swc-darwin-x64": { - "version": "14.2.14", - "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-14.2.14.tgz", - "integrity": "sha512-cC9/I+0+SK5L1k9J8CInahduTVWGMXhQoXFeNvF0uNs3Bt1Ub0Azb8JzTU9vNCr0hnaMqiWu/Z0S1hfKc3+dww==", + "version": "14.2.20", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-14.2.20.tgz", + "integrity": "sha512-XIQlC+NAmJPfa2hruLvr1H1QJJeqOTDV+v7tl/jIdoFvqhoihvSNykLU/G6NMgoeo+e/H7p/VeWSOvMUHKtTIg==", "cpu": [ "x64" ], @@ -3297,9 +3297,9 @@ } }, "node_modules/@next/swc-linux-arm64-gnu": { - "version": "14.2.14", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-14.2.14.tgz", - "integrity": "sha512-RMLOdA2NU4O7w1PQ3Z9ft3PxD6Htl4uB2TJpocm+4jcllHySPkFaUIFacQ3Jekcg6w+LBaFvjSPthZHiPmiAUg==", + "version": "14.2.20", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-14.2.20.tgz", + "integrity": "sha512-pnzBrHTPXIMm5QX3QC8XeMkpVuoAYOmyfsO4VlPn+0NrHraNuWjdhe+3xLq01xR++iCvX+uoeZmJDKcOxI201Q==", "cpu": [ "arm64" ], @@ -3312,9 +3312,9 @@ } }, "node_modules/@next/swc-linux-arm64-musl": { - "version": "14.2.14", - "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-14.2.14.tgz", - "integrity": "sha512-WgLOA4hT9EIP7jhlkPnvz49iSOMdZgDJVvbpb8WWzJv5wBD07M2wdJXLkDYIpZmCFfo/wPqFsFR4JS4V9KkQ2A==", + "version": "14.2.20", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-14.2.20.tgz", + "integrity": "sha512-WhJJAFpi6yqmUx1momewSdcm/iRXFQS0HU2qlUGlGE/+98eu7JWLD5AAaP/tkK1mudS/rH2f9E3WCEF2iYDydQ==", "cpu": [ "arm64" ], @@ -3327,9 +3327,9 @@ } }, "node_modules/@next/swc-linux-x64-gnu": { - "version": "14.2.14", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-14.2.14.tgz", - "integrity": "sha512-lbn7svjUps1kmCettV/R9oAvEW+eUI0lo0LJNFOXoQM5NGNxloAyFRNByYeZKL3+1bF5YE0h0irIJfzXBq9Y6w==", + "version": "14.2.20", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-14.2.20.tgz", + "integrity": "sha512-ao5HCbw9+iG1Kxm8XsGa3X174Ahn17mSYBQlY6VGsdsYDAbz/ZP13wSLfvlYoIDn1Ger6uYA+yt/3Y9KTIupRg==", "cpu": [ "x64" ], @@ -3342,9 +3342,9 @@ } }, "node_modules/@next/swc-linux-x64-musl": { - "version": "14.2.14", - "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-14.2.14.tgz", - "integrity": "sha512-7TcQCvLQ/hKfQRgjxMN4TZ2BRB0P7HwrGAYL+p+m3u3XcKTraUFerVbV3jkNZNwDeQDa8zdxkKkw2els/S5onQ==", + "version": "14.2.20", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-14.2.20.tgz", + "integrity": "sha512-CXm/kpnltKTT7945np6Td3w7shj/92TMRPyI/VvveFe8+YE+/YOJ5hyAWK5rpx711XO1jBCgXl211TWaxOtkaA==", "cpu": [ "x64" ], @@ -3357,9 +3357,9 @@ } }, "node_modules/@next/swc-win32-arm64-msvc": { - "version": "14.2.14", - "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-14.2.14.tgz", - "integrity": "sha512-8i0Ou5XjTLEje0oj0JiI0Xo9L/93ghFtAUYZ24jARSeTMXLUx8yFIdhS55mTExq5Tj4/dC2fJuaT4e3ySvXU1A==", + "version": "14.2.20", + "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-14.2.20.tgz", + "integrity": "sha512-upJn2HGQgKNDbXVfIgmqT2BN8f3z/mX8ddoyi1I565FHbfowVK5pnMEwauvLvaJf4iijvuKq3kw/b6E9oIVRWA==", "cpu": [ "arm64" ], @@ -3372,9 +3372,9 @@ } }, "node_modules/@next/swc-win32-ia32-msvc": { - "version": "14.2.14", - "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-14.2.14.tgz", - "integrity": "sha512-2u2XcSaDEOj+96eXpyjHjtVPLhkAFw2nlaz83EPeuK4obF+HmtDJHqgR1dZB7Gb6V/d55FL26/lYVd0TwMgcOQ==", + "version": "14.2.20", + "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-14.2.20.tgz", + "integrity": "sha512-igQW/JWciTGJwj3G1ipalD2V20Xfx3ywQy17IV0ciOUBbFhNfyU1DILWsTi32c8KmqgIDviUEulW/yPb2FF90w==", "cpu": [ "ia32" ], @@ -3387,9 +3387,9 @@ } }, "node_modules/@next/swc-win32-x64-msvc": { - "version": "14.2.14", - "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.2.14.tgz", - "integrity": "sha512-MZom+OvZ1NZxuRovKt1ApevjiUJTcU2PmdJKL66xUPaJeRywnbGGRWUlaAOwunD6dX+pm83vj979NTC8QXjGWg==", + "version": "14.2.20", + "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.2.20.tgz", + "integrity": "sha512-AFmqeLW6LtxeFTuoB+MXFeM5fm5052i3MU6xD0WzJDOwku6SkZaxb1bxjBaRC8uNqTRTSPl0yMFtjNowIVI67w==", "cpu": [ "x64" ], @@ -13642,11 +13642,11 @@ "peer": true }, "node_modules/next": { - "version": "14.2.14", - "resolved": "https://registry.npmjs.org/next/-/next-14.2.14.tgz", - "integrity": "sha512-Q1coZG17MW0Ly5x76shJ4dkC23woLAhhnDnw+DfTc7EpZSGuWrlsZ3bZaO8t6u1Yu8FVfhkqJE+U8GC7E0GLPQ==", + "version": "14.2.20", + "resolved": "https://registry.npmjs.org/next/-/next-14.2.20.tgz", + "integrity": "sha512-yPvIiWsiyVYqJlSQxwmzMIReXn5HxFNq4+tlVQ812N1FbvhmE+fDpIAD7bcS2mGYQwPJ5vAsQouyme2eKsxaug==", "dependencies": { - "@next/env": "14.2.14", + "@next/env": "14.2.20", "@swc/helpers": "0.5.5", "busboy": "1.6.0", "caniuse-lite": "^1.0.30001579", @@ -13661,15 +13661,15 @@ "node": ">=18.17.0" }, "optionalDependencies": { - "@next/swc-darwin-arm64": "14.2.14", - "@next/swc-darwin-x64": "14.2.14", - "@next/swc-linux-arm64-gnu": "14.2.14", - "@next/swc-linux-arm64-musl": "14.2.14", - "@next/swc-linux-x64-gnu": "14.2.14", - "@next/swc-linux-x64-musl": "14.2.14", - "@next/swc-win32-arm64-msvc": "14.2.14", - "@next/swc-win32-ia32-msvc": "14.2.14", - "@next/swc-win32-x64-msvc": "14.2.14" + "@next/swc-darwin-arm64": "14.2.20", + "@next/swc-darwin-x64": "14.2.20", + "@next/swc-linux-arm64-gnu": "14.2.20", + "@next/swc-linux-arm64-musl": "14.2.20", + "@next/swc-linux-x64-gnu": "14.2.20", + "@next/swc-linux-x64-musl": "14.2.20", + "@next/swc-win32-arm64-msvc": "14.2.20", + "@next/swc-win32-ia32-msvc": "14.2.20", + "@next/swc-win32-x64-msvc": "14.2.20" }, "peerDependencies": { "@opentelemetry/api": "^1.1.0", diff --git a/cueweb/package.json b/cueweb/package.json index 866d5c33c..a0fa4555a 100644 --- a/cueweb/package.json +++ b/cueweb/package.json @@ -41,7 +41,7 @@ "lodash": "^4.17.21", "lodash.debounce": "^4.0.8", "lucide-react": "^0.304.0", - "next": "^14.2.3", + "next": "^14.2.20", "next-auth": "^4.24.10", "next-themes": "^0.2.1", "prom-client": "^15.1.2",