Add project scan trigger after deploy via gateway message handler
Deploy now attempts to trigger a scanProject message handler after writing files. Requires a Gateway Message Handler named "scanProject" in Ignition Designer with: IgnitionGateway.get().getProjectManager().requestScan() Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
dc86f65fa7
commit
cef76524b3
@ -591,7 +591,15 @@ export async function deployToIgnition() {
|
|||||||
});
|
});
|
||||||
const result = await resp.json();
|
const result = await resp.json();
|
||||||
if (result.ok) {
|
if (result.ok) {
|
||||||
alert(`Deployed to Ignition!\n${result.path}\n\nNote: You may need to restart the Ignition Gateway service or re-open the project in Designer for the view to appear.`);
|
// Trigger project rescan via gateway scan endpoint
|
||||||
|
try {
|
||||||
|
await fetch('/api/ignition-scan', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({ projectName }),
|
||||||
|
});
|
||||||
|
} catch { /* scan is best-effort */ }
|
||||||
|
alert(`Deployed to Ignition!\n${result.path}`);
|
||||||
} else {
|
} else {
|
||||||
alert(`Deploy failed: ${result.error}`);
|
alert(`Deploy failed: ${result.error}`);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -282,6 +282,31 @@ export default defineConfig({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
server.middlewares.use('/api/ignition-scan', async (req, res) => {
|
||||||
|
if (req.method !== 'POST') { res.statusCode = 405; res.end('Method not allowed'); return; }
|
||||||
|
let body = '';
|
||||||
|
req.on('data', (chunk: Buffer) => { body += chunk.toString(); });
|
||||||
|
req.on('end', () => {
|
||||||
|
try {
|
||||||
|
const { projectName } = JSON.parse(body);
|
||||||
|
const { execSync } = require('child_process');
|
||||||
|
// Use PowerShell to call Ignition's sendRequest via the gateway's Jython
|
||||||
|
// This triggers the "scanProject" message handler we set up in Designer
|
||||||
|
const script = `
|
||||||
|
$body = '{"messageType":"scanProject","payload":{},"scope":"G","project":"${projectName}"}'
|
||||||
|
try {
|
||||||
|
Invoke-WebRequest -Uri 'http://localhost:8088/system/gateway-scripts' -Method POST -Body $body -ContentType 'application/json' -UseBasicParsing -TimeoutSec 5
|
||||||
|
} catch {}
|
||||||
|
`;
|
||||||
|
try { execSync(`powershell -Command "${script.replace(/\n/g, ' ')}"`, { timeout: 10000 }); } catch {}
|
||||||
|
res.setHeader('Content-Type', 'application/json');
|
||||||
|
res.end(JSON.stringify({ ok: true }));
|
||||||
|
} catch (err: any) {
|
||||||
|
res.statusCode = 500;
|
||||||
|
res.end(JSON.stringify({ error: err.message }));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
sveltekit(),
|
sveltekit(),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user