Compare commits

..

4 Commits

Author SHA1 Message Date
ef009b2d0e wall-display: Add an error modal for event fetching errors 2022-12-10 16:44:43 -05:00
084f398d41 Add a loading spinner to wall-display
Spinner GIF derived from https://loading.io/, using `apng2gif` to get
correct transparency behavior
2022-12-10 16:33:27 -05:00
cf0127c5a8 Bump dependencies 2022-12-10 12:43:22 -05:00
91d729eaf0 Use asset module instead of file-loader for html files in webpack 2022-12-10 12:20:16 -05:00
8 changed files with 747 additions and 751 deletions

View File

@ -10,31 +10,30 @@
"serve": "webpack serve"
},
"devDependencies": {
"@babel/core": "^7.19.3",
"@babel/plugin-transform-runtime": "^7.19.1",
"@babel/preset-env": "^7.19.3",
"@babel/core": "^7.20.5",
"@babel/plugin-transform-runtime": "^7.19.6",
"@babel/preset-env": "^7.20.2",
"@types/intl": "^1.2.0",
"babel-loader": "^8.2.5",
"css-loader": "^6.7.1",
"file-loader": "^6.2.0",
"babel-loader": "^9.1.0",
"css-loader": "^6.7.2",
"style-loader": "^3.3.1",
"ts-loader": "^9.4.1",
"typescript": "^4.8.4",
"webpack": "^5.74.0",
"webpack-cli": "^4.10.0",
"ts-loader": "^9.4.2",
"typescript": "^4.9.4",
"webpack": "^5.75.0",
"webpack-cli": "^5.0.1",
"webpack-dev-server": "^4.11.1"
},
"dependencies": {
"@babel/runtime": "^7.19.0",
"@babel/runtime": "^7.20.6",
"@fullcalendar/core": "^5.11.3",
"@fullcalendar/icalendar": "^5.11.3",
"@fullcalendar/resource-common": "^5.11.3",
"@fullcalendar/resource-timegrid": "^5.11.3",
"@fullcalendar/resource-timeline": "^5.11.3",
"@fullcalendar/timegrid": "^5.11.3",
"core-js": "^3.25.5",
"core-js": "^3.26.1",
"intl": "^1.2.5",
"preact": "^10.11.1",
"preact": "^10.11.3",
"unique-colors": "^1.0.1"
}
}

1388
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

BIN
src/DejaVuSans.ttf Normal file

Binary file not shown.

BIN
src/loading.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

41
src/modal.css Normal file
View File

@ -0,0 +1,41 @@
@font-face {
font-family: 'DejaVu Sans';
src: local('DejaVu Sans'), url(./DejaVuSans.ttf);
}
.modal {
position: fixed;
z-index: 99;
top: 0;
left: 0;
width: 100%;
height: 100%;
text-align: center;
}
.modal:before {
content: '';
display: inline-block;
height: 100%;
vertical-align: middle;
}
.modal-content {
display: inline-block;
vertical-align: middle;
}
#loadingSpinner {
background-image: url(./loading.gif);
background-repeat: no-repeat;
background-position: center;
}
#errorModal {
background-color: rgba(200, 200, 200, 0.6);
}
.modal-icon {
font-size: 10em;
font-family: 'DejaVu Sans';
}

View File

@ -7,6 +7,13 @@
<title>Tool Reservations</title>
</head>
<body>
<div class="modal" id="loadingSpinner"></div>
<div class="modal" id="errorModal">
<div class="modal-content">
<div class="modal-icon">&#9888;</div>
<div class="modal-message"></div>
</div>
</div>
<div id="calendar"></div>
<script src="bundle-wall-display.js"></script>
</body>

View File

@ -10,6 +10,7 @@ import { CalendarOptions } from '@fullcalendar/core';
import { common_calendarOptions, main } from './common';
import './wall-display.html';
import './modal.css';
import './ios-fixes.css';
document.body.addEventListener('touchmove', (e) => e.preventDefault(), {
@ -29,6 +30,30 @@ const calendarOptions: CalendarOptions = {
};
})
: [],
eventSourceFailure(error: { message: string }) {
console.error('Error fetching events', error);
const errorModal = document.getElementById('errorModal');
if (errorModal) {
errorModal.style.display = '';
const message = errorModal.querySelector('.modal-message');
if (message) {
message.textContent = `Failed to fetch events: ${error.message}. Displayed events may not be accurate.`;
}
}
},
loading(isLoading: boolean) {
if (isLoading) {
const errorModal = document.getElementById('errorModal');
if (errorModal) {
errorModal.style.display = 'none';
}
}
const spinner = document.getElementById('loadingSpinner');
if (spinner) {
spinner.style.display = isLoading ? '' : 'none';
}
},
};
const calendar = main(calendarOptions, !toolFilter);

View File

@ -4,17 +4,19 @@ const common = {
mode: 'development',
module: {
rules: [
{
test: /\.(png|jpg|gif|svg|eot|ttf|woff)$/,
type: 'asset/resource',
},
{
test: /\.css$/i,
use: ['style-loader', 'css-loader'],
},
{
test: /\.html$/i,
use: {
loader: 'file-loader',
options: {
name: '[name].[ext]',
},
type: 'asset/resource',
generator: {
filename: '[name][ext]',
},
},
],