Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(web): adapt to HTTP API of DASD operations #1549

Merged
merged 62 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
9e8cc77
start with new web API for DASD
jreidinger Aug 21, 2024
daf6124
[WIP] Try to add a supported check to DASD API
teclator Aug 22, 2024
e05a7cc
try to have working dasd#supported
jreidinger Aug 22, 2024
5e246d1
Replaced DASD is supported check
teclator Aug 22, 2024
c772472
[WIP] Start adapting DASDPage
teclator Aug 22, 2024
7e4b34d
Temporal fix for showing dasds
teclator Aug 22, 2024
d866bd8
adapt ids
jreidinger Aug 22, 2024
8788502
Merge branch 'http-dasd' into web-dasd
teclator Aug 22, 2024
08edd00
Start moving DASD pages to Typescript
teclator Aug 22, 2024
e796206
add dasd probe
jreidinger Aug 22, 2024
2b40f73
add more api and queries for dasd
jreidinger Aug 22, 2024
455fa66
add format api call
jreidinger Aug 23, 2024
fa7ac90
fix sort types
jreidinger Aug 23, 2024
b2d7f6c
add backspace icon
jreidinger Aug 23, 2024
6251f72
Move DASD actions to queries
teclator Aug 23, 2024
6e8e581
add jobs api
jreidinger Aug 23, 2024
d4be0c8
Merge remote-tracking branch 'origin/http-dasd' into web-dasd
jreidinger Aug 23, 2024
fc3497f
Moved DASD filters to queries
teclator Aug 23, 2024
41251bf
Move DASD selection to queries
teclator Aug 23, 2024
b7ab21c
Merge remote-tracking branch 'origin/http-dasd' into web-dasd
jreidinger Aug 23, 2024
897bbf4
first attempt to implement proper format with storage jobs
jreidinger Aug 23, 2024
fc8f79c
optimize dasd devices query to not use invalidate
jreidinger Aug 27, 2024
f7530fd
Merge branch 'http-dasd' into web-dasd
teclator Aug 27, 2024
87e4e13
Fix jobs url
teclator Aug 27, 2024
fa3eae7
Getting rid of the DASD initial state
teclator Aug 27, 2024
e2da06a
Use the DASD id for notifing format job changes
teclator Aug 27, 2024
8991d01
Small fixes for the DASD Format progress dialog
teclator Aug 27, 2024
d67205d
Fix jobs summary test
teclator Aug 27, 2024
d7033e5
Merge remote-tracking branch 'origin/master' into web-dasd
jreidinger Aug 28, 2024
94f92fa
add non-working test for component with mutating queries
jreidinger Aug 28, 2024
23405eb
add test for dasd format progress together with fix it reveals
jreidinger Aug 28, 2024
5dba41c
transform DASDFormatProgress component to typescript
jreidinger Aug 29, 2024
40baceb
Update web/src/api/dasd.ts
jreidinger Aug 29, 2024
4e8e129
Removing dasd client
teclator Aug 29, 2024
eeba75f
Removing leftovers
teclator Aug 29, 2024
ad92d01
use connsistent name in API
jreidinger Aug 29, 2024
6b97d1d
Remove not needed code from DASD Page
teclator Aug 29, 2024
c13bfbf
Merge branch 'master' into web-dasd
teclator Aug 29, 2024
debcfb7
Merge remote-tracking branch 'origin/web-dasd' into dasd_failing_test
jreidinger Aug 29, 2024
1a3d485
fix dasd table test
jreidinger Aug 29, 2024
a6cb882
Improve DASDFormat progress dialog
teclator Aug 29, 2024
df7ca94
Notify id in Jobs events
teclator Aug 29, 2024
7ddbba5
Handle JobAdded event
teclator Aug 29, 2024
f585806
Remove running jobs when finish
teclator Aug 29, 2024
b028a3b
Fix DASDFormatProgress unit test
teclator Sep 2, 2024
9fd4544
Removed leftover Deviceinfo
teclator Sep 2, 2024
dbdf722
Changes based on CR
teclator Sep 2, 2024
8bbf57b
Changes based on code review
teclator Sep 3, 2024
918a5e3
Use mutations instead of API direct calls
teclator Sep 3, 2024
4405715
More changes based on code review
teclator Sep 4, 2024
6d140be
Replace dasd filter queries by component state
teclator Sep 4, 2024
8fc01b9
Replace dasd selection queries by component state
teclator Sep 4, 2024
50e76ad
Do not set any info about formatting.
teclator Sep 4, 2024
a75354f
Added DASD route only if supported
teclator Sep 4, 2024
669f102
Removed selected DASD leftover queries
teclator Sep 4, 2024
76d295b
Use only one mutation for modifying DASD state
teclator Sep 4, 2024
a705ac6
Do not modify existent cache but return new object
teclator Sep 4, 2024
d0bf495
Another inmutability fix
teclator Sep 4, 2024
3c9c319
Merge branch 'master' into web-dasd
teclator Sep 4, 2024
1c9dfdd
Added changelog
teclator Sep 4, 2024
9b96a93
Apply suggestions from CR
teclator Sep 5, 2024
e896085
Redirect to storage page in case DASD is not supported
teclator Sep 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion web/src/api/dasd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ const probeDASD = () => post("/api/storage/dasd/probe");
/**
* Start format job for given list of devices
* @param devicesIDs array of device ids
teclator marked this conversation as resolved.
Show resolved Hide resolved
* @return id of format job
*/
const DASDFormat = (devicesIDs: string[]) => post("/api/storage/dasd/format", { devices: devicesIDs });
const DASDFormat = (devicesIDs: string[]): Promise<string> => post("/api/storage/dasd/format", { devices: devicesIDs }).then(({ data }) => data);

