From ec92effe9171a0ff90ec59382de4f9e5fc205dcf Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Wed, 27 Dec 2023 11:05:22 -0500 Subject: [PATCH] Move shops definition to json file --- src/common.ts | 53 +++++--------------------------------------------- src/shops.json | 44 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 48 deletions(-) create mode 100644 src/shops.json diff --git a/src/common.ts b/src/common.ts index 96e2997..fc4e4e7 100644 --- a/src/common.ts +++ b/src/common.ts @@ -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({ diff --git a/src/shops.json b/src/shops.json new file mode 100644 index 0000000..c8e84d8 --- /dev/null +++ b/src/shops.json @@ -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\"" + ] + } +}