-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from PCS-Poli-USP/develop
Develop
- Loading branch information
Showing
46 changed files
with
2,290 additions
and
274 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
npm run build | ||
scp -P 2222 -r ./build/ ubuntu@200.144.244.245:/diskb/home/USPolis-Admin-Frontend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{ | ||
"proxy": "", | ||
"name": "uspolis-admin", | ||
"version": "0.1.0", | ||
"private": true, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
import { | ||
Button, | ||
List, | ||
ListItem, | ||
ListIcon, | ||
Modal, | ||
ModalOverlay, | ||
ModalContent, | ||
ModalHeader, | ||
ModalFooter, | ||
ModalBody, | ||
ModalCloseButton, | ||
useDisclosure, | ||
Alert, | ||
AlertIcon, | ||
} from '@chakra-ui/react'; | ||
|
||
import { DownloadIcon, CalendarIcon } from '@chakra-ui/icons'; | ||
import Dialog from '../common/dialog.component'; | ||
import { useState } from 'react'; | ||
|
||
interface AllocationOptionsProps { | ||
isOpen: boolean; | ||
hasError: boolean; | ||
onLoad: () => void; | ||
onNew: () => void; | ||
onClose: () => void; | ||
} | ||
|
||
export default function AllocationOptions({ | ||
isOpen, | ||
hasError, | ||
onLoad, | ||
onNew, | ||
onClose, | ||
}: AllocationOptionsProps) { | ||
const { | ||
isOpen: isOpenAllocDialog, | ||
onOpen: onOpenAllocDialog, | ||
onClose: onCloseAllocDialog, | ||
} = useDisclosure(); | ||
|
||
const [isLoading, setIsLoading] = useState(false); | ||
|
||
function handleAllocClick() { | ||
onOpenAllocDialog(); | ||
} | ||
|
||
function handleAllocConfirm() { | ||
onCloseAllocDialog(); | ||
if (isLoading) onLoad(); | ||
else onNew(); | ||
} | ||
|
||
return ( | ||
<Modal isOpen={isOpen} onClose={onClose} size={'xl'}> | ||
<ModalOverlay /> | ||
<ModalContent> | ||
<ModalHeader>Alocação Automática</ModalHeader> | ||
<ModalCloseButton /> | ||
<ModalBody> | ||
<Dialog | ||
isOpen={isOpenAllocDialog} | ||
onClose={onCloseAllocDialog} | ||
onConfirm={handleAllocConfirm} | ||
title={ | ||
isLoading | ||
? 'Deseja recuperar a última alocação feita para as turmas e salas cadastradas' | ||
: 'Deseja calcular uma alocação para as turmas e salas cadastradas' | ||
} | ||
warningText='ATENÇÃO: AO CONFIRMAR QUALQUER ALOCAÇÃO SALVA SERÁ PERDIDA' | ||
/> | ||
<List spacing={3}> | ||
<ListItem> | ||
<ListIcon as={DownloadIcon} /> | ||
Recuperar a última alocação | ||
</ListItem> | ||
<ListItem> | ||
<ListIcon as={CalendarIcon} /> | ||
Fazer uma nova alocação | ||
</ListItem> | ||
</List> | ||
{hasError ? ( | ||
<Alert status={'error'} mt={4}> | ||
<AlertIcon /> | ||
Não há alocação para recuperar, faça uma alocação antes! | ||
</Alert> | ||
) : undefined} | ||
</ModalBody> | ||
|
||
<ModalFooter> | ||
<Button | ||
colorScheme='blue' | ||
mr={3} | ||
leftIcon={<DownloadIcon />} | ||
onClick={() => { | ||
setIsLoading(true); | ||
handleAllocClick(); | ||
}} | ||
> | ||
Recuperar | ||
</Button> | ||
<Button | ||
colorScheme='blue' | ||
mr={3} | ||
leftIcon={<CalendarIcon />} | ||
onClick={() => { | ||
setIsLoading(false); | ||
handleAllocClick(); | ||
}} | ||
> | ||
Fazer | ||
</Button> | ||
<Button colorScheme='blue' mr={3} onClick={onClose}> | ||
Fechar | ||
</Button> | ||
</ModalFooter> | ||
</ModalContent> | ||
</Modal> | ||
); | ||
} |
162 changes: 162 additions & 0 deletions
162
src/components/allocation/automaticAllocation.accordion.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
import { | ||
Accordion, | ||
AccordionItem, | ||
AccordionButton, | ||
AccordionPanel, | ||
AccordionIcon, | ||
Box, | ||
Button, | ||
HStack, | ||
Link, | ||
Text, | ||
} from '@chakra-ui/react'; | ||
import { CalendarIcon } from '@chakra-ui/icons'; | ||
import { BsBookHalf, BsHouseFill, BsFillPenFill } from 'react-icons/bs'; | ||
|
||
import Classroom from 'models/classroom.model'; | ||
import Event from 'models/event.model'; | ||
|
||
import { useEffect, useState } from 'react'; | ||
import { weekDaysFormatter } from 'utils/classes/classes.formatter'; | ||
import ClassroomsService from 'services/classrooms.service'; | ||
import { sortClassrooms, sortEventsByClassroomAndTime } from 'utils/sorter'; | ||
|
||
interface AutomaticAllocationAccordionProps { | ||
onEdit: (event: Event) => void; | ||
allocated: Event[]; | ||
unallocated: Event[]; | ||
} | ||
|
||
export default function AutomaticAllocationAccordion({ | ||
onEdit, | ||
allocated, | ||
unallocated, | ||
}: AutomaticAllocationAccordionProps) { | ||
const classroomService = new ClassroomsService(); | ||
const [classrooms, setClassrooms] = useState<Classroom[]>([]); | ||
const [allocatedEvents, setAllocatedEvents] = useState<Event[]>([]); | ||
const [unallocatedEvents, setUnallocatedEvents] = useState<Event[]>([]); | ||
|
||
useEffect(() => { | ||
if (classrooms.length <= 0) fetchClassrooms(); | ||
if (allocated) setAllocatedEvents(allocated); | ||
if (unallocated) setUnallocatedEvents(unallocated); | ||
}, [classrooms, allocated, unallocated]); | ||
|
||
function fetchClassrooms() { | ||
classroomService.list().then((it) => { | ||
it.data.sort(sortClassrooms); | ||
setClassrooms(it.data); | ||
}); | ||
} | ||
|
||
allocatedEvents.sort(sortEventsByClassroomAndTime); | ||
unallocatedEvents.sort(sortEventsByClassroomAndTime); | ||
|
||
return ( | ||
<Accordion | ||
defaultIndex={unallocated && unallocated.length > 0 ? [1] : [0]} | ||
allowMultiple={true} | ||
> | ||
<AccordionItem> | ||
<AccordionButton | ||
bg={'uspolis.blue'} | ||
color={'blackAlpha.900'} | ||
fontWeight={'bold'} | ||
> | ||
<Box as='span' flex='1' textAlign='left'> | ||
Turmas Alocadas | ||
</Box> | ||
<AccordionIcon /> | ||
</AccordionButton> | ||
<AccordionPanel pb={4}> | ||
{allocatedEvents.map((value, index) => ( | ||
<HStack spacing={3} key={index}> | ||
<BsBookHalf /> | ||
<Text>{`${value.subject_code} - ${value.class_code}, ${value.vacancies} vagas`}</Text> | ||
<CalendarIcon /> | ||
<Text>{`${weekDaysFormatter(value.week_day)}, ${ | ||
value.start_time | ||
} às ${value.end_time}`}</Text> | ||
<BsHouseFill /> | ||
<Text>{`${value.classroom}`}</Text> | ||
<Button | ||
leftIcon={<BsFillPenFill />} | ||
variant={'ghost'} | ||
size={'sm'} | ||
onClick={() => onEdit(value)} | ||
> | ||
Editar | ||
</Button> | ||
</HStack> | ||
))} | ||
</AccordionPanel> | ||
</AccordionItem> | ||
|
||
{unallocatedEvents.length > 0 ? ( | ||
<AccordionItem> | ||
<AccordionButton bg={'red.500'} color={'black'} fontWeight={'bold'}> | ||
<Box as='span' flex='1' textAlign='left'> | ||
Turmas Não Alocadas | ||
</Box> | ||
<AccordionIcon /> | ||
</AccordionButton> | ||
<AccordionPanel pb={4}> | ||
{unallocatedEvents.map((value, index) => ( | ||
<HStack spacing={3} key={index}> | ||
<BsBookHalf /> | ||
<Text>{`${value.subject_code} - ${value.class_code}, ${value.vacancies} vagas`}</Text> | ||
<CalendarIcon /> | ||
<Text>{`${weekDaysFormatter(value.week_day)}, ${ | ||
value.start_time | ||
} às ${value.end_time}`}</Text> | ||
<Button | ||
leftIcon={<BsFillPenFill />} | ||
variant={'ghost'} | ||
size={'sm'} | ||
onClick={() => onEdit(value)} | ||
> | ||
Editar | ||
</Button> | ||
</HStack> | ||
))} | ||
</AccordionPanel> | ||
</AccordionItem> | ||
) : undefined} | ||
|
||
<AccordionItem> | ||
<AccordionButton | ||
bg={'uspolis.blue'} | ||
color={'blackAlpha.900'} | ||
fontWeight={'bold'} | ||
> | ||
<Box as='span' flex='1' textAlign='left'> | ||
Salas cadastradas | ||
</Box> | ||
<AccordionIcon /> | ||
</AccordionButton> | ||
<AccordionPanel pb={4}> | ||
{classrooms.length > 0 ? ( | ||
classrooms.map((value, index) => ( | ||
<HStack spacing={3} key={index}> | ||
<BsHouseFill /> | ||
{value.ignore_to_allocate ? ( | ||
<Text> | ||
{`${value.classroom_name} - ${value.capacity} capacidade (Ignorada)`} | ||
</Text> | ||
) : ( | ||
<Text>{`${value.classroom_name} - ${value.capacity} capacidade`}</Text> | ||
)} | ||
</HStack> | ||
)) | ||
) : ( | ||
<Text> | ||
Sem salas cadastradas, ir para{' '} | ||
<Link href='/classrooms'>criação de salas</Link> | ||
</Text> | ||
)} | ||
</AccordionPanel> | ||
</AccordionItem> | ||
</Accordion> | ||
); | ||
} |
Oops, something went wrong.