Compare commits

...

2 Commits

3 changed files with 73 additions and 59 deletions

View File

@ -3,59 +3,14 @@ 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);
export const common_calendarOptions: CalendarOptions = {
schedulerLicenseKey: 'CC-Attribution-NonCommercial-NoDerivatives',
plugins: [iCalendarPlugin, resourceTimeGridPlugin],
@ -82,7 +37,15 @@ export const common_calendarOptions: CalendarOptions = {
minute: '2-digit',
hour12: false,
},
resources: Object.entries(shops).map(([shop_name, shop]) => {
};
export function main(
calendarOptions: CalendarOptions,
showNewTools: boolean = false,
shops: { [key: string]: Shop } = ALL_SHOPS
) {
const calendarEl = document.getElementById('calendar');
calendarOptions.resources = Object.entries(shops).map(([shop_name, shop]) => {
return {
id: shop_name,
title: shop_name,
@ -96,15 +59,10 @@ export const common_calendarOptions: CalendarOptions = {
};
}),
};
}),
};
export function main(
calendarOptions: CalendarOptions,
allTools: boolean = false
) {
const calendarEl = document.getElementById('calendar');
});
const calendar = new Calendar(calendarEl!, calendarOptions);
const colors: string[] = unique_colors(Object.keys(shops).length);
Object.entries(shops)
.filter(([shop_name, shop]) => shop.calendar !== undefined)
.forEach(([shop_name, shop], idx) => {
@ -125,7 +83,7 @@ export function main(
// assume any event not for a specific tool is for the shop as a whole
eventData.resourceId = shop_name;
}
if (allTools) {
if (showNewTools) {
if (!calendar.getResourceById(eventData.resourceId)) {
calendar.addResource(
{ id: eventData.resourceId, title: eventData.resourceId },

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\""
]
}
}

View File

@ -1,6 +1,6 @@
import type { CalendarOptions } from '@fullcalendar/core';
import { common_calendarOptions, main } from './common';
import { ALL_SHOPS, common_calendarOptions, main } from './common';
import './wall-display.html';
import './modal.css';
@ -61,7 +61,19 @@ const calendarOptions: CalendarOptions = {
},
};
const calendar = main(calendarOptions, !toolFilter);
const calendar = main(
calendarOptions,
!toolFilter,
toolFilter
? Object.fromEntries(
Object.entries(ALL_SHOPS).filter(
([shop_name, shop]) =>
toolFilter.includes(shop_name) ||
shop.children?.some((t) => toolFilter.includes(t))
)
)
: ALL_SHOPS
);
function refresh() {
calendar.refetchEvents();