Pre-define all resources, with shops as parents of tools
This commit is contained in:
parent
000cd56039
commit
730776620a
@ -4,17 +4,62 @@ import resourceTimeGridPlugin from '@fullcalendar/resource-timegrid';
|
||||
|
||||
import { unique_colors } from 'unique-colors';
|
||||
|
||||
const calendars: { [key: string]: string } = {
|
||||
computer_lab: '6mmjp85e4732ru6skf1dda54ls@group.calendar.google.com',
|
||||
electronics: '1g8atbdschshrg2inf162rcqt4@group.calendar.google.com',
|
||||
wood_shop: '4unv3ia1n9mc9u31n2n5lv8nd8@group.calendar.google.com',
|
||||
fiber_arts_studio: '7gbndciog37ge0hd8ug33ml70k@group.calendar.google.com',
|
||||
jewelry_studio: 'l0dl2jq3vhbi9f4lfmaf5negc0@group.calendar.google.com',
|
||||
metal_shop: 'a4p97kiiafatqdr52c3a0cpre0@group.calendar.google.com',
|
||||
room_reservations: 'f4ro53uklj2u6pr0se7ucskm6g@group.calendar.google.com',
|
||||
interface Shop {
|
||||
calendar?: string;
|
||||
children?: string[];
|
||||
}
|
||||
|
||||
const shops: { [key: string]: Shop } = {
|
||||
Cafe: {}, // same calendar as mezzanine
|
||||
'Classroom / Computer Lab': {
|
||||
calendar: '6mmjp85e4732ru6skf1dda54ls@group.calendar.google.com',
|
||||
children: ['Printer, Canon iPF8400S 44" 8-Color/Pigment'],
|
||||
},
|
||||
'Digital Fabrication and Electronics Lab': {
|
||||
calendar: '1g8atbdschshrg2inf162rcqt4@group.calendar.google.com',
|
||||
children: [
|
||||
'3d printer, Lulzbot Taz 6',
|
||||
'3d printer, Lulzbot Mini',
|
||||
'Laser Cutter, GLS Hybrid',
|
||||
],
|
||||
},
|
||||
'Fiber Arts Studio': {
|
||||
calendar: '7gbndciog37ge0hd8ug33ml70k@group.calendar.google.com',
|
||||
children: ['Mid Arm, Brother DQLT15'],
|
||||
},
|
||||
'Jewelry Studio': {
|
||||
calendar: 'l0dl2jq3vhbi9f4lfmaf5negc0@group.calendar.google.com',
|
||||
},
|
||||
'Metal Shop': {
|
||||
calendar: 'a4p97kiiafatqdr52c3a0cpre0@group.calendar.google.com',
|
||||
children: [
|
||||
'Plasma Cutter, Hypertherm Powermax85',
|
||||
'MIG Welder, Miller 210',
|
||||
],
|
||||
},
|
||||
Mezzanine: {
|
||||
calendar: 'f4ro53uklj2u6pr0se7ucskm6g@group.calendar.google.com',
|
||||
},
|
||||
'Wood Shop': {
|
||||
calendar: '4unv3ia1n9mc9u31n2n5lv8nd8@group.calendar.google.com',
|
||||
children: [
|
||||
'ShopBot, PRSstandard 96-48-8, w/2.2hp Spindle',
|
||||
'Table Saw, SawStop 3HP 10"',
|
||||
'Planer, Powermatic 20"',
|
||||
'Jointer, Powermatic 8"',
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
const colors: string[] = unique_colors(Object.keys(calendars).length);
|
||||
function extract_calendars(shops: { [key: string]: Shop }): string[] {
|
||||
return Object.values(shops)
|
||||
.map((shop) => shop.calendar)
|
||||
.filter((calendar) => calendar !== undefined) as string[];
|
||||
}
|
||||
|
||||
const calendars: string[] = extract_calendars(shops);
|
||||
|
||||
const colors: string[] = unique_colors(calendars.length);
|
||||
|
||||
export const common_calendarOptions: CalendarOptions = {
|
||||
schedulerLicenseKey: 'CC-Attribution-NonCommercial-NoDerivatives',
|
||||
@ -41,6 +86,18 @@ export const common_calendarOptions: CalendarOptions = {
|
||||
minute: '2-digit',
|
||||
hour12: false,
|
||||
},
|
||||
resources: Object.entries(shops).map(([shop, tools]) => {
|
||||
return {
|
||||
id: shop,
|
||||
title: shop,
|
||||
children: tools.children?.map((tool) => {
|
||||
return {
|
||||
id: tool,
|
||||
title: tool,
|
||||
};
|
||||
}),
|
||||
};
|
||||
}),
|
||||
};
|
||||
|
||||
export function main(
|
||||
@ -49,7 +106,7 @@ export function main(
|
||||
) {
|
||||
const calendarEl = document.getElementById('calendar');
|
||||
const calendar = new Calendar(calendarEl!, calendarOptions);
|
||||
Object.values(calendars).forEach((id, idx) =>
|
||||
calendars.forEach((id, idx) =>
|
||||
calendar.addEventSource({
|
||||
url: '/calendar/ical/' + id + '/public/basic.ics',
|
||||
format: 'ics',
|
||||
@ -64,9 +121,11 @@ export function main(
|
||||
eventData.title = `${member}`;
|
||||
eventData.resourceId = tool;
|
||||
if (allTools) {
|
||||
if (!calendar.getResourceById(tool)) {
|
||||
calendar.addResource({ id: tool, title: tool }, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
return eventData;
|
||||
},
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user