v0.15.8
This commit is contained in:
+12
-1
@@ -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); }
|
||||
|
||||
Reference in New Issue
Block a user