/**
* Enables given list of devices
Expand Down
11 changes: 10 additions & 1 deletion web/src/api/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,18 @@ import { post, get, put } from "~/api/http";
import { Job } from "~/types/job";

/**
* Returns the installer status information
* Returns the list of jobs
*/
const fetchStorageJobs = async (): Promise<Job[]> => {
const jobs: Job[] = await get("/api/manager/installer");
return jobs;
};

/**
* Returns the job with given id or undefined
*/
const findStorageJob = async (id: string): Promise<Job|undefined> => {
return fetchStorageJobs().then((jobs: Job[]) => jobs.find((value, _i, _o) => value.id === id));
teclator marked this conversation as resolved.
Show resolved Hide resolved
};

export { fetchStorageJobs, findStorageJob };
46 changes: 45 additions & 1 deletion web/src/queries/dasd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { useInstallerClient } from "~/context/installer";
import React from "react";
import { hex } from "~/utils";
import { DASDDevice } from "~/types/dasd";
import { findStorageJob } from "~/api/storage";

/**
* Returns a query for retrieving the dasd devices
Expand All @@ -48,6 +49,47 @@ const useDASDDevices = () => {
return devices.map((d) => ({ ...d, hexId: hex(d.id) }));
};

/**
* Returns a query for retrieving the dasd format job
*/
const DASDFormatJobQuery = (id: string) => ({
queryKey: ["dasd", "formatJob", id],
queryFn: () => findStorageJob(id),
});

/**
* Hook that returns DASD devices.
*/
const useDASDFormatJob = (id: string) => {
const { data: job } = useSuspenseQuery(DASDFormatJobQuery(id));
return job;
};

/**
* Listens for DASD format job changes.
*/
const useDASDFormatJobChanges = (id: string) => {
const client = useInstallerClient();
const queryClient = useQueryClient();

React.useEffect(() => {
if (!client) return;

return client.ws().onEvent((event) => {
// TODO: for simplicity we now just invalidate query instead of manually adding, removing or changing devices
if (
teclator marked this conversation as resolved.
Show resolved Hide resolved
event.type === "DASDFormatJobChanged" && event.job_id === id
) {
const data = queryClient.getQueryData(["dasd", "formatJob", id]) as object;
const { step, total, done } = event;
queryClient.setQueryData(["dasd", "formatJob", id], { ...data, step, total, done });
}
});
});
const { data: formatJob } = useSuspenseQuery(DASDFormatJobQuery(id));
return formatJob;
};

/**
* Returns seleced DASD ids
*/
Expand Down Expand Up @@ -198,4 +240,6 @@ const useDiagDisableMutation = () => {
return useMutation(query);
};

export { useDASDDevices, useDASDDevicesChanges, useDASDEnableMutation, useDASDDisableMutation, useDiagDisableMutation, useDiagEnableMutation, useFilterDASDChange, filterDASDQuery, useFilterDASD, useSelectedDASD, useSelectedDASDChange, selectedDASDQuery };
export { useDASDDevices, useDASDDevicesChanges, useDASDEnableMutation, useDASDDisableMutation, useDiagDisableMutation,
useDiagEnableMutation, useFilterDASDChange, filterDASDQuery, useFilterDASD, useSelectedDASD, useSelectedDASDChange, selectedDASDQuery,
useDASDFormatJobChanges, useDASDFormatJob };
9 changes: 8 additions & 1 deletion web/src/types/dasd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,11 @@ type DASDDevice = {
hexId: number;
};

export type { DASDDevice };
type FormatJob = {
job_id: string,
jreidinger marked this conversation as resolved.
Show resolved Hide resolved
total: number,
step: number,
done: boolean
}

export type { DASDDevice, FormatJob };
Loading