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

chore(web): merge the master branch into storage-typescript #1579

Merged
merged 3 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
1 change: 1 addition & 0 deletions rust/agama-server/src/web/common/jobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ impl JobsStream {
values: &HashMap<String, OwnedValue>,
) -> Result<&'a Job, ServiceError> {
let job = cache.find_or_create(path);
job.id = path.to_string();
property_from_dbus!(job, running, "Running", values, bool);
property_from_dbus!(job, exit_code, "ExitCode", values, u32);
Ok(job)
Expand Down
2 changes: 1 addition & 1 deletion service/lib/agama/dbus/storage/dasds_format_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def initialize(initial, dasds_tree, path, logger: nil)
# Current status, in the format described by the D-Bus API
def summary
result = {}
@infos.each_value { |i| result[i.path] = i.to_dbus if i.path }
@infos.each_value { |i| result[i.id] = i.to_dbus if i.id }
result
end

Expand Down
2 changes: 1 addition & 1 deletion service/test/agama/dbus/storage/jobs_tree_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
expect(job.path).to match(/#{described_class::ROOT_PATH}\/[0-9]+/)

expect(job.summary).to eq(
{ "/path/dasd1" => [1000, 0, false], "/path/dasd2" => [2000, 0, false] }
{ "0.0.001" => [1000, 0, false], "0.0.002" => [2000, 0, false] }
)
end

Expand Down
5 changes: 5 additions & 0 deletions web/package/agama-web-ui.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
-------------------------------------------------------------------
Wed Sep 4 21:00:34 UTC 2024 - Knut Anderssen <[email protected]>

- Bring back DASD management support (gh#openSUSE/agama#1549).

-------------------------------------------------------------------
Tue Aug 13 14:57:21 UTC 2024 - David Diaz <[email protected]>

Expand Down
89 changes: 89 additions & 0 deletions web/src/api/dasd.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* 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 { post, get, put } from "~/api/http";
import { DASDDevice } from "~/types/dasd";

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

/**
* Returns if DASD is supported at all
*/
const DASDSupported = (): Promise<boolean> => get("/api/storage/dasd/supported");

/**
* probes DASD devices
*/
const probeDASD = () => post("/api/storage/dasd/probe");

/**
* Start format job for given list of DASD devices
* @param devicesIDs - array of DASD device ids
* @return id of format job
*/
const formatDASD = (devicesIDs: string[]): Promise<string> =>
post("/api/storage/dasd/format", { devices: devicesIDs }).then(({ data }) => data);

/**
* Enable given list of DASD devices
*
* @param devicesIDs - array of DASD device ids
*/
const enableDASD = (devicesIDs: string[]) =>
post("/api/storage/dasd/enable", { devices: devicesIDs });

/**
* Disable given list of DASD devices
*
* @param devicesIDs - array of DASD device ids
*/
const disableDASD = (devicesIDs: string[]) =>
post("/api/storage/dasd/disable", { devices: devicesIDs });

/**
* Enables diag on given list of DASD devices
*
* @param devicesIDs - array of DASD device ids
*/
const enableDiag = (devicesIDs: string[]) =>
put("/api/storage/dasd/diag", { devices: devicesIDs, diag: true });

/**
* Disables diag on given list of DASD devices
*
* @param devicesIDs - array of DASD device ids
*/
const disableDiag = (devicesIDs: string[]) =>
put("/api/storage/dasd/diag", { devices: devicesIDs, diag: false });

export {
fetchDASDDevices,
DASDSupported,
formatDASD,
probeDASD,
enableDASD,
disableDASD,
enableDiag,
disableDiag,
};
2 changes: 1 addition & 1 deletion web/src/api/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const addConnection = (connection: APIConnection) => post("/api/network/connecti
/**
* Updates given connection
*
* @param connection - connection to be added
* @param connection - connection to be updated
*/
const updateConnection = (connection: APIConnection) =>
put(`/api/network/connections/${connection.id}`, connection);
Expand Down
16 changes: 15 additions & 1 deletion web/src/api/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
* find current contact information at www.suse.com.
*/

import { post } from "~/api/http";
import { get, post } from "~/api/http";
import { Job } from "~/types/job";

/**
* Starts the storage probing process.
Expand All @@ -29,3 +30,16 @@ const probe = (): Promise<any> => post("/api/storage/probe");
export {
probe
}

/**
* Returns the list of jobs
*/
const fetchStorageJobs = (): Promise<Job[]> => get("/api/storage/jobs");

/**
* Returns the job with given id or undefined
*/
const findStorageJob = (id: string): Promise<Job | undefined> =>
fetchStorageJobs().then((jobs: Job[]) => jobs.find((value) => value.id === id));

export { fetchStorageJobs, findStorageJob };
Loading
Loading