|
|
@ -1,6 +1,7 @@
|
|
|
|
import _ from 'lodash'
|
|
|
|
import _ from 'lodash'
|
|
|
|
import { render } from 'preact'
|
|
|
|
import { render } from 'preact'
|
|
|
|
import { useEffect, useState } from 'preact/hooks'
|
|
|
|
import { useEffect, useState } from 'preact/hooks'
|
|
|
|
|
|
|
|
import { differenceInMinutes, startOfDay } from 'date-fns'
|
|
|
|
|
|
|
|
|
|
|
|
// import { ToolOverlay } from './components/ToolOverlay.jsx'
|
|
|
|
// import { ToolOverlay } from './components/ToolOverlay.jsx'
|
|
|
|
//
|
|
|
|
//
|
|
|
@ -18,12 +19,7 @@ import { Icon } from './components/Icon.jsx'
|
|
|
|
import { Popup } from './components/Popup.jsx'
|
|
|
|
import { Popup } from './components/Popup.jsx'
|
|
|
|
import { Toolbar } from './components/Toolbar.jsx'
|
|
|
|
import { Toolbar } from './components/Toolbar.jsx'
|
|
|
|
import { OptionBar } from './components/OptionBar.jsx'
|
|
|
|
import { OptionBar } from './components/OptionBar.jsx'
|
|
|
|
import {
|
|
|
|
import { prettyAulaName, prettyProfName, usePersistentState } from './utils.jsx'
|
|
|
|
prettyAulaName,
|
|
|
|
|
|
|
|
prettyProfName,
|
|
|
|
|
|
|
|
clearOldPersistentStates,
|
|
|
|
|
|
|
|
usePersistentState,
|
|
|
|
|
|
|
|
} from './utils.jsx'
|
|
|
|
|
|
|
|
import { SettingsBar } from './components/SettingsBar.jsx'
|
|
|
|
import { SettingsBar } from './components/SettingsBar.jsx'
|
|
|
|
|
|
|
|
|
|
|
|
// Che fanno queste due righe?
|
|
|
|
// Che fanno queste due righe?
|
|
|
@ -67,11 +63,14 @@ function specialEventPatches(eventi) {
|
|
|
|
|
|
|
|
|
|
|
|
function formatEvents(timetable) {
|
|
|
|
function formatEvents(timetable) {
|
|
|
|
return timetable.map(({ nome, dataInizio, dataFine, docenti, aule }) => {
|
|
|
|
return timetable.map(({ nome, dataInizio, dataFine, docenti, aule }) => {
|
|
|
|
|
|
|
|
const start = new Date(dataInizio)
|
|
|
|
|
|
|
|
const end = new Date(dataFine)
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
id: nome,
|
|
|
|
id: nome,
|
|
|
|
name: _.split(nome, '-', 1)[0].trim(),
|
|
|
|
name: _.split(nome, '-', 1)[0].trim(),
|
|
|
|
start: new Date(dataInizio),
|
|
|
|
day: start.getDay(),
|
|
|
|
end: new Date(dataFine),
|
|
|
|
start: differenceInMinutes(start, startOfDay(start)),
|
|
|
|
|
|
|
|
end: differenceInMinutes(end, startOfDay(start)),
|
|
|
|
docenti: docenti.map(({ nome, cognome }) =>
|
|
|
|
docenti: docenti.map(({ nome, cognome }) =>
|
|
|
|
prettyProfName(nome, cognome)
|
|
|
|
prettyProfName(nome, cognome)
|
|
|
|
),
|
|
|
|
),
|
|
|
@ -142,19 +141,50 @@ async function loadCalendari(date) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const View = ({ view, selection, setSelection, timetables }) => {
|
|
|
|
const View = ({
|
|
|
|
|
|
|
|
view,
|
|
|
|
|
|
|
|
selection,
|
|
|
|
|
|
|
|
setSelection,
|
|
|
|
|
|
|
|
timetables,
|
|
|
|
|
|
|
|
custom,
|
|
|
|
|
|
|
|
setCustom,
|
|
|
|
|
|
|
|
}) => {
|
|
|
|
if (view === 'orario') {
|
|
|
|
if (view === 'orario') {
|
|
|
|
return <Schedule selection={selection} timetables={timetables} />
|
|
|
|
return (
|
|
|
|
|
|
|
|
<Schedule
|
|
|
|
|
|
|
|
selection={selection}
|
|
|
|
|
|
|
|
timetables={timetables}
|
|
|
|
|
|
|
|
custom={custom}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
)
|
|
|
|
} else if (view === 'lista') {
|
|
|
|
} else if (view === 'lista') {
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<Courses
|
|
|
|
<Courses
|
|
|
|
selection={selection}
|
|
|
|
selection={selection}
|
|
|
|
setSelection={setSelection}
|
|
|
|
setSelection={setSelection}
|
|
|
|
source={'tutti'}
|
|
|
|
|
|
|
|
timetables={timetables}
|
|
|
|
timetables={timetables}
|
|
|
|
hideOtherCourses={true}
|
|
|
|
custom={custom}
|
|
|
|
|
|
|
|
isRestrictedList={true}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
} else if (view === 'custom') {
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
|
|
<div class="custom-events-view">
|
|
|
|
|
|
|
|
<textarea
|
|
|
|
|
|
|
|
value={custom}
|
|
|
|
|
|
|
|
onChange={e => setCustom(e.target.value)}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
<p>Esempio di evento personalizzato</p>
|
|
|
|
|
|
|
|
<p>
|
|
|
|
|
|
|
|
Nome evento [label globale]:
|
|
|
|
|
|
|
|
<br />
|
|
|
|
|
|
|
|
- Lun 9-11
|
|
|
|
|
|
|
|
<br />
|
|
|
|
|
|
|
|
- Mar 9:00-11:00
|
|
|
|
|
|
|
|
<br />- Gio 8:00-12:00 [label locale]
|
|
|
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<Courses
|
|
|
|
<Courses
|
|
|
@ -162,7 +192,7 @@ const View = ({ view, selection, setSelection, timetables }) => {
|
|
|
|
setSelection={setSelection}
|
|
|
|
setSelection={setSelection}
|
|
|
|
source={view}
|
|
|
|
source={view}
|
|
|
|
timetables={timetables}
|
|
|
|
timetables={timetables}
|
|
|
|
hideOtherCourses={false}
|
|
|
|
isRestrictedList={false}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -184,15 +214,15 @@ const App = ({}) => {
|
|
|
|
setTimetables(await loadCalendari(new Date(date)))
|
|
|
|
setTimetables(await loadCalendari(new Date(date)))
|
|
|
|
}, [date])
|
|
|
|
}, [date])
|
|
|
|
|
|
|
|
|
|
|
|
// View Modes
|
|
|
|
|
|
|
|
// const [mode, setMode] = usePersistentState('orario.mode', MODE_COURSES)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Selection
|
|
|
|
// Selection
|
|
|
|
const [selectedCourses, setSelectedCourses] = usePersistentState(
|
|
|
|
const [selectedCourses, setSelectedCourses] = usePersistentState(
|
|
|
|
'selection',
|
|
|
|
'selection',
|
|
|
|
[]
|
|
|
|
[]
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Custom Events
|
|
|
|
|
|
|
|
const [custom, setCustom] = usePersistentState('custom', [])
|
|
|
|
|
|
|
|
|
|
|
|
// Menus
|
|
|
|
// Menus
|
|
|
|
const [helpVisible, setHelpVisible] = useState(false)
|
|
|
|
const [helpVisible, setHelpVisible] = useState(false)
|
|
|
|
const [showMobileMenu, setShowMobileMenu] = useState(false)
|
|
|
|
const [showMobileMenu, setShowMobileMenu] = useState(false)
|
|
|
@ -281,6 +311,8 @@ const App = ({}) => {
|
|
|
|
setSelection={setSelectedCourses}
|
|
|
|
setSelection={setSelectedCourses}
|
|
|
|
view={view}
|
|
|
|
view={view}
|
|
|
|
timetables={timetables}
|
|
|
|
timetables={timetables}
|
|
|
|
|
|
|
|
custom={custom}
|
|
|
|
|
|
|
|
setCustom={setCustom}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
))}
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|