mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-11-16 14:54:23 +08:00
perf(nodes): paginate node lists and fetch details directly (#54)
* perf(nodes): paginate node lists and fetch details directly * fix(nodes): preserve Unicode search and page transition state * fix(nodes): validate search using the UTF-8 byte limit
This commit is contained in:
@@ -38,6 +38,8 @@ export type {
|
||||
NodeAgentUpdatePayload,
|
||||
NodeBootstrapToken,
|
||||
NodeItem,
|
||||
NodeListQuery,
|
||||
NodeListResult,
|
||||
NodeMutationPayload,
|
||||
NodeHealthEvent,
|
||||
NodeObservability,
|
||||
|
||||
@@ -4,6 +4,8 @@ import type {
|
||||
NodeAgentUpdatePayload,
|
||||
NodeBootstrapToken,
|
||||
NodeItem,
|
||||
NodeListQuery,
|
||||
NodeListResult,
|
||||
NodeMutationPayload,
|
||||
NodeObservability,
|
||||
ReleaseChannel,
|
||||
@@ -16,6 +18,16 @@ export class NodeService extends OpenFlareBaseService {
|
||||
return this.get<NodeItem[]>('/');
|
||||
}
|
||||
|
||||
static async listNodePage(
|
||||
query: NodeListQuery = {},
|
||||
): Promise<NodeListResult> {
|
||||
return this.get<NodeListResult>('/page', { ...query });
|
||||
}
|
||||
|
||||
static async getNode(id: number): Promise<NodeItem> {
|
||||
return this.get<NodeItem>(`/${id}`);
|
||||
}
|
||||
|
||||
static async createNode(payload: NodeMutationPayload): Promise<NodeItem> {
|
||||
return this.post<NodeItem>('/', payload);
|
||||
}
|
||||
|
||||
@@ -56,6 +56,21 @@ export interface NodeItem {
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
export interface NodeListQuery {
|
||||
page?: number;
|
||||
page_size?: number;
|
||||
search?: string;
|
||||
status?: NodeStatus | '';
|
||||
node_type?: NodeType | '';
|
||||
}
|
||||
|
||||
export interface NodeListResult {
|
||||
total: number;
|
||||
results: NodeItem[];
|
||||
page: number;
|
||||
page_size: number;
|
||||
}
|
||||
|
||||
export interface NodeBootstrapToken {
|
||||
discovery_token: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user