Files
klz-cables.com/scripts/add-status-panel.ts

40 lines
1.3 KiB
TypeScript

import { createDirectus, rest, authentication, createPanel, readDashboards } from '@directus/sdk';
async function addStatusPanel() {
const url = 'http://localhost:8059';
const email = 'marc@mintel.me';
const password = 'Tim300493.';
console.log(`🚀 Adding Status Panel: ${url}`);
const client = createDirectus(url).with(authentication('json')).with(rest());
try {
await client.login(email, password);
console.log('✅ Authenticated');
const dashboards = await client.request(readDashboards({ filter: { name: { _eq: 'Feedback Operational Intelligence' } } }));
const db = dashboards[0];
if (db) {
await client.request(createPanel({
dashboard: db.id,
name: 'Dashboard Status: LIVE',
type: 'label',
width: 24, height: 2, position_x: 0, position_y: 24,
options: {
text: '### ✅ Dashboard Rendering Service Active\n\nIf you see this, the system is online and updated as of ' + new Date().toISOString()
}
}));
console.log('✅ Status Panel Added');
} else {
console.error('❌ Dashboard not found');
}
} catch (e: any) {
console.error('❌ Failed:');
console.error(e.message);
}
}
addStatusPanel();