Commit 19db695a authored by Matheus Horstmann's avatar Matheus Horstmann 🐴

Add disciplina filter, fix permission o comissao

parent c9d7d9ca
......@@ -176,7 +176,6 @@ export function Options(props) {
{"icon":salasIcon,"text":"Gerenciamento de Salas", "link":"/gerenciasala" },
{"icon":locationIcon,"text":"Gerenciamento de Setores", "link":"/gerenciasetores" },
{"icon":locationIcon,"text":"Gerenciamento de Blocos", "link":"/gerenciabloco" },
{"icon":locationIcon,"text":"Gerenciamento de Usuarios", "link":"/gerenciausuarios" },
]
break;
case "secretario_dpto":
......
import React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import Chip from '@material-ui/core/Chip';
import Autocomplete from '@material-ui/lab/Autocomplete';
import TextField from '@material-ui/core/TextField';
import clsx from 'clsx';
import { makeStyles, useTheme } from '@material-ui/core/styles';
import Input from '@material-ui/core/Input';
import InputLabel from '@material-ui/core/InputLabel';
import MenuItem from '@material-ui/core/MenuItem';
import FormControl from '@material-ui/core/FormControl';
import ListItemText from '@material-ui/core/ListItemText';
import Select from '@material-ui/core/Select';
import Checkbox from '@material-ui/core/Checkbox';
const _useStyles = makeStyles(theme => ({
formControl: {
margin: theme.spacing(1),
minWidth: "100%",
maxWidth: "100%",
},
chips: {
display: 'flex',
flexWrap: 'wrap',
},
chip: {
margin: 2,
},
noLabel: {
marginTop: theme.spacing(3),
},
}));
const ITEM_HEIGHT = 48;
const ITEM_PADDING_TOP = 8;
const MenuProps = {
PaperProps: {
style: {
maxHeight: ITEM_HEIGHT * 4.5 + ITEM_PADDING_TOP,
width: 250,
},
},
};
function getStyles(name, personName, theme) {
return {
fontWeight:
personName.indexOf(name) === -1
? theme.typography.fontWeightRegular
: theme.typography.fontWeightMedium,
};
}
export function MultipleSelect(props) {
const classes = _useStyles();
const theme = useTheme();
const [personName, setPersonName] = React.useState((props.defaultValue)? props.defaultValue : []);
React.useEffect(() => {
if( props.defaultValue)
setPersonName(props.defaultValue)
},[props.defaultValue]);
const handleChange = event => {
setPersonName(event.target.value);
console.log("valor em handleChange de MultipleSelect: ",event.target.value)
console.log("valor do array: ", personName)
};
React.useEffect(() => {
props.func(personName)
},[personName]);
const handleChangeMultiple = event => {
const { options } = event.target;
const value = [];
for (let i = 0, l = options.length; i < l; i += 1) {
if (options[i].selected) {
value.push(options[i].value);
}
}
setPersonName(value);
};
return (
<div>
<FormControl className={classes.formControl}>
<InputLabel id="demo-mutiple-checkbox-label">{props.label}</InputLabel>
<Select
labelId="demo-mutiple-checkbox-label"
id="demo-mutiple-checkbox"
multiple
value={personName}
onChange={handleChange}
input={<Input />}
renderValue={selected => selected.join(', ')}
MenuProps={MenuProps}
>
{props.suggestions.map(suggestion => (
<MenuItem key={suggestion[props.index_value]} value={suggestion[props.index_value]}>
<Checkbox color="default" checked={personName.indexOf(suggestion[props.index_value]) > -1} />
<ListItemText primary={suggestion[props.index]} />
</MenuItem>
))}
</Select>
</FormControl>
</div>
);
}
export function Tags(props) {
return (
......@@ -10,7 +115,13 @@ export function Tags(props) {
<Autocomplete
multiple
options={props.suggestions}
getOptionLabel={option => option[props.index]}
getOptionLabel={option => option[props.index]}
onChange = { (evt,v) =>{
if(v)
props.func(v.map((i) => {return i[props.index_value]}))
else
props.func({})
}}
filterSelectedOptions
renderInput={params => (
<TextField
......@@ -52,16 +163,22 @@ export function SelectField(props) {
}}
autoHightlight
defaultValue={props.defaultValue}
onChange = { (evt,v) =>{
if(v)
props.func(v[props.index_value])
else
props.func({})
}}
onChange = { (evt,v) =>{
if(v)
props.func(v[props.index_value])
else
props.func({})
}}
getOptionLabel={option => ( option && option[props.index] )? option[props.index] : ""}
renderOption={option => (
<React.Fragment>
{/*<span>{option.value}</span> */}
{/* se a oppção show_code estiver ativa ao passar o componente
* SelectField, então ao mostrar as opções no select será mostrado
* os valores de props.option[props.index_value] e props.option[props.index]
*/}
{ props.show_code &&
<span>{option[props.index_value]}</span>
}
<span>{option[props.index]}</span>
</React.Fragment>
)}
......
......@@ -162,29 +162,32 @@ export function CustTable(props) {
setSelected([]);
}
function handleClick(event, name) {
const selectedIndex = selected.indexOf(name);
let newSelected = [];
function handleClick(event, name) {
const selectedIndex = selected.indexOf(name);
let newSelected = [];
if(props.setSelect) {
props.setSelect(props.array[name]);
}
// se foi passado uma funcao de selecao como props então chama essa
// funcao com o id da linha que foi clicada.
if(props.setSelect) {
props.setSelect(props.array[name]);
}
if (selectedIndex === -1) {
newSelected = newSelected.concat(selected, name);
} else if (selectedIndex === 0) {
newSelected = newSelected.concat(selected.slice(1));
} else if (selectedIndex === selected.length - 1) {
newSelected = newSelected.concat(selected.slice(0, -1));
} else if (selectedIndex > 0) {
newSelected = newSelected.concat(
selected.slice(0, selectedIndex),
selected.slice(selectedIndex + 1),
);
}
// javascript não tem switch case??
if (selectedIndex === -1) {
newSelected = newSelected.concat(selected, name);
} else if (selectedIndex === 0) {
newSelected = newSelected.concat(selected.slice(1));
} else if (selectedIndex === selected.length - 1) {
newSelected = newSelected.concat(selected.slice(0, -1));
} else if (selectedIndex > 0) {
newSelected = newSelected.concat(
selected.slice(0, selectedIndex),
selected.slice(selectedIndex + 1),
);
}
setSelected(newSelected);
}
setSelected(newSelected);
}
function handleChangePage(event, newPage) {
setPage(newPage);
......@@ -232,6 +235,7 @@ export function CustTable(props) {
<TableCell padding="checkbox">
<Checkbox
checked={isItemSelected}
color="green"
inputProps={{ 'aria-labelledby': labelId }}
/>
</TableCell>
......
......@@ -73,7 +73,6 @@ const useStyles = makeStyles(theme => ({
}));
export function HeaderDisciplina(props) {
const {change, setChange} = useContext(Change);
const classes = useStyles();
const style_code = {
fontSize: "18px",
......@@ -109,7 +108,6 @@ export function HeaderDisciplina(props) {
setMessage("Erro ao tentar remover disciplina: "+e)
setMessageActive(true)
}
setChange(!change);
}
return (
<Paper className={classes.paper}>
......@@ -259,7 +257,6 @@ export function Disciplina(props) {
const {disciplinas, setDisciplinas} = useContext(Disciplinas)
const {disciplina_select,setDisciplinaSelected} = useContext(DisciplinaSelect);
const [dpt_code, setDptCodigo] = useState(departamento.codigo);
const {change, setChange} = useContext(Change);
useEffect(() => {
const fetchData = async () => {
const result = await api.get(`disciplinas?filter[where][departamentoCod]=${dpt_code}`,);
......@@ -272,18 +269,15 @@ export function Disciplina(props) {
}
setDisciplinas(_disciplinas);
};
fetchData();},[dpt_code,change])
fetchData();},[dpt_code])
return (
<Grid container justify="flex-end" spacing={2} direction="column">
<div>
<Grid item >
<HeaderDisciplina nome_curso={departamento.nome}></HeaderDisciplina>
</Grid>
<Grid item xs={12} md={12} sm={12}>
<ListDisciplina disciplinas={Object.values(disciplinas)} departamento={departamento.nome}/>
</Grid>
</div>
<Grid container justify="flex-end">
<Grid item sm={12}>
<HeaderDisciplina nome_curso={departamento.nome}></HeaderDisciplina>
</Grid>
<Grid item sm={12}>
<ListDisciplina disciplinas={Object.values(disciplinas)} departamento={departamento.nome}/>
</Grid>
</Grid>
)
......@@ -295,7 +289,6 @@ function Equivalencia(props) {
const {disciplinas,setDisciplinas} = useContext(Disciplinas)
const {message_active,setMessageActive} = React.useContext(MessageActive)
const {message,setMessage} = React.useContext(Messages);
const {change, setChange} = useContext(Change);
async function handleDelete() {
try {
var a = await api.delete(`disciplinas/${disciplina_select.codigo}/equivalencias`,{params: { disciplina_eq_code:props.disciplina}})
......@@ -333,7 +326,6 @@ function Equivalencia(props) {
function AddEquivalency(props) {
const {disciplinas,setDisciplinas} = useContext(Disciplinas)
const {disciplina_select, setDisciplinaSelected} = useContext(DisciplinaSelect);
const {change, setChange} = useContext(Change);
const {message_active,setMessageActive} = React.useContext(MessageActive)
const {message,setMessage} = React.useContext(Messages);
const [equiv, setEquiv] = useState("");
......@@ -361,6 +353,7 @@ function AddEquivalency(props) {
index="nome"
index_value="codigo"
placeholder="selecione a disciplina"
show_code
func={(value)=>setEquiv(value)}
/>
<Grid item align="right" >
......@@ -374,13 +367,9 @@ function AddEquivalency(props) {
export function MenuEquivalencia(props) {
const {disciplinas,setDisciplinas} = useContext(Disciplinas)
const {disciplina_select, setDisciplinaSelected} = useContext(DisciplinaSelect);
const {change, setChange} = useContext(Change);
const {message_active,setMessageActive} = React.useContext(MessageActive)
const {message,setMessage} = React.useContext(Messages);
const classes = useStyles();
function handleClick() {
console.log("oi")
}
const [new_equivalency, setNewEquivalency] = useState(false);
function handleClickNewEquivalency() {
setNewEquivalency(!new_equivalency);
......@@ -424,7 +413,6 @@ export function MenuEquivalencia(props) {
export function Menu(props) {
const classes = useStyles();
const {disciplina_select, setDisciplinaSelect} = useContext(DisciplinaSelect);
const {change, setChange} = useContext(Change);
const {message_active,setMessageActive} = React.useContext(MessageActive)
const {message,setMessage} = React.useContext(Messages);
async function salvahandle(event) {
......@@ -438,7 +426,6 @@ export function Menu(props) {
setMessageActive(true)
/* handle error */
}
setChange(!change);
}
return (
<Paper elevation={2} >
......@@ -476,15 +463,14 @@ export function GerenciarDisciplina (props) {
var [departamentos, setDepartamentos] = useState([])
var [dpts, setDpts] = useState({})
var [disciplina_select, setDisciplinaSelect] = useState({});
var [change, setChange] = useState(false);
const [disciplinas, setDisciplinas] = useState({});
//get data from apit
//get data from api
useEffect(() => {
const fetchData = async () => {
const result = await api.get(`departamentos?filter${query}`,);
setDepartamentos(result.data);
};
fetchData();},[query,change])
fetchData();},[])
useEffect(() => {
const fetchData = async () => {
var _dpts = {}
......@@ -500,7 +486,6 @@ export function GerenciarDisciplina (props) {
function change_query(value) {
setQuery("[where][codigo]="+value);
set_query_cache("departamento_disciplina",value);
setChange(!change)
}
function setDisciplinaSelected(disciplina){
setDisciplinaSelect(disciplina);
......@@ -508,7 +493,6 @@ export function GerenciarDisciplina (props) {
return (
<DisciplinaSelect.Provider value={{disciplina_select,setDisciplinaSelected}}>
<Disciplinas.Provider value={{disciplinas,setDisciplinas}}>
<Change.Provider value={{change,setChange}}>
<div className={classes._body}>
<Grid container spacing={4} >
<Grid item xs={12}>
......@@ -525,12 +509,12 @@ export function GerenciarDisciplina (props) {
/>
</Grid>
</Grid>
<Grid container direction="row" spacing={4} >
<Grid item xs={8} md={8} lg={9} sm={8}>
<Grid container direction="column" justify="flex-start" spacing={4} >
<Grid container direction="row" spacing={1} >
<Grid item xs={8} md={8} lg={9} >
<Grid container direction="column" justify="flex-start" >
{ departamentos.map((departamento) =>{
return (
<Grid item >
<Grid item sm={12} >
<Disciplina departamento={departamento} setDisciplinaSelect={setDisciplinaSelect} />
</Grid>
)
......@@ -543,7 +527,6 @@ export function GerenciarDisciplina (props) {
</Grid>
</Grid>
</div>
</Change.Provider>
</Disciplinas.Provider>
</DisciplinaSelect.Provider>
)
......
......@@ -98,7 +98,7 @@ export function HeaderEnsalamento(props) {
async function handleDelete() {
try {
const response_t = api.delete("/semestres/deletesemestre",{params: {"semestreId":ensalamento_select.semestre}});
setMessage("Ensalamento removido com sucesso")
setMessage("Requisição de remoção do semestre: "+ensalamento_select.semestre+" agendada com sucesso, pode demorar alguns minutos para ser totalmente removido")
setMessageActive(true)
} catch (e) {
......@@ -122,7 +122,7 @@ export function HeaderEnsalamento(props) {
initial_icon={<DeleteOutline style={{color:"#676767", fontSize:"12px"}}/>}
initial_button_title={"Excluir"}
handle_accept={handleDelete}
description={"Você realmente deseja remover este semestre? não é possível desfazer está operação. " } />
description={"Você realmente deseja remover este semestre? está operação vai remover todas as turmas e horarios associado ao semestre e não é possível desfazer. " } />
</Grid>
</Grid>
</Grid>
......@@ -241,10 +241,7 @@ async function get_file_upload(ensalamento) {
var query = "[where][semestre]="+ensalamento.semestre;
const f = await api.get(`file-uploads?filter${query}`)
console.log("--------------------------------")
console.log(ensalamento,f.data[0])
ensalamento.fileupload = (f.data.length)? f.data[0] : {status:"Sem arquivo"};
console.log(ensalamento.fileupload.completed)
}
return ensalamento;
......@@ -275,16 +272,16 @@ export function Ensalamento(props) {
setInterval(()=> {
fetchData();
},4000);
return () => clearInterval(4000);
return () => clearInterval(4000); // intervalo em milisegundos
},[change])
return (
<Grid container justify="flex-end" spacing={2} direction="column">
<Grid container justify="flex-end" direction="column">
<div>
<Grid item >
<Grid item sm={11} >
<HeaderEnsalamento nome_curso="Ensalamentos"></HeaderEnsalamento>
</Grid>
<Grid item xs={12} md={12} sm={12}>
<Grid item xs={12} md={12} sm={11}>
<ListEnsalamento ensalamentos={ensalamentos} />
</Grid>
</div>
......@@ -333,13 +330,13 @@ export function GerenciarEnsalador (props) {
<EnsalamentoSelect.Provider value={{ensalamento_select,setEnsalamentoSelected}}>
<Change.Provider value={{change,setChange}}>
<div className={classes._body}>
<Grid container spacing={4} >
<Grid item xs={12}>
<Grid container spacing={4} justify="space-between" >
<Grid item xs={12} sm={6}>
<Typography color="#707070" className={classes.header} >Gerenciar Ensalamentos</Typography>
</Grid>
</Grid>
<Grid container direction="row" spacing={4} >
<Grid item xs={8} md={8} lg={9} sm={8}>
<Grid container direction="row" justify="space-between" spacing={4} >
<Grid item xs={8} md={8} lg={9} sm={7}>
<Grid container direction="column" justify="flex-start" spacing={4} >
<Grid item >
<Ensalamento />
......@@ -347,7 +344,7 @@ export function GerenciarEnsalador (props) {
</Grid>
</Grid>
<Grid item xs={4} md={4} sm={4} lg={3}> {/* menu */}
<Grid item xs={4} md={4} sm={3} lg={3}> {/* menu */}
<Menu setEnsalamentoSelect={setEnsalamentoSelect} codigo_ensalamento={ensalamento_select.nome}></Menu>
</Grid>
</Grid>
......
This diff is collapsed.
......@@ -87,6 +87,10 @@ export function SalaSearch(props) {
{dia: 3, horario_inicial: "19:30:00", horario_final: "21:30:00", livre: false, motivo: "aula", …}
]
<<<<<<< HEAD
=======
[
>>>>>>> e71fc51... Add disciplina filter, fix permission o comissao
curso: {
nome: "Informatica Biomedica"
codigo: "96A"
......@@ -95,7 +99,21 @@ export function SalaSearch(props) {
secretarioId: null
blocoCod: "pa"
setorCod: null
<<<<<<< HEAD
}
=======
},
curso: {
nome: "Ciencia da computacao"
codigo: "21A"
_id: 35
localizacao: null
secretarioId: null
blocoCod: "pa"
setorCod: null
},
]
>>>>>>> e71fc51... Add disciplina filter, fix permission o comissao
disciplina: {
codigo: "ci204"
nome: "ADMINISTRACAO DE INFORMATICA"
......@@ -138,7 +156,7 @@ export function TurmaTable(props) {
</TableCell >
{rows.map(row => (
<TableCell align="center" >
{row.curso? row.curso.nome : ""}
{row.curso_str? row.curso_str: ""}
</TableCell>))}
</TableRow>
......@@ -158,7 +176,7 @@ export function TurmaTable(props) {
</TableCell >
{rows.map(row => (
<TableCell align="center" >
{row.horarios.map((value, index) => {
{ row.horarios && row.horarios.map((value, index) => {
return <p>{value.salaCode}</p>
})}
</TableCell>))}
......@@ -170,7 +188,7 @@ export function TurmaTable(props) {
</TableCell >
{rows.map(row => (
<TableCell align="center" >
{row.horarios.map((value, index) => {
{row.horarios && row.horarios.map((value, index) => {
return <p>{DIAS_SEMANAS[value.dia]}</p>
})}
</TableCell>))}
......@@ -182,7 +200,7 @@ export function TurmaTable(props) {
</TableCell >
{rows.map(row => (
<TableCell align="center" >
{row.horarios.map((value, index) => {
{row.horarios && row.horarios.map((value, index) => {
return <p>{value.horario_inicial}</p>
})}
</TableCell>))}
......@@ -194,18 +212,18 @@ export function TurmaTable(props) {
</TableCell >
{rows.map(row => (
<TableCell align="center" >
{row.horarios.map((value, index) => {
{row.horarios && row.horarios.map((value, index) => {
return <p>{value.horario_final}</p>
})}
</TableCell>))}
</TableRow>
</TableRow>
{/* <TableRow align="right">Sala</TableRow>
<TableRow align="right">Dia</TableRow>
<TableRow align="right">Início</TableRow>
<TableRow align="right">Fim</TableRow> */}
</TableBody>
</TableBody>
</Table>
</Paper>
</div>
......@@ -215,7 +233,25 @@ export function DisciplinaSearch(props) {
const {rows, setRows} = React.useContext(Rows);
const [r,setR] = React.useState([])
React.useEffect(()=>{
setR(rows)
var _turmas = []
setR([])
rows.map((row)=>{
if(row.turmas)
row.turmas.map((turma)=>{
var curso_str = ( turma.cursos)? turma.cursos.map((curso)=>{return (curso)? curso.nome : ""}) : null
var professor_str = ( turma.professores)? turma.professores.map((professor)=>{return (professor)? professor.nome : ""}) : null
_turmas.push({
"turma": turma,
"horarios": (turma.horarios)? turma.horarios : [],
"curso": (curso_str)? curso_str.join(", ") : "",
"professor": (professor_str)? professor_str.join(", ") : "",
"disciplina": turma.disciplina
})
})
})
setR(_turmas)
console.log("r: ",rows)
},rows)
return (<TurmaTable rows={r} />)
......@@ -231,11 +267,13 @@ function DepartamentoSubComponente(props) {
if (props.row.turmas) {
for(var i=0; i<props.row.turmas.length; i++) {
var turma = props.row.turmas[i]
var curso_str = ( turma.cursos)? turma.cursos.map((curso)=>{return (curso)? curso.nome : ""}) : null
var professor_str = ( turma.professores)? turma.professores.map((professor)=>{return (professor)? professor.nome : ""}) : null
_turmas.push({ "turma": turma,
"horarios": turma.horarios,
"professor": turma.professor,
"disciplina": turma.disciplina,
"curso": turma.cursos
"curso": (curso_str)? curso_str.join(", ") : "",
"professor": (professor_str)? professor_str.join(", ") : "",
})
}
}
......@@ -256,11 +294,13 @@ export function CursoSubComponente(props) {
if(props.row.turmas) {
for(var i=0; i< props.row.turmas.length; i++) {
var turma = props.row.turmas[i]
var curso_str = ( turma.cursos)? turma.cursos.map((curso)=>{return (curso)? curso.nome : ""}) : null
var professor_str = ( turma.professores)? turma.professores.map((professor)=>{return (professor)? professor.nome : ""}) : null
_turmas.push({ "turma": turma,
"curso": (curso_str)? curso_str.join(", ") : "",
"professor": (professor_str)? professor_str.join(", ") : "",
"horarios": turma.horarios,
"professor": turma.professor,
"disciplina": turma.disciplina,
"curso": props.row
})
}
}
......@@ -376,7 +416,7 @@ export function PaginaInicial(props) {
break;
}
}
......@@ -394,7 +434,7 @@ export function PaginaInicial(props) {
>
<img className={classes.logoImage} src={logo} alt={"logo"} />
</Grid>
<form onSubmit={handleSubmit}>
<Grid
container
......@@ -433,7 +473,7 @@ export function PaginaInicial(props) {
InputProps={{
endAdornment: (
<InputAdornment position="start">
<IconButton type="submit">
<IconButton type="submit">
<ChevronRightIcon />
</IconButton>
</InputAdornment>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment