Move shops definition to json file

This commit is contained in:
Adam Goldsmith 2023-12-27 11:05:22 -05:00
parent cb3f5c350f
commit ec92effe91
2 changed files with 49 additions and 48 deletions

View File

@ -3,58 +3,15 @@ import iCalendarPlugin from '@fullcalendar/icalendar';
import resourceTimeGridPlugin from '@fullcalendar/resource-timegrid';
import { unique_colors } from 'unique-colors';
import _ALL_SHOPS from './shops.json';
export const ALL_SHOPS: { [key: string]: Shop } = _ALL_SHOPS;
interface Shop {
calendar?: string;
children?: string[];
}
const shops: { [key: string]: Shop } = {
Cafe: {
calendar: 'ofbkp5ctd1hr7917sknlj9s15g@group.calendar.google.com',
},
'Conference Room': {}, // 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',
'Table Saw, SawStop 3HP 10"',
'Planer, Powermatic 20"',
'Jointer, Powermatic 8"',
],
},
};
const colors: string[] = unique_colors(Object.keys(shops).length);
const colors: string[] = unique_colors(Object.keys(ALL_SHOPS).length);
export const common_calendarOptions: CalendarOptions = {
schedulerLicenseKey: 'CC-Attribution-NonCommercial-NoDerivatives',
@ -82,7 +39,7 @@ export const common_calendarOptions: CalendarOptions = {
minute: '2-digit',
hour12: false,
},
resources: Object.entries(shops).map(([shop_name, shop]) => {
resources: Object.entries(ALL_SHOPS).map(([shop_name, shop]) => {
return {
id: shop_name,
title: shop_name,
@ -105,7 +62,7 @@ export function main(
) {
const calendarEl = document.getElementById('calendar');
const calendar = new Calendar(calendarEl!, calendarOptions);
Object.entries(shops)
Object.entries(ALL_SHOPS)
.filter(([shop_name, shop]) => shop.calendar !== undefined)
.forEach(([shop_name, shop], idx) => {
calendar.addEventSource({

44
src/shops.json Normal file
View File

@ -0,0 +1,44 @@
{
"Cafe": {
"calendar": "ofbkp5ctd1hr7917sknlj9s15g@group.calendar.google.com"
},
"Conference Room": {},
"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",
"Table Saw, SawStop 3HP 10\"",
"Planer, Powermatic 20\"",
"Jointer, Powermatic 8\""
]
}
}