-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(web): replace NetworkClient with queries (#1519)
Adapt the network management code to use queries instead of NetworkCient. Related to #1439. Additionally, starts migrating the code to TypeScript and fixes bugs found by the type system. --- Reviewers, please note that this ended up being a rather long PR, reason why is better to not only review the code but also to do manual testing if possible. Take your time, but any issue out of the scope of state management / queries migration should be reported as a new issue to be addressed in a new PBI. --- Notes for creating follow-up work, * Fix WifiConnectionForm to avoid `"error": "Network system error: Network state error: Connection '<ssid>' already exists"` when connecting to hidden network that previously failed. In short, we should either, to drop the configuration created for a failed { hidden: true } connection or to implement a mechanism to know that such a configuration already exists and performs an _update_ instead of _add_. * Review when it's possible to define a gateway and fix the UI information accordingly * Check if we can use the type Address from ipaddr package instead of our own IPAddress type (most probably not) * Add support for IPv6 since as @jreidinger [said](#1519 (comment)) its usage is becoming more common. Look for `FIXME: IPv6 is not supported yet.` comments
- Loading branch information
Showing
45 changed files
with
2,405 additions
and
2,420 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/* | ||
* 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, post, put } from "~/api/http"; | ||
import { APIAccessPoint, APIConnection, APIDevice, NetworkGeneralState } from "~/types/network"; | ||
|
||
/** | ||
* Returns the network configuration | ||
*/ | ||
const fetchState = (): Promise<NetworkGeneralState> => get("/api/network/state"); | ||
|
||
/** | ||
* Returns a list of known devices | ||
*/ | ||
const fetchDevices = (): Promise<APIDevice[]> => get("/api/network/devices"); | ||
|
||
/** | ||
* Returns data for given connection name | ||
*/ | ||
const fetchConnection = (name: string): Promise<APIConnection> => | ||
get(`/api/network/connections/${name}`); | ||
|
||
/** | ||
* Returns the list of known connections | ||
*/ | ||
const fetchConnections = (): Promise<APIConnection[]> => get("/api/network/connections"); | ||
|
||
/** | ||
* Returns the list of known access points | ||
*/ | ||
const fetchAccessPoints = (): Promise<APIAccessPoint[]> => get("/api/network/wifi"); | ||
|
||
/** | ||
* Adds a new connection | ||
* | ||
* @param connection - connection to be added | ||
*/ | ||
const addConnection = (connection: APIConnection) => post("/api/network/connections", connection); | ||
|
||
/** | ||
* Updates given connection | ||
* | ||
* @param connection - connection to be added | ||
*/ | ||
const updateConnection = (connection: APIConnection) => | ||
put(`/api/network/connections/${connection.id}`, connection); | ||
|
||
/** | ||
* Deletes the connection matching given name | ||
*/ | ||
const deleteConnection = (name: string) => del(`/api/network/connections/${name}`); | ||
|
||
/** | ||
* Apply network changes | ||
*/ | ||
const applyChanges = () => post("/api/network/system/apply"); | ||
|
||
/** | ||
* Performs the connect action for connection matching given name | ||
*/ | ||
const connect = (name: string) => patch(`/api/network/connections/${name}/connect`); | ||
|
||
/** | ||
* Performs the disconnect action for connection matching given name | ||
*/ | ||
const disconnect = (name: string) => patch(`/api/network/connections/${name}/disconnect`); | ||
|
||
export { | ||
fetchState, | ||
fetchDevices, | ||
fetchConnection, | ||
fetchConnections, | ||
fetchAccessPoints, | ||
applyChanges, | ||
addConnection, | ||
updateConnection, | ||
deleteConnection, | ||
connect, | ||
disconnect, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.