Skip to content

Commit

Permalink
chore(web): merge the master branch into storage-typescript (#1579)
Browse files Browse the repository at this point in the history
Let's merge `master` into the `storage-typescript` branch to avoid
potential conflicts.
  • Loading branch information
imobachgs authored Sep 5, 2024
2 parents b6ec8e0 + 8552ddf commit 412b6f6
Show file tree
Hide file tree
Showing 23 changed files with 847 additions and 639 deletions.
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

0 comments on commit 412b6f6

Please sign in to comment.