Files
klz-cables.com/scripts/debug-dashboard-variants.ts

83 lines
2.5 KiB
TypeScript

import { createDirectus, rest, authentication, readDashboards, createDashboard, createPanel } from '@directus/sdk';
async function debugVariants() {
const url = 'http://localhost:8059';
const email = 'marc@mintel.me';
const password = 'Tim300493.';
console.log(`🚀 creating Debug Variants Dashboard: ${url}`);
const client = createDirectus(url).with(authentication('json')).with(rest());
try {
await client.login(email, password);
console.log('✅ Authenticated');
const dashboard = await client.request(createDashboard({
name: 'Debug List Variants',
icon: 'bug_report',
color: '#FF0000'
}));
// Variant 1: No Template
await client.request(createPanel({
dashboard: dashboard.id,
name: 'No Template',
type: 'list',
width: 8, height: 8, position_x: 0, position_y: 0,
options: {
collection: 'visual_feedback',
fields: ['text'],
limit: 5
}
}));
// Variant 2: Simple Template {{text}}
await client.request(createPanel({
dashboard: dashboard.id,
name: 'Simple {{text}}',
type: 'list',
width: 8, height: 8, position_x: 8, position_y: 0,
options: {
collection: 'visual_feedback',
template: '{{text}}',
limit: 5
}
}));
// Variant 3: Spaced Template {{ text }}
await client.request(createPanel({
dashboard: dashboard.id,
name: 'Spaced {{ text }}',
type: 'list',
width: 8, height: 8, position_x: 16, position_y: 0,
options: {
collection: 'visual_feedback',
template: '{{ text }}',
limit: 5
}
}));
// Variant 4: With fields array AND template
await client.request(createPanel({
dashboard: dashboard.id,
name: 'Fields + Template',
type: 'list',
width: 8, height: 8, position_x: 0, position_y: 8,
options: {
collection: 'visual_feedback',
fields: ['text', 'user_name'],
template: '{{user_name}}: {{text}}',
limit: 5
}
}));
console.log('✅ Debug Dashboard Created');
} catch (e: any) {
console.error('❌ Creation failed:');
console.error(e.message);
}
}
debugVariants();