Renaming part 1

This commit is contained in:
Janus Knudsen 2025-08-07 00:15:44 +02:00
parent 36ac8d18ab
commit 29811fd4b5
20 changed files with 1424 additions and 582 deletions

View file

@ -1,6 +1,7 @@
import { EventBus } from '../core/EventBus';
import { IEventBus, CalendarEvent } from '../types/CalendarTypes';
import { IEventBus, CalendarEvent, ResourceCalendarData } from '../types/CalendarTypes';
import { EventTypes } from '../constants/EventTypes';
import { calendarConfig } from '../core/CalendarConfig';
/**
* EventManager - Administrerer event lifecycle og CRUD operationer
@ -11,9 +12,17 @@ export class EventManager {
private events: CalendarEvent[] = [];
constructor(eventBus: IEventBus) {
console.log('EventManager: Constructor called');
this.eventBus = eventBus;
this.setupEventListeners();
this.loadMockData();
console.log('EventManager: About to call loadMockData()');
this.loadMockData().then(() => {
console.log('EventManager: loadMockData() completed, syncing events');
// Data loaded, sync events after loading
this.syncEvents();
}).catch(error => {
console.error('EventManager: loadMockData() failed:', error);
});
}
private setupEventListeners(): void {
@ -30,189 +39,54 @@ export class EventManager {
});
}
private loadMockData(): void {
// Mock events for current week (July 27 - August 2, 2025)
this.events = [
// Sunday August 3, 2025
{
id: '1',
title: 'Weekend Planning',
start: '2025-08-03T10:00:00',
end: '2025-08-03T11:00:00',
type: 'work',
allDay: false,
syncStatus: 'synced',
metadata: { duration: 60, color: '#9c27b0' } // Purple
},
// Monday August 4, 2025
{
id: '2',
title: 'Team Standup',
start: '2025-08-04T09:00:00',
end: '2025-08-04T09:30:00',
type: 'meeting',
allDay: false,
syncStatus: 'synced',
metadata: { duration: 30, color: '#ff5722' } // Deep Orange
},
{
id: '3',
title: 'Project Kickoff',
start: '2025-08-04T14:00:00',
end: '2025-08-04T15:30:00',
type: 'meeting',
allDay: false,
syncStatus: 'synced',
metadata: { duration: 90, color: '#e91e63' } // Pink
},
// Tuesday August 5, 2025
{
id: '4',
title: 'Deep Work Session',
start: '2025-08-05T10:00:00',
end: '2025-08-05T12:00:00',
type: 'work',
allDay: false,
syncStatus: 'synced',
metadata: { duration: 120, color: '#3f51b5' } // Indigo
},
{
id: '5',
title: 'Lunch Meeting',
start: '2025-08-05T12:30:00',
end: '2025-08-05T13:30:00',
type: 'meal',
allDay: false,
syncStatus: 'synced',
metadata: { duration: 60, color: '#ff9800' } // Orange
},
// Wednesday August 6, 2025
{
id: '6',
title: 'Client Review',
start: '2025-08-06T15:00:00',
end: '2025-08-06T16:00:00',
type: 'meeting',
allDay: false,
syncStatus: 'synced',
metadata: { duration: 60, color: '#795548' } // Brown
},
// Thursday August 7, 2025
{
id: '7',
title: 'Sprint Planning',
start: '2025-08-07T09:00:00',
end: '2025-08-07T10:30:00',
type: 'meeting',
allDay: false,
syncStatus: 'synced',
metadata: { duration: 90, color: '#607d8b' } // Blue Grey
},
{
id: '8',
title: 'Code Review',
start: '2025-08-07T14:00:00',
end: '2025-08-07T15:00:00',
type: 'work',
allDay: false,
syncStatus: 'synced',
metadata: { duration: 60, color: '#009688' } // Teal
},
// Friday August 8, 2025
{
id: '9',
title: 'Team Standup',
start: '2025-08-08T09:00:00',
end: '2025-08-08T09:30:00',
type: 'meeting',
allDay: false,
syncStatus: 'synced',
metadata: { duration: 30, color: '#8bc34a' } // Light Green
},
{
id: '10',
title: 'Client Meeting',
start: '2025-08-08T14:00:00',
end: '2025-08-08T15:30:00',
type: 'meeting',
allDay: false,
syncStatus: 'synced',
metadata: { duration: 90, color: '#cddc39' } // Lime
},
// Saturday August 9, 2025
{
id: '11',
title: 'Weekend Project',
start: '2025-08-09T10:00:00',
end: '2025-08-09T12:00:00',
type: 'work',
allDay: false,
syncStatus: 'synced',
metadata: { duration: 120, color: '#f44336' } // Red
},
// Test events for early/late hours
{
id: '12',
title: 'Early Morning Workout',
start: '2025-08-05T06:00:00',
end: '2025-08-05T07:00:00',
type: 'work',
allDay: false,
syncStatus: 'synced',
metadata: { duration: 60, color: '#00bcd4' } // Cyan
},
{
id: '13',
title: 'Late Evening Call',
start: '2025-08-06T21:00:00',
end: '2025-08-06T22:00:00',
type: 'meeting',
allDay: false,
syncStatus: 'synced',
metadata: { duration: 60, color: '#673ab7' } // Deep Purple
},
{
id: '14',
title: 'Midnight Deployment',
start: '2025-08-07T23:00:00',
end: '2025-08-08T01:00:00',
type: 'work',
allDay: false,
syncStatus: 'synced',
metadata: { duration: 120, color: '#ffc107' } // Amber
},
// All-day events for demo
{
id: '15',
title: 'Company Holiday',
start: '2025-08-04T00:00:00',
end: '2025-08-05T23:59:59',
type: 'milestone',
allDay: true,
syncStatus: 'synced',
metadata: {
duration: 1440, // Full day in minutes
color: '#4caf50' // Green color
}
},
{
id: '16',
title: 'Team Building Event',
start: '2025-08-06T00:00:00',
end: '2025-08-06T23:59:59',
type: 'meeting',
allDay: true,
syncStatus: 'synced',
metadata: {
duration: 1440, // Full day in minutes
color: '#2196f3' // Blue color
}
private async loadMockData(): Promise<void> {
try {
const calendarType = calendarConfig.getCalendarType();
let jsonFile: string;
console.log(`EventManager: Calendar type detected: '${calendarType}'`);
if (calendarType === 'resource') {
jsonFile = '/src/data/mock-resource-events.json';
} else {
jsonFile = '/src/data/mock-events.json';
}
];
console.log(`EventManager: Loaded ${this.events.length} mock events`);
console.log('EventManager: First event:', this.events[0]);
console.log('EventManager: Last event:', this.events[this.events.length - 1]);
console.log(`EventManager: Loading ${calendarType} calendar data from ${jsonFile}`);
const response = await fetch(jsonFile);
if (!response.ok) {
throw new Error(`Failed to load mock events: ${response.status}`);
}
if (calendarType === 'resource') {
const resourceData: ResourceCalendarData = await response.json();
// Flatten events from all resources and add resource metadata
this.events = resourceData.resources.flatMap(resource =>
resource.events.map(event => ({
...event,
resourceName: resource.name,
resourceDisplayName: resource.displayName,
resourceEmployeeId: resource.employeeId
}))
);
console.log(`EventManager: Loaded ${this.events.length} events from ${resourceData.resources.length} resources`);
// Emit resource data for GridManager
this.eventBus.emit(EventTypes.RESOURCE_DATA_LOADED, {
resourceData: resourceData
});
} else {
this.events = await response.json();
console.log(`EventManager: Loaded ${this.events.length} date calendar events`);
}
console.log('EventManager: First event:', this.events[0]);
console.log('EventManager: Last event:', this.events[this.events.length - 1]);
} catch (error) {
console.error('EventManager: Failed to load mock events:', error);
this.events = []; // Fallback to empty array
}
}
private syncEvents(): void {