This commit is contained in:
Mateusz Gruszczyński
2026-09-18 23:57:28 +02:00
parent 00cbe975bb
commit be3708f14d
17 changed files with 424 additions and 83 deletions
+12 -1
View File
@@ -731,6 +731,17 @@ function flowSourcePayload() {
};
}
function flowExportSharedInputs() {
if (!app.flowDraft) return [];
const ids = new Set((app.flowDraft.nodes || [])
.filter(node => node.kind === 'shared_input')
.map(node => node.config?.input_id)
.filter(Boolean));
return (app.flowSharedInputs || [])
.filter(item => ids.has(item.id))
.map(item => JSON.parse(JSON.stringify(item)));
}
function downloadJsonFile(filename, data) {
const blob = new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' });
const url = URL.createObjectURL(blob); const a = document.createElement('a');
@@ -743,7 +754,7 @@ async function exportFlow() {
try {
const envelope = app.flowDraft.id && !app.flowDirty
? await api(`/api/flows/${encodeURIComponent(app.flowDraft.id)}/export`)
: { format: 'gree-controller-flow', version: 1, exported_at: new Date().toISOString(), flow: flowSourcePayload() };
: { format: 'gree-controller-flow', version: 1, exported_at: new Date().toISOString(), shared_inputs: flowExportSharedInputs(), flow: flowSourcePayload() };
const safe = (flowSourcePayload()?.name || 'flow').replace(/[^a-z0-9_-]+/gi, '-').replace(/^-+|-+$/g, '').toLowerCase() || 'flow';
downloadJsonFile(`${safe}.flow.json`, envelope); toast(tr('flow.exported'));
} catch (error) { toast(error.message, true); }