Move shops definition to json file
This commit is contained in:
parent
cb3f5c350f
commit
ec92effe91
@ -3,58 +3,15 @@ import iCalendarPlugin from '@fullcalendar/icalendar';
|
|||||||
import resourceTimeGridPlugin from '@fullcalendar/resource-timegrid';
|
import resourceTimeGridPlugin from '@fullcalendar/resource-timegrid';
|
||||||
|
|
||||||
import { unique_colors } from 'unique-colors';
|
import { unique_colors } from 'unique-colors';
|
||||||
|
import _ALL_SHOPS from './shops.json';
|
||||||
|
export const ALL_SHOPS: { [key: string]: Shop } = _ALL_SHOPS;
|
||||||
|
|
||||||
interface Shop {
|
interface Shop {
|
||||||
calendar?: string;
|
calendar?: string;
|
||||||
children?: string[];
|
children?: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
const shops: { [key: string]: Shop } = {
|
const colors: string[] = unique_colors(Object.keys(ALL_SHOPS).length);
|
||||||
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);
|
|
||||||
|
|
||||||
export const common_calendarOptions: CalendarOptions = {
|
export const common_calendarOptions: CalendarOptions = {
|
||||||
schedulerLicenseKey: 'CC-Attribution-NonCommercial-NoDerivatives',
|
schedulerLicenseKey: 'CC-Attribution-NonCommercial-NoDerivatives',
|
||||||
@ -82,7 +39,7 @@ export const common_calendarOptions: CalendarOptions = {
|
|||||||
minute: '2-digit',
|
minute: '2-digit',
|
||||||
hour12: false,
|
hour12: false,
|
||||||
},
|
},
|
||||||
resources: Object.entries(shops).map(([shop_name, shop]) => {
|
resources: Object.entries(ALL_SHOPS).map(([shop_name, shop]) => {
|
||||||
return {
|
return {
|
||||||
id: shop_name,
|
id: shop_name,
|
||||||
title: shop_name,
|
title: shop_name,
|
||||||
@ -105,7 +62,7 @@ export function main(
|
|||||||
) {
|
) {
|
||||||
const calendarEl = document.getElementById('calendar');
|
const calendarEl = document.getElementById('calendar');
|
||||||
const calendar = new Calendar(calendarEl!, calendarOptions);
|
const calendar = new Calendar(calendarEl!, calendarOptions);
|
||||||
Object.entries(shops)
|
Object.entries(ALL_SHOPS)
|
||||||
.filter(([shop_name, shop]) => shop.calendar !== undefined)
|
.filter(([shop_name, shop]) => shop.calendar !== undefined)
|
||||||
.forEach(([shop_name, shop], idx) => {
|
.forEach(([shop_name, shop], idx) => {
|
||||||
calendar.addEventSource({
|
calendar.addEventSource({
|
||||||
|
44
src/shops.json
Normal file
44
src/shops.json
Normal 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\""
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user