Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
fix: template loading and usage
Kyle Mendellc994404d48c7
diff --git a/backend/internal/api/template_handler.go b/backend/internal/api/template_handler.goindex 525a95269..71f666021 100644--- a/backend/internal/api/template_handler.go+++ b/backend/internal/api/template_handler.go@@ -6,11 +6,11 @@ import ("fmt""io""net/http"- "strconv""strings""time""github.com/gin-gonic/gin"+ "github.com/google/uuid""github.com/ofkm/arcane-backend/internal/models""github.com/ofkm/arcane-backend/internal/services")@@ -135,9 +135,13 @@ func (h *TemplateHandler) CreateTemplate(c *gin.Context) {}template := &models.ComposeTemplate{+ // Generate a UUID for the new template+ ID: uuid.NewString(),Name: req.Name,Description: req.Description,Content: req.Content,+ IsCustom: true, // New templates created via API are custom+ IsRemote: false,}if req.EnvContent != "" {@@ -192,6 +196,9 @@ func (h *TemplateHandler) UpdateTemplate(c *gin.Context) {if req.EnvContent != "" {updates.EnvContent = &req.EnvContent+ } else {+ // If envContent is empty in the request, explicitly set it to nil+ updates.EnvContent = nil}err := h.templateService.UpdateTemplate(c.Request.Context(), id, updates)@@ -210,9 +217,21 @@ func (h *TemplateHandler) UpdateTemplate(c *gin.Context) {return}+ // Fetch the updated template to return in the response+ updatedTemplate, err := h.templateService.GetTemplate(c.Request.Context(), id)+ if err != nil {+ // Handle error fetching the updated template, though the update succeeded+ c.JSON(http.StatusOK, gin.H{+ "success": true,+ "message": "Template updated successfully, but failed to fetch updated template details.",+ })+ return+ }+c.JSON(http.StatusOK, gin.H{- "success": true,- "message": "Template updated successfully",+ "success": true,+ "message": "Template updated successfully",+ "template": updatedTemplate, // Return the updated template})}@@ -317,6 +336,8 @@ func (h *TemplateHandler) CreateRegistry(c *gin.Context) {}registry := &models.TemplateRegistry{+ // Generate a UUID for the registry ID+ ID: uuid.NewString(),Name: req.Name,URL: req.URL,Description: req.Description,@@ -339,12 +360,11 @@ func (h *TemplateHandler) CreateRegistry(c *gin.Context) {}func (h *TemplateHandler) UpdateRegistry(c *gin.Context) {- idStr := c.Param("id")- id, err := strconv.ParseUint(idStr, 10, 32)- if err != nil {+ id := c.Param("id")+ if id == "" {c.JSON(http.StatusBadRequest, gin.H{"success": false,- "error": "Invalid registry ID",+ "error": "Registry ID is required",})return}@@ -371,7 +391,8 @@ func (h *TemplateHandler) UpdateRegistry(c *gin.Context) {Enabled: req.Enabled,}- err = h.templateService.UpdateRegistry(c.Request.Context(), uint(id), updates)+ // Pass the string ID to the service layer+ err := h.templateService.UpdateRegistry(c.Request.Context(), id, updates)if err != nil {if err.Error() == "registry not found" {c.JSON(http.StatusNotFound, gin.H{@@ -394,17 +415,17 @@ func (h *TemplateHandler) UpdateRegistry(c *gin.Context) {}func (h *TemplateHandler) DeleteRegistry(c *gin.Context) {- idStr := c.Param("id")- id, err := strconv.ParseUint(idStr, 10, 32)- if err != nil {+ id := c.Param("id")+ if id == "" {c.JSON(http.StatusBadRequest, gin.H{"success": false,- "error": "Invalid registry ID",+ "error": "Registry ID is required",})return}- err = h.templateService.DeleteRegistry(c.Request.Context(), uint(id))+ // Pass the string ID to the service layer+ err := h.templateService.DeleteRegistry(c.Request.Context(), id)if err != nil {if err.Error() == "registry not found" {c.JSON(http.StatusNotFound, gin.H{diff --git a/backend/internal/models/template.go b/backend/internal/models/template.goindex e7072f4bf..894e89182 100644--- a/backend/internal/models/template.go+++ b/backend/internal/models/template.go@@ -5,7 +5,7 @@ import ()type TemplateRegistry struct {- ID uint `json:"id" gorm:"primaryKey"`+ ID string `json:"id" gorm:"primaryKey"`Name string `json:"name" gorm:"not null"`URL string `json:"url" gorm:"not null;unique"`Enabled bool `json:"enabled" gorm:"default:true"`@@ -22,7 +22,7 @@ type ComposeTemplate struct {EnvContent *string `json:"envContent,omitempty" gorm:"type:text"`IsCustom bool `json:"isCustom" gorm:"default:true"`IsRemote bool `json:"isRemote" gorm:"default:false"`- RegistryID *uint `json:"registryId,omitempty"`+ RegistryID *string `json:"registryId,omitempty"`Registry *TemplateRegistry `json:"registry,omitempty" gorm:"foreignKey:RegistryID"`Metadata *ComposeTemplateMetadata `json:"metadata,omitempty" gorm:"embedded;embeddedPrefix:meta_"`CreatedAt time.Time `json:"createdAt"`diff --git a/backend/internal/services/template_service.go b/backend/internal/services/template_service.goindex 6b61a104a..083631347 100644--- a/backend/internal/services/template_service.go+++ b/backend/internal/services/template_service.go@@ -11,6 +11,7 @@ import ("path/filepath""regexp""strings"+ "sync" // Import sync package"time""github.com/ofkm/arcane-backend/internal/database"@@ -20,25 +21,62 @@ import (type TemplateService struct {db *database.DB+ // Add fields for caching remote templates+ remoteTemplatesCache []models.ComposeTemplate+ lastRemoteFetch time.Time+ remoteFetchMutex sync.Mutex}+const remoteCacheDuration = 5 * time.Minute // Cache duration+func NewTemplateService(db *database.DB) *TemplateService {return &TemplateService{db: db}}+// Helper to load remote templates into cache+func (s *TemplateService) ensureRemoteTemplatesLoaded(ctx context.Context) error {+ s.remoteFetchMutex.Lock()+ defer s.remoteFetchMutex.Unlock()++ // Check if cache is fresh+ if time.Since(s.lastRemoteFetch) < remoteCacheDuration && s.remoteTemplatesCache != nil {+ return nil // Cache is fresh+ }++ // Fetch and update cache+ fetchedTemplates, err := s.loadRemoteTemplates(ctx) // This function already exists+ if err != nil {+ // Log the error but don't fail the request if local templates are available+ fmt.Printf("Warning: failed to refresh remote templates cache: %v\n", err)+ // Keep the old cache if fetching failed, unless it's the first fetch+ if s.remoteTemplatesCache == nil {+ return fmt.Errorf("failed to load remote templates: %w", err)+ }+ return nil // Use stale cache if fetch failed+ }++ s.remoteTemplatesCache = fetchedTemplates+ s.lastRemoteFetch = time.Now()+ return nil+}+func (s *TemplateService) GetAllTemplates(ctx context.Context) ([]models.ComposeTemplate, error) {var templates []models.ComposeTemplate+ // Get local templateserr := s.db.WithContext(ctx).Preload("Registry").Find(&templates).Errorif err != nil {return nil, fmt.Errorf("failed to get local templates: %w", err)}- remoteTemplates, err := s.loadRemoteTemplates(ctx)+ // Ensure remote templates are loaded into cache+ err = s.ensureRemoteTemplatesLoaded(ctx)if err != nil {- fmt.Printf("Warning: failed to load remote templates: %v\n", err)+ // Log the error but proceed with local templates if remote loading failed+ fmt.Printf("Warning: failed to load remote templates for GetAllTemplates: %v\n", err)} else {- templates = append(templates, remoteTemplates...)+ // Append remote templates from cache+ templates = append(templates, s.remoteTemplatesCache...)}return templates, nil@@ -46,17 +84,41 @@ func (s *TemplateService) GetAllTemplates(ctx context.Context) ([]models.Composefunc (s *TemplateService) GetTemplate(ctx context.Context, id string) (*models.ComposeTemplate, error) {var template models.ComposeTemplate++ // 1. Try to find in local databaseerr := s.db.WithContext(ctx).Preload("Registry").Where("id = ?", id).First(&template).Error+ if err == nil {+ return &template, nil // Found a local template+ }++ // If not found in DB, check if it's a record not found error+ if !errors.Is(err, gorm.ErrRecordNotFound) {+ return nil, fmt.Errorf("failed to query local template: %w", err) // Other DB error+ }++ // 2. If not found in local DB, try to find in remote templates cache+ err = s.ensureRemoteTemplatesLoaded(ctx) // Ensure cache is loaded/freshif err != nil {- if errors.Is(err, gorm.ErrRecordNotFound) {- return nil, fmt.Errorf("template not found")+ // If loading remote templates failed and there's no local template, return not found+ return nil, fmt.Errorf("template not found (failed to load remote templates): %w", err)+ }++ // Search in the in-memory cache+ for _, remoteTemplate := range s.remoteTemplatesCache {+ if remoteTemplate.ID == id {+ // Found the remote template in cache+ // Return a copy to avoid modifying the cached object directly+ foundTemplate := remoteTemplate+ return &foundTemplate, nil}- return nil, fmt.Errorf("failed to get template: %w", err)}- return &template, nil++ // 3. If not found in local DB or remote cache+ return nil, fmt.Errorf("template not found")}func (s *TemplateService) CreateTemplate(ctx context.Context, template *models.ComposeTemplate) error {+ // Ensure ID is set if not provided (for custom templates)if template.ID == "" {template.ID = s.generateTemplateID(template.Name)}@@ -82,6 +144,11 @@ func (s *TemplateService) UpdateTemplate(ctx context.Context, id string, updatesreturn fmt.Errorf("failed to find template: %w", err)}+ // Only allow updating local templates+ if existing.IsRemote {+ return fmt.Errorf("cannot update remote template")+ }+existing.Name = updates.Nameexisting.Description = updates.Descriptionexisting.Content = updates.Content@@ -96,12 +163,27 @@ func (s *TemplateService) UpdateTemplate(ctx context.Context, id string, updates}func (s *TemplateService) DeleteTemplate(ctx context.Context, id string) error {+ var existing models.ComposeTemplate+ err := s.db.WithContext(ctx).Where("id = ?", id).First(&existing).Error+ if err != nil {+ if errors.Is(err, gorm.ErrRecordNotFound) {+ return fmt.Errorf("template not found")+ }+ return fmt.Errorf("failed to find template: %w", err)+ }++ // Only allow deleting local templates+ if existing.IsRemote {+ return fmt.Errorf("cannot delete remote template directly")+ }+result := s.db.WithContext(ctx).Where("id = ?", id).Delete(&models.ComposeTemplate{})if result.Error != nil {return fmt.Errorf("failed to delete template: %w", result.Error)}if result.RowsAffected == 0 {- return fmt.Errorf("template not found")+ // This case should ideally not be reached if First() succeeded, but as a safeguard+ return fmt.Errorf("template not found after finding it")}return nil}@@ -146,36 +228,24 @@ func (s *TemplateService) CreateRegistry(ctx context.Context, registry *models.Treturn nil}-func (s *TemplateService) UpdateRegistry(ctx context.Context, id uint, updates *models.TemplateRegistry) error {- var existing models.TemplateRegistry- err := s.db.WithContext(ctx).Where("id = ?", id).First(&existing).Error- if err != nil {- if errors.Is(err, gorm.ErrRecordNotFound) {- return fmt.Errorf("registry not found")- }- return fmt.Errorf("failed to find registry: %w", err)+func (s *TemplateService) UpdateRegistry(ctx context.Context, id string, updates *models.TemplateRegistry) error {+ result := s.db.WithContext(ctx).Model(&models.TemplateRegistry{}).Where("id = ?", id).Updates(updates)+ if result.Error != nil {+ return result.Error}-- existing.Name = updates.Name- existing.URL = updates.URL- existing.Enabled = updates.Enabled- existing.Description = updates.Description-- err = s.db.WithContext(ctx).Save(&existing).Error- if err != nil {- return fmt.Errorf("failed to update registry: %w", err)+ if result.RowsAffected == 0 {+ return errors.New("registry not found")}-return nil}-func (s *TemplateService) DeleteRegistry(ctx context.Context, id uint) error {+func (s *TemplateService) DeleteRegistry(ctx context.Context, id string) error {result := s.db.WithContext(ctx).Where("id = ?", id).Delete(&models.TemplateRegistry{})if result.Error != nil {- return fmt.Errorf("failed to delete registry: %w", result.Error)+ return result.Error}if result.RowsAffected == 0 {- return fmt.Errorf("registry not found")+ return errors.New("registry not found")}return nil}@@ -246,10 +316,12 @@ func (s *TemplateService) convertRemoteToLocal(remote models.RemoteTemplate, reg}return models.ComposeTemplate{- ID: fmt.Sprintf("%s/%s", registry.Name, remote.ID),+ // Use the combined ID format here+ ID: fmt.Sprintf("%s-%s", registry.ID, remote.ID),Name: remote.Name,Description: remote.Description,- Content: "",+ Content: "", // Content is not stored for remote templates initially+ EnvContent: nil, // EnvContent is not stored for remote templates initiallyIsCustom: false,IsRemote: true,RegistryID: ®istry.ID,@@ -276,6 +348,9 @@ func (s *TemplateService) generateTemplateID(name string) string {id = "template"}+ // Ensure uniqueness for local templates if needed, e.g., append a short hash or timestamp+ // For now, relying on DB primary key constraint for uniqueness on save.+return id}@@ -303,17 +378,22 @@ POSTGRES_PORT=5432func (s *TemplateService) FetchTemplateContent(ctx context.Context, template *models.ComposeTemplate) (string, string, error) {if !template.IsRemote || template.Metadata == nil || template.Metadata.RemoteURL == nil {- return template.Content, "", fmt.Errorf("not a remote template")+ return template.Content, "", fmt.Errorf("not a remote template or missing remote URL")}composeContent, err := s.fetchURL(ctx, *template.Metadata.RemoteURL)if err != nil {- return "", "", fmt.Errorf("failed to fetch compose content: %w", err)+ return "", "", fmt.Errorf("failed to fetch compose content from %s: %w", *template.Metadata.RemoteURL, err)}var envContent stringif template.Metadata.EnvURL != nil && *template.Metadata.EnvURL != "" {- envContent, _ = s.fetchURL(ctx, *template.Metadata.EnvURL)+ envContent, err = s.fetchURL(ctx, *template.Metadata.EnvURL)+ if err != nil {+ // Log error but don't fail if env file fetch fails+ fmt.Printf("Warning: failed to fetch env content from %s: %v\n", *template.Metadata.EnvURL, err)+ envContent = "" // Ensure envContent is empty string on failure+ }}return composeContent, envContent, nil@@ -323,21 +403,21 @@ func (s *TemplateService) fetchURL(ctx context.Context, url string) (string, errclient := &http.Client{Timeout: 30 * time.Second}req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)if err != nil {- return "", err+ return "", fmt.Errorf("failed to create request for %s: %w", url, err)}resp, err := client.Do(req)if err != nil {- return "", err+ return "", fmt.Errorf("failed to fetch URL %s: %w", url, err)}defer resp.Body.Close()if resp.StatusCode != http.StatusOK {- return "", fmt.Errorf("HTTP %d", resp.StatusCode)+ return "", fmt.Errorf("HTTP status %d for URL %s", resp.StatusCode, url)}body, err := io.ReadAll(resp.Body)if err != nil {- return "", err+ return "", fmt.Errorf("failed to read response body from %s: %w", url, err)}return string(body), nil@@ -348,19 +428,27 @@ func (s *TemplateService) DownloadTemplate(ctx context.Context, remoteTemplate *return nil, fmt.Errorf("template is not remote")}+ // Check if a local version with the same remote ID already exists+ // This prevents duplicate downloads of the same remote template+ existingLocalTemplate, err := s.GetTemplate(ctx, s.generateTemplateID(remoteTemplate.Name)) // Assuming local ID is based on name+ if err == nil && !existingLocalTemplate.IsRemote {+ return existingLocalTemplate, fmt.Errorf("template '%s' is already downloaded", remoteTemplate.Name)+ }+composeContent, envContent, err := s.FetchTemplateContent(ctx, remoteTemplate)if err != nil {- return nil, fmt.Errorf("failed to fetch template content: %w", err)+ return nil, fmt.Errorf("failed to fetch template content for download: %w", err)}localTemplate := &models.ComposeTemplate{- ID: s.generateTemplateID(remoteTemplate.Name + "-local"),+ // Generate a new ID for the local copy, distinct from the remote ID+ ID: s.generateTemplateID(remoteTemplate.Name), // Use a local-specific ID generationName: remoteTemplate.Name,Description: fmt.Sprintf("%s (Downloaded from %s)", remoteTemplate.Description, remoteTemplate.Registry.Name),Content: composeContent,- IsCustom: true,+ IsCustom: true, // Downloaded templates are custom local copiesIsRemote: false,- RegistryID: nil,+ RegistryID: nil, // No longer linked to a remote registryRegistry: nil,}@@ -368,16 +456,15 @@ func (s *TemplateService) DownloadTemplate(ctx context.Context, remoteTemplate *localTemplate.EnvContent = &envContent}+ // Copy relevant metadataif remoteTemplate.Metadata != nil {localTemplate.Metadata = &models.ComposeTemplateMetadata{Version: remoteTemplate.Metadata.Version,Author: remoteTemplate.Metadata.Author,Tags: remoteTemplate.Metadata.Tags,- RemoteURL: remoteTemplate.Metadata.RemoteURL,- EnvURL: remoteTemplate.Metadata.EnvURL,DocumentationURL: remoteTemplate.Metadata.DocumentationURL,IconURL: remoteTemplate.Metadata.IconURL,- UpdatedAt: remoteTemplate.Metadata.UpdatedAt,+ // Do not copy RemoteURL, EnvURL, UpdatedAt as it's now local}}@@ -386,5 +473,22 @@ func (s *TemplateService) DownloadTemplate(ctx context.Context, remoteTemplate *return nil, fmt.Errorf("failed to save local template: %w", err)}+ // After successful download and save, remove the remote template from the cache+ // This is optional but can help keep the list clean if you only want to see local after download+ // s.removeRemoteTemplateFromCache(remoteTemplate.ID) // Need to implement this helper if desired+return localTemplate, nil}++// Helper to remove a template from the remote cache (optional)+// func (s *TemplateService) removeRemoteTemplateFromCache(id string) {+// s.remoteFetchMutex.Lock()+// defer s.remoteFetchMutex.Unlock()+// var updatedCache []models.ComposeTemplate+// for _, t := range s.remoteTemplatesCache {+// if t.ID != id {+// updatedCache = append(updatedCache, t)+// }+// }+// s.remoteTemplatesCache = updatedCache+// }diff --git a/frontend/src/lib/components/dialogs/template-selection-dialog.svelte b/frontend/src/lib/components/dialogs/template-selection-dialog.svelteindex 962ea995f..1a03e5be9 100644--- a/frontend/src/lib/components/dialogs/template-selection-dialog.svelte+++ b/frontend/src/lib/components/dialogs/template-selection-dialog.svelte@@ -3,10 +3,9 @@import { Button } from '$lib/components/ui/button/index.js';import { Card } from '$lib/components/ui/card/index.js';import { Badge } from '$lib/components/ui/badge/index.js';- import * as Alert from '$lib/components/ui/alert/index.js';import { FileText, Globe, FolderOpen, Settings, Download, Loader2 } from '@lucide/svelte';import { templateAPI } from '$lib/services/api';- import type { TemplateRegistry, Template } from '$lib/types/template.type';+ import type { Template } from '$lib/types/template.type';import { toast } from 'svelte-sonner';interface Props {@@ -17,41 +16,39 @@let { open = $bindable(), templates, onSelect }: Props = $props();- // Loading states for individual templateslet loadingStates = $state(new Map<string, boolean>());async function handleSelect(template: Template) {- // Set loading stateloadingStates.set(template.id, true);loadingStates = new Map(loadingStates);try {- let finalTemplate = template;-- if (template.isRemote) {- const templateContent = await templateAPI.getById(template.id);-- if (!templateContent.content) {- toast.error('Failed to load template content');- return;- }-- // Create the final template with actual content- finalTemplate = {- ...template,- content: templateContent.content,- envContent: templateContent.envContent || template.envContent- };+ const templateDetails = await templateAPI.getTemplateContent(template.id);++ if (!templateDetails.content) {+ toast.error('Failed to load template content');+ return;}+ const finalTemplate = {+ ...templateDetails.template,+ content: templateDetails.content,+ envContent: templateDetails.envContent+ };+onSelect(finalTemplate);open = false;toast.success(`Template "${template.name}" loaded successfully!`);} catch (error) {console.error('Error loading template:', error);- toast.error('Failed to load template content');+ let errorMessage = 'Failed to load template content';+ if (error instanceof Error) {+ errorMessage = error.message;+ } else if (error && typeof error === 'object' && 'message' in error) {+ errorMessage = String(error.message);+ }+ toast.error(errorMessage);} finally {- // Clear loading stateloadingStates.delete(template.id);loadingStates = new Map(loadingStates);}@@ -101,7 +98,10 @@<FileText class="size-5" />Choose a Template</Dialog.Title>- <Dialog.Description>Select a Docker Compose template to get started quickly, or download remote templates for local use.</Dialog.Description>+ <Dialog.Description+ >Select a Docker Compose template to get started quickly, or download remote templates for+ local use.</Dialog.Description+ ></Dialog.Header><div class="space-y-6 py-4">@@ -110,7 +110,10 @@<FileText class="mx-auto mb-4 size-12 opacity-50" /><p class="mb-2">No templates available</p><p class="text-sm">- Configure remote registries in <a href="/settings/templates" class="text-primary hover:underline">Template Settings</a> to access community templates+ Configure remote registries in <a+ href="/settings/templates"+ class="text-primary hover:underline">Template Settings</a+ > to access community templates</p></div>{:else}@@ -123,7 +126,9 @@</h3><div class="grid grid-cols-1 gap-4 md:grid-cols-2">{#each localTemplates as template}- <Card class="hover:bg-muted/50 hover:border-primary/20 cursor-pointer border-2 transition-colors">+ <Card+ class="hover:bg-muted/50 hover:border-primary/20 cursor-pointer border-2 transition-colors"+ ><div class="p-4"><div class="mb-2 flex items-start justify-between"><h4 class="truncate pr-2 font-semibold">{template.name}</h4>@@ -147,7 +152,11 @@<div class="text-muted-foreground text-xs">{template.envContent ? 'Includes environment variables' : 'Ready to use'}</div>- <Button size="sm" onclick={() => handleSelect(template)} disabled={loadingStates.get(template.id)}>+ <Button+ size="sm"+ onclick={() => handleSelect(template)}+ disabled={loadingStates.get(template.id)}+ >{#if loadingStates.get(template.id)}<Loader2 class="mr-1 size-3 animate-spin" />Loading...@@ -198,7 +207,7 @@</p>{/if}<div class="flex items-center justify-between gap-2">- <div class="text-muted-foreground flex-1 text-xs">+ <div class="flex-1 text-xs">{#if template.metadata?.version}<Badge variant="outline" class="text-xs">v{template.metadata.version}@@ -206,7 +215,12 @@{/if}</div><div class="flex gap-2">- <Button variant="outline" size="sm" onclick={() => handleDownload(template)} disabled={loadingStates.get(`download-${template.id}`)}>+ <Button+ variant="outline"+ size="sm"+ onclick={() => handleDownload(template)}+ disabled={loadingStates.get(`download-${template.id}`)}+ >{#if loadingStates.get(`download-${template.id}`)}<Loader2 class="mr-1 size-3 animate-spin" />Downloading...@@ -215,7 +229,11 @@Download{/if}</Button>- <Button size="sm" onclick={() => handleSelect(template)} disabled={loadingStates.get(template.id)}>+ <Button+ size="sm"+ onclick={() => handleSelect(template)}+ disabled={loadingStates.get(template.id)}+ >{#if loadingStates.get(template.id)}<Loader2 class="mr-1 size-3 animate-spin" />Loading...diff --git a/frontend/src/lib/services/api/template-api-service.ts b/frontend/src/lib/services/api/template-api-service.tsindex bb95f08cf..fba2647c9 100644--- a/frontend/src/lib/services/api/template-api-service.ts+++ b/frontend/src/lib/services/api/template-api-service.ts@@ -17,7 +17,8 @@ export default class TemplateAPIService extends BaseAPIService {envContent: string;template: Template;}> {- const response = await this.api.get(`/templates/${id}/content`);+ const encodedId = encodeURIComponent(id);+ const response = await this.api.get(`/templates/${encodedId}/content`);return {content: response.data.content,envContent: response.data.envContent,@@ -25,7 +26,12 @@ export default class TemplateAPIService extends BaseAPIService {};}- async create(template: { name: string; description: string; content: string; envContent?: string }): Promise<Template> {+ async create(template: {+ name: string;+ description: string;+ content: string;+ envContent?: string;+ }): Promise<Template> {const response = await this.api.post('/templates', template);return response.data.template;}@@ -65,7 +71,12 @@ export default class TemplateAPIService extends BaseAPIService {return response.data.registries;}- async addRegistry(registry: { name: string; url: string; description?: string; enabled: boolean }): Promise<TemplateRegistry> {+ async addRegistry(registry: {+ name: string;+ url: string;+ description?: string;+ enabled: boolean;+ }): Promise<TemplateRegistry> {const response = await this.api.post('/templates/registries', registry);return response.data.registry;}@@ -102,7 +113,11 @@ export default class TemplateAPIService extends BaseAPIService {async search(query: string, category?: string): Promise<Template[]> {const templates = await this.loadAll();- return templates.filter((template) => template.name.toLowerCase().includes(query.toLowerCase()) || template.description.toLowerCase().includes(query.toLowerCase()));+ return templates.filter(+ (template) =>+ template.name.toLowerCase().includes(query.toLowerCase()) ||+ template.description.toLowerCase().includes(query.toLowerCase())+ );}async getCategories(): Promise<string[]> {@@ -110,7 +125,9 @@ export default class TemplateAPIService extends BaseAPIService {const categories = new Set<string>();templates.forEach((template) => {if (template.metadata?.tags) {- const tags = Array.isArray(template.metadata.tags) ? template.metadata.tags : JSON.parse(template.metadata.tags || '[]');+ const tags = Array.isArray(template.metadata.tags)+ ? template.metadata.tags+ : JSON.parse(template.metadata.tags || '[]');tags.forEach((tag: string) => categories.add(tag));}});diff --git a/frontend/src/routes/compose/+page.svelte b/frontend/src/routes/compose/+page.svelteindex 14055c229..b44755f15 100644--- a/frontend/src/routes/compose/+page.svelte+++ b/frontend/src/routes/compose/+page.svelte@@ -12,7 +12,8 @@StopCircle,Trash2,Ellipsis,- Pen+ Pen,+ PlayCircle} from '@lucide/svelte';import UniversalTable from '$lib/components/universal-table.svelte';import { openConfirmDialog } from '$lib/components/confirm-dialog';@@ -33,6 +34,7 @@import { autoUpdateAPI, environmentAPI } from '$lib/services/api';import { onMount } from 'svelte';import type { Stack } from '$lib/models/stack.type';+ import StatCard from '$lib/components/stat-card.svelte';let { data }: { data: PageData } = $props();@@ -215,41 +217,27 @@</Card.Root>{:else}<div class="grid grid-cols-1 gap-4 sm:grid-cols-3">- <Card.Root>- <Card.Content class="flex items-center justify-between p-4">- <div>- <p class="text-muted-foreground text-sm font-medium">Total Compose Projects</p>- <p class="text-2xl font-bold">{totalStacks}</p>- </div>- <div class="bg-primary/10 rounded-full p-2">- <FileStack class="text-primary size-5" />- </div>- </Card.Content>- </Card.Root>-- <Card.Root>- <Card.Content class="flex items-center justify-between p-4">- <div>- <p class="text-muted-foreground text-sm font-medium">Running</p>- <p class="text-2xl font-bold">{runningStacks}</p>- </div>- <div class="rounded-full bg-green-500/10 p-2">- <Layers class="size-5 text-green-500" />- </div>- </Card.Content>- </Card.Root>-- <Card.Root>- <Card.Content class="flex items-center justify-between p-4">- <div>- <p class="text-muted-foreground text-sm font-medium">Stopped</p>- <p class="text-2xl font-bold">{stoppedStacks}</p>- </div>- <div class="rounded-full bg-gray-500/10 p-2">- <Layers class="size-5 text-gray-500" />- </div>- </Card.Content>- </Card.Root>+ <StatCard+ title="Total Compose Projects"+ value={totalStacks}+ icon={FileStack}+ iconColor="text-amber-500"+ class="border-l-4 border-l-amber-500"+ />+ <StatCard+ title="Running"+ value={runningStacks}+ icon={PlayCircle}+ iconColor="text-green-500"+ class="border-l-4 border-l-green-500"+ />+ <StatCard+ title="Stopped"+ value={stoppedStacks}+ icon={StopCircle}+ iconColor="text-red-500"+ class="border-l-4 border-l-red-500"+ /></div><Card.Root class="border shadow-sm">diff --git a/frontend/src/routes/compose/new/+page.svelte b/frontend/src/routes/compose/new/+page.svelteindex 482a094c5..ff3f2a374 100644--- a/frontend/src/routes/compose/new/+page.svelte+++ b/frontend/src/routes/compose/new/+page.svelte@@ -18,7 +18,7 @@import DropdownCard from '$lib/components/dropdown-card.svelte';import * as Resizable from '$lib/components/ui/resizable/index.js';import TemplateSelectionDialog from '$lib/components/dialogs/template-selection-dialog.svelte';- import { environmentAPI, converterAPI } from '$lib/services/api';+ import { environmentAPI, converterAPI, templateAPI } from '$lib/services/api';import type { Template } from '$lib/types/template.type';import type { PageProps } from './+page';@@ -27,6 +27,7 @@let saving = $state(false);let converting = $state(false);let showTemplateDialog = $state(false);+ let isLoadingTemplateContent = $state(false);let name = $state('');let composeContent = $state(data.defaultTemplate || defaultComposeTemplate);@@ -71,18 +72,42 @@});}- function handleTemplateSelect(template: Template) {- composeContent = template.content;+ async function handleTemplateSelect(template: Template) {+ showTemplateDialog = false; // Close the dialog immediately- if (template.envContent) {- envContent = template.envContent;- }+ if (template.isRemote) {+ isLoadingTemplateContent = true;+ handleApiResultWithCallbacks({+ result: await tryCatch(templateAPI.getTemplateContent(template.id)),+ message: `Failed to load content for template "${template.name}"`,+ setLoadingState: (value) => (isLoadingTemplateContent = value),+ onSuccess: (data) => {+ composeContent = data.content;+ envContent = data.envContent;+ if (!name.trim()) {+ name = template.name.toLowerCase().replace(/[^a-z0-9-]/g, '-');+ }+ toast.success(`Template "${template.name}" loaded successfully!`);+ },+ onError: () => {+ // Re-open dialog or show error state if fetching fails+ showTemplateDialog = true;+ }+ });+ } else {+ // Handle local templates which should have content already+ composeContent = template.content;+ if (template.envContent) {+ envContent = template.envContent;+ } else {+ envContent = defaultEnvTemplate;+ }- if (!name.trim()) {- name = template.name.toLowerCase().replace(/[^a-z0-9-]/g, '-');+ if (!name.trim()) {+ name = template.name.toLowerCase().replace(/[^a-z0-9-]/g, '-');+ }+ toast.success(`Template "${template.name}" loaded successfully!`);}-- toast.success(`Template "${template.name}" loaded successfully!`);}const exampleCommands = [@@ -120,15 +145,32 @@</div><!-- Docker Run to Compose Converter -->- <DropdownCard id="docker-run-converter" title="Docker Run to Compose Converter" description="Convert existing docker run commands to Docker Compose format" icon={Terminal}>+ <DropdownCard+ id="docker-run-converter"+ title="Docker Run to Compose Converter"+ description="Convert existing docker run commands to Docker Compose format"+ icon={Terminal}+ ><div class="space-y-4"><div class="space-y-2"><Label for="dockerRunCommand">Docker Run Command</Label>- <Textarea id="dockerRunCommand" bind:value={dockerRunCommand} placeholder="docker run -d --name my-app -p 8080:80 nginx:alpine" rows={3} disabled={converting} class="font-mono text-sm" />+ <Textarea+ id="dockerRunCommand"+ bind:value={dockerRunCommand}+ placeholder="docker run -d --name my-app -p 8080:80 nginx:alpine"+ rows={3}+ disabled={converting}+ class="font-mono text-sm"+ /></div><div class="flex items-center gap-2">- <Button type="button" disabled={!dockerRunCommand.trim() || converting} size="sm" onclick={handleConvertDockerRun}>+ <Button+ type="button"+ disabled={!dockerRunCommand.trim() || converting}+ size="sm"+ onclick={handleConvertDockerRun}+ >{#if converting}<Loader2 class="mr-2 size-4 animate-spin" />Converting...@@ -143,7 +185,13 @@<Label class="text-muted-foreground text-xs">Example Commands:</Label><div class="space-y-1">{#each exampleCommands as command}- <Button type="button" variant="ghost" size="sm" class="h-auto w-full justify-start p-2 text-left font-mono text-xs" onclick={() => useExample(command)}>+ <Button+ type="button"+ variant="ghost"+ size="sm"+ class="h-auto w-full justify-start p-2 text-left font-mono text-xs"+ onclick={() => useExample(command)}+ ><Copy class="mr-2 size-3" />{command}</Button>@@ -163,12 +211,28 @@</div><div><Card.Title>Compose Project Configuration</Card.Title>- <Card.Description>Create a new Docker Compose Project with environment variables</Card.Description>+ <Card.Description+ >Create a new Docker Compose Project with environment variables</Card.Description+ ></div></div><div class="flex items-center gap-2">- <ArcaneButton action="template" onClick={() => (showTemplateDialog = true)} loading={saving} disabled={saving || converting} />- <ArcaneButton action="create" onClick={handleSubmit} loading={saving} disabled={!name || !composeContent} />+ <ArcaneButton+ action="template"+ onClick={() => (showTemplateDialog = true)}+ loading={saving || isLoadingTemplateContent}+ disabled={saving || converting || isLoadingTemplateContent}+ />+ <ArcaneButton+ action="create"+ onClick={handleSubmit}+ loading={saving}+ disabled={!name ||+ !composeContent ||+ saving ||+ converting ||+ isLoadingTemplateContent}+ /></div></div></Card.Header>@@ -176,7 +240,15 @@<div class="space-y-4"><div class="grid w-full max-w-sm items-center gap-1.5"><Label for="name">Compose Project Name</Label>- <Input type="text" id="name" name="name" bind:value={name} required placeholder="e.g., my-web-app" disabled={saving} />+ <Input+ type="text"+ id="name"+ name="name"+ bind:value={name}+ required+ placeholder="e.g., my-web-app"+ disabled={saving || isLoadingTemplateContent}+ /></div><Resizable.PaneGroup direction="horizontal">@@ -184,7 +256,10 @@<div class="mr-3 space-y-2"><Label for="compose-editor" class="mb-2">Docker Compose File</Label><div class="mt-2 h-[550px] overflow-hidden rounded-md border">- <YamlEditor bind:value={composeContent} readOnly={saving} />+ <YamlEditor+ bind:value={composeContent}+ readOnly={saving || isLoadingTemplateContent}+ /></div></div></Resizable.Pane>@@ -195,7 +270,10 @@<div class="mt-2 h-[550px] overflow-hidden rounded-md border"><!-- Add a unique key to force re-render -->{#key `env-${envContent.length}`}- <EnvEditor bind:value={envContent} readOnly={saving} />+ <EnvEditor+ bind:value={envContent}+ readOnly={saving || isLoadingTemplateContent}+ />{/key}</div></div>@@ -204,7 +282,12 @@</div></Card.Content><Card.Footer class="flex justify-between">- <Button variant="outline" type="button" onclick={() => window.history.back()} disabled={saving}>+ <Button+ variant="outline"+ type="button"+ onclick={() => window.history.back()}+ disabled={saving || isLoadingTemplateContent}+ ><ArrowLeft class="mr-2 size-4" />Cancel</Button>@@ -214,4 +297,8 @@</div><!-- Template Selection Dialog -->-<TemplateSelectionDialog bind:open={showTemplateDialog} templates={data.composeTemplates || []} onSelect={handleTemplateSelect} />+<TemplateSelectionDialog+ bind:open={showTemplateDialog}+ templates={data.composeTemplates || []}+ onSelect={handleTemplateSelect}+/>diff --git a/frontend/src/routes/images/+page.svelte b/frontend/src/routes/images/+page.svelteindex 67887d062..24da51189 100644--- a/frontend/src/routes/images/+page.svelte+++ b/frontend/src/routes/images/+page.svelte@@ -12,7 +12,8 @@ChevronDown,Ellipsis,ScanSearch,- Funnel+ Funnel,+ Package} from '@lucide/svelte';import * as Alert from '$lib/components/ui/alert/index.js';import * as Card from '$lib/components/ui/card/index.js';@@ -38,6 +39,7 @@} from '$lib/stores/maturity-store';import { environmentAPI } from '$lib/services/api';import { onMount } from 'svelte';+ import StatCard from '$lib/components/stat-card.svelte';let { data }: { data: PageData } = $props();@@ -271,29 +273,20 @@</Card.Root>{:else}<div class="grid grid-cols-1 gap-4 sm:grid-cols-2">- <Card.Root>- <Card.Content class="flex items-center justify-between p-4">- <div>- <p class="text-muted-foreground text-sm font-medium">Total Images</p>- <p class="text-2xl font-bold">{totalImages}</p>- </div>- <div class="rounded-full bg-blue-500/10 p-2">- <HardDrive class="size-5 text-blue-500" />- </div>- </Card.Content>- </Card.Root>-- <Card.Root>- <Card.Content class="flex items-center justify-between p-4">- <div>- <p class="text-muted-foreground text-sm font-medium">Total Size</p>- <p class="text-2xl font-bold">{formatBytes(totalSize)}</p>- </div>- <div class="rounded-full bg-purple-500/10 p-2">- <HardDrive class="size-5 text-purple-500" />- </div>- </Card.Content>- </Card.Root>+ <StatCard+ title="Total Images"+ value={totalImages}+ icon={HardDrive}+ iconColor="text-blue-500"+ class="border-l-4 border-l-blue-500"+ />+ <StatCard+ title="Total Size"+ value={formatBytes(totalSize)}+ icon={Package}+ iconColor="text-amber-500"+ class="border-l-4 border-l-amber-500"+ /></div>{#if filteredImages.length > 0}diff --git a/frontend/src/routes/networks/+page.svelte b/frontend/src/routes/networks/+page.svelteindex 16275d8ce..99a92bea8 100644--- a/frontend/src/routes/networks/+page.svelte+++ b/frontend/src/routes/networks/+page.svelte@@ -1,5 +1,13 @@<script lang="ts">- import { Trash2, Plus, Network, Ellipsis, ScanSearch, Loader2 } from '@lucide/svelte';+ import {+ Trash2,+ Plus,+ Network,+ Ellipsis,+ ScanSearch,+ Loader2,+ EthernetPort+ } from '@lucide/svelte';import { Button } from '$lib/components/ui/button/index.js';import * as Card from '$lib/components/ui/card/index.js';import * as Alert from '$lib/components/ui/alert/index.js';@@ -19,6 +27,7 @@import ArcaneButton from '$lib/components/arcane-button.svelte';import { tablePersistence } from '$lib/stores/table-store';import { onMount } from 'svelte';+ import StatCard from '$lib/components/stat-card.svelte';let { data }: { data: PageData } = $props();@@ -172,6 +181,7 @@<ArcaneButtonaction="restart"onClick={refreshNetworks}+ label="Refresh"loading={isLoading.refresh}disabled={isLoading.refresh}/>@@ -218,42 +228,21 @@</Card.Content></Card.Root>{:else}- <div class="grid grid-cols-1 gap-4 sm:grid-cols-3">- <Card.Root>- <Card.Content class="flex items-center justify-between p-4">- <div>- <p class="text-muted-foreground text-sm font-medium">Total Networks</p>- <p class="text-2xl font-bold">{totalNetworks}</p>- </div>- <div class="rounded-full bg-blue-500/10 p-2">- <Network class="size-5 text-blue-500" />- </div>- </Card.Content>- </Card.Root>-- <Card.Root>- <Card.Content class="flex items-center justify-between p-4">- <div>- <p class="text-muted-foreground text-sm font-medium">Bridge Networks</p>- <p class="text-2xl font-bold">{bridgeNetworks}</p>- </div>- <div class="rounded-full bg-green-500/10 p-2">- <Network class="size-5 text-green-500" />- </div>- </Card.Content>- </Card.Root>-- <Card.Root>- <Card.Content class="flex items-center justify-between p-4">- <div>- <p class="text-muted-foreground text-sm font-medium">Overlay Networks</p>- <p class="text-2xl font-bold">{overlayNetworks}</p>- </div>- <div class="rounded-full bg-purple-500/10 p-2">- <Network class="size-5 text-purple-500" />- </div>- </Card.Content>- </Card.Root>+ <div class="grid grid-cols-1 gap-4 sm:grid-cols-2">+ <StatCard+ title="Total Networks"+ value={totalNetworks}+ icon={Network}+ iconColor="text-blue-500"+ class="border-l-4 border-l-blue-500"+ />+ <StatCard+ title="Bridge Networks"+ value={bridgeNetworks}+ icon={EthernetPort}+ iconColor="text-green-500"+ class="border-l-4 border-l-green-500"+ /></div>{#if networks && networks.length > 0}diff --git a/frontend/src/routes/volumes/+page.svelte b/frontend/src/routes/volumes/+page.svelteindex e993018d3..0e77b678c 100644--- a/frontend/src/routes/volumes/+page.svelte+++ b/frontend/src/routes/volumes/+page.svelte@@ -1,5 +1,14 @@<script lang="ts">- import { Trash2, HardDrive, Ellipsis, ScanSearch, Loader2, ChevronDown } from '@lucide/svelte';+ import {+ Trash2,+ HardDrive,+ Ellipsis,+ ScanSearch,+ Loader2,+ ChevronDown,+ ArchiveRestore,+ ArchiveX+ } from '@lucide/svelte';import { Button } from '$lib/components/ui/button/index.js';import * as Card from '$lib/components/ui/card/index.js';import * as Alert from '$lib/components/ui/alert/index.js';@@ -8,7 +17,6 @@import { toast } from 'svelte-sonner';import { goto } from '$app/navigation';import { openConfirmDialog } from '$lib/components/confirm-dialog';- import type { PageData } from './$types';import UniversalTable from '$lib/components/universal-table.svelte';import { handleApiResultWithCallbacks } from '$lib/utils/api.util';import { tryCatch } from '$lib/utils/try-catch';@@ -20,8 +28,7 @@import { tablePersistence } from '$lib/stores/table-store';import { environmentAPI } from '$lib/services/api';import { onMount } from 'svelte';-- let { data }: { data: PageData } = $props();+ import StatCard from '$lib/components/stat-card.svelte';let volumes = $state<EnhancedVolumeInfo[]>([]);let error = $state<string | null>(null);@@ -61,7 +68,7 @@async function loadVolumes() {try {- isLoadingVolumes = true;+ isLoading.refresh = true;const response = await environmentAPI.getVolumes();volumes = response || [];error = null;@@ -70,6 +77,7 @@error = err instanceof Error ? err.message : 'Failed to load volumes';volumes = [];} finally {+ isLoading.refresh = false;isLoadingVolumes = false;}}@@ -100,6 +108,7 @@label: 'Remove',destructive: true,action: async () => {+ isLoading.remove = true;handleApiResultWithCallbacks({result: await tryCatch(environmentAPI.deleteVolume(name)),message: `Failed to Remove Volume "${name}"`,@@ -218,175 +227,173 @@</Card.Content></Card.Root>{:else}- <div class="grid grid-cols-1 gap-4 sm:grid-cols-2">- <Card.Root>- <Card.Content class="flex items-center justify-between p-4">- <div>- <p class="text-muted-foreground text-sm font-medium">Total Volumes</p>- <p class="text-2xl font-bold">{totalVolumes}</p>- </div>- <div class="rounded-full bg-blue-500/10 p-2">- <HardDrive class="size-5 text-blue-500" />- </div>- </Card.Content>- </Card.Root>+ <div class="grid grid-cols-1 gap-4 sm:grid-cols-3">+ <StatCard+ title="Total Volumes"+ value={totalVolumes}+ icon={HardDrive}+ iconColor="text-blue-500"+ class="border-l-4 border-l-blue-500"+ />+ <StatCard+ title="Used Volumes"+ value={usedVolumes}+ icon={ArchiveRestore}+ iconColor="text-green-500"+ class="border-l-4 border-l-green-500"+ />+ <StatCard+ title="Unused Volumes"+ value={unusedVolumes}+ icon={ArchiveX}+ iconColor="text-red-500"+ class="border-l-4 border-l-red-500"+ />+ </div>+ {/if}- <Card.Root>- <Card.Content class="flex items-center justify-between p-4">+ {#if filteredVolumes.length > 0}+ <Card.Root class="border shadow-sm">+ <Card.Header class="px-6">+ <div class="flex items-center justify-between"><div>- <p class="text-muted-foreground text-sm font-medium">Used Volumes</p>- <p class="text-2xl font-bold">{usedVolumes}</p>+ <Card.Title>Volumes List</Card.Title></div>- <div class="rounded-full bg-green-500/10 p-2">- <HardDrive class="size-5 text-green-500" />+ <div class="flex items-center gap-2">+ <DropdownMenu.Root>+ <DropdownMenu.Trigger>+ {#snippet child({ props })}+ <Button {...props} variant="outline" size="sm">+ Filter <ChevronDown class="ml-2 size-4" />+ </Button>+ {/snippet}+ </DropdownMenu.Trigger>+ <DropdownMenu.Content>+ <DropdownMenu.Label>Volume Usage</DropdownMenu.Label>+ <DropdownMenu.CheckboxItem+ checked={volumeFilters.showUsed}+ onCheckedChange={(checked) => {+ volumeFilters.showUsed = checked;+ }}+ >+ Show Used Volumes+ </DropdownMenu.CheckboxItem>+ <DropdownMenu.CheckboxItem+ checked={volumeFilters.showUnused}+ onCheckedChange={(checked) => {+ volumeFilters.showUnused = checked;+ }}+ >+ Show Unused Volumes+ </DropdownMenu.CheckboxItem>+ </DropdownMenu.Content>+ </DropdownMenu.Root>+ {#if selectedIds.length > 0}+ <ArcaneButton+ action="remove"+ onClick={handleDeleteSelected}+ loading={isLoading.remove}+ disabled={isLoading.remove}+ />+ {/if}+ <ArcaneButton+ action="create"+ label="Create Volume"+ onClick={() => (isDialogOpen.create = true)}+ loading={isLoading.creating}+ disabled={isLoading.creating}+ /></div>- </Card.Content>- </Card.Root>- </div>-- {#if filteredVolumes.length > 0}- <Card.Root class="border shadow-sm">- <Card.Header class="px-6">- <div class="flex items-center justify-between">- <div>- <Card.Title>Volumes List</Card.Title>- </div>- <div class="flex items-center gap-2">+ </div>+ </Card.Header>+ <Card.Content>+ <UniversalTable+ data={filteredVolumes}+ columns={[+ { accessorKey: 'Name', header: 'Name' },+ { accessorKey: 'inUse', header: 'Status' },+ { accessorKey: 'Driver', header: 'Driver' },+ { accessorKey: 'CreatedAt', header: 'Created' },+ { accessorKey: 'actions', header: ' ', enableSorting: false }+ ]}+ pagination={{+ pageSize: tablePersistence.getPageSize('volumes')+ }}+ onPageSizeChange={(newSize) => {+ tablePersistence.setPageSize('volumes', newSize);+ }}+ sort={{+ defaultSort: { id: 'Name', desc: false }+ }}+ bind:selectedIds+ >+ {#snippet rows({ item })}+ <Table.Cell>+ <a class="font-medium hover:underline" href="/volumes/{item.Name}/">{item.Name}</a>+ </Table.Cell>+ <Table.Cell>+ {#if item.inUse}+ <StatusBadge text="In Use" variant="green" />+ {:else}+ <StatusBadge text="Unused" variant="amber" />+ {/if}+ </Table.Cell>+ <Table.Cell>{item.Driver}</Table.Cell>+ <Table.Cell>{formatFriendlyDate(item.CreatedAt)}</Table.Cell>+ <Table.Cell><DropdownMenu.Root><DropdownMenu.Trigger>{#snippet child({ props })}- <Button {...props} variant="outline" size="sm">- Filter <ChevronDown class="ml-2 size-4" />+ <Button {...props} variant="ghost" size="icon" class="relative size-8 p-0">+ <span class="sr-only">Open menu</span>+ <Ellipsis /></Button>{/snippet}</DropdownMenu.Trigger>- <DropdownMenu.Content>- <DropdownMenu.Label>Volume Usage</DropdownMenu.Label>- <DropdownMenu.CheckboxItem- checked={volumeFilters.showUsed}- onCheckedChange={(checked) => {- volumeFilters.showUsed = checked;- }}- >- Show Used Volumes- </DropdownMenu.CheckboxItem>- <DropdownMenu.CheckboxItem- checked={volumeFilters.showUnused}- onCheckedChange={(checked) => {- volumeFilters.showUnused = checked;- }}- >- Show Unused Volumes- </DropdownMenu.CheckboxItem>+ <DropdownMenu.Content align="end">+ <DropdownMenu.Group>+ <DropdownMenu.Item onclick={() => goto(`/volumes/${item.Name}`)}>+ <ScanSearch class="size-4" />+ Inspect+ </DropdownMenu.Item>+ <DropdownMenu.Item+ class="focus:text-red-700! text-red-500"+ onclick={() => handleRemoveVolumeConfirm(item.Name)}+ >+ <Trash2 class="size-4" />+ Remove+ </DropdownMenu.Item>+ </DropdownMenu.Group></DropdownMenu.Content></DropdownMenu.Root>- {#if selectedIds.length > 0}- <ArcaneButton- action="remove"- onClick={handleDeleteSelected}- loading={isLoading.remove}- disabled={isLoading.remove}- />- {/if}- <ArcaneButton- action="create"- label="Create Volume"- onClick={() => (isDialogOpen.create = true)}- loading={isLoading.creating}- disabled={isLoading.creating}- />- </div>- </div>- </Card.Header>- <Card.Content>- <UniversalTable- data={filteredVolumes}- columns={[- { accessorKey: 'Name', header: 'Name' },- { accessorKey: 'inUse', header: 'Status' },- { accessorKey: 'Driver', header: 'Driver' },- { accessorKey: 'CreatedAt', header: 'Created' },- { accessorKey: 'actions', header: ' ', enableSorting: false }- ]}- pagination={{- pageSize: tablePersistence.getPageSize('volumes')- }}- onPageSizeChange={(newSize) => {- tablePersistence.setPageSize('volumes', newSize);- }}- sort={{- defaultSort: { id: 'Name', desc: false }- }}- bind:selectedIds- >- {#snippet rows({ item })}- <Table.Cell>- <a class="font-medium hover:underline" href="/volumes/{item.Name}/">{item.Name}</a>- </Table.Cell>- <Table.Cell>- {#if item.inUse}- <StatusBadge text="In Use" variant="green" />- {:else}- <StatusBadge text="Unused" variant="amber" />- {/if}- </Table.Cell>- <Table.Cell>{item.Driver}</Table.Cell>- <Table.Cell>{formatFriendlyDate(item.CreatedAt)}</Table.Cell>- <Table.Cell>- <DropdownMenu.Root>- <DropdownMenu.Trigger>- {#snippet child({ props })}- <Button {...props} variant="ghost" size="icon" class="relative size-8 p-0">- <span class="sr-only">Open menu</span>- <Ellipsis />- </Button>- {/snippet}- </DropdownMenu.Trigger>- <DropdownMenu.Content align="end">- <DropdownMenu.Group>- <DropdownMenu.Item onclick={() => goto(`/volumes/${item.Name}`)}>- <ScanSearch class="size-4" />- Inspect- </DropdownMenu.Item>- <DropdownMenu.Item- class="focus:text-red-700! text-red-500"- onclick={() => handleRemoveVolumeConfirm(item.Name)}- >- <Trash2 class="size-4" />- Remove- </DropdownMenu.Item>- </DropdownMenu.Group>- </DropdownMenu.Content>- </DropdownMenu.Root>- </Table.Cell>- {/snippet}- </UniversalTable>- </Card.Content>- </Card.Root>- {:else if !error}- <div- class="bg-card flex flex-col items-center justify-center rounded-lg border px-6 py-12 text-center"- >- <HardDrive class="text-muted-foreground mb-4 size-12 opacity-40" />- <p class="text-lg font-medium">No volumes found</p>- <p class="text-muted-foreground mt-1 max-w-md text-sm">- Create a new volume using the "Create Volume" button above- </p>- <div class="mt-4 flex gap-3">- <ArcaneButton- action="create"- label="Create Volume"- onClick={() => (isDialogOpen.create = true)}- size="sm"- />- </div>+ </Table.Cell>+ {/snippet}+ </UniversalTable>+ </Card.Content>+ </Card.Root>+ {:else if !error}+ <div+ class="bg-card flex flex-col items-center justify-center rounded-lg border px-6 py-12 text-center"+ >+ <HardDrive class="text-muted-foreground mb-4 size-12 opacity-40" />+ <p class="text-lg font-medium">No volumes found</p>+ <p class="text-muted-foreground mt-1 max-w-md text-sm">+ Create a new volume using the "Create Volume" button above+ </p>+ <div class="mt-4 flex gap-3">+ <ArcaneButton+ action="create"+ label="Create Volume"+ onClick={() => (isDialogOpen.create = true)}+ size="sm"+ /></div>- {/if}-- <CreateVolumeSheet- bind:open={isDialogOpen.create}- isLoading={isLoading.creating}- onSubmit={handleCreateVolumeSubmit}- />+ </div>{/if}++ <CreateVolumeSheet+ bind:open={isDialogOpen.create}+ isLoading={isLoading.creating}+ onSubmit={handleCreateVolumeSubmit}+ /></div>