-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathapp.vue
353 lines (328 loc) · 9.99 KB
/
app.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
<template>
<div class="view-container">
<Background ref="background" />
<DateAndHourHeader />
<Lundi
v-if="Object.keys(views).includes('lundi')"
:isActive="currentView == 'lundi'"
/>
<Mardi
v-if="Object.keys(views).includes('mardi')"
:isActive="currentView == 'mardi'"
/>
<Mercredi
v-if="Object.keys(views).includes('mercredi')"
:isActive="currentView == 'mercredi'"
/>
<Jeudi
v-if="Object.keys(views).includes('jeudi')"
:isActive="currentView == 'jeudi'"
/>
<Vendredi
v-if="Object.keys(views).includes('vendredi')"
:isActive="currentView == 'vendredi'"
/>
<Menus
v-if="Object.keys(views).includes('menus')"
:isActive="currentView == 'menus'"
/>
<Planning
v-if="Object.keys(views).includes('planning')"
:isActive="currentView == 'planning'"
/>
<client-only>
<Transport
v-if="Object.keys(views).includes('transport')"
:isActive="currentView == 'transport'"
/>
<Weather
v-if="Object.keys(views).includes('weather')"
:isActive="currentView == 'weather'"
/>
</client-only>
<Discord
v-if="Object.keys(views).includes('discord')"
:isActive="currentView == 'discord'"
/>
<MaintainerProposal
v-if="Object.keys(views).includes('maintainer')"
:isActive="currentView == 'maintainer'"
/>
<Announcement
v-if="Object.keys(views).includes('announcement')"
:isActive="currentView == 'announcement'"
/>
<Announcement2
v-if="Object.keys(views).includes('announcement')"
:isActive="currentView == 'announcement2'"
/>
<TeacherAnnouncement
v-if="Object.keys(views).includes('tannouncement')"
:isActive="currentView == 'tannouncement'"
/>
<WelcomeAmericans
v-if="Object.keys(views).includes('welcAmericans')"
:isActive="currentView == 'welcAmericans'"
/>
<LoadingBar :view="views[currentView]" />
<TransitionOverlay ref="loading" />
</div>
</template>
<script>
import DateAndHourHeader from "./components/DateHourHeader.vue";
import TransitionOverlay from "./components/TransitionOverlay.vue";
import Background from "./components/Background.vue";
import LoadingBar from "./components/LoadingBar.vue";
import Menus from "./views/Menus.vue";
import Transport from "./views/Transport.vue";
import Weather from "./views/Weather.vue";
import Planning from "./views/NextPlannings.vue";
import Discord from "./views/Discord.vue";
import MaintainerProposal from "./views/MaintainerProposal.vue";
import "./stylesheets/reset.css";
import Announcement from "./views/Announcement.vue";
import Announcement2 from "./views/Announcement2.vue";
import TeacherAnnouncement from "./views/TeacherAnnouncement.vue";
import WelcomeAmericans from "./views/WelcomeMessage.vue";
import Lundi from "./views/Lundi.vue";
import Mardi from "./views/Mardi.vue";
import Mercredi from "./views/Mercredi.vue";
import Jeudi from "./views/Jeudi.vue";
import Vendredi from "./views/Vendredi.vue";
const DEVELOPEMENT_MODE = false;
export default {
data() {
return {
currentView: "planning",
views: {
/*
To active only one or some views, juste comment here what you dont want to be
displayed.
If only one view is uncommented, the slide show will be disabled (Usefull for development).
The order in the object is the display order
*/
lundi: {
time: () => DEVELOPEMENT_MODE ? 10000 : 1000 * 7,
allowed: () => true && !this.isEndOfDay() && new Date().getDay() === 1,
},
mardi: {
time: () => DEVELOPEMENT_MODE ? 10000 : 1000 * 7,
allowed: () => true && !this.isEndOfDay() && new Date().getDay() === 2,
},
mercredi: {
time: () => DEVELOPEMENT_MODE ? 10000 : 1000 * 7,
allowed: () => true && !this.isEndOfDay() && new Date().getDay() === 3,
},
jeudi: {
time: () => DEVELOPEMENT_MODE ? 10000 : 1000 * 7,
allowed: () => true && !this.isEndOfDay() && new Date().getDay() === 4,
},
vendredi: {
time: () => DEVELOPEMENT_MODE ? 10000 : 1000 * 7,
allowed: () => true && !this.isEndOfDay() && new Date().getDay() === 5,
},
planning: {
time: () => DEVELOPEMENT_MODE ? 5000 : this.returnTimeForPlanning(),
allowed: () => {
// 6h to 17h30
const currentTime =
new Date().getHours() * 60 + new Date().getMinutes();
return currentTime >= 6 * 60 && currentTime <= 17 * 60 + 30;
}
},
transport: {
time: () => DEVELOPEMENT_MODE ? 10000 : this.getTimeForBusesAndWeather(),
allowed: () => true,
},
weather: {
time: () => DEVELOPEMENT_MODE ? 10000 : 7 * 1000,
allowed: () => true,
},
menus: {
time: () => DEVELOPEMENT_MODE ? 10000 : 1000 * 15,
allowed: () => {
// 6h to 14h
let currentHour = new Date().getHours();
return currentHour >= 6 && currentHour < 14;
},
},
/* Enable this at the start of each year (The QR code has to be updated)*/
discord: {
time: () => DEVELOPEMENT_MODE ? 10000 : 1000 * 7,
allowed: () => false,
},
/* Enable when looking for new maintainers */
maintainer: {
time: () => DEVELOPEMENT_MODE ? 10000 : 1000 * 10,
allowed: () => false && !this.isEndOfDay(),
},
announcement: {
time: () => DEVELOPEMENT_MODE ? 10000 : 1000 * 7,
allowed: () => false && !this.isEndOfDay(),
},
announcement2: {
time: () => DEVELOPEMENT_MODE ? 10000 : 1000 * 7,
allowed: () => false && !this.isEndOfDay(),
},
tannouncement: {
time: () => DEVELOPEMENT_MODE ? 10000 : 1000 * 7,
allowed: () => false && !this.isEndOfDay(),
},
welcAmericans: {
time: () => DEVELOPEMENT_MODE ? 10000 : 1000 * 7,
allowed: () => false && !this.isEndOfDay(),
}
},
};
},
methods: {
/**
* @return If the courses of the day are finished.
*/
isEndOfDay() {
const currentTime = new Date().getHours() * 60 + new Date().getMinutes();
return currentTime > (17 * 60 + 30);
},
/**
* @return the time to show the weather and transport card depending on current Hour
*/
getTimeForBusesAndWeather() {
const currentTime = new Date().getHours() * 60 + new Date().getMinutes();
if(currentTime > 17 * 60 + 30) {
return 60000;
}
return 7000;
},
/**
* @return the name of the next view that will be displayed
*/
getNextViewName() {
const viewTypes = Object.keys(this.views);
let nextView = viewTypes[viewTypes.indexOf(this.currentView) + 1];
if (nextView === undefined) nextView = viewTypes[0];
return nextView;
},
/**
* Change the actual view
*
* Will display only allowed views (Hour range is currently valid)
*/
changeView() {
this.currentView = this.getNextViewName();
if (
this.views[this.currentView].allowed() === false &&
!DEVELOPEMENT_MODE
) {
this.changeView();
return;
}
if (Object.keys(this.views).length <= 1)
//Detect we've commented all views except one
return; // (Disable slide show)
setTimeout(() => {
this.$refs.loading && this.$refs.loading.show();
this.$refs.background && this.$refs.background.next();
setTimeout(this.changeView, 200);
}, this.views[this.currentView].time());
},
/**
* Return true if the view allowed to be displayed is the Planning only
* This method is used to ensure that 5 minutes before the end of the each break only the Planning is displayed,
* and not the other views.
* @return {boolean}
*/
onlyPlanning() {
const currentHour = new Date().getHours();
const currentMinutes = new Date().getMinutes();
switch (currentHour) {
case 8:
return currentMinutes >= 10 && currentMinutes < 20;
case 10:
return currentMinutes >= 20 && currentMinutes < 30;
case 13:
return currentMinutes >= 55 && currentMinutes <= 59;
case 16:
return currentMinutes >= 5 && currentMinutes < 10;
default:
return false;
}
},
/**
* Return the time in ms before the next view is displayed (after the planning)
* @return {number}
*/
returnTimeForPlanning() {
if (this.onlyPlanning())
return 1000 * 60 * 10; // Forcing for 10 minutes
return 1000 * 10;
},
},
mounted() {
this.$refs.background && this.$refs.background.next();
this.changeView();
},
components: {
Planning,
TransitionOverlay,
Background,
Lundi,
Mardi,
Mercredi,
Jeudi,
Vendredi,
Menus,
Transport,
Weather,
DateAndHourHeader,
LoadingBar,
Discord,
MaintainerProposal,
Announcement,
Announcement2,
TeacherAnnouncement,
WelcomeAmericans,
},
};
</script>
<style>
body {
font-family: Poppins, sans-serif;
font-weight: bold;
font-size: 1.2em;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
}
.view-container {
position: absolute;
top: 0;
bottom: 0;
right: 0;
left: 0;
display: flex;
justify-content: space-evenly;
align-items: center;
flex-direction: column;
height: 100vh;
overflow: hidden; /* Hide scroll-bars */
}
.view-content {
width: 100%;
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-evenly;
}
.view-title {
margin-top: 90px;
min-width: 400px;
background-color: white;
box-shadow: 0px 1px 15px rgba(0, 0, 0, 0.25);
color: rgb(73, 72, 72);
line-height: 43px;
font-size: 37px;
font-weight: 800;
padding: 30px 50px;
border-radius: 30px;
}
</style>