feat: integrate feedback module
This commit is contained in:
60
scripts/final-fix.ts
Normal file
60
scripts/final-fix.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
import { createDirectus, rest, staticToken, updateCollection, createPermission, readCollections, readPermissions, createDashboard, createPanel, createItems } from '@directus/sdk';
|
||||
import { config } from '../lib/config';
|
||||
|
||||
async function finalFix() {
|
||||
const url = 'http://localhost:8059';
|
||||
const token = '59fb8f4c1a51b18fe28ad947f713914e';
|
||||
const client = createDirectus(url).with(staticToken(token)).with(rest());
|
||||
|
||||
try {
|
||||
console.log('--- 1. UPDATE COLLECTION ACCOUNTABILITY ---');
|
||||
await client.request(updateCollection('visual_feedback', {
|
||||
meta: { accountability: null }
|
||||
} as any));
|
||||
console.log('✅ Accountability set to null.');
|
||||
|
||||
console.log('\n--- 2. GRANT PUBLIC READ ---');
|
||||
// Policy ID for Public is always 'abf8a154-5b1c-4a46-ac9c-7300570f4f17' in v11 bootstrap usually,
|
||||
// but let's check first.
|
||||
try {
|
||||
await client.request(createPermission({
|
||||
policy: 'abf8a154-5b1c-4a46-ac9c-7300570f4f17',
|
||||
collection: 'visual_feedback',
|
||||
action: 'read',
|
||||
fields: ['*']
|
||||
} as any));
|
||||
console.log('✅ Public READ granted.');
|
||||
} catch (e) {
|
||||
console.log(' (Public READ might already exist)');
|
||||
}
|
||||
|
||||
console.log('\n--- 3. RECREATE DASHBOARD ---');
|
||||
const dash = await client.request(createDashboard({
|
||||
name: 'Feedback Final',
|
||||
icon: 'check_circle',
|
||||
color: '#00FF00'
|
||||
}));
|
||||
console.log(`✅ Dashboard "Feedback Final" ID: ${dash.id}`);
|
||||
|
||||
await client.request(createPanel({
|
||||
dashboard: dash.id,
|
||||
name: 'Visible Feedbacks',
|
||||
type: 'metric',
|
||||
width: 12,
|
||||
height: 6,
|
||||
position_x: 1,
|
||||
position_y: 1,
|
||||
options: { collection: 'visual_feedback', function: 'count', field: 'id' }
|
||||
} as any));
|
||||
|
||||
console.log('\n--- 4. VERIFY READ VIA TOKEN ---');
|
||||
const items = await client.request(() => ({ path: '/items/visual_feedback', method: 'GET' }));
|
||||
console.log(`✅ Items count via token: ${items.data.length}`);
|
||||
|
||||
} catch (e: any) {
|
||||
console.error('❌ Final fix failed:', e);
|
||||
if (e.errors) console.error(JSON.stringify(e.errors, null, 2));
|
||||
}
|
||||
}
|
||||
|
||||
finalFix();
|
||||
Reference in New Issue
Block a user