Commit b4d62b64 authored by Matheus Horstmann's avatar Matheus Horstmann 🐴

Merge branch 'pages-odair' into 'develop'

Pages odair

See merge request !8
parents 760927aa 65904b0a
Pipeline #22354 failed with stages
in 56 seconds
/*
import React, { useState, useEffect } from 'react';
import './App.css';
import {Header} from './components/header/Header';
import {Toast} from './components/toast/Toast';
// import {Wizard} from './components/wizard/Wizard';
import {SimpleModal} from './components/modal/Modal';
import {CustTable} from './components/table/Table';
import Button from '@material-ui/core/Button';
import {Upload} from './pages/ensalamento.jsx';
import {GerenciarTurma} from './pages/gerenciarturma.jsx';
function createData(a, b, c, d, t,f) {
return { a, b, c, d, t, f };
}
const tmp = [
createData('Cupcake', 305, 3.7, 67, 4.3,'da'),
createData('Donut', 452, 25.0, 51, 4.9,'da'),
createData('Eclair', 262, 16.0, 24, 6.0,'da'),
createData('Frozen yoghurt', 159, 6.0, 24, 4.0,'da'),
createData('Gingerbread', 356, 16.0, 49, 3.9,'da'),
createData('Honeycomb', 408, 3.2, 87, 6.5,'da'),
createData('Ice cream sandwich', 237, 9.0, 37, 4.3,'da'),
createData('Jelly Bean', 375, 0.0, 94, 0.0,'da'),
createData('KitKat', 518, 26.0, 65, 7.0,'da'),
createData('Lollipop', 392, 0.2, 98, 0.0,'da'),
createData('Marshmallow', 318, 0, 81, 2.0,'da'),
createData('Nougat', 360, 19.0, 9, 37.0,'da'),
createData('Oreo', 437, 18.0, 63, 4.0,'da'),
];
let tmp2 = [
{ id: 'a', numeric: false, disablePadding: true, label: 'a' },
{ id: 'b', numeric: true, disablePadding: false, label: 'b' },
{ id: 'c', numeric: true, disablePadding: false, label: 'c' },
{ id: 'd', numeric: true, disablePadding: false, label: 'd' },
{ id: 't', numeric: true, disablePadding: false, label: 'tdddddd' },
{ id: 'f', numeric: true, disablePadding: false, label: 'f' },
];
const login = {
"email":"admin@admin.com",
"username":"admin",
"password":"123mudar"
}
function App() {
var [screen, setScreen] = useState(false);
var [token, setToken] = useState(null);
return (screen)? (
<div className="App">
<Header> </Header>
<Upload></Upload>
</div>
) :
( <div className="App">
<Header> </Header>
<GerenciarTurma></GerenciarTurma>
</div> ) ;
}
export default App;
*/
import React from 'react';
import './App.css';
import {Header} from './components/header/Header';
import {Toast} from './components/toast/Toast';
// import {Wizard} from './components/wizard/Wizard';
import {SimpleModal} from './components/modal/Modal';
import {CustTable} from './components/table/Table';
function createData(a, b, c, d, t,f) {
return { a, b, c, d, t, f };
}
const tmp = [
createData('Cupcake', 305, 3.7, 67, 4.3,'da'),
createData('Donut', 452, 25.0, 51, 4.9,'da'),
createData('Eclair', 262, 16.0, 24, 6.0,'da'),
createData('Frozen yoghurt', 159, 6.0, 24, 4.0,'da'),
createData('Gingerbread', 356, 16.0, 49, 3.9,'da'),
createData('Honeycomb', 408, 3.2, 87, 6.5,'da'),
createData('Ice cream sandwich', 237, 9.0, 37, 4.3,'da'),
createData('Jelly Bean', 375, 0.0, 94, 0.0,'da'),
createData('KitKat', 518, 26.0, 65, 7.0,'da'),
createData('Lollipop', 392, 0.2, 98, 0.0,'da'),
createData('Marshmallow', 318, 0, 81, 2.0,'da'),
createData('Nougat', 360, 19.0, 9, 37.0,'da'),
createData('Oreo', 437, 18.0, 63, 4.0,'da'),
];
let tmp2 = [
{ id: 'a', numeric: false, disablePadding: true, label: 'a' },
{ id: 'b', numeric: true, disablePadding: false, label: 'b' },
{ id: 'c', numeric: true, disablePadding: false, label: 'c' },
{ id: 'd', numeric: true, disablePadding: false, label: 'd' },
{ id: 't', numeric: true, disablePadding: false, label: 'tdddddd' },
{ id: 'f', numeric: true, disablePadding: false, label: 'f' },
];
function App() {
return (
<div className="App">
<Header> </Header>
<Toast msg='Behold the work of the mighty toast' timer='60000' ></Toast>
{/* <SimpleModal /> */}
<CustTable rows={tmp} headCell={tmp2} order='asc' orderBy='b'/>
</div>
);
}
export default App;
import React, { useState, useEffect } from 'react';
import './App.css';
import {Header} from './components/header/Header';
import {Toast} from './components/toast/Toast';
// import {Wizard} from './components/wizard/Wizard';
import {SimpleModal} from './components/modal/Modal';
import {CustTable} from './components/table/Table';
import Button from '@material-ui/core/Button';
import {Upload} from './pages/ensalamento.jsx';
import {GerenciarTurma} from './pages/gerenciarturma.jsx';
function createData(a, b, c, d, t,f) {
return { a, b, c, d, t, f };
}
const tmp = [
createData('Cupcake', 305, 3.7, 67, 4.3,'da'),
createData('Donut', 452, 25.0, 51, 4.9,'da'),
createData('Eclair', 262, 16.0, 24, 6.0,'da'),
createData('Frozen yoghurt', 159, 6.0, 24, 4.0,'da'),
createData('Gingerbread', 356, 16.0, 49, 3.9,'da'),
createData('Honeycomb', 408, 3.2, 87, 6.5,'da'),
createData('Ice cream sandwich', 237, 9.0, 37, 4.3,'da'),
createData('Jelly Bean', 375, 0.0, 94, 0.0,'da'),
createData('KitKat', 518, 26.0, 65, 7.0,'da'),
createData('Lollipop', 392, 0.2, 98, 0.0,'da'),
createData('Marshmallow', 318, 0, 81, 2.0,'da'),
createData('Nougat', 360, 19.0, 9, 37.0,'da'),
createData('Oreo', 437, 18.0, 63, 4.0,'da'),
];
let tmp2 = [
{ id: 'a', numeric: false, disablePadding: true, label: 'a' },
{ id: 'b', numeric: true, disablePadding: false, label: 'b' },
{ id: 'c', numeric: true, disablePadding: false, label: 'c' },
{ id: 'd', numeric: true, disablePadding: false, label: 'd' },
{ id: 't', numeric: true, disablePadding: false, label: 'tdddddd' },
{ id: 'f', numeric: true, disablePadding: false, label: 'f' },
];
const login = {
"email":"admin@admin.com",
"username":"admin",
"password":"123mudar"
}
function App() {
var [screen, setScreen] = useState(false);
var [token, setToken] = useState(null);
return (screen)? (
<div className="App">
<Header> </Header>
<Upload></Upload>
</div>
) :
( <div className="App">
<Header> </Header>
<GerenciarTurma></GerenciarTurma>
</div> ) ;
}
export default App;
import React from 'react';
import Button from '@material-ui/core/Button';
import CallMergeIcon from '@material-ui/icons/CallMerge';
import AccessTimeIcon from '@material-ui/icons/AccessTime';
import AddCircleOutlineIcon from '@material-ui/icons/AddCircleOutline';
import Dialog from '@material-ui/core/Dialog';
import DialogActions from '@material-ui/core/DialogActions';
import DialogContent from '@material-ui/core/DialogContent';
......@@ -24,7 +27,7 @@ export default function AlertDialog(props) {
return (
<div>
<Button color="primary" style={props.initial_button_style} onClick={handleClickOpen}>
<Button startIcon={props.initial_icon} color="primary" style={props.initial_button_style} onClick={handleClickOpen}>
{props.initial_button_title}
</Button>
<Dialog
......
......@@ -16,6 +16,7 @@ import SearchIcon from '@material-ui/icons/Search';
// Drawer
import Drawer from '@material-ui/core/Drawer'
import Divider from '@material-ui/core/Divider';
import {Wizard} from '../wizard/Wizard.jsx'
import ChevronLeftIcon from '@material-ui/icons/ChevronLeft';
import ChevronRightIcon from '@material-ui/icons/ChevronRight';
import Grid from '@material-ui/core/Grid';
......@@ -270,6 +271,13 @@ export function Header(props) {
const handleDrawerClose = () => {
setOpen(false);
};
const [w, setW] = React.useState(false);
function wizard() {
return (<Wizard handleClose={handleClose} iniState={1} />)
}
function handleClose() {
setW(false);
}
return (
<div className={classes.root}>
<AppBar position="static" className={classes.header}>
......@@ -285,14 +293,15 @@ export function Header(props) {
<Button color="inherit" className={classes.headerButton} >Resultado</Button>
<Button color="inherit" className={classes.headerButton} >Indicadores</Button>
<Button color="inherit" className={classes.headerButton} >Universidade</Button>*/}
<Button color="inherit" className={classes.headerButton} >Mapas</Button>
<IconButton edge="end" color="inherit" aria-label="searchBar" className={classes.headerButton} >
<SearchIcon />
</IconButton>
<Button color="inherit" href="http://www.campusmap.ufpr.br/" className={classes.headerButton} >Mapas</Button>
{ isAuthenticated() &&
<Button color="inherit" onClick={()=>setW(!w)} className={classes.headerButton} >{(!w)? "Ajuda" : "fechar ajuda"}</Button>
}
</Grid>
</Toolbar>
</AppBar>
<DrawerMenu open={open} handleDrawerOpen={handleDrawerOpen} handleDrawerClose={handleDrawerClose} />
{ w && wizard() }
</div>
)
}
......@@ -82,4 +82,3 @@ export function SelectField(props) {
/>
);
}
......@@ -90,8 +90,11 @@ export function Wizard(props) {
const [activeStep, setActiveStep] = React.useState(iniState);
const steps = getSteps();
function handleNext() {
setActiveStep(prevActiveStep => prevActiveStep + 1);
function handleNext() {
if (activeStep == steps.length -1)
props.handleClose()
else
setActiveStep(prevActiveStep => prevActiveStep + 1);
}
function handleBack() {
......
......@@ -5,4 +5,3 @@ export const MessageActive = React.createContext(false);
export const warn = 1
export const error = 2
export const success = 3
import React, {useState, useEffect,useContext} from 'react';
import {Messages,MessageActive} from "../messagesystem"
import AlertDialog from '../components/dialog/dialog';
import CallMergeIcon from '@material-ui/icons/CallMerge';
import TextField from '@material-ui/core/TextField';
import Divider from '@material-ui/core/Divider';
......@@ -16,6 +16,7 @@ import Grid from '@material-ui/core/Grid';
import { makeStyles } from '@material-ui/core/styles';
import Paper from '@material-ui/core/Paper';
import Button from '@material-ui/core/Button';
import {SelectField, Tags} from '../components/select/Select'
const BlocoSelect = React.createContext({ "bloco":"", "curso":"", "periodo":"", "vagas":0, });
const Change = React.createContext(false);
const useStyles = makeStyles(theme => ({
......@@ -94,7 +95,7 @@ export function HeaderBloco(props) {
const response = await api.delete(`blocos/${bloco_select.codigo}`);
setMessage("Bloco removido com sucesso")
setMessageActive(true)
} catch (e) {
setMessage("Erro ao tentar remover bloco: "+e)
setMessageActive(true)
......@@ -114,7 +115,12 @@ export function HeaderBloco(props) {
<Button onClick={addBloco} startIcon={<Add style={{color: "#636363", fontSize: "12px"}}/>} style={{color:"#676767", fontSize:"12px"}}>Adicionar bloco</Button>
</Grid>
<Grid item align="left">
<Button onClick={handleDelete} style={{color:"#676767", fontSize:"12px"}} startIcon={<DeleteOutline style={{color:"#676767", fontSize:"12px"}}/>}>Excluir</Button>
<AlertDialog title={"Confirmação de remoção do bloco selecionado"}
initial_button_style={{color:"#676767", fontSize:"12px"}}
initial_icon={<DeleteOutline style={{color:"#676767", fontSize:"12px"}}/>}
initial_button_title={"Excluir"}
handle_accept={handleDelete}
description={"Você realmente deseja remover o bloco selecionado? esta operação não pode ser desfeita"} />
</Grid>
</Grid>
</Grid>
......@@ -147,8 +153,12 @@ export function MenuInfo(props) {
const classes = useStyles();
const {bloco_select, setBlocoSelected} = useContext(BlocoSelect);
const handleChange = name => event => {
console.log(bloco_select)
setBlocoSelected({ ...bloco_select, [name]: event.target.value });
};
const handleChangeSelect = name => value => {
var _bloco = bloco_select;
_bloco[name] = value;
setBlocoSelected(_bloco)
};
return (
<Grid container align="left" direction="column" >
......@@ -160,10 +170,14 @@ export function MenuInfo(props) {
/>
</Grid>
<Grid item xs={12} >
<InputField
label="Setor"
value={bloco_select.setorCod}
func={handleChange('setorCod')}
<SelectField
suggestions={Object.values(props.obj.setores)}
label={"Setor"}
placeholder={"Nome do setor"}
index={"nome"}
index_value={"codigo"}
defaultValue={props.obj.setores[bloco_select.setorCod]}
func={handleChangeSelect('setorCod')}
/>
</Grid>
<Grid item xs={12} >
......@@ -176,14 +190,14 @@ export function MenuInfo(props) {
<Grid item xs={12} >
<Grid container spacing={4} >
<Grid item xs={6} >
<InputField
<InputField
label="Latitude"
value={bloco_select.latitude}
func={handleChange('latitude')}
/>
</Grid>
<Grid item xs={6} >
<InputField
<InputField
label="Longetidude"
value={bloco_select.longitude}
func={handleChange('longitude')}
......@@ -217,7 +231,12 @@ export function ListBloco(props) {
var setor = props.setor
var blocos_list = [];
blocos.map((i,index) => {
var localizacao = (i.localizacao)? i.localizacao.lat + " " + i.localizacao.lng : ""
var localizacao = "";
if (i.localizacao) {
localizacao = i.localizacao.lat + " " + i.localizacao.lng
i.latitude = i.localizacao.lat
i.longitude = i.localizacao.lng
}
blocos_list.push(createBlocoList(index,i.codigo,i.nome,localizacao,));
});
return (
......@@ -241,7 +260,7 @@ export function Bloco(props) {
bloco.latitude = bloco.localizacao.lat;
bloco.longitude = bloco.localizacao.lng;
}
})
setBlocos(_blocos);
};
......@@ -278,7 +297,7 @@ export function Menu(props) {
const result = await api.put("blocos",bloco_select);
setMessage("Bloco criado ou atualizado com sucesso")
setMessageActive(true);
} catch (e) {
setMessage("Erro ao tentar criar ou atualizar bloco: "+e)
setMessageActive(true);
......@@ -294,7 +313,7 @@ export function Menu(props) {
<Grid container className={classes.container} direction="column" spacing={2}>
<Grid item xs={12} >
<MenuInfo ></MenuInfo>
<MenuInfo obj={props.obj}></MenuInfo>
</Grid>
<Grid item xs={12} > {/* Linha divisoria */}
......@@ -315,13 +334,21 @@ export function GerenciarBloco (props) {
const classes = useStyles();
var [query, setQuery] = useState("[where][codigo]=exatas")
var [setors, setSetors] = useState([])
const [obj, setObj] = useState({"setores":{}});
var [bloco_select, setBlocoSelect] = useState({});
var [change, setChange] = useState(false);
//get data from api
useEffect(() => {
const fetchData = async () => {
const result = await api.get(`setores`,);
var __data = {}
var _obj = obj;
for(var i=0; i<result.data.length; i++) {
__data[result.data[i].codigo] = result.data[i]
}
_obj["setores"] = __data;
setSetors(result.data);
setObj(_obj);
};
fetchData();},[query,change])
function setBlocoSelected(bloco){
......@@ -350,7 +377,7 @@ export function GerenciarBloco (props) {
</Grid>
<Grid item xs={4} md={4} sm={4} lg={3}> {/* menu */}
<Menu setBlocoSelect={setBlocoSelect} codigo_bloco={bloco_select.nome}></Menu>
<Menu obj={obj} setBlocoSelect={setBlocoSelect} codigo_bloco={bloco_select.nome}></Menu>
</Grid>
</Grid>
</div>
......
import React, {useState, useEffect,useContext} from 'react';
import AlertDialog from '../components/dialog/dialog';
import CallMergeIcon from '@material-ui/icons/CallMerge';
import {SelectField, Tags} from '../components/select/Select'
import TextField from '@material-ui/core/TextField';
import {Messages,MessageActive} from "../messagesystem"
import Divider from '@material-ui/core/Divider';
......@@ -96,7 +97,7 @@ export function HeaderCurso(props) {
const response = await api.delete(`cursos/${curso_select.codigo}`);
setMessage("Curso removido com sucesso")
setMessageActive(true)
} catch (e) {
setMessage("Erro ao tentar remover curso: "+e)
setMessageActive(true)
......@@ -115,7 +116,12 @@ export function HeaderCurso(props) {
<Button onClick={addCurso} startIcon={<Add style={{color: "#636363", fontSize: "12px"}}/>} style={{color:"#676767", fontSize:"12px"}}>Adicionar curso</Button>
</Grid>
<Grid item align="left">
<Button onClick={handleDelete} style={{color:"#676767", fontSize:"12px"}} startIcon={<DeleteOutline style={{color:"#676767", fontSize:"12px"}}/>}>Excluir</Button>
<AlertDialog title={"Confirmação de remoção de curso"}
initial_button_style={{color:"#676767", fontSize:"12px"}}
initial_icon={<DeleteOutline style={{color:"#676767", fontSize:"12px"}}/>}
initial_button_title={"Excluir"}
handle_accept={handleDelete}
description={"Você realmente deseja remover o curso selecionada? esta operação não pode ser desfeita"} />
</Grid>
</Grid>
</Grid>
......@@ -149,25 +155,45 @@ export function MenuInfo(props) {
const {curso_select, setCursoSelected} = useContext(CursoSelect);
const handleChange = name => event => {
setCursoSelected({ ...curso_select, [name]: event.target.value });
};
const handleChangeSelect = name => value => {
var _curso = curso_select;
_curso[name] = value;
setCursoSelected(_curso)
};
return (
<Grid container align="left" direction="column" >
<Grid item xs={12} >
<InputField
<InputField
label="Curso"
value={curso_select.nome}
func={handleChange('nome')}
/>
</Grid>
<Grid item xs={12} >
<InputField
label="Setor"
value={curso_select.setorCod}
func={handleChange('setorCod')}
<SelectField
suggestions={Object.values(props.obj.setores)}
label={"Setor"}
placeholder={"Nome do setor"}
index={"nome"}
index_value={"codigo"}
defaultValue={props.obj.setores[curso_select.setorCod]}
func={handleChangeSelect('setorCod')}
/>
</Grid>
<Grid item xs={12} >
<SelectField
suggestions={Object.values(props.obj.blocos)}
label={"Bloco"}
placeholder={"Nome do bloco"}
index={"nome"}
index_value={"codigo"}
defaultValue={props.obj.blocos[curso_select.blocoCod]}
func={handleChangeSelect('blocoCod')}
/>
</Grid>
<Grid item xs={12} >
<InputField
<InputField
label="Código"
value={curso_select.codigo}
func={handleChange('codigo')}
......@@ -180,8 +206,8 @@ export function MenuInfo(props) {
}
function createCursoList(a,codigo,nome,localizacao) {
return {a,codigo,nome,localizacao};
function createCursoList(a,codigo,nome,setor,bloco,localizacao) {
return {a,codigo,nome,setor,bloco,localizacao};
}
export function ListCurso(props) {
const classes = useStyles();
......@@ -192,6 +218,8 @@ export function ListCurso(props) {
{ id: 'a', numeric: false, disablePadding: false, label: "Id"},
{ id: 'codigo', numeric: false, disablePadding: false, label: "Código"},
{ id: 'nome', numeric: false, disablePadding: false, label: "Nome"},
{ id: 'setor', numeric: false, disablePadding: false, label: "Setor"},
{ id: 'bloco', numeric: false, disablePadding: false, label: "Bloco"},
{ id: 'localizacao', numeric: false, disablePadding: false, label: "Localização"}
......@@ -200,7 +228,9 @@ export function ListCurso(props) {
var cursos_list = [];
cursos.map((i,index) => {
var localizacao = (i.localizacao)? i.localizacao.lat + " " + i.localizacao.lng : ""
cursos_list.push(createCursoList(index,i.codigo,i.nome,localizacao,));
var setor = props.obj.setores[i.setorCod]? props.obj.setores[i.setorCod].nome : ""
var bloco = props.obj.blocos[i.blocoCod]? props.obj.blocos[i.blocoCod].nome : ""
cursos_list.push(createCursoList(index,i.codigo,i.nome,setor,bloco,localizacao,));
});
return (
<CustTable rows={cursos_list} array={props.cursos} setSelect={setCursoSelected} width="100%" height="0" options_number={10} headCell={header_list} order='asc' orderBy='codigo' />
......@@ -212,23 +242,23 @@ export function Curso(props) {
var setor = props.setor
const [cursos, setCursos] = useState([])
const {curso_select,setCursoSelected} = useContext(CursoSelect);
const [dpt_id, setDptId] = useState(setor.codigo);
const [dpt_id, setDptId] = useState(setor);
const {change, setChange} = useContext(Change);
useEffect(() => {
const fetchData = async () => {
const result = await api.get(`setores/${dpt_id}/cursos`,);
const result = await api.get(`cursos`,);
var _cursos = result.data;
setCursos(_cursos);
};
fetchData();},[dpt_id,change])
return (
fetchData();},[change])
return (
<Grid container justify="flex-end" spacing={2} direction="column">
<div>
<Grid item >
<HeaderCurso nome_curso={setor.nome}></HeaderCurso>
<HeaderCurso nome_curso={setor}></HeaderCurso>
</Grid>
<Grid item xs={12} md={12} sm={12}>
<ListCurso cursos={cursos} setor={setor.nome}/>
<ListCurso obj={props.obj} cursos={cursos} setor={setor}/>
</Grid>
</div>
</Grid>
......@@ -245,9 +275,13 @@ export function Menu(props) {
const {message,setMessage} = React.useContext(Messages);
async function salvahandle() {
try {
var _curso = curso_select;
if (_curso.blocoCod) {
var bloco = props.obj.blocos[_curso.blocoCod]
_curso.localizacao = (bloco.localizacao)? bloco.localizacao : {"lat":0,"lng":0};
}
const result = await api.put("cursos",curso_select);
setMessage("Professor criado ou atualizado com sucesso")
setMessage("Curso criado ou atualizado com sucesso")
setMessageActive(true);
} catch (e) {
setMessage("Erro ao tentar criar ou atualizar curso: "+e)
......@@ -264,7 +298,7 @@ export function Menu(props) {
<Grid container className={classes.container} direction="column" spacing={2}>
<Grid item xs={12} >
<MenuInfo/>
<MenuInfo obj={props.obj}/>
</Grid>
<Grid item xs={12} > {/* Linha divisoria */}
......@@ -273,7 +307,7 @@ export function Menu(props) {
<Grid item align="right">
<Button onClick={salvahandle} style={{color:"#5E8D37",fontSize:"14px"}}>Salvar</Button>