Compare commits

..

No commits in common. "b8ce38ce71ffa7a0aae8d43594e812273775adab" and "78f07ca745b10331de84532e927764856454ca59" have entirely different histories.

10 changed files with 11118 additions and 3957 deletions

1
.gitignore vendored
View File

@ -1,4 +1,3 @@
/node_modules/ /node_modules/
/.cache/ /.cache/
/dist/ /dist/
/.log/

View File

@ -1 +0,0 @@
pnpm-lock.yaml

View File

@ -1,9 +1,7 @@
module.exports = { module.exports = {
plugins: ['@babel/plugin-transform-runtime'], plugins: ['@babel/plugin-transform-runtime'],
presets: [ presets: [
[ ['@babel/preset-env', {
'@babel/preset-env',
{
useBuiltIns: 'usage', useBuiltIns: 'usage',
corejs: 3, corejs: 3,
}, },

11047
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,7 @@
{ {
"browserslist": [ "browserslist": [
"defaults", "defaults",
"ios 8.4", "ios 8.4"
"ios 5.1"
], ],
"scripts": { "scripts": {
"start": "npm run serve", "start": "npm run serve",
@ -10,26 +9,26 @@
"serve": "webpack serve" "serve": "webpack serve"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.18.6", "@babel/core": "^7.16.0",
"@babel/plugin-transform-runtime": "^7.18.6", "@babel/plugin-transform-runtime": "^7.16.0",
"@babel/preset-env": "^7.18.6", "@babel/preset-env": "^7.16.0",
"@types/intl": "^1.2.0", "@types/intl": "^1.2.0",
"babel-loader": "^8.2.5", "babel-loader": "^8.2.3",
"css-loader": "^6.7.1", "css-loader": "^6.5.1",
"file-loader": "^6.2.0", "file-loader": "^6.2.0",
"style-loader": "^3.3.1", "style-loader": "^3.3.1",
"ts-loader": "^9.3.1", "ts-loader": "^9.2.6",
"typescript": "^4.7.4", "typescript": "^4.2.3",
"webpack": "^5.73.0", "webpack": "^5.64.0",
"webpack-cli": "^4.10.0", "webpack-cli": "^4.9.1",
"webpack-dev-server": "^4.9.2" "webpack-dev-server": "^4.4.0"
}, },
"dependencies": { "dependencies": {
"@babel/runtime": "^7.18.6", "@fullcalendar/core": "^5.10.0",
"@fullcalendar/core": "^5.11.0", "@fullcalendar/icalendar": "^5.10.1",
"@fullcalendar/icalendar": "^5.11.0", "@fullcalendar/resource-timegrid": "^5.10.1",
"@fullcalendar/resource-timegrid": "^5.11.0", "core-js": "^3.19.1",
"core-js": "^3.23.3", "ical.js": "github:ekreative/ical.js#var-ical",
"intl": "^1.2.5", "intl": "^1.2.5",
"unique-colors": "^1.0.1" "unique-colors": "^1.0.1"
} }

File diff suppressed because it is too large Load Diff

View File

@ -11,7 +11,7 @@
} }
.fc .fc-timegrid-now-indicator-line { .fc .fc-timegrid-now-indicator-line {
border-color: rgba(255, 0, 0, 0.4); border-color: rgba(255, 0, 0, .4);
border-top-width: 1px; border-top-width: 1px;
border-top-color: red; border-top-color: red;
border-bottom-width: 9px; border-bottom-width: 9px;

View File

@ -1,11 +1,13 @@
import 'core-js/stable/url'; // TODO: could probably be a dynamic import
import 'core-js/stable/function'; import intl from 'intl';
import Intl from 'intl';
import 'intl/locale-data/jsonp/en.js'; import 'intl/locale-data/jsonp/en.js';
window.Intl = Intl;
import { Calendar, CalendarOptions } from '@fullcalendar/core'; if (!window.Intl) {
// No `Intl`, so use and load the polyfill.
window.Intl = intl;
}
import { EventInput, Calendar, CalendarOptions } from '@fullcalendar/core';
import iCalendarPlugin from '@fullcalendar/icalendar'; import iCalendarPlugin from '@fullcalendar/icalendar';
import resourceTimeGridPlugin from '@fullcalendar/resource-timegrid'; import resourceTimeGridPlugin from '@fullcalendar/resource-timegrid';
@ -29,6 +31,22 @@ const colors: string[] = unique_colors(Object.keys(calendars).length);
const urlParams = new URLSearchParams(window.location.search); const urlParams = new URLSearchParams(window.location.search);
const toolFilter: string[] | undefined = urlParams.get('tool')?.split(';'); const toolFilter: string[] | undefined = urlParams.get('tool')?.split(';');
function eventDataTransform(eventData: EventInput): EventInput {
// clear the url to prevent clicking on the event
delete eventData.url;
const match = eventData?.title?.match(/([^\/]*) \| ([^-]*) - (.*)/);
if (match) {
const [, member, shop, tool] = match;
eventData.title = `${member}`;
eventData.resourceId = tool;
if (!toolFilter) {
calendar.addResource({ id: tool, title: tool }, false);
}
}
return eventData;
}
const calendarOptions: CalendarOptions = { const calendarOptions: CalendarOptions = {
schedulerLicenseKey: 'CC-Attribution-NonCommercial-NoDerivatives', schedulerLicenseKey: 'CC-Attribution-NonCommercial-NoDerivatives',
plugins: [iCalendarPlugin, resourceTimeGridPlugin], plugins: [iCalendarPlugin, resourceTimeGridPlugin],
@ -44,6 +62,14 @@ const calendarOptions: CalendarOptions = {
startTime: '10:00', startTime: '10:00',
endTime: '21:00', endTime: '21:00',
}, },
eventSources: Object.values(calendars).map((id, idx) => {
return {
url: '/calendar/ical/' + id + '/public/basic.ics',
format: 'ics',
color: colors[idx],
eventDataTransform: eventDataTransform,
};
}),
slotLabelFormat: { slotLabelFormat: {
hour: 'numeric', hour: 'numeric',
minute: '2-digit', minute: '2-digit',
@ -64,41 +90,15 @@ const calendarOptions: CalendarOptions = {
: [], : [],
}; };
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.values(calendars).forEach((id, idx) =>
calendar.addEventSource({
url: '/calendar/ical/' + id + '/public/basic.ics',
format: 'ics',
color: colors[idx],
eventDataTransform: (eventData) => {
// clear the url to prevent clicking on the event
delete eventData.url;
const match = eventData?.title?.match(/([^\/]*) \| ([^-]*) - (.*)/); calendar.render();
if (match) {
const [, member, shop, tool] = match;
eventData.title = `${member}`;
eventData.resourceId = tool;
if (!toolFilter) {
calendar.addResource({ id: tool, title: tool }, false);
}
}
return eventData;
},
})
);
calendar.render(); function refresh() {
calendar.refetchEvents();
function refresh() { calendar.today();
calendar.refetchEvents();
calendar.today();
}
// refresh data every five minutes
window.setInterval(refresh, 5 * 60 * 1000);
} }
main(); // refresh data every five minutes
window.setInterval(refresh, 5 * 60 * 1000);

1
src/intl.d.ts vendored
View File

@ -1 +0,0 @@
declare module 'intl/locale-data/jsonp/en.js';

View File

@ -11,7 +11,7 @@ module.exports = {
}, },
}, },
}, },
devtool: 'source-map', devtool: "eval-cheap-source-map",
module: { module: {
rules: [ rules: [
{ {
@ -22,19 +22,27 @@ module.exports = {
{ {
test: /\.tsx?$/, test: /\.tsx?$/,
exclude: /node_modules/, exclude: /node_modules/,
use: ['babel-loader', 'ts-loader'], use: [
'babel-loader',
{
loader: 'ts-loader',
options: {
appendTsSuffixTo: [/\.vue$/],
},
}
],
}, },
{ {
test: /\.css$/i, test: /\.css$/i,
use: ['style-loader', 'css-loader'], use: ["style-loader", "css-loader"],
}, },
{ {
test: /\/index.html$/i, test: /\/index.html$/i,
use: { use: {
loader: 'file-loader', loader: "file-loader",
options: { options: {
name: '[name].[ext]', name: '[name].[ext]',
}, }
}, },
}, },
], ],