kuchen diagram update
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Client, Databases, Teams, Users, ID, Permission, Role, Query } from 'node-appwrite';
|
||||
import { Client, Databases, Teams, Users, ID, Permission, Role, Query, Storage } from 'node-appwrite';
|
||||
import { readFileSync } from 'fs';
|
||||
import { resolve, dirname } from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
@@ -39,6 +39,9 @@ const client = new Client()
|
||||
const databases = new Databases(client);
|
||||
const teamsService = new Teams(client);
|
||||
const users = new Users(client);
|
||||
const storageService = new Storage(client);
|
||||
|
||||
const ATTACHMENTS_BUCKET_ID = 'defekttrack_anhaenge';
|
||||
|
||||
const TEAM_ROLES = ['admin', 'firmenleiter', 'filialleiter', 'service', 'lager'];
|
||||
|
||||
@@ -180,7 +183,7 @@ async function createAssetsCollection() {
|
||||
await databases.createStringAttribute(DATABASE_ID, COLLECTION_ID, 'zustaendig', 128, true);
|
||||
await databases.createStringAttribute(DATABASE_ID, COLLECTION_ID, 'status', 32, true);
|
||||
await databases.createStringAttribute(DATABASE_ID, COLLECTION_ID, 'prio', 16, true);
|
||||
await databases.createStringAttribute(DATABASE_ID, COLLECTION_ID, 'kommentar', 2048, false, '');
|
||||
await databases.createStringAttribute(DATABASE_ID, COLLECTION_ID, 'kommentar', 8192, false, '');
|
||||
await databases.createStringAttribute(DATABASE_ID, COLLECTION_ID, 'createdBy', 128, false, '');
|
||||
await databases.createStringAttribute(DATABASE_ID, COLLECTION_ID, 'lastEditedBy', 128, false, '');
|
||||
console.log(' Attribute fuer assets erstellt (erlNummer, seriennummer, artikelNr, bezeichnung, defekt, lagerstandortId, zustaendig, status, prio, kommentar, createdBy, lastEditedBy)');
|
||||
@@ -234,6 +237,27 @@ async function createAuditLogsCollection() {
|
||||
console.log(' Attribute fuer audit_logs erstellt (assetId, action, details, userId, userName)');
|
||||
}
|
||||
|
||||
async function createAttachmentsBucket() {
|
||||
try {
|
||||
await storageService.createBucket({
|
||||
bucketId: ATTACHMENTS_BUCKET_ID,
|
||||
name: 'DefektTrack Kommentar-Anhänge',
|
||||
permissions: [Permission.read(Role.users()), Permission.create(Role.users())],
|
||||
fileSecurity: false,
|
||||
enabled: true,
|
||||
maximumFileSize: 15 * 1024 * 1024,
|
||||
allowedFileExtensions: ['jpg', 'jpeg', 'png', 'gif', 'webp', 'pdf'],
|
||||
});
|
||||
console.log(`Storage-Bucket erstellt: ${ATTACHMENTS_BUCKET_ID}`);
|
||||
} catch (err) {
|
||||
if (err.code === 409) {
|
||||
console.log(`Storage-Bucket existiert bereits: ${ATTACHMENTS_BUCKET_ID}`);
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function createTeams() {
|
||||
for (const role of TEAM_ROLES) {
|
||||
try {
|
||||
@@ -330,6 +354,9 @@ async function main() {
|
||||
await createDatabase();
|
||||
console.log('');
|
||||
|
||||
await createAttachmentsBucket();
|
||||
console.log('');
|
||||
|
||||
await createLocationsCollection();
|
||||
console.log('');
|
||||
|
||||
@@ -361,6 +388,9 @@ async function main() {
|
||||
console.log(' Passwort: Admin1234!');
|
||||
console.log('');
|
||||
console.log('Vergiss nicht, den API-Key aus .env zu entfernen oder sicher aufzubewahren.');
|
||||
console.log('');
|
||||
console.log(`Kommentar-Anhänge: Bucket „${ATTACHMENTS_BUCKET_ID}“ — optional in .env:`);
|
||||
console.log(` VITE_APPWRITE_ATTACHMENTS_BUCKET_ID=${ATTACHMENTS_BUCKET_ID}`);
|
||||
}
|
||||
|
||||
main().catch((err) => {
|
||||
|
||||
Reference in New Issue
Block a user