mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-30 23:25:24 +00:00
feat: convert network-topology to a full plugin (B1)
This commit is contained in:
1 parent
95abe24798
commit
fdedca39fd
51 files changed
+30321
-814
No files matched your search
@@ -0,0 +1,55 @@
|
||||
import type { PluginApiClient } from "@termix/plugin-sdk/frontend";
|
||||
|
||||
export interface NetworkTopologyNode {
|
||||
data: {
|
||||
id: string;
|
||||
label?: string;
|
||||
ip?: string;
|
||||
status?: string;
|
||||
tags?: string[];
|
||||
parent?: string;
|
||||
color?: string;
|
||||
/** Absent on nodes; callers tell nodes from edges by testing these. */
|
||||
source?: undefined;
|
||||
target?: undefined;
|
||||
};
|
||||
position?: { x: number; y: number };
|
||||
}
|
||||
|
||||
export interface NetworkTopologyEdge {
|
||||
data: {
|
||||
id?: string;
|
||||
source: string;
|
||||
target: string;
|
||||
label?: undefined;
|
||||
ip?: undefined;
|
||||
};
|
||||
}
|
||||
|
||||
export interface NetworkTopologyData {
|
||||
nodes: NetworkTopologyNode[];
|
||||
edges: NetworkTopologyEdge[];
|
||||
}
|
||||
|
||||
/**
|
||||
* The topology routes, through the plugin's own client. Paths are relative
|
||||
* to /plugin-api/network-topology/, which the client already points at.
|
||||
*/
|
||||
export function createNetworkTopologyApi(api: PluginApiClient) {
|
||||
return {
|
||||
get: async (): Promise<NetworkTopologyData | null> => {
|
||||
const response = await api.get<NetworkTopologyData | null>("/");
|
||||
return response.data;
|
||||
},
|
||||
save: async (
|
||||
topology: NetworkTopologyData,
|
||||
): Promise<{ success: boolean }> => {
|
||||
const response = await api.post<{ success: boolean }>("/", {
|
||||
topology,
|
||||
});
|
||||
return response.data;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export type NetworkTopologyApi = ReturnType<typeof createNetworkTopologyApi>;
|
||||
Reference in new issue
Block a user