Skip to content

Commit

Permalink
start with new web API for DASD
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Aug 21, 2024
1 parent 04ff47d commit 145c975
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 0 deletions.
30 changes: 30 additions & 0 deletions web/src/api/dasd.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (c) [2024] SUSE LLC
*
* All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, contact SUSE LLC.
*
* To contact SUSE LLC about this file by physical or electronic mail, you may
* find current contact information at www.suse.com.
*/

import { del, get, patch, put } from "~/api/http";
import { DASDDevice } from "~/types/dasd";

/**
* Returns the list of DASD devices
*/
const fetchDASDDevices = (): Promise<DASDDevice[]> => get("/api/storage/dasd/devices");

export { fetchDASDDevices };
44 changes: 44 additions & 0 deletions web/src/queries/dasd.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright (c) [2024] SUSE LLC
*
* All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, contact SUSE LLC.
*
* To contact SUSE LLC about this file by physical or electronic mail, you may
* find current contact information at www.suse.com.
*/

import { useSuspenseQuery } from "@tanstack/react-query";
import { _ } from "~/i18n";
import {
fetchDASDDevices,
} from "~/api/dasd";

/**
* Returns a query for retrieving the dasd devices
*/
const DASDDevicesQuery = () => ({
queryKey: ["dasd", "devices"],
queryFn: fetchDASDDevices,
});

/**
* Hook that returns the first user.
*/
const useDASDDevices = () => {
const { data: devices } = useSuspenseQuery(DASDDevicesQuery());
return devices;
};

export { useDASDDevices };
34 changes: 34 additions & 0 deletions web/src/types/dasd.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (c) [2024] SUSE LLC
*
* All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, contact SUSE LLC.
*
* To contact SUSE LLC about this file by physical or electronic mail, you may
* find current contact information at www.suse.com.
*/

type DASDDevice = {
id: string;
enabled: boolean;
deviceName: string;
formatted: boolean;
diag: boolean;
status: string; // TODO: sync with rust when it switch to enum
deviceType: string; // TODO: sync with rust when it switch to enum
accessType: string; // TODO: sync with rust when it switch to enum
partitionInfo: string;
};

export type { DASDDevice };

0 comments on commit 145c975

Please sign in to comment.