feat: Add canvas gallery with soft delete, snapshots and components
Replace the empty dynamic canvas placeholder with a gallery showing saved canvases, snapshots and Vue components. Users can create new canvases, restore snapshots, load components, and manage canvas toolbar/archive settings from the gallery. - Backend: soft delete (archive) instead of hard delete, status column - Frontend: CanvasGallery component with grid, search, settings popover - Show canvas name in global header when viewing a project canvas - Remove ProjectsPage (replaced by gallery), clean all references - MCP tools: project category available on canvas page, update handlers
This commit is contained in:
@@ -14,6 +14,7 @@ import { initToolRegistry, activatePageTools, initToolsOnRefresh } from './servi
|
|||||||
import { setTerminalControls } from './services/tools/handlers/terminalHandlers'
|
import { setTerminalControls } from './services/tools/handlers/terminalHandlers'
|
||||||
import { setResponseControls } from './services/tools/handlers/responseHandlers'
|
import { setResponseControls } from './services/tools/handlers/responseHandlers'
|
||||||
import { useCanvasStore } from './stores/canvas'
|
import { useCanvasStore } from './stores/canvas'
|
||||||
|
import { useProjectCanvasStore } from './stores/projectCanvas'
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
@@ -63,6 +64,7 @@ const terminalRef = ref<InstanceType<typeof FloatingTerminal> | null>(null)
|
|||||||
const responseRef = ref<InstanceType<typeof FloatingResponse> | null>(null)
|
const responseRef = ref<InstanceType<typeof FloatingResponse> | null>(null)
|
||||||
const voiceRef = ref<InstanceType<typeof FloatingVoice> | null>(null)
|
const voiceRef = ref<InstanceType<typeof FloatingVoice> | null>(null)
|
||||||
const canvasStore = useCanvasStore()
|
const canvasStore = useCanvasStore()
|
||||||
|
const projectCanvasStore = useProjectCanvasStore()
|
||||||
|
|
||||||
// Voice FAB push-to-talk state
|
// Voice FAB push-to-talk state
|
||||||
const voicePTTActive = ref(false)
|
const voicePTTActive = ref(false)
|
||||||
@@ -238,7 +240,7 @@ function triggerToolFlash() {
|
|||||||
}, 500)
|
}, 500)
|
||||||
}
|
}
|
||||||
|
|
||||||
type PageName = 'home' | 'canvas' | 'components' | 'themes' | 'projects' | 'project-canvas' | 'database' | 'source' | 'terminal' | 'tools'
|
type PageName = 'home' | 'canvas' | 'components' | 'themes' | 'project-canvas' | 'database' | 'source' | 'terminal' | 'tools'
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
// Connect to WebSocket for Claude status updates
|
// Connect to WebSocket for Claude status updates
|
||||||
@@ -350,6 +352,11 @@ watch(() => route.name, (newPage) => {
|
|||||||
<header class="app-header">
|
<header class="app-header">
|
||||||
<div class="header-left">
|
<div class="header-left">
|
||||||
<h1 class="logo">Agent UI</h1>
|
<h1 class="logo">Agent UI</h1>
|
||||||
|
<template v-if="projectCanvasStore.activeCanvas && route.name === 'project-canvas'">
|
||||||
|
<span class="header-sep">/</span>
|
||||||
|
<span class="header-canvas-name">{{ projectCanvasStore.activeCanvas.name }}</span>
|
||||||
|
<span v-if="projectCanvasStore.activeCanvas.is_system" class="header-canvas-badge">Sistema</span>
|
||||||
|
</template>
|
||||||
<button class="debug-btn" :class="{ active: showDebugConsole }" @click="showDebugConsole = !showDebugConsole" title="Debug Console">
|
<button class="debug-btn" :class="{ active: showDebugConsole }" @click="showDebugConsole = !showDebugConsole" title="Debug Console">
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||||
<path d="M12 20h9"/><path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"/>
|
<path d="M12 20h9"/><path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"/>
|
||||||
@@ -561,6 +568,27 @@ watch(() => route.name, (newPage) => {
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.header-sep {
|
||||||
|
color: var(--text-muted);
|
||||||
|
font-size: 1.1rem;
|
||||||
|
opacity: 0.4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-canvas-name {
|
||||||
|
font-size: 0.9rem;
|
||||||
|
font-weight: 500;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-canvas-badge {
|
||||||
|
padding: 0.125rem 0.5rem;
|
||||||
|
background: rgba(99, 102, 241, 0.15);
|
||||||
|
color: #6366f1;
|
||||||
|
font-size: 0.6875rem;
|
||||||
|
font-weight: 500;
|
||||||
|
border-radius: 999px;
|
||||||
|
}
|
||||||
|
|
||||||
.refresh-btn {
|
.refresh-btn {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted, onUnmounted } from 'vue'
|
import { ref, onMounted, onUnmounted } from 'vue'
|
||||||
import { renderInlineComponent, type VueComponentDefinition } from '../services/dynamicComponents'
|
import { renderInlineComponent, type VueComponentDefinition } from '../services/dynamicComponents'
|
||||||
import { useCanvasStore } from '../stores/canvas'
|
import { useCanvasStore } from '../stores/canvas'
|
||||||
|
import CanvasGallery from './CanvasGallery.vue'
|
||||||
|
|
||||||
const canvasStore = useCanvasStore()
|
const canvasStore = useCanvasStore()
|
||||||
|
const showGallery = ref(true)
|
||||||
|
|
||||||
function handleLoadComponent(e: Event) {
|
function handleLoadComponent(e: Event) {
|
||||||
const detail = (e as CustomEvent).detail
|
const detail = (e as CustomEvent).detail
|
||||||
@@ -12,6 +14,9 @@ function handleLoadComponent(e: Event) {
|
|||||||
const container = document.getElementById('canvas-content')
|
const container = document.getElementById('canvas-content')
|
||||||
if (!container) return
|
if (!container) return
|
||||||
|
|
||||||
|
// Hide gallery when MCP renders content
|
||||||
|
showGallery.value = false
|
||||||
|
|
||||||
const placeholder = container.querySelector('.canvas-placeholder')
|
const placeholder = container.querySelector('.canvas-placeholder')
|
||||||
if (placeholder) placeholder.remove()
|
if (placeholder) placeholder.remove()
|
||||||
|
|
||||||
@@ -32,26 +37,42 @@ function handleLoadComponent(e: Event) {
|
|||||||
canvasStore.addToHistory({ tool: 'load_vue_component', args: detail, timestamp: Date.now() })
|
canvasStore.addToHistory({ tool: 'load_vue_component', args: detail, timestamp: Date.now() })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleContentRendered() {
|
||||||
|
showGallery.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleClearCanvas() {
|
||||||
|
showGallery.value = true
|
||||||
|
const container = document.getElementById('canvas-content')
|
||||||
|
if (container) {
|
||||||
|
// Remove all non-gallery content
|
||||||
|
const children = Array.from(container.children)
|
||||||
|
for (const child of children) {
|
||||||
|
if (!(child as HTMLElement).classList?.contains('canvas-placeholder')) {
|
||||||
|
child.remove()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
window.addEventListener('load-vue-component', handleLoadComponent)
|
window.addEventListener('load-vue-component', handleLoadComponent)
|
||||||
|
window.addEventListener('clear-canvas', handleClearCanvas)
|
||||||
|
window.addEventListener('canvas-content-rendered', handleContentRendered)
|
||||||
})
|
})
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
window.removeEventListener('load-vue-component', handleLoadComponent)
|
window.removeEventListener('load-vue-component', handleLoadComponent)
|
||||||
|
window.removeEventListener('clear-canvas', handleClearCanvas)
|
||||||
|
window.removeEventListener('canvas-content-rendered', handleContentRendered)
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="canvas-container">
|
<div class="canvas-container">
|
||||||
<div id="canvas-content" class="canvas-content">
|
<div id="canvas-content" class="canvas-content">
|
||||||
<div class="canvas-placeholder">
|
<div v-if="showGallery" class="canvas-placeholder">
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
|
<CanvasGallery @snapshot-restored="showGallery = false" @component-loaded="showGallery = false" />
|
||||||
<rect x="3" y="3" width="18" height="18" rx="2"/>
|
|
||||||
<path d="M3 9h18"/>
|
|
||||||
<path d="M9 21V9"/>
|
|
||||||
</svg>
|
|
||||||
<p>Canvas listo</p>
|
|
||||||
<span>Haz clic en el cuadrado azul (abajo derecha) para conectar con Claude Code</span>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -75,28 +96,7 @@ onUnmounted(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.canvas-placeholder {
|
.canvas-placeholder {
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
height: 100%;
|
height: 100%;
|
||||||
min-height: 400px;
|
min-height: 400px;
|
||||||
color: var(--text-muted);
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.canvas-placeholder svg {
|
|
||||||
margin-bottom: 1rem;
|
|
||||||
opacity: 0.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
.canvas-placeholder p {
|
|
||||||
font-size: 1.25rem;
|
|
||||||
margin: 0 0 0.5rem 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.canvas-placeholder span {
|
|
||||||
font-size: 0.875rem;
|
|
||||||
opacity: 0.7;
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
944
frontend/src/components/CanvasGallery.vue
Normal file
944
frontend/src/components/CanvasGallery.vue
Normal file
@@ -0,0 +1,944 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { ref, computed, onMounted } from 'vue'
|
||||||
|
import { useRouter } from 'vue-router'
|
||||||
|
import { useProjectCanvasStore } from '../stores/projectCanvas'
|
||||||
|
import { useSnapshotsStore, type SnapshotSummary } from '../stores/snapshots'
|
||||||
|
import {
|
||||||
|
componentsApi,
|
||||||
|
renderInlineComponent,
|
||||||
|
type VueComponentDefinition
|
||||||
|
} from '../services/dynamicComponents'
|
||||||
|
import { getWindowDefinitions } from '../services/tools/handlers/canvasHandlers'
|
||||||
|
import { useCanvasStore } from '../stores/canvas'
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(e: 'snapshot-restored'): void
|
||||||
|
(e: 'component-loaded'): void
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const router = useRouter()
|
||||||
|
const store = useProjectCanvasStore()
|
||||||
|
const snapshotsStore = useSnapshotsStore()
|
||||||
|
|
||||||
|
const canvasStore = useCanvasStore()
|
||||||
|
|
||||||
|
const showArchived = ref(false)
|
||||||
|
const searchQuery = ref('')
|
||||||
|
const settingsOpenId = ref<string | null>(null)
|
||||||
|
const restoringSnapshot = ref<string | null>(null)
|
||||||
|
const showNewForm = ref(false)
|
||||||
|
const newName = ref('')
|
||||||
|
const creating = ref(false)
|
||||||
|
const savedComponents = ref<VueComponentDefinition[]>([])
|
||||||
|
const loadingComponent = ref<string | null>(null)
|
||||||
|
|
||||||
|
// Editable settings state
|
||||||
|
const editIcon = ref('')
|
||||||
|
const editOrder = ref(99)
|
||||||
|
|
||||||
|
const filteredCanvases = computed(() => {
|
||||||
|
const list = showArchived.value ? store.canvases : store.activeCanvasesList
|
||||||
|
if (!searchQuery.value) return list
|
||||||
|
const q = searchQuery.value.toLowerCase()
|
||||||
|
return list.filter(c =>
|
||||||
|
c.name.toLowerCase().includes(q) ||
|
||||||
|
(c.description && c.description.toLowerCase().includes(q))
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
const filteredSnapshots = computed(() => {
|
||||||
|
if (!searchQuery.value) return snapshotsStore.snapshots
|
||||||
|
const q = searchQuery.value.toLowerCase()
|
||||||
|
return snapshotsStore.snapshots.filter(s => s.name.toLowerCase().includes(q))
|
||||||
|
})
|
||||||
|
|
||||||
|
const filteredComponents = computed(() => {
|
||||||
|
if (!searchQuery.value) return savedComponents.value
|
||||||
|
const q = searchQuery.value.toLowerCase()
|
||||||
|
return savedComponents.value.filter(c => c.name.toLowerCase().includes(q) || c.id.toLowerCase().includes(q))
|
||||||
|
})
|
||||||
|
|
||||||
|
const totalItems = computed(() => store.canvases.length + snapshotsStore.snapshots.length + savedComponents.value.length)
|
||||||
|
const showSearch = computed(() => totalItems.value > 8)
|
||||||
|
|
||||||
|
function navigateToCanvas(id: string) {
|
||||||
|
router.push(`/canvas/${id}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function createNewCanvas() {
|
||||||
|
const name = newName.value.trim()
|
||||||
|
if (!name) return
|
||||||
|
creating.value = true
|
||||||
|
try {
|
||||||
|
const id = await store.createCanvas({ name, type: 'project' } as any)
|
||||||
|
if (id) {
|
||||||
|
newName.value = ''
|
||||||
|
showNewForm.value = false
|
||||||
|
router.push(`/canvas/${id}`)
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
creating.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadSnapshot(snap: SnapshotSummary) {
|
||||||
|
restoringSnapshot.value = snap.id
|
||||||
|
try {
|
||||||
|
await snapshotsStore.restore(snap.id)
|
||||||
|
emit('snapshot-restored')
|
||||||
|
} finally {
|
||||||
|
restoringSnapshot.value = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatDate(timestamp: number) {
|
||||||
|
return new Date(timestamp).toLocaleDateString(undefined, {
|
||||||
|
day: 'numeric', month: 'short', year: 'numeric',
|
||||||
|
hour: '2-digit', minute: '2-digit'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleSettings(id: string) {
|
||||||
|
if (settingsOpenId.value === id) {
|
||||||
|
settingsOpenId.value = null
|
||||||
|
} else {
|
||||||
|
settingsOpenId.value = id
|
||||||
|
const canvas = store.canvases.find(c => c.id === id)
|
||||||
|
if (canvas) {
|
||||||
|
editIcon.value = canvas.toolbar_icon || ''
|
||||||
|
editOrder.value = canvas.toolbar_order ?? 99
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function toggleToolbar(id: string, current: boolean) {
|
||||||
|
await store.updateCanvas(id, { show_in_toolbar: !current } as any)
|
||||||
|
await store.fetchToolbarCanvases()
|
||||||
|
}
|
||||||
|
|
||||||
|
async function updateIcon(id: string) {
|
||||||
|
await store.updateCanvas(id, { toolbar_icon: editIcon.value || null } as any)
|
||||||
|
await store.fetchToolbarCanvases()
|
||||||
|
}
|
||||||
|
|
||||||
|
async function updateOrder(id: string) {
|
||||||
|
await store.updateCanvas(id, { toolbar_order: editOrder.value } as any)
|
||||||
|
await store.fetchToolbarCanvases()
|
||||||
|
}
|
||||||
|
|
||||||
|
async function archiveCanvas(id: string) {
|
||||||
|
await store.deleteCanvas(id)
|
||||||
|
await store.fetchCanvases(showArchived.value)
|
||||||
|
await store.fetchToolbarCanvases()
|
||||||
|
settingsOpenId.value = null
|
||||||
|
}
|
||||||
|
|
||||||
|
async function restoreCanvas(id: string) {
|
||||||
|
await store.restoreCanvas(id)
|
||||||
|
await store.fetchCanvases(showArchived.value)
|
||||||
|
settingsOpenId.value = null
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadComponent(comp: VueComponentDefinition) {
|
||||||
|
loadingComponent.value = comp.id
|
||||||
|
try {
|
||||||
|
const container = document.getElementById('canvas-content')
|
||||||
|
if (!container) return
|
||||||
|
|
||||||
|
const placeholder = container.querySelector('.canvas-placeholder')
|
||||||
|
if (placeholder) placeholder.remove()
|
||||||
|
|
||||||
|
const result = renderInlineComponent(comp, container, {}, true)
|
||||||
|
|
||||||
|
getWindowDefinitions().set(comp.id, {
|
||||||
|
source: 'db',
|
||||||
|
componentId: comp.id,
|
||||||
|
definition: comp,
|
||||||
|
componentProps: {}
|
||||||
|
})
|
||||||
|
|
||||||
|
;(window as any).__vueComponentUnmount = result.unmount
|
||||||
|
canvasStore.addToHistory({ tool: 'load_vue_component', args: { id: comp.id }, timestamp: Date.now() })
|
||||||
|
emit('component-loaded')
|
||||||
|
} finally {
|
||||||
|
loadingComponent.value = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function fetchComponents() {
|
||||||
|
try {
|
||||||
|
savedComponents.value = await componentsApi.getAll()
|
||||||
|
} catch {
|
||||||
|
savedComponents.value = []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function deleteSnapshot(id: string) {
|
||||||
|
await snapshotsStore.remove(id)
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleArchived() {
|
||||||
|
showArchived.value = !showArchived.value
|
||||||
|
store.fetchCanvases(showArchived.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
store.fetchCanvases(false)
|
||||||
|
snapshotsStore.list()
|
||||||
|
fetchComponents()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="canvas-gallery">
|
||||||
|
<div class="gallery-header">
|
||||||
|
<h2>Canvases</h2>
|
||||||
|
<div class="header-actions">
|
||||||
|
<button
|
||||||
|
class="toggle-archived"
|
||||||
|
:class="{ active: showArchived }"
|
||||||
|
@click="toggleArchived"
|
||||||
|
>
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||||
|
<polyline points="21 8 21 21 3 21 3 8"/>
|
||||||
|
<rect x="1" y="3" width="22" height="5"/>
|
||||||
|
<line x1="10" y1="12" x2="14" y2="12"/>
|
||||||
|
</svg>
|
||||||
|
Archivados
|
||||||
|
</button>
|
||||||
|
<input
|
||||||
|
v-if="showSearch"
|
||||||
|
v-model="searchQuery"
|
||||||
|
type="text"
|
||||||
|
placeholder="Buscar..."
|
||||||
|
class="search-input"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="store.loading" class="gallery-loading">
|
||||||
|
<div class="spinner"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<template v-else>
|
||||||
|
<!-- Project Canvases -->
|
||||||
|
<div class="gallery-grid">
|
||||||
|
<!-- New canvas card -->
|
||||||
|
<div class="canvas-card new-card" @click="showNewForm = true" v-if="!showNewForm">
|
||||||
|
<div class="card-icon new-icon">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
|
||||||
|
<circle cx="12" cy="12" r="10"/>
|
||||||
|
<line x1="12" y1="8" x2="12" y2="16"/>
|
||||||
|
<line x1="8" y1="12" x2="16" y2="12"/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<div class="card-content">
|
||||||
|
<div class="card-name">Nuevo canvas</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- New canvas form (inline) -->
|
||||||
|
<div class="canvas-card new-form-card" v-if="showNewForm" @click.stop>
|
||||||
|
<input
|
||||||
|
v-model="newName"
|
||||||
|
type="text"
|
||||||
|
class="new-canvas-input"
|
||||||
|
placeholder="Nombre del canvas..."
|
||||||
|
autofocus
|
||||||
|
@keyup.enter="createNewCanvas"
|
||||||
|
@keyup.escape="showNewForm = false; newName = ''"
|
||||||
|
/>
|
||||||
|
<div class="new-form-actions">
|
||||||
|
<button class="new-btn create" :disabled="!newName.trim() || creating" @click="createNewCanvas">
|
||||||
|
{{ creating ? '...' : 'Crear' }}
|
||||||
|
</button>
|
||||||
|
<button class="new-btn cancel" @click="showNewForm = false; newName = ''">Cancelar</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-for="canvas in filteredCanvases"
|
||||||
|
:key="canvas.id"
|
||||||
|
class="canvas-card"
|
||||||
|
:class="{ archived: canvas.status === 'archived' }"
|
||||||
|
@click="navigateToCanvas(canvas.id)"
|
||||||
|
>
|
||||||
|
<div class="card-icon">
|
||||||
|
<span v-if="canvas.toolbar_icon" class="card-emoji">{{ canvas.toolbar_icon }}</span>
|
||||||
|
<svg v-else xmlns="http://www.w3.org/2000/svg" width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
|
||||||
|
<rect x="3" y="3" width="18" height="18" rx="2"/>
|
||||||
|
<path d="M3 9h18"/>
|
||||||
|
<path d="M9 21V9"/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card-content">
|
||||||
|
<div class="card-name">{{ canvas.name }}</div>
|
||||||
|
<div v-if="canvas.description" class="card-desc">{{ canvas.description }}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card-meta">
|
||||||
|
<span class="card-badge" :class="canvas.type">{{ canvas.type }}</span>
|
||||||
|
<span v-if="canvas.status === 'archived'" class="card-badge archived-badge">Archivado</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button
|
||||||
|
class="card-settings-btn"
|
||||||
|
@click.stop="toggleSettings(canvas.id)"
|
||||||
|
title="Configurar"
|
||||||
|
>
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||||
|
<circle cx="12" cy="12" r="3"/>
|
||||||
|
<path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<!-- Settings popover -->
|
||||||
|
<div v-if="settingsOpenId === canvas.id" class="settings-popover" @click.stop>
|
||||||
|
<div class="settings-row">
|
||||||
|
<label>En toolbar</label>
|
||||||
|
<button
|
||||||
|
class="switch-btn"
|
||||||
|
:class="{ on: canvas.show_in_toolbar }"
|
||||||
|
@click="toggleToolbar(canvas.id, canvas.show_in_toolbar)"
|
||||||
|
>
|
||||||
|
<span class="switch-knob"></span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="settings-row">
|
||||||
|
<label>Icono</label>
|
||||||
|
<input
|
||||||
|
v-model="editIcon"
|
||||||
|
type="text"
|
||||||
|
class="settings-input icon-input"
|
||||||
|
placeholder="emoji"
|
||||||
|
maxlength="2"
|
||||||
|
@change="updateIcon(canvas.id)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="settings-row">
|
||||||
|
<label>Orden</label>
|
||||||
|
<input
|
||||||
|
v-model.number="editOrder"
|
||||||
|
type="number"
|
||||||
|
class="settings-input order-input"
|
||||||
|
min="0"
|
||||||
|
max="999"
|
||||||
|
@change="updateOrder(canvas.id)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="settings-divider"></div>
|
||||||
|
|
||||||
|
<button
|
||||||
|
v-if="canvas.status !== 'archived'"
|
||||||
|
class="settings-action archive-btn"
|
||||||
|
@click="archiveCanvas(canvas.id)"
|
||||||
|
:disabled="canvas.is_system"
|
||||||
|
>
|
||||||
|
Archivar
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
v-else
|
||||||
|
class="settings-action restore-btn"
|
||||||
|
@click="restoreCanvas(canvas.id)"
|
||||||
|
>
|
||||||
|
Restaurar
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Snapshots section -->
|
||||||
|
<template v-if="filteredSnapshots.length > 0">
|
||||||
|
<h3 class="section-title">Snapshots</h3>
|
||||||
|
<div class="gallery-grid">
|
||||||
|
<div
|
||||||
|
v-for="snap in filteredSnapshots"
|
||||||
|
:key="snap.id"
|
||||||
|
class="canvas-card snapshot-card"
|
||||||
|
@click="loadSnapshot(snap)"
|
||||||
|
>
|
||||||
|
<div class="card-icon">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
|
||||||
|
<path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"/>
|
||||||
|
<circle cx="12" cy="13" r="4"/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card-content">
|
||||||
|
<div class="card-name">{{ snap.name }}</div>
|
||||||
|
<div class="card-desc">{{ formatDate(snap.created_at) }}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card-meta">
|
||||||
|
<span class="card-badge snapshot">snapshot</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Loading overlay -->
|
||||||
|
<div v-if="restoringSnapshot === snap.id" class="card-loading">
|
||||||
|
<div class="spinner-sm"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button
|
||||||
|
class="card-delete-btn"
|
||||||
|
@click.stop="deleteSnapshot(snap.id)"
|
||||||
|
title="Eliminar snapshot"
|
||||||
|
>
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||||
|
<path d="M3 6h18"/>
|
||||||
|
<path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/>
|
||||||
|
<path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<!-- Components section -->
|
||||||
|
<template v-if="filteredComponents.length > 0">
|
||||||
|
<h3 class="section-title">Componentes</h3>
|
||||||
|
<div class="gallery-grid">
|
||||||
|
<div
|
||||||
|
v-for="comp in filteredComponents"
|
||||||
|
:key="comp.id"
|
||||||
|
class="canvas-card component-card"
|
||||||
|
@click="loadComponent(comp)"
|
||||||
|
>
|
||||||
|
<div class="card-icon">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
|
||||||
|
<path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"/>
|
||||||
|
<polyline points="3.29 7 12 12 20.71 7"/>
|
||||||
|
<line x1="12" y1="22" x2="12" y2="12"/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card-content">
|
||||||
|
<div class="card-name">{{ comp.name }}</div>
|
||||||
|
<div class="card-desc card-id">{{ comp.id }}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card-meta">
|
||||||
|
<span class="card-badge component">componente</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Loading overlay -->
|
||||||
|
<div v-if="loadingComponent === comp.id" class="card-loading">
|
||||||
|
<div class="spinner-sm"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<!-- Empty state -->
|
||||||
|
<div v-if="filteredCanvases.length === 0 && filteredSnapshots.length === 0 && filteredComponents.length === 0" class="gallery-empty">
|
||||||
|
<p v-if="showArchived && store.archivedCanvases.length === 0">No hay canvases archivados</p>
|
||||||
|
<p v-else-if="searchQuery">Sin resultados para "{{ searchQuery }}"</p>
|
||||||
|
<p v-else>No hay canvases, snapshots ni componentes guardados</p>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.canvas-gallery {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
height: 100%;
|
||||||
|
padding: 2rem;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gallery-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-bottom: 1.5rem;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gallery-header h2 {
|
||||||
|
font-size: 1.25rem;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--text-primary);
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-title {
|
||||||
|
font-size: 1rem;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
margin: 1.5rem 0 0.75rem 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-actions {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggle-archived {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.375rem;
|
||||||
|
padding: 0.375rem 0.75rem;
|
||||||
|
background: transparent;
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
border-radius: 6px;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
font-size: 0.8125rem;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.15s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggle-archived:hover {
|
||||||
|
background: var(--bg-hover);
|
||||||
|
color: var(--text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggle-archived.active {
|
||||||
|
background: rgba(99, 102, 241, 0.15);
|
||||||
|
border-color: rgba(99, 102, 241, 0.3);
|
||||||
|
color: #6366f1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-input {
|
||||||
|
padding: 0.375rem 0.75rem;
|
||||||
|
background: var(--bg-primary);
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
border-radius: 6px;
|
||||||
|
color: var(--text-primary);
|
||||||
|
font-size: 0.8125rem;
|
||||||
|
outline: none;
|
||||||
|
width: 180px;
|
||||||
|
transition: border-color 0.15s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-input:focus {
|
||||||
|
border-color: #6366f1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gallery-loading {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 3rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spinner {
|
||||||
|
width: 32px;
|
||||||
|
height: 32px;
|
||||||
|
border: 3px solid var(--border-color);
|
||||||
|
border-top-color: #6366f1;
|
||||||
|
border-radius: 50%;
|
||||||
|
animation: spin 1s linear infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spinner-sm {
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
border: 2px solid rgba(255, 255, 255, 0.3);
|
||||||
|
border-top-color: white;
|
||||||
|
border-radius: 50%;
|
||||||
|
animation: spin 1s linear infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes spin {
|
||||||
|
to { transform: rotate(360deg); }
|
||||||
|
}
|
||||||
|
|
||||||
|
.gallery-empty {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 3rem;
|
||||||
|
color: var(--text-muted);
|
||||||
|
font-size: 0.875rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gallery-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
|
||||||
|
gap: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.canvas-card {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.75rem;
|
||||||
|
padding: 1.25rem;
|
||||||
|
background: var(--bg-secondary);
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
border-radius: 10px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.15s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.canvas-card:hover {
|
||||||
|
border-color: rgba(99, 102, 241, 0.4);
|
||||||
|
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
|
||||||
|
transform: translateY(-1px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.canvas-card.archived {
|
||||||
|
opacity: 0.55;
|
||||||
|
}
|
||||||
|
|
||||||
|
.canvas-card.archived:hover {
|
||||||
|
opacity: 0.8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.snapshot-card:hover {
|
||||||
|
border-color: rgba(168, 85, 247, 0.4);
|
||||||
|
}
|
||||||
|
|
||||||
|
.component-card:hover {
|
||||||
|
border-color: rgba(6, 182, 212, 0.4);
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-id {
|
||||||
|
font-family: monospace;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
opacity: 0.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-icon {
|
||||||
|
color: var(--text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-emoji {
|
||||||
|
font-size: 1.75rem;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-content {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-name {
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 0.9375rem;
|
||||||
|
color: var(--text-primary);
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-desc {
|
||||||
|
font-size: 0.8125rem;
|
||||||
|
color: var(--text-muted);
|
||||||
|
margin-top: 0.25rem;
|
||||||
|
display: -webkit-box;
|
||||||
|
-webkit-line-clamp: 2;
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-meta {
|
||||||
|
display: flex;
|
||||||
|
gap: 0.375rem;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-badge {
|
||||||
|
padding: 0.125rem 0.5rem;
|
||||||
|
border-radius: 999px;
|
||||||
|
font-size: 0.6875rem;
|
||||||
|
font-weight: 500;
|
||||||
|
text-transform: capitalize;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-badge.system {
|
||||||
|
background: rgba(99, 102, 241, 0.15);
|
||||||
|
color: #6366f1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-badge.project {
|
||||||
|
background: rgba(16, 185, 129, 0.15);
|
||||||
|
color: #10b981;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-badge.dynamic {
|
||||||
|
background: rgba(245, 158, 11, 0.15);
|
||||||
|
color: #f59e0b;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-badge.snapshot {
|
||||||
|
background: rgba(168, 85, 247, 0.15);
|
||||||
|
color: #a855f7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-badge.component {
|
||||||
|
background: rgba(6, 182, 212, 0.15);
|
||||||
|
color: #06b6d4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-badge.archived-badge {
|
||||||
|
background: rgba(239, 68, 68, 0.15);
|
||||||
|
color: #ef4444;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-settings-btn,
|
||||||
|
.card-delete-btn {
|
||||||
|
position: absolute;
|
||||||
|
top: 0.75rem;
|
||||||
|
right: 0.75rem;
|
||||||
|
width: 28px;
|
||||||
|
height: 28px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
border-radius: 6px;
|
||||||
|
color: var(--text-muted);
|
||||||
|
cursor: pointer;
|
||||||
|
opacity: 0;
|
||||||
|
transition: all 0.15s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.canvas-card:hover .card-settings-btn,
|
||||||
|
.canvas-card:hover .card-delete-btn {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-settings-btn:hover,
|
||||||
|
.card-delete-btn:hover {
|
||||||
|
background: var(--bg-hover);
|
||||||
|
color: var(--text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-delete-btn:hover {
|
||||||
|
color: #ef4444;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-loading {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
background: rgba(0, 0, 0, 0.4);
|
||||||
|
border-radius: 10px;
|
||||||
|
z-index: 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Settings popover */
|
||||||
|
.settings-popover {
|
||||||
|
position: absolute;
|
||||||
|
top: 2.5rem;
|
||||||
|
right: 0.75rem;
|
||||||
|
width: 200px;
|
||||||
|
background: var(--bg-secondary);
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 0.75rem;
|
||||||
|
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
|
||||||
|
z-index: 10;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-row {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-row label {
|
||||||
|
font-size: 0.75rem;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-input {
|
||||||
|
padding: 0.25rem 0.5rem;
|
||||||
|
background: var(--bg-primary);
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
border-radius: 4px;
|
||||||
|
color: var(--text-primary);
|
||||||
|
font-size: 0.75rem;
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-input:focus {
|
||||||
|
border-color: #6366f1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-input {
|
||||||
|
width: 48px;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.order-input {
|
||||||
|
width: 56px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.switch-btn {
|
||||||
|
position: relative;
|
||||||
|
width: 36px;
|
||||||
|
height: 20px;
|
||||||
|
background: var(--bg-hover);
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
border-radius: 10px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.switch-btn.on {
|
||||||
|
background: #6366f1;
|
||||||
|
border-color: #6366f1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.switch-knob {
|
||||||
|
position: absolute;
|
||||||
|
top: 2px;
|
||||||
|
left: 2px;
|
||||||
|
width: 14px;
|
||||||
|
height: 14px;
|
||||||
|
background: white;
|
||||||
|
border-radius: 50%;
|
||||||
|
transition: transform 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.switch-btn.on .switch-knob {
|
||||||
|
transform: translateX(16px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-divider {
|
||||||
|
height: 1px;
|
||||||
|
background: var(--border-color);
|
||||||
|
margin: 0.25rem 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-action {
|
||||||
|
width: 100%;
|
||||||
|
padding: 0.375rem;
|
||||||
|
border: none;
|
||||||
|
border-radius: 6px;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
font-weight: 500;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.15s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.archive-btn {
|
||||||
|
background: rgba(239, 68, 68, 0.1);
|
||||||
|
color: #ef4444;
|
||||||
|
}
|
||||||
|
|
||||||
|
.archive-btn:hover {
|
||||||
|
background: rgba(239, 68, 68, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.archive-btn:disabled {
|
||||||
|
opacity: 0.3;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
.restore-btn {
|
||||||
|
background: rgba(16, 185, 129, 0.1);
|
||||||
|
color: #10b981;
|
||||||
|
}
|
||||||
|
|
||||||
|
.restore-btn:hover {
|
||||||
|
background: rgba(16, 185, 129, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* New canvas card */
|
||||||
|
.new-card {
|
||||||
|
border-style: dashed;
|
||||||
|
border-color: var(--border-color);
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
min-height: 120px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.new-card:hover {
|
||||||
|
border-color: rgba(99, 102, 241, 0.5);
|
||||||
|
background: rgba(99, 102, 241, 0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
.new-card .card-content {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.new-icon {
|
||||||
|
color: var(--text-muted);
|
||||||
|
opacity: 0.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.new-card:hover .new-icon {
|
||||||
|
opacity: 1;
|
||||||
|
color: #6366f1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.new-form-card {
|
||||||
|
border-color: #6366f1;
|
||||||
|
gap: 0.75rem;
|
||||||
|
justify-content: center;
|
||||||
|
min-height: 120px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.new-canvas-input {
|
||||||
|
width: 100%;
|
||||||
|
padding: 0.5rem 0.75rem;
|
||||||
|
background: var(--bg-primary);
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
border-radius: 6px;
|
||||||
|
color: var(--text-primary);
|
||||||
|
font-size: 0.875rem;
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.new-canvas-input:focus {
|
||||||
|
border-color: #6366f1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.new-form-actions {
|
||||||
|
display: flex;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.new-btn {
|
||||||
|
flex: 1;
|
||||||
|
padding: 0.375rem 0.75rem;
|
||||||
|
border: none;
|
||||||
|
border-radius: 6px;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
font-weight: 500;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.15s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.new-btn.create {
|
||||||
|
background: #6366f1;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.new-btn.create:hover {
|
||||||
|
background: #4f46e5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.new-btn.create:disabled {
|
||||||
|
opacity: 0.5;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
.new-btn.cancel {
|
||||||
|
background: var(--bg-hover);
|
||||||
|
color: var(--text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.new-btn.cancel:hover {
|
||||||
|
background: var(--border-color);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -9,20 +9,7 @@ const canvasStore = useCanvasStore()
|
|||||||
const projectCanvasStore = useProjectCanvasStore()
|
const projectCanvasStore = useProjectCanvasStore()
|
||||||
|
|
||||||
function clearCanvas() {
|
function clearCanvas() {
|
||||||
const container = document.getElementById('canvas-content')
|
window.dispatchEvent(new CustomEvent('clear-canvas'))
|
||||||
if (container) {
|
|
||||||
container.innerHTML = `
|
|
||||||
<div class="canvas-placeholder">
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
|
|
||||||
<rect x="3" y="3" width="18" height="18" rx="2"/>
|
|
||||||
<path d="M3 9h18"/>
|
|
||||||
<path d="M9 21V9"/>
|
|
||||||
</svg>
|
|
||||||
<p>Canvas listo</p>
|
|
||||||
<span>Claude Code puede renderizar contenido aquí</span>
|
|
||||||
</div>
|
|
||||||
`
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleHistory() {
|
function toggleHistory() {
|
||||||
@@ -79,12 +66,6 @@ onMounted(() => {
|
|||||||
|
|
||||||
<!-- Gestion -->
|
<!-- Gestion -->
|
||||||
<div class="toolbar-section">
|
<div class="toolbar-section">
|
||||||
<RouterLink to="/projects" class="toolbar-btn" :class="{ active: route.path === '/projects' }" title="Proyectos">
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
||||||
<path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"/>
|
|
||||||
</svg>
|
|
||||||
</RouterLink>
|
|
||||||
|
|
||||||
<RouterLink to="/components" class="toolbar-btn" :class="{ active: route.path === '/components' }" title="Componentes">
|
<RouterLink to="/components" class="toolbar-btn" :class="{ active: route.path === '/components' }" title="Componentes">
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||||
<path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"/>
|
<path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"/>
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ function handleLoadComponent(e: Event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function goBack() {
|
function goBack() {
|
||||||
router.push('/projects')
|
router.push('/dynamic/canvas')
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
@@ -117,24 +117,6 @@ watch(() => props.id, () => {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="project-canvas-page">
|
<div class="project-canvas-page">
|
||||||
<header class="canvas-header">
|
|
||||||
<button class="back-btn" @click="goBack" title="Volver a proyectos">
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
||||||
<path d="M19 12H5"/>
|
|
||||||
<path d="M12 19l-7-7 7-7"/>
|
|
||||||
</svg>
|
|
||||||
</button>
|
|
||||||
<div class="canvas-info" v-if="projectCanvasStore.activeCanvas">
|
|
||||||
<h1>{{ projectCanvasStore.activeCanvas.name }}</h1>
|
|
||||||
<span v-if="projectCanvasStore.activeCanvas.description">
|
|
||||||
{{ projectCanvasStore.activeCanvas.description }}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<div class="canvas-badge" v-if="projectCanvasStore.activeCanvas?.is_system">
|
|
||||||
Sistema
|
|
||||||
</div>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<div class="canvas-container">
|
<div class="canvas-container">
|
||||||
<div v-if="loading" class="canvas-loading">
|
<div v-if="loading" class="canvas-loading">
|
||||||
<div class="spinner"></div>
|
<div class="spinner"></div>
|
||||||
@@ -175,59 +157,6 @@ watch(() => props.id, () => {
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.canvas-header {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 1rem;
|
|
||||||
padding: 0.75rem 1rem;
|
|
||||||
background: var(--bg-secondary);
|
|
||||||
border-bottom: 1px solid var(--border-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.back-btn {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
width: 36px;
|
|
||||||
height: 36px;
|
|
||||||
background: transparent;
|
|
||||||
border: none;
|
|
||||||
border-radius: 8px;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
cursor: pointer;
|
|
||||||
transition: all 0.15s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.back-btn:hover {
|
|
||||||
background: var(--bg-hover);
|
|
||||||
color: var(--text-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.canvas-info {
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.canvas-info h1 {
|
|
||||||
font-size: 1rem;
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--text-primary);
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.canvas-info span {
|
|
||||||
font-size: 0.75rem;
|
|
||||||
color: var(--text-muted);
|
|
||||||
}
|
|
||||||
|
|
||||||
.canvas-badge {
|
|
||||||
padding: 0.25rem 0.5rem;
|
|
||||||
background: var(--accent-muted);
|
|
||||||
color: var(--accent);
|
|
||||||
font-size: 0.75rem;
|
|
||||||
font-weight: 500;
|
|
||||||
border-radius: var(--radius-full);
|
|
||||||
}
|
|
||||||
|
|
||||||
.canvas-container {
|
.canvas-container {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@@ -1,504 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
import { onMounted, ref, computed } from 'vue'
|
|
||||||
import { useRouter } from 'vue-router'
|
|
||||||
import { useProjectCanvasStore } from '../stores/projectCanvas'
|
|
||||||
import type { ProjectCanvas } from '../types/canvas'
|
|
||||||
|
|
||||||
const router = useRouter()
|
|
||||||
const store = useProjectCanvasStore()
|
|
||||||
|
|
||||||
const showCreateModal = ref(false)
|
|
||||||
const newCanvasName = ref('')
|
|
||||||
const newCanvasDescription = ref('')
|
|
||||||
const selectedCloneSource = ref<string | null>(null)
|
|
||||||
|
|
||||||
const systemCanvases = computed(() => store.systemCanvases)
|
|
||||||
const projectCanvases = computed(() => store.projectCanvases)
|
|
||||||
|
|
||||||
async function createCanvas() {
|
|
||||||
if (!newCanvasName.value.trim()) return
|
|
||||||
|
|
||||||
let id: string | null = null
|
|
||||||
|
|
||||||
if (selectedCloneSource.value) {
|
|
||||||
id = await store.cloneCanvas(selectedCloneSource.value, newCanvasName.value)
|
|
||||||
} else {
|
|
||||||
id = await store.createCanvas({
|
|
||||||
name: newCanvasName.value,
|
|
||||||
description: newCanvasDescription.value,
|
|
||||||
type: 'project'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
if (id) {
|
|
||||||
closeModal()
|
|
||||||
router.push(`/canvas/${id}`)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function openCanvas(canvas: ProjectCanvas) {
|
|
||||||
router.push(`/canvas/${canvas.id}`)
|
|
||||||
}
|
|
||||||
|
|
||||||
function openCreateModal(cloneSource?: string) {
|
|
||||||
selectedCloneSource.value = cloneSource || null
|
|
||||||
newCanvasName.value = ''
|
|
||||||
newCanvasDescription.value = ''
|
|
||||||
showCreateModal.value = true
|
|
||||||
}
|
|
||||||
|
|
||||||
function closeModal() {
|
|
||||||
showCreateModal.value = false
|
|
||||||
newCanvasName.value = ''
|
|
||||||
newCanvasDescription.value = ''
|
|
||||||
selectedCloneSource.value = null
|
|
||||||
}
|
|
||||||
|
|
||||||
async function deleteCanvas(canvas: ProjectCanvas) {
|
|
||||||
if (canvas.is_system) return
|
|
||||||
|
|
||||||
if (confirm(`¿Eliminar el canvas "${canvas.name}"?`)) {
|
|
||||||
await store.deleteCanvas(canvas.id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
store.fetchCanvases()
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div class="projects-page">
|
|
||||||
<header class="page-header">
|
|
||||||
<h1>Proyectos</h1>
|
|
||||||
<button class="create-btn" @click="openCreateModal()">
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
||||||
<path d="M12 5v14"/>
|
|
||||||
<path d="M5 12h14"/>
|
|
||||||
</svg>
|
|
||||||
Nuevo Canvas
|
|
||||||
</button>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<div class="content">
|
|
||||||
<!-- System Templates -->
|
|
||||||
<section v-if="systemCanvases.length > 0" class="canvas-section">
|
|
||||||
<h2>
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
||||||
<path d="M12 2L2 7l10 5 10-5-10-5z"/>
|
|
||||||
<path d="M2 17l10 5 10-5"/>
|
|
||||||
<path d="M2 12l10 5 10-5"/>
|
|
||||||
</svg>
|
|
||||||
Templates del Sistema
|
|
||||||
</h2>
|
|
||||||
<div class="canvas-grid">
|
|
||||||
<div
|
|
||||||
v-for="canvas in systemCanvases"
|
|
||||||
:key="canvas.id"
|
|
||||||
class="canvas-card system"
|
|
||||||
>
|
|
||||||
<div class="card-content" @click="openCanvas(canvas)">
|
|
||||||
<div class="card-icon">
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
|
|
||||||
<rect x="3" y="3" width="18" height="18" rx="2"/>
|
|
||||||
<path d="M3 9h18"/>
|
|
||||||
<path d="M9 21V9"/>
|
|
||||||
</svg>
|
|
||||||
</div>
|
|
||||||
<h3>{{ canvas.name }}</h3>
|
|
||||||
<p v-if="canvas.description">{{ canvas.description }}</p>
|
|
||||||
</div>
|
|
||||||
<div class="card-actions">
|
|
||||||
<button @click.stop="openCreateModal(canvas.id)" title="Clonar template">
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
||||||
<rect x="9" y="9" width="13" height="13" rx="2" ry="2"/>
|
|
||||||
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/>
|
|
||||||
</svg>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<!-- Project Canvases -->
|
|
||||||
<section class="canvas-section">
|
|
||||||
<h2>
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
||||||
<path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"/>
|
|
||||||
</svg>
|
|
||||||
Mis Proyectos
|
|
||||||
</h2>
|
|
||||||
<div v-if="projectCanvases.length === 0" class="empty-state">
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
|
|
||||||
<path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"/>
|
|
||||||
<line x1="12" y1="11" x2="12" y2="17"/>
|
|
||||||
<line x1="9" y1="14" x2="15" y2="14"/>
|
|
||||||
</svg>
|
|
||||||
<p>No tienes proyectos aun</p>
|
|
||||||
<span>Crea un nuevo canvas o clona un template del sistema</span>
|
|
||||||
</div>
|
|
||||||
<div v-else class="canvas-grid">
|
|
||||||
<div
|
|
||||||
v-for="canvas in projectCanvases"
|
|
||||||
:key="canvas.id"
|
|
||||||
class="canvas-card"
|
|
||||||
>
|
|
||||||
<div class="card-content" @click="openCanvas(canvas)">
|
|
||||||
<div class="card-icon">
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
|
|
||||||
<rect x="3" y="3" width="18" height="18" rx="2"/>
|
|
||||||
<path d="M3 9h18"/>
|
|
||||||
<path d="M9 21V9"/>
|
|
||||||
</svg>
|
|
||||||
</div>
|
|
||||||
<h3>{{ canvas.name }}</h3>
|
|
||||||
<p v-if="canvas.description">{{ canvas.description }}</p>
|
|
||||||
</div>
|
|
||||||
<div class="card-actions">
|
|
||||||
<button @click.stop="openCreateModal(canvas.id)" title="Clonar">
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
||||||
<rect x="9" y="9" width="13" height="13" rx="2" ry="2"/>
|
|
||||||
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/>
|
|
||||||
</svg>
|
|
||||||
</button>
|
|
||||||
<button @click.stop="deleteCanvas(canvas)" class="delete-btn" title="Eliminar">
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
||||||
<path d="M3 6h18"/>
|
|
||||||
<path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/>
|
|
||||||
<path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/>
|
|
||||||
</svg>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Create Modal -->
|
|
||||||
<div v-if="showCreateModal" class="modal-overlay" @click.self="closeModal">
|
|
||||||
<div class="modal">
|
|
||||||
<h2>{{ selectedCloneSource ? 'Clonar Canvas' : 'Nuevo Canvas' }}</h2>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="canvas-name">Nombre</label>
|
|
||||||
<input
|
|
||||||
id="canvas-name"
|
|
||||||
v-model="newCanvasName"
|
|
||||||
type="text"
|
|
||||||
placeholder="Mi proyecto"
|
|
||||||
@keyup.enter="createCanvas"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="canvas-desc">Descripcion (opcional)</label>
|
|
||||||
<textarea
|
|
||||||
id="canvas-desc"
|
|
||||||
v-model="newCanvasDescription"
|
|
||||||
placeholder="Descripcion del canvas..."
|
|
||||||
rows="3"
|
|
||||||
></textarea>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="modal-actions">
|
|
||||||
<button class="cancel-btn" @click="closeModal">Cancelar</button>
|
|
||||||
<button class="submit-btn" @click="createCanvas" :disabled="!newCanvasName.trim()">
|
|
||||||
{{ selectedCloneSource ? 'Clonar' : 'Crear' }}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.projects-page {
|
|
||||||
flex: 1;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
background: var(--bg-primary);
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.page-header {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
padding: 1.5rem;
|
|
||||||
border-bottom: 1px solid var(--border-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.page-header h1 {
|
|
||||||
font-size: 1.5rem;
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--text-primary);
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.create-btn {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 0.5rem;
|
|
||||||
padding: 0.5rem 1rem;
|
|
||||||
background: var(--accent);
|
|
||||||
color: var(--accent-text);
|
|
||||||
border: none;
|
|
||||||
border-radius: var(--radius-md);
|
|
||||||
font-size: 0.875rem;
|
|
||||||
font-weight: 500;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: background 0.15s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.create-btn:hover {
|
|
||||||
background: var(--accent-hover);
|
|
||||||
}
|
|
||||||
|
|
||||||
.content {
|
|
||||||
flex: 1;
|
|
||||||
padding: 1.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.canvas-section {
|
|
||||||
margin-bottom: 2rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.canvas-section h2 {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 0.5rem;
|
|
||||||
font-size: 1rem;
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--text-primary);
|
|
||||||
margin: 0 0 1rem 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.canvas-section h2 svg {
|
|
||||||
color: var(--text-muted);
|
|
||||||
}
|
|
||||||
|
|
||||||
.canvas-grid {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
|
|
||||||
gap: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.canvas-card {
|
|
||||||
background: var(--bg-secondary);
|
|
||||||
border: 1px solid var(--border-color);
|
|
||||||
border-radius: var(--radius-lg);
|
|
||||||
overflow: hidden;
|
|
||||||
transition: all 0.15s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.canvas-card:hover {
|
|
||||||
border-color: var(--border-hover);
|
|
||||||
box-shadow: var(--shadow-md);
|
|
||||||
}
|
|
||||||
|
|
||||||
.canvas-card.system {
|
|
||||||
border-color: var(--accent-muted);
|
|
||||||
}
|
|
||||||
|
|
||||||
.canvas-card.system:hover {
|
|
||||||
border-color: var(--accent);
|
|
||||||
}
|
|
||||||
|
|
||||||
.card-content {
|
|
||||||
padding: 1.25rem;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card-icon {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
width: 48px;
|
|
||||||
height: 48px;
|
|
||||||
background: var(--bg-hover);
|
|
||||||
border-radius: var(--radius-md);
|
|
||||||
margin-bottom: 1rem;
|
|
||||||
color: var(--text-muted);
|
|
||||||
}
|
|
||||||
|
|
||||||
.canvas-card.system .card-icon {
|
|
||||||
background: var(--accent-muted);
|
|
||||||
color: var(--accent);
|
|
||||||
}
|
|
||||||
|
|
||||||
.card-content h3 {
|
|
||||||
font-size: 1rem;
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--text-primary);
|
|
||||||
margin: 0 0 0.25rem 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card-content p {
|
|
||||||
font-size: 0.875rem;
|
|
||||||
color: var(--text-muted);
|
|
||||||
margin: 0;
|
|
||||||
display: -webkit-box;
|
|
||||||
-webkit-line-clamp: 2;
|
|
||||||
-webkit-box-orient: vertical;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card-actions {
|
|
||||||
display: flex;
|
|
||||||
gap: 0.5rem;
|
|
||||||
padding: 0.75rem 1.25rem;
|
|
||||||
border-top: 1px solid var(--border-color);
|
|
||||||
background: var(--bg-tertiary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.card-actions button {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
width: 32px;
|
|
||||||
height: 32px;
|
|
||||||
background: transparent;
|
|
||||||
border: none;
|
|
||||||
border-radius: var(--radius-sm);
|
|
||||||
color: var(--text-secondary);
|
|
||||||
cursor: pointer;
|
|
||||||
transition: all 0.15s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card-actions button:hover {
|
|
||||||
background: var(--bg-hover);
|
|
||||||
color: var(--text-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.card-actions .delete-btn:hover {
|
|
||||||
background: var(--error-bg);
|
|
||||||
color: var(--error);
|
|
||||||
}
|
|
||||||
|
|
||||||
.empty-state {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
padding: 3rem;
|
|
||||||
text-align: center;
|
|
||||||
color: var(--text-muted);
|
|
||||||
}
|
|
||||||
|
|
||||||
.empty-state svg {
|
|
||||||
margin-bottom: 1rem;
|
|
||||||
opacity: 0.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
.empty-state p {
|
|
||||||
font-size: 1rem;
|
|
||||||
margin: 0 0 0.25rem 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.empty-state span {
|
|
||||||
font-size: 0.875rem;
|
|
||||||
opacity: 0.7;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Modal */
|
|
||||||
.modal-overlay {
|
|
||||||
position: fixed;
|
|
||||||
inset: 0;
|
|
||||||
background: rgba(0, 0, 0, 0.6);
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
z-index: 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
.modal {
|
|
||||||
background: var(--bg-secondary);
|
|
||||||
border: 1px solid var(--border-color);
|
|
||||||
border-radius: var(--radius-lg);
|
|
||||||
padding: 1.5rem;
|
|
||||||
width: 100%;
|
|
||||||
max-width: 400px;
|
|
||||||
box-shadow: var(--shadow-lg);
|
|
||||||
}
|
|
||||||
|
|
||||||
.modal h2 {
|
|
||||||
font-size: 1.25rem;
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--text-primary);
|
|
||||||
margin: 0 0 1.5rem 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-group {
|
|
||||||
margin-bottom: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-group label {
|
|
||||||
display: block;
|
|
||||||
font-size: 0.875rem;
|
|
||||||
font-weight: 500;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
margin-bottom: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-group input,
|
|
||||||
.form-group textarea {
|
|
||||||
width: 100%;
|
|
||||||
padding: 0.75rem;
|
|
||||||
background: var(--bg-primary);
|
|
||||||
border: 1px solid var(--border-color);
|
|
||||||
border-radius: var(--radius-md);
|
|
||||||
color: var(--text-primary);
|
|
||||||
font-size: 0.875rem;
|
|
||||||
resize: vertical;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-group input:focus,
|
|
||||||
.form-group textarea:focus {
|
|
||||||
outline: none;
|
|
||||||
border-color: var(--accent);
|
|
||||||
}
|
|
||||||
|
|
||||||
.modal-actions {
|
|
||||||
display: flex;
|
|
||||||
justify-content: flex-end;
|
|
||||||
gap: 0.75rem;
|
|
||||||
margin-top: 1.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cancel-btn {
|
|
||||||
padding: 0.5rem 1rem;
|
|
||||||
background: transparent;
|
|
||||||
border: 1px solid var(--border-color);
|
|
||||||
border-radius: var(--radius-md);
|
|
||||||
color: var(--text-secondary);
|
|
||||||
font-size: 0.875rem;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: all 0.15s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cancel-btn:hover {
|
|
||||||
background: var(--bg-hover);
|
|
||||||
color: var(--text-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.submit-btn {
|
|
||||||
padding: 0.5rem 1rem;
|
|
||||||
background: var(--accent);
|
|
||||||
border: none;
|
|
||||||
border-radius: var(--radius-md);
|
|
||||||
color: var(--accent-text);
|
|
||||||
font-size: 0.875rem;
|
|
||||||
font-weight: 500;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: background 0.15s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.submit-btn:hover:not(:disabled) {
|
|
||||||
background: var(--accent-hover);
|
|
||||||
}
|
|
||||||
|
|
||||||
.submit-btn:disabled {
|
|
||||||
opacity: 0.5;
|
|
||||||
cursor: not-allowed;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -19,11 +19,6 @@ const router = createRouter({
|
|||||||
component: () => import('../pages/ProjectCanvasPage.vue'),
|
component: () => import('../pages/ProjectCanvasPage.vue'),
|
||||||
props: true
|
props: true
|
||||||
},
|
},
|
||||||
{
|
|
||||||
path: '/projects',
|
|
||||||
name: 'projects',
|
|
||||||
component: () => import('../pages/ProjectsPage.vue')
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
path: '/components',
|
path: '/components',
|
||||||
name: 'components',
|
name: 'components',
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ import { setRouter } from './tools/handlers/globalHandlers'
|
|||||||
import { setGiteaCredentials, clearGiteaCredentials } from './tools/handlers/sourceCodeHandlers'
|
import { setGiteaCredentials, clearGiteaCredentials } from './tools/handlers/sourceCodeHandlers'
|
||||||
import { ALL_TOOL_METAS, getAllToolNames, type ToolCategory } from './tools/toolDefinitions'
|
import { ALL_TOOL_METAS, getAllToolNames, type ToolCategory } from './tools/toolDefinitions'
|
||||||
|
|
||||||
export type PageName = 'home' | 'canvas' | 'components' | 'themes' | 'projects' | 'project-canvas' | 'database' | 'source' | 'terminal' | 'tools' | 'git'
|
export type PageName = 'home' | 'canvas' | 'components' | 'themes' | 'project-canvas' | 'database' | 'source' | 'terminal' | 'tools' | 'git'
|
||||||
|
|
||||||
// Internal webmcp functions (not exported for external use)
|
// Internal webmcp functions (not exported for external use)
|
||||||
let webmcpInstance: any = null
|
let webmcpInstance: any = null
|
||||||
@@ -156,9 +156,8 @@ const categoryTools: Record<ToolCategory, string[]> = {
|
|||||||
// Page to categories mapping
|
// Page to categories mapping
|
||||||
const pageCategories: Record<PageName, ToolCategory[]> = {
|
const pageCategories: Record<PageName, ToolCategory[]> = {
|
||||||
home: ['global', 'torch', 'canvas', 'component', 'project', 'terminal'],
|
home: ['global', 'torch', 'canvas', 'component', 'project', 'terminal'],
|
||||||
canvas: ['global', 'torch', 'canvas', 'component', 'terminal'],
|
canvas: ['global', 'torch', 'canvas', 'component', 'project', 'terminal'],
|
||||||
'project-canvas': ['global', 'torch', 'canvas', 'component', 'project', 'terminal'],
|
'project-canvas': ['global', 'torch', 'canvas', 'component', 'project', 'terminal'],
|
||||||
projects: ['global', 'torch', 'project', 'terminal'],
|
|
||||||
components: ['global', 'torch', 'component', 'terminal'],
|
components: ['global', 'torch', 'component', 'terminal'],
|
||||||
themes: ['global', 'torch', 'theme', 'terminal'],
|
themes: ['global', 'torch', 'theme', 'terminal'],
|
||||||
database: ['global', 'torch', 'database', 'terminal'],
|
database: ['global', 'torch', 'database', 'terminal'],
|
||||||
|
|||||||
@@ -49,7 +49,10 @@ function getCanvasContainer() {
|
|||||||
|
|
||||||
function removePlaceholder(container: HTMLElement) {
|
function removePlaceholder(container: HTMLElement) {
|
||||||
const placeholder = container.querySelector('.canvas-placeholder')
|
const placeholder = container.querySelector('.canvas-placeholder')
|
||||||
if (placeholder) placeholder.remove()
|
if (placeholder) {
|
||||||
|
placeholder.remove()
|
||||||
|
window.dispatchEvent(new CustomEvent('canvas-content-rendered'))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function emitComponentRendered(args: any) {
|
function emitComponentRendered(args: any) {
|
||||||
|
|||||||
@@ -13,7 +13,10 @@ function getCanvasContainer() {
|
|||||||
|
|
||||||
function removePlaceholder(container: HTMLElement) {
|
function removePlaceholder(container: HTMLElement) {
|
||||||
const placeholder = container.querySelector('.canvas-placeholder')
|
const placeholder = container.querySelector('.canvas-placeholder')
|
||||||
if (placeholder) placeholder.remove()
|
if (placeholder) {
|
||||||
|
placeholder.remove()
|
||||||
|
window.dispatchEvent(new CustomEvent('canvas-content-rendered'))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createComponentHandlers(): ToolConfig[] {
|
export function createComponentHandlers(): ToolConfig[] {
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ export function createGlobalHandlers(callbacks: ToolManagementCallbacks): ToolCo
|
|||||||
themes: 'Themes - Editor visual de temas',
|
themes: 'Themes - Editor visual de temas',
|
||||||
database: 'Database - Explorador de base de datos',
|
database: 'Database - Explorador de base de datos',
|
||||||
source: 'Source - Navegador de codigo fuente',
|
source: 'Source - Navegador de codigo fuente',
|
||||||
projects: 'Projects - Gestiona proyectos',
|
|
||||||
terminal: 'Terminal - Consola de comandos',
|
terminal: 'Terminal - Consola de comandos',
|
||||||
tools: 'Tools - Gestion de herramientas MCP'
|
tools: 'Tools - Gestion de herramientas MCP'
|
||||||
}
|
}
|
||||||
@@ -63,7 +62,7 @@ export function createGlobalHandlers(callbacks: ToolManagementCallbacks): ToolCo
|
|||||||
properties: {
|
properties: {
|
||||||
page: {
|
page: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
enum: ['home', 'canvas', 'components', 'themes', 'database', 'source', 'projects', 'terminal', 'tools'],
|
enum: ['home', 'canvas', 'components', 'themes', 'database', 'source', 'terminal', 'tools'],
|
||||||
description: 'Pagina a la que navegar'
|
description: 'Pagina a la que navegar'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -81,7 +80,6 @@ export function createGlobalHandlers(callbacks: ToolManagementCallbacks): ToolCo
|
|||||||
themes: '/themes',
|
themes: '/themes',
|
||||||
database: '/database',
|
database: '/database',
|
||||||
source: '/source',
|
source: '/source',
|
||||||
projects: '/projects',
|
|
||||||
terminal: '/terminal',
|
terminal: '/terminal',
|
||||||
tools: '/tools'
|
tools: '/tools'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,12 +10,13 @@ export function createProjectCanvasHandlers(): ToolConfig[] {
|
|||||||
schema: {
|
schema: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
type: { type: 'string', enum: ['all', 'project', 'system'], description: 'Filtrar por tipo' }
|
type: { type: 'string', enum: ['all', 'project', 'system'], description: 'Filtrar por tipo' },
|
||||||
|
include_archived: { type: 'boolean', description: 'Incluir canvases archivados' }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handler: async (args: { type?: string }) => {
|
handler: async (args: { type?: string; include_archived?: boolean }) => {
|
||||||
const store = useProjectCanvasStore()
|
const store = useProjectCanvasStore()
|
||||||
await store.fetchCanvases()
|
await store.fetchCanvases(args.include_archived || false)
|
||||||
let canvases = store.canvases
|
let canvases = store.canvases
|
||||||
|
|
||||||
if (args.type === 'project') {
|
if (args.type === 'project') {
|
||||||
@@ -28,6 +29,7 @@ export function createProjectCanvasHandlers(): ToolConfig[] {
|
|||||||
id: c.id,
|
id: c.id,
|
||||||
name: c.name,
|
name: c.name,
|
||||||
type: c.type,
|
type: c.type,
|
||||||
|
status: c.status,
|
||||||
description: c.description
|
description: c.description
|
||||||
})), null, 2)
|
})), null, 2)
|
||||||
}
|
}
|
||||||
@@ -110,7 +112,7 @@ export function createProjectCanvasHandlers(): ToolConfig[] {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'delete_canvas',
|
name: 'delete_canvas',
|
||||||
description: 'Elimina un canvas',
|
description: 'Archiva un canvas (soft delete)',
|
||||||
category: 'project',
|
category: 'project',
|
||||||
schema: {
|
schema: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
@@ -124,7 +126,7 @@ export function createProjectCanvasHandlers(): ToolConfig[] {
|
|||||||
const success = await store.deleteCanvas(args.id)
|
const success = await store.deleteCanvas(args.id)
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
return `Canvas "${args.id}" eliminado`
|
return `Canvas "${args.id}" archivado`
|
||||||
}
|
}
|
||||||
return `Error: ${store.error}`
|
return `Error: ${store.error}`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,14 @@ export const useProjectCanvasStore = defineStore('projectCanvas', () => {
|
|||||||
canvases.value.find(c => c.type === 'dynamic')
|
canvases.value.find(c => c.type === 'dynamic')
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const activeCanvasesList = computed(() =>
|
||||||
|
canvases.value.filter(c => c.status !== 'archived')
|
||||||
|
)
|
||||||
|
|
||||||
|
const archivedCanvases = computed(() =>
|
||||||
|
canvases.value.filter(c => c.status === 'archived')
|
||||||
|
)
|
||||||
|
|
||||||
const canvasCount = computed(() => canvases.value.length)
|
const canvasCount = computed(() => canvases.value.length)
|
||||||
|
|
||||||
const hasActiveCanvas = computed(() => activeCanvas.value !== null)
|
const hasActiveCanvas = computed(() => activeCanvas.value !== null)
|
||||||
@@ -38,11 +46,12 @@ export const useProjectCanvasStore = defineStore('projectCanvas', () => {
|
|||||||
const hasDefaultCanvas = computed(() => defaultCanvas.value !== null)
|
const hasDefaultCanvas = computed(() => defaultCanvas.value !== null)
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
async function fetchCanvases() {
|
async function fetchCanvases(includeArchived = false) {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
error.value = null
|
error.value = null
|
||||||
try {
|
try {
|
||||||
const res = await fetch(`${API_URL}/api/canvas`)
|
const url = includeArchived ? `${API_URL}/api/canvas?include_archived=true` : `${API_URL}/api/canvas`
|
||||||
|
const res = await fetch(url)
|
||||||
if (!res.ok) throw new Error('Failed to fetch canvases')
|
if (!res.ok) throw new Error('Failed to fetch canvases')
|
||||||
canvases.value = await res.json()
|
canvases.value = await res.json()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -168,6 +177,10 @@ export const useProjectCanvasStore = defineStore('projectCanvas', () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function restoreCanvas(id: string): Promise<boolean> {
|
||||||
|
return updateCanvas(id, { status: 'active' } as any)
|
||||||
|
}
|
||||||
|
|
||||||
async function cloneCanvas(id: string, newName?: string): Promise<string | null> {
|
async function cloneCanvas(id: string, newName?: string): Promise<string | null> {
|
||||||
saving.value = true
|
saving.value = true
|
||||||
error.value = null
|
error.value = null
|
||||||
@@ -304,6 +317,8 @@ export const useProjectCanvasStore = defineStore('projectCanvas', () => {
|
|||||||
projectCanvases,
|
projectCanvases,
|
||||||
systemCanvases,
|
systemCanvases,
|
||||||
dynamicCanvas,
|
dynamicCanvas,
|
||||||
|
activeCanvasesList,
|
||||||
|
archivedCanvases,
|
||||||
canvasCount,
|
canvasCount,
|
||||||
hasActiveCanvas,
|
hasActiveCanvas,
|
||||||
hasDefaultCanvas,
|
hasDefaultCanvas,
|
||||||
@@ -315,6 +330,7 @@ export const useProjectCanvasStore = defineStore('projectCanvas', () => {
|
|||||||
createCanvas,
|
createCanvas,
|
||||||
updateCanvas,
|
updateCanvas,
|
||||||
deleteCanvas,
|
deleteCanvas,
|
||||||
|
restoreCanvas,
|
||||||
cloneCanvas,
|
cloneCanvas,
|
||||||
fetchCanvasComponents,
|
fetchCanvasComponents,
|
||||||
addComponentToCanvas,
|
addComponentToCanvas,
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
export type CanvasType = 'dynamic' | 'project' | 'system' | 'external'
|
export type CanvasType = 'dynamic' | 'project' | 'system' | 'external'
|
||||||
|
export type CanvasStatus = 'active' | 'archived'
|
||||||
|
|
||||||
export interface CanvasConfig {
|
export interface CanvasConfig {
|
||||||
layout?: 'free' | 'grid' | 'stack'
|
layout?: 'free' | 'grid' | 'stack'
|
||||||
@@ -21,6 +22,7 @@ export interface ProjectCanvas {
|
|||||||
name: string
|
name: string
|
||||||
description?: string
|
description?: string
|
||||||
type: CanvasType
|
type: CanvasType
|
||||||
|
status: CanvasStatus
|
||||||
theme_id?: string | null
|
theme_id?: string | null
|
||||||
config: CanvasConfig | null
|
config: CanvasConfig | null
|
||||||
tools: string[]
|
tools: string[]
|
||||||
|
|||||||
@@ -119,7 +119,8 @@ function runColumnMigrations(db: Database) {
|
|||||||
const alterStatements = [
|
const alterStatements = [
|
||||||
'ALTER TABLE project_canvas ADD COLUMN show_in_toolbar INTEGER DEFAULT 0',
|
'ALTER TABLE project_canvas ADD COLUMN show_in_toolbar INTEGER DEFAULT 0',
|
||||||
'ALTER TABLE project_canvas ADD COLUMN toolbar_icon TEXT',
|
'ALTER TABLE project_canvas ADD COLUMN toolbar_icon TEXT',
|
||||||
'ALTER TABLE project_canvas ADD COLUMN toolbar_order INTEGER DEFAULT 99'
|
'ALTER TABLE project_canvas ADD COLUMN toolbar_order INTEGER DEFAULT 99',
|
||||||
|
'ALTER TABLE project_canvas ADD COLUMN status TEXT DEFAULT \'active\''
|
||||||
]
|
]
|
||||||
|
|
||||||
for (const sql of alterStatements) {
|
for (const sql of alterStatements) {
|
||||||
|
|||||||
@@ -7,18 +7,19 @@ function parseCanvas(row: any) {
|
|||||||
is_default: !!row.is_default,
|
is_default: !!row.is_default,
|
||||||
is_system: !!row.is_system,
|
is_system: !!row.is_system,
|
||||||
show_in_toolbar: !!row.show_in_toolbar,
|
show_in_toolbar: !!row.show_in_toolbar,
|
||||||
|
status: row.status || 'active',
|
||||||
config: row.config ? JSON.parse(row.config) : null,
|
config: row.config ? JSON.parse(row.config) : null,
|
||||||
tools: row.tools ? JSON.parse(row.tools) : []
|
tools: row.tools ? JSON.parse(row.tools) : []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function handleToolbarCanvas() {
|
export function handleToolbarCanvas() {
|
||||||
const rows = db.query('SELECT * FROM project_canvas WHERE show_in_toolbar = 1 ORDER BY toolbar_order ASC, name ASC').all()
|
const rows = db.query('SELECT * FROM project_canvas WHERE show_in_toolbar = 1 AND (status = \'active\' OR status IS NULL) ORDER BY toolbar_order ASC, name ASC').all()
|
||||||
return jsonResponse((rows as any[]).map(parseCanvas))
|
return jsonResponse((rows as any[]).map(parseCanvas))
|
||||||
}
|
}
|
||||||
|
|
||||||
export function handleDefaultCanvas() {
|
export function handleDefaultCanvas() {
|
||||||
const row = db.query('SELECT * FROM project_canvas WHERE is_default = 1 LIMIT 1').get() as any
|
const row = db.query('SELECT * FROM project_canvas WHERE is_default = 1 AND (status = \'active\' OR status IS NULL) LIMIT 1').get() as any
|
||||||
if (!row) {
|
if (!row) {
|
||||||
return jsonResponse({ hasDefault: false })
|
return jsonResponse({ hasDefault: false })
|
||||||
}
|
}
|
||||||
@@ -27,7 +28,10 @@ export function handleDefaultCanvas() {
|
|||||||
|
|
||||||
export async function handleCanvas(req: Request) {
|
export async function handleCanvas(req: Request) {
|
||||||
if (req.method === 'GET') {
|
if (req.method === 'GET') {
|
||||||
const rows = db.query('SELECT * FROM project_canvas ORDER BY is_system DESC, is_default DESC, name ASC').all()
|
const url = new URL(req.url)
|
||||||
|
const includeArchived = url.searchParams.get('include_archived') === 'true'
|
||||||
|
const whereClause = includeArchived ? '' : 'WHERE (status = \'active\' OR status IS NULL)'
|
||||||
|
const rows = db.query(`SELECT * FROM project_canvas ${whereClause} ORDER BY is_system DESC, is_default DESC, name ASC`).all()
|
||||||
return jsonResponse((rows as any[]).map(parseCanvas))
|
return jsonResponse((rows as any[]).map(parseCanvas))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,6 +133,7 @@ export async function handleCanvasById(req: Request, id: string, action?: string
|
|||||||
if (body.show_in_toolbar !== undefined) { updates.push('show_in_toolbar = ?'); values.push(body.show_in_toolbar ? 1 : 0) }
|
if (body.show_in_toolbar !== undefined) { updates.push('show_in_toolbar = ?'); values.push(body.show_in_toolbar ? 1 : 0) }
|
||||||
if (body.toolbar_icon !== undefined) { updates.push('toolbar_icon = ?'); values.push(body.toolbar_icon) }
|
if (body.toolbar_icon !== undefined) { updates.push('toolbar_icon = ?'); values.push(body.toolbar_icon) }
|
||||||
if (body.toolbar_order !== undefined) { updates.push('toolbar_order = ?'); values.push(body.toolbar_order) }
|
if (body.toolbar_order !== undefined) { updates.push('toolbar_order = ?'); values.push(body.toolbar_order) }
|
||||||
|
if (body.status !== undefined) { updates.push('status = ?'); values.push(body.status) }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (updates.length > 0) {
|
if (updates.length > 0) {
|
||||||
@@ -141,13 +146,13 @@ export async function handleCanvasById(req: Request, id: string, action?: string
|
|||||||
return jsonResponse({ success: true, id })
|
return jsonResponse({ success: true, id })
|
||||||
}
|
}
|
||||||
|
|
||||||
// DELETE /api/canvas/:id
|
// DELETE /api/canvas/:id (soft delete - archive)
|
||||||
if (req.method === 'DELETE' && !action) {
|
if (req.method === 'DELETE' && !action) {
|
||||||
const canvas = db.query('SELECT is_system FROM project_canvas WHERE id = ?').get(id) as { is_system: number } | null
|
const canvas = db.query('SELECT is_system FROM project_canvas WHERE id = ?').get(id) as { is_system: number } | null
|
||||||
if (canvas?.is_system) {
|
if (canvas?.is_system) {
|
||||||
return errorResponse('Cannot delete system canvas', 403)
|
return errorResponse('Cannot delete system canvas', 403)
|
||||||
}
|
}
|
||||||
db.run('DELETE FROM project_canvas WHERE id = ?', [id])
|
db.run('UPDATE project_canvas SET status = \'archived\', show_in_toolbar = 0, updated_at = CURRENT_TIMESTAMP WHERE id = ?', [id])
|
||||||
return jsonResponse({ success: true })
|
return jsonResponse({ success: true })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user