Implements clickable name field with inline URL editor for Docker resources, matching the Proxmox guest URL feature:
- Create DockerMetadataAPI for storing custom URLs
- Add metadata loading and caching in DockerHosts component
- Add URL editing UI to DockerContainerRow and DockerServiceRow
- Global editing state prevents multiple simultaneous edits
- Shows external link icon when URL is set
- Supports Enter to save, Escape to cancel
- Toast notifications for save/delete operations
- Stores metadata with format: {hostId}:container:{containerId}
Allows users to add quick links to container/service dashboards (e.g., Portainer, Traefik, internal UIs).
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
// Docker Metadata API
|
|
import { apiFetchJSON } from '@/utils/apiClient';
|
|
|
|
export interface DockerMetadata {
|
|
id: string;
|
|
customUrl?: string;
|
|
description?: string;
|
|
tags?: string[];
|
|
}
|
|
|
|
export class DockerMetadataAPI {
|
|
private static baseUrl = '/api/docker/metadata';
|
|
|
|
// Get metadata for a specific docker resource (container or service)
|
|
static async getMetadata(resourceId: string): Promise<DockerMetadata> {
|
|
return apiFetchJSON(`${this.baseUrl}/${encodeURIComponent(resourceId)}`);
|
|
}
|
|
|
|
// Get all docker metadata
|
|
static async getAllMetadata(): Promise<Record<string, DockerMetadata>> {
|
|
return apiFetchJSON(this.baseUrl);
|
|
}
|
|
|
|
// Update metadata for a docker resource
|
|
static async updateMetadata(
|
|
resourceId: string,
|
|
metadata: Partial<DockerMetadata>,
|
|
): Promise<DockerMetadata> {
|
|
return apiFetchJSON(`${this.baseUrl}/${encodeURIComponent(resourceId)}`, {
|
|
method: 'PUT',
|
|
body: JSON.stringify(metadata),
|
|
});
|
|
}
|
|
|
|
// Delete metadata for a docker resource
|
|
static async deleteMetadata(resourceId: string): Promise<void> {
|
|
await apiFetchJSON(`${this.baseUrl}/${encodeURIComponent(resourceId)}`, {
|
|
method: 'DELETE',
|
|
});
|
|
}
|
|
}
|