More template work & configure backend URL

This commit is contained in:
space-nuko
2023-05-24 23:21:06 -05:00
parent 4ae4e71616
commit 0fedef30c0
17 changed files with 764 additions and 623 deletions

View File

@@ -31,7 +31,6 @@
$: rebuildTemplates($templateState.templates);
function rebuildTemplates(templates: SerializedComfyBoxTemplate[]) {
console.error("recreate");
_sorted = Array.from(templates).map(t => {
return {
type: "template", id: uuidv4(), template: t, attrs: {...defaultWidgetAttributes}, attrsChanged: writable(0)
@@ -76,6 +75,9 @@
}
function handleClick(layout: TemplateLayout) {
if ($uiState.uiUnlocked)
return;
const updateTemplate = (modal: ModalData) => {
const state = get(modal.state);
layout.template.metadata.title = state.name || layout.template.metadata.title
@@ -94,6 +96,23 @@
}
}
const deleteTemplate = (modal: ModalData) => {
if (!confirm("Are you sure you want to delete this template?"))
return false;
try {
if (templateState.remove(layout.template.id)) {
notify("Template deleted!", { type: "success" })
}
else {
notify("Failed to delete template: not saved to local storage.", { type: "warning" })
}
}
catch (error) {
notify(`Failed to delete template: ${error}`, { type: "error", timeout: 10000 })
}
}
const downloadTemplate = (modal: ModalData) => {
updateTemplate(modal);
const svg = embedTemplateInSvg(layout.template);
@@ -120,6 +139,11 @@
onClick: downloadTemplate,
closeOnClick: false
},
{
name: "Delete",
variant: "secondary",
onClick: deleteTemplate
},
{
name: "Close",
variant: "secondary",