From b8aefa4c58d41cb26e0d4d2f4d13274b4e469998 Mon Sep 17 00:00:00 2001
From: Mateus Vieira <68292695+mateusvrs@users.noreply.github.com>
Date: Sun, 10 Dec 2023 12:11:32 -0300
Subject: [PATCH] =?UTF-8?q?task(front):=20cria=20p=C3=A1gina=20de=20cria?=
=?UTF-8?q?=C3=A7=C3=A3o=20de=20grades=20com=20funcionalidades=20propostas?=
=?UTF-8?q?=20(#157)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* web(components): cria modal flutuante padrão
Co-authored-by: Arthur Ribeiro
* web(context): disponibilização das grades p/app
* web(comp): versão básica do botão de gerar grades
* web(api): integração com a geração de grades
* web(schedules): versão simples da grade horária
Co-authored-by: Arthur Ribeiro
* web(fix): fix the bug of info page
* web(comp): arruma nome do setModal
* web(comp): define v1 da mostragem de grade
* web(contexts): personaliza set de grades do user
* web(mygrades): adiciona test index 0 p
* web(api): remove import desnecessário
* web(tailwind): adiciona nova cor snow
* web(fix): changing the modal and schedule base colors
* web(icons): add icons for upload, download, delete
* web(modal): rm context desnecessário
* web(comps): adiciona estado de preview ao schedule
* web(schedules): muda layout pra p[a]
* fix(app): lógica correta p/atualização de grades
* web(schedules): add fnc remover grades locais
* web(styles): deixa scroll bar mais fina no chrome
* web(comp): cria um set de profs únicos pmostrar
* task(frontend): trás as modificações da api para salvamento de grade para continuidade da criação do flow layout (#152)
* task(schedule/save): criar a rota de salvamento de grade p/usuários autênticados (#144)
* api(save-schedule): Created models and url path.
- Still working on views
* api(models): add migrations para o modelo d/grades
* api(urls): arruma rota da view de salvamento
* api(views): organiza imports por grupos de lib
Co-authored-by: GabrielCastelo-31
Co-authored-by: Caio
Co-authored-by: Arthur Ribeiro
* api(settings): desliga adição de slash
Co-authored-by: GabrielCastelo-31
Co-authored-by: Caio
Co-authored-by: Arthur Ribeiro
* api(utils): funcs p/salvar grade horária no db
Co-authored-by: GabrielCastelo-31
Co-authored-by: Caio
Co-authored-by: Arthur Ribeiro
* api(views): modulariza views em uma pasta separada
Co-authored-by: GabrielCastelo-31
Co-authored-by: Caio
Co-authored-by: Arthur Ribeiro
* api(views): fnc p/verificar e salvar grade do user
Co-authored-by: GabrielCastelo-31
Co-authored-by: Caio
Co-authored-by: Arthur Ribeiro
* api(urls): adição da view nas rotas e no admin
Co-authored-by: GabrielCastelo-31
Co-authored-by: Caio
Co-authored-by: Arthur Ribeiro
* api(settings): definição da auth padrão do swagger
Co-authored-by: GabrielCastelo-31
Co-authored-by: Caio
Co-authored-by: Arthur Ribeiro
* api(views): correção do parm status de retorno da
* api(utils): add linha de no cover p/tests
* refactor(api): add espaço entre classe e função
* tests(api): verifica as fnc do salvamento de grade
- Tests para os casos de sucesso e erro do salvamento de grade
- Verificação da models e do método __str__ da grade
* refactor(views): tenta diminuir cog complexidade
* refactor(views): diminui cog complexidade
- A função de gerar estava com uma complexidade alta
assim foi necessário refatorar para diminuir a complexidade
* api(admin): deixa json bonito na pág admin
* api(views): adiciona validador de request body
* tests(api): verifica os casos de body incorreto
* refactor(api/views): diminui cog complexidade
* refactor(api): reduz cong complexidade do checker
* refactor(api): modulariza validade class func
---------
Co-authored-by: GabrielCastelo-31
Co-authored-by: Caio
Co-authored-by: Arthur Ribeiro
* task(frontend): alteração do ícone da volta para tela de login (#147)
* frontend(feature): criação da nova página de informações para usuários
* frontend(fixxing): ajustando tamanho do ícone de informação
* frontend(feature): add information page for new users
* web(info): organiza layout dos colaboradores
* web(info): adição da descrição de utilização do site.
* web(info): modulariza página de informações
* fix(web): fix information page for new users
* web(icons): add icons for google and search
* web(icon): mudando o icone da volta para o home
* web(icon): add search icon to the search bar
* web(fixing): fixing search icon alt text
---------
Co-authored-by: mateuvrs
Co-authored-by: Mateus Vieira <68292695+mateusvrs@users.noreply.github.com>
* models(schedules): add created_at field
* serializers(schedules): add serializer for schedule
* api(urls): add get_schedules endpoint
* models(migrations): make migrations
* api(schedules): add get schedules api
* utils(db_handler): add get_schedule function
* api(test): make tests for get schedule api
---------
Co-authored-by: GabrielCastelo-31
Co-authored-by: Caio
Co-authored-by: Arthur Ribeiro
Co-authored-by: Arthur Ribeiro <109052099+artrsousa1@users.noreply.github.com>
* Squashed commit of the following:
commit 25375c9254917cde6e7262326c11167c4eebb4b2
Author: Caio Felipe
Date: Fri Dec 8 17:29:50 2023 -0300
task(delete-schedule): deleta grades do usuário e altera rotas (#151)
* utils(db-handler): add delete_schedule function
* api(delete-schedules): delete schedule endpoint
* test(deleteschedule): add test for delete schedule
* test(delete-schedule): add test for invalid token
* Delete api/api/tests/test_schedules_api.py
* django(api): rename and delete useless files
* api(urls): update urls
* utils(test): update test urls
* api(save_schedule): remove auth save_schedule
* api(views): add schedule view
* api(views): rename view generate schedule
* fix(typo): nome da classe p/ testar delete
---------
Co-authored-by: Mateus Vieira <68292695+mateusvrs@users.noreply.github.com>
commit 16813aba93d0ddf2e59fbd0288e182c7ad7814fd
Merge: d39a16d 610c520
Author: Caio Felipe
Date: Thu Dec 7 23:38:43 2023 -0300
Merge pull request #149 from unb-mds/task/get-schedule
task(get-schedule): Cria API para obtenção de grades do usuário
commit 610c520530642e2ddad59d29ed3ab03e33fcc719
Author: Caio
Date: Thu Dec 7 23:14:08 2023 -0300
api(test): make tests for get schedule api
commit fe4dee55eb356d98933344e5a4d7c19b6424fc8c
Author: Caio
Date: Thu Dec 7 22:34:30 2023 -0300
utils(db_handler): add get_schedule function
commit d4b15057a8736328d45ab2601a55cd85946ad2b0
Author: Caio
Date: Thu Dec 7 22:33:57 2023 -0300
api(schedules): add get schedules api
commit 492c0decc22322b768a27c649ae2820b4ef4a672
Author: Caio
Date: Thu Dec 7 22:33:38 2023 -0300
models(migrations): make migrations
commit 67ed0ee9b26d29fb2d939cc2838fa49f3657871b
Author: Caio
Date: Thu Dec 7 22:28:20 2023 -0300
api(urls): add get_schedules endpoint
commit 9b754ced794c0eb9965ca4b22e85d7d1cbd71bf4
Author: Caio
Date: Thu Dec 7 22:27:59 2023 -0300
serializers(schedules): add serializer for schedule
commit e028f6dcede671c5590c75803bc0d1be3a43daca
Author: Caio
Date: Thu Dec 7 22:27:43 2023 -0300
models(schedules): add created_at field
commit d39a16d05310b5f1ceabac12666beb6a0d30de6a
Author: Arthur Ribeiro <109052099+artrsousa1@users.noreply.github.com>
Date: Thu Dec 7 22:18:30 2023 -0300
task(frontend): alteração do ícone da volta para tela de login (#147)
* frontend(feature): criação da nova página de informações para usuários
* frontend(fixxing): ajustando tamanho do ícone de informação
* frontend(feature): add information page for new users
* web(info): organiza layout dos colaboradores
* web(info): adição da descrição de utilização do site.
* web(info): modulariza página de informações
* fix(web): fix information page for new users
* web(icons): add icons for google and search
* web(icon): mudando o icone da volta para o home
* web(icon): add search icon to the search bar
* web(fixing): fixing search icon alt text
---------
Co-authored-by: mateuvrs
Co-authored-by: Mateus Vieira <68292695+mateusvrs@users.noreply.github.com>
commit 39c7d1a43b2bf38cb3391905346c942292aa04b3
Author: Mateus Vieira <68292695+mateusvrs@users.noreply.github.com>
Date: Thu Dec 7 21:05:46 2023 -0300
task(schedule/save): criar a rota de salvamento de grade p/usuários autênticados (#144)
* api(save-schedule): Created models and url path.
- Still working on views
* api(models): add migrations para o modelo d/grades
* api(urls): arruma rota da view de salvamento
* api(views): organiza imports por grupos de lib
Co-authored-by: GabrielCastelo-31
Co-authored-by: Caio
Co-authored-by: Arthur Ribeiro
* api(settings): desliga adição de slash
Co-authored-by: GabrielCastelo-31
Co-authored-by: Caio
Co-authored-by: Arthur Ribeiro
* api(utils): funcs p/salvar grade horária no db
Co-authored-by: GabrielCastelo-31
Co-authored-by: Caio
Co-authored-by: Arthur Ribeiro
* api(views): modulariza views em uma pasta separada
Co-authored-by: GabrielCastelo-31
Co-authored-by: Caio
Co-authored-by: Arthur Ribeiro
* api(views): fnc p/verificar e salvar grade do user
Co-authored-by: GabrielCastelo-31
Co-authored-by: Caio
Co-authored-by: Arthur Ribeiro
* api(urls): adição da view nas rotas e no admin
Co-authored-by: GabrielCastelo-31
Co-authored-by: Caio
Co-authored-by: Arthur Ribeiro
* api(settings): definição da auth padrão do swagger
Co-authored-by: GabrielCastelo-31
Co-authored-by: Caio
Co-authored-by: Arthur Ribeiro
* api(views): correção do parm status de retorno da
* api(utils): add linha de no cover p/tests
* refactor(api): add espaço entre classe e função
* tests(api): verifica as fnc do salvamento de grade
- Tests para os casos de sucesso e erro do salvamento de grade
- Verificação da models e do método __str__ da grade
* refactor(views): tenta diminuir cog complexidade
* refactor(views): diminui cog complexidade
- A função de gerar estava com uma complexidade alta
assim foi necessário refatorar para diminuir a complexidade
* api(admin): deixa json bonito na pág admin
* api(views): adiciona validador de request body
* tests(api): verifica os casos de body incorreto
* refactor(api/views): diminui cog complexidade
* refactor(api): reduz cong complexidade do checker
* refactor(api): modulariza validade class func
---------
Co-authored-by: GabrielCastelo-31
Co-authored-by: Caio
Co-authored-by: Arthur Ribeiro
* web(comp): rm unicidade de professores
* web(comps): add fnc de upload p/cloud
* web(utils): reorganiza datas e meses separados
* web(api): generate schedule request fnc
* web(api): get schedule request fnc com api
* web(api): fnc p/salvar grade no cloud
* web(utils): fnc p/request com auth
* web(contexts): add fnc de deletar grade da nuvem
* web(comps): func de fazer download grade com pdf
* refactor(app): arrumar erros de layout e ui/ux
* web(tailwind): adiciona font mono p/datas
* web(icons): adiciona expand_less/expand_more
* fix(front): arruma funçao do LayoutJSX
* web(fix): fixing LayoutJSX function cognitive complexity
* web(fix): improving MyGrades function
* web(fix): fix generate schedule function
* web(fix): fixing codeclimate issues
* fix(mygrades): export incorreto não utilizado
* refactor(comps): reduz cog complexidade do preview
* refactor(comps): reduz linhas de código
Co-authored-by: Arthur Ribeiro
* fix(pdf): deixa download mais responsivo e ideal
Co-authored-by: Arthur Ribeiro
* web(app): coloca index correto nas grades
---------
Co-authored-by: Arthur Ribeiro
Co-authored-by: GabrielCastelo-31
Co-authored-by: Caio
Co-authored-by: Arthur Ribeiro <109052099+artrsousa1@users.noreply.github.com>
---
api/api/views/get_schedules.py | 32 +++
api/utils/db_handler.py | 4 +-
.../AsideSchedulePopUp/DisciplineFragment.tsx | 9 +-
.../components/AsideSchedulePopUp/Tooltip.tsx | 10 +-
web/app/components/ClassInfo.tsx | 51 ++--
web/app/components/InfoHeader.tsx | 3 +-
web/app/components/Modal/Modal.tsx | 23 ++
web/app/components/Schedule/Schedule.tsx | 141 +++++++++++
.../SchedulePreview/SchedulePreview.tsx | 223 ++++++++++++++++++
web/app/contexts/SchedulesContext.tsx | 82 +++++++
web/app/contexts/UserContext.tsx | 17 ++
web/app/globals.css | 4 +-
web/app/hooks/useSchedules.ts | 10 +
web/app/layout.tsx | 34 ++-
.../components/GenerateScheduleButton.tsx | 28 ++-
web/app/schedules/info/page.tsx | 8 +-
web/app/schedules/layout.tsx | 10 +-
web/app/schedules/mygrades/page.tsx | 50 +++-
web/app/schedules/profile/page.tsx | 40 +++-
web/app/utils/api/deleteSchedule.ts | 11 +
web/app/utils/api/generateSchedule.ts | 20 ++
web/app/utils/api/getSchedules.ts | 8 +
web/app/utils/api/saveSchedule.ts | 10 +
web/app/utils/dates.ts | 2 +
web/app/utils/settingsWithAuth.ts | 11 +
web/package-lock.json | 188 ++++++++++++++-
web/package.json | 1 +
web/public/icons/delete.jpg | Bin 0 -> 289 bytes
web/public/icons/download.jpg | Bin 0 -> 295 bytes
web/public/icons/expand_less.png | Bin 0 -> 217 bytes
web/public/icons/expand_more.png | Bin 0 -> 190 bytes
web/public/icons/upload.jpg | Bin 0 -> 420 bytes
web/tailwind.config.ts | 2 +
web/tsconfig.json | 23 +-
34 files changed, 979 insertions(+), 76 deletions(-)
create mode 100644 api/api/views/get_schedules.py
create mode 100644 web/app/components/Modal/Modal.tsx
create mode 100644 web/app/components/Schedule/Schedule.tsx
create mode 100644 web/app/components/SchedulePreview/SchedulePreview.tsx
create mode 100644 web/app/contexts/SchedulesContext.tsx
create mode 100644 web/app/hooks/useSchedules.ts
create mode 100644 web/app/utils/api/deleteSchedule.ts
create mode 100644 web/app/utils/api/generateSchedule.ts
create mode 100644 web/app/utils/api/getSchedules.ts
create mode 100644 web/app/utils/api/saveSchedule.ts
create mode 100644 web/app/utils/dates.ts
create mode 100644 web/app/utils/settingsWithAuth.ts
create mode 100644 web/public/icons/delete.jpg
create mode 100644 web/public/icons/download.jpg
create mode 100644 web/public/icons/expand_less.png
create mode 100644 web/public/icons/expand_more.png
create mode 100644 web/public/icons/upload.jpg
diff --git a/api/api/views/get_schedules.py b/api/api/views/get_schedules.py
new file mode 100644
index 00000000..08cd0df8
--- /dev/null
+++ b/api/api/views/get_schedules.py
@@ -0,0 +1,32 @@
+from drf_yasg.utils import swagger_auto_schema
+from drf_yasg import openapi
+
+from rest_framework.views import APIView
+from rest_framework.permissions import IsAuthenticated
+from rest_framework import status, request, response
+
+from api.swagger import Errors
+from api.serializers import ScheduleSerializer
+
+from utils.db_handler import get_schedules
+
+class GetSchedules(APIView):
+
+ permission_classes = [IsAuthenticated]
+
+ @swagger_auto_schema(
+ operation_description="Retorna as grades horárias do usuário logado.",
+ security=[{'Bearer': []}],
+ responses={
+ 200: openapi.Response('OK', ScheduleSerializer(many=True)),
+ **Errors([401, 403]).retrieve_erros()
+ }
+ )
+ def get(self, request: request.Request) -> response.Response:
+ """Retorna as grades horárias do usuário logado."""
+
+ user = request.user
+ schedules = get_schedules(user)
+ data = ScheduleSerializer(schedules, many=True).data
+
+ return response.Response(status=status.HTTP_200_OK, data=data)
\ No newline at end of file
diff --git a/api/utils/db_handler.py b/api/utils/db_handler.py
index 2fbd2a54..1779b8ce 100644
--- a/api/utils/db_handler.py
+++ b/api/utils/db_handler.py
@@ -111,5 +111,5 @@ def delete_schedule(user: User, id: int) -> bool:
Schedule.objects.get(user=user, id=id).delete()
except Schedule.DoesNotExist:
return False
-
- return True
\ No newline at end of file
+
+ return True
diff --git a/web/app/components/AsideSchedulePopUp/DisciplineFragment.tsx b/web/app/components/AsideSchedulePopUp/DisciplineFragment.tsx
index 96af9441..9478c922 100644
--- a/web/app/components/AsideSchedulePopUp/DisciplineFragment.tsx
+++ b/web/app/components/AsideSchedulePopUp/DisciplineFragment.tsx
@@ -1,8 +1,11 @@
import { Fragment } from 'react';
+import Image from 'next/image';
+import ClassInfoBox from './ClassInfoBox';
import { ClassType, DisciplineType } from '@/app/utils/api/searchDiscipline';
-import ClassInfoBox from './ClassInfoBox';
+import expand_more from '@/public/icons/expand_more.png';
+import expand_less from '@/public/icons/expand_less.png';
interface DisciplineFragmentPropsType {
index: number,
@@ -26,9 +29,7 @@ function DisciplineFragmentJSX({ handleDisciplineToggle, ...props }: {
onClick={() => handleDisciplineToggle(index)}
className='flex items-center gap-3'
>
-
- {discipline.expanded ? 'expand_less' : 'expand_more'}
-
+ {discipline.name} - {discipline.code}
{discipline.expanded &&
diff --git a/web/app/components/AsideSchedulePopUp/Tooltip.tsx b/web/app/components/AsideSchedulePopUp/Tooltip.tsx
index 8da937ca..e2aed464 100644
--- a/web/app/components/AsideSchedulePopUp/Tooltip.tsx
+++ b/web/app/components/AsideSchedulePopUp/Tooltip.tsx
@@ -9,6 +9,10 @@ interface TooltipPropsType {
children: React.ReactNode,
};
+export const isMobile = (width?: number) => {
+ return width && width <= 768;
+};
+
export default function Tooltip({ children }: TooltipPropsType) {
const [active, setActive] = useState(false);
const { width } = useWindowDimensions();
@@ -25,10 +29,6 @@ export default function Tooltip({ children }: TooltipPropsType) {
};
}, [active]);
- const isMobile = () => {
- return width && width <= 768;
- };
-
return (
Na página inicial, clique no botão Buscar Matéria para selecionar as disciplinas desejadas para a sua grade. Escolha o ano/período e insira o nome da disciplina para poder optar por turmas potenciais na criação da grade, permitindo a escolha de até quatro turmas para cada disciplina.
-
Após fazer suas escolhas, clique no botão Gerar Grade e defina a prioridade dos turnos que melhor se adequam à sua rotina. Em seguida, basta escolher a grade mais adequada entre as opções geradas para realizar o download e/ou salvar as disciplinas escolhidas.
-
Compartilhe suas experiências e sugestões. O aplicativo está em constante desenvolvimento, e seu feedback é valioso para aprimorar a experiência de todos os usuários.
-
+
Na página inicial, clique no botão Buscar Matéria para selecionar as disciplinas desejadas para a sua grade. Escolha o ano/período e insira o nome da disciplina para poder optar por turmas potenciais na criação da grade, permitindo a escolha de até quatro turmas para cada disciplina.
+
Após fazer suas escolhas, clique no botão Gerar Grade e defina a prioridade dos turnos que melhor se adequam à sua rotina. Em seguida, basta escolher a grade mais adequada entre as opções geradas para realizar o download e/ou salvar as disciplinas escolhidas.
+
Compartilhe suas experiências e sugestões. O aplicativo está em constante desenvolvimento, e seu feedback é valioso para aprimorar a experiência de todos os usuários.