Skip to content
Snippets Groups Projects
Commit 4e9a6eeb authored by lfr20's avatar lfr20
Browse files

Passed the admin routes to App.js

parent 618dfd57
Branches
Tags
4 merge requests!57Merge of develop into master,!56Fixed buttons reportar, seguir, compartilhar, guardar and entrar (in comments...,!40merge admin into develop,!39Update admin system
/*Copyright (C) 2019 Centro de Computacao Cientifica e Software Livre
Departamento de Informatica - Universidade Federal do Parana
This file is part of Plataforma Integrada MEC.
Plataforma Integrada MEC is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Plataforma Integrada MEC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Plataforma Integrada MEC. If not, see <http://www.gnu.org/licenses/>.*/
import React, { useState, useContext } from 'react';
//imports from material ui
import clsx from 'clsx';
import { makeStyles } from '@material-ui/core/styles';
import Drawer from '@material-ui/core/Drawer';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import IconButton from '@material-ui/core/IconButton';
import DisplayIcon from '../../Components/Components/DisplayIcon';
import ListItemText from '@material-ui/core/ListItemText';
import MenuIcon from '@material-ui/icons/Menu';
import Fab from '@material-ui/core/Fab';
//imports from routers
import { BrowserRouter, Switch, Route, Link } from 'react-router-dom';
//imports from local files
import { TabsItens } from '../AdminLabelTabs/LabelTabs';
import Welcome from '../../Components/Components/Welcome';
import NoteVariables from './SubPages/NoteVariables';
import Institution from './SubPages/Institutions';
import SendEmail from './SubPages/SendEmail';
import Inframe from './SubPages/Inframe';
import Languages from './SubPages/Languages';
import Activity from './SubPages/Activity';
import InstitutionCard from '../../Components/Components/DataCards/InstitutionsCard';
import InstitutionsInput from '../../Components/Components/Inputs/IntitutionsInputs';
import CreateInstitution from '../../Components/Components/Inputs/CreateInstitution';
import NoteVarCard from '../../Components/Components/DataCards/NoteVarCard';
import NoteVarInputs from '../../Components/Components/Inputs/NoteVarInputs';
import EditLanguage from '../../Components/Components/Inputs/EditLanguage';
import CreateLanguage from '../../Components/Components/Inputs/CreateLanguage';
import ActivityCard from '../../Components/Components/DataCards/ActivityCard';
import CommunityQuestions from './SubPages/CommunityQuestions';
import CommunityCard from '../../Components/Components/DataCards/CommunityQuestionCard';
import Collections from './SubPages/Collections';
import CollectionCard from '../../Components/Components/DataCards/CollectionCard';
import EditCollection from '../../Components/Components/Inputs/EditCollection';
import Ratings from './SubPages/Rating';
import RatingCard from '../../Components/Components/DataCards/RatingCard';
import EditRating from '../../Components/Components/Inputs/EditRating';
import CreateRating from '../../Components/Components/Inputs/CreateRating';
import Questions from './SubPages/Questions';
import CreateQuestions from '../../Components/Components/Inputs/CreateQuestion';
import EducationalObject from './SubPages/EducationalObjects';
import EducationalObjectCard from '../../Components/Components/DataCards/EducationalObjectsCard';
import EducationalObjectEdit from '../../Components/Components/Inputs/EditEducationalObect';
import Complaints from './SubPages/Complaints';
import ComplaintCard from '../../Components/Components/DataCards/ComplaintsCard';
import AproveTeacher from './SubPages/AproveTeacher';
import UserCard from '../../Components/Components/DataCards/UserCard';
import EditUser from '../../Components/Components/Inputs/EditUser';
import UserList from './SubPages/Users';
import UserPermissions from './SubPages/Permissions'
import EditRole from '../../Components/Components/Inputs/EditRoles';
import CreateRole from '../../Components/Components/Inputs/CreateRole'
import BlockedUser from './SubPages/BlockedUsers';
const useStyles = makeStyles({
list: {
width: 250,
},
fullList: {
width: 'auto',
},
});
const fab = {
margin: 0,
top: 'auto',
right: 20,
bottom: 20,
left: 'auto',
position: 'fixed',
}
export default function Admin() {
const classes = useStyles();
//State of the Drawer
const [State, setState] = React.useState({
left: false
});
{/**************** Controlls the state of the Drawer ****************/ }
const toggleDrawer = (anchor, open) => (event) => {
if (event.type === 'keydown' && (event.key === 'Tab' || event.key === 'Shift')) {
return;
}
setState({ ...State, [anchor]: open });
};
{/**************** Dsiplay the itens of the Drawer ****************/ }
const list = (anchor) => (
<div
className={clsx(classes.list, {
[classes.fullList]: anchor === 'top' || anchor === 'bottom',
})}
role="presentation"
onClick={toggleDrawer(anchor, false)}
onKeyDown={toggleDrawer(anchor, false)}
>
<List>
{TabsItens.map((text, index) => (
<Link to={text.href} key={text.label} style={{ color: "black" }}>
<ListItem button key={text.label}>
<IconButton>
<DisplayIcon i={index} />
</IconButton>
<ListItemText primary={text.label} />
</ListItem>
</Link>
))}
</List>
</div>
);
return (
<BrowserRouter>
<Switch>
<div style={{ paddingTop: '2em', paddingLeft: '2em', paddingRight: '2em', paddingBottom: '2em', backgroundColor: ' #D3D3D3' }}>
<Route path='/admin/home' exact={true} component={Welcome}/>
<Route path='/admin/intitutions' component={Institution} />
<Route path='/admin/institution/:id' component={InstitutionCard} />
<Route path='/admin/institutionEdit/:id' component={InstitutionsInput}/>
<Route path='/admin/InstitutionCreate' component={CreateInstitution} />
<Route path='/admin/noteVars' component={NoteVariables} />
<Route path='/admin/noteVar/:id' component={NoteVarCard} />
<Route path='/admin/noteVarEdit/:id' component={NoteVarInputs} />
<Route path='/admin/languages' component={Languages} />
<Route path='/admin/languageEdit/:id' component={EditLanguage} />
<Route path='/admin/languageCreate' component={CreateLanguage} />
<Route path='/admin/CommunityQuestions' component={CommunityQuestions} />
<Route path='/admin/CommunityQuestion/:id' component={CommunityCard} />
<Route path='/admin/Collections' component={Collections} />
<Route path='/admin/Collection/:id' component={CollectionCard} />
<Route path='/admin/EditCollection/:id' component={EditCollection} />
<Route path='/admin/Ratings' component={Ratings} />
<Route path='/admin/Rating/:id' component={RatingCard} />
<Route path='/admin/EditRating/:id' component={EditRating} />
<Route path='/admin/CreateRating' component={CreateRating} />
<Route path='/admin/Questions' component={Questions} />
<Route path='/admin/CreateQuestion' component={CreateQuestions} />
<Route path='/admin/activities' component={Activity} />
<Route path='/admin/activity/:id' component={ActivityCard} />
<Route path='/admin/learningObjects' component={EducationalObject} />
<Route path='/admin/learningObject/:id' component={EducationalObjectCard} />
<Route path='/admin/learningObjectEdit/:id' component={EducationalObjectEdit} />
<Route path='/admin/complaints' component={Complaints} />
<Route path='/admin/complaint/:id' component={ComplaintCard} />
<Route path='/admin/users/teacher_requests' component={AproveTeacher} />
<Route path='/admin/usersList' component={UserList} />
<Route path='/admin/user/:id' component={UserCard} />
<Route path='/admin/EditUser/:id' component={EditUser} />
<Route path='/admin/permissions' component={UserPermissions} />
<Route path='/admin/EditPermissions/:id' component={EditRole} />
<Route path='/admin/CreateRole' component={CreateRole} />
<Route path='/admin/BlockedUsers' component={BlockedUser} />
<Route path='/admin/sendEmail/:email' component={SendEmail} />
<Route path='/admin/inframe' component={Inframe} />
</div>
</Switch>
<React.Fragment>
<Drawer anchor={'left'} open={State['left']} onClose={toggleDrawer('left', false)}>
{list('left')}
</Drawer>
</React.Fragment>
<Fab color="primary" aria-label="add" style={fab} onClick={toggleDrawer('left', true)}>
<MenuIcon />
</Fab>
</BrowserRouter>
);
}
......@@ -23,7 +23,6 @@ import Header from './Components/Header'
import EcFooter from './Components/EcFooter';
import GNUAGPLfooter from './Components/AGPLFooter';
import UserPage from './Pages/UserPage';
import Admin from './Admin/Pages/Pages/Admin';
import UserTerms from './Pages/UserTerms';
import Contact from './Pages/Contact';
import Teste from './Pages/Teste';
......@@ -36,7 +35,7 @@ import TabManageAc from './Pages/TabsHelp/TabManageAc';
import PasswordRecoveryPage from './Pages/PasswordRecoveryPage.js'
import PageProfessor from './Pages/PageProfessor.js'
import ResourcePage from './Pages/ResourcePage';
import {BrowserRouter, Switch, Route } from 'react-router-dom';
import { BrowserRouter, Switch, Route, Link } from 'react-router-dom';
import { Store } from './Store'
import TermsPage from './Pages/TermsPage.js'
import PublicationPermissionsPage from './Pages/PublicationPermissionsPage.js'
......@@ -52,11 +51,126 @@ import CollectionPage from './Pages/CollectionPage.js'
import FormationMaterialPage from './Pages/FormationMaterialPage.js';
import FormationMaterialIframe from './Pages/FormationMaterialIframe.js';
//admin
import clsx from 'clsx';
import { makeStyles } from '@material-ui/core/styles';
import Drawer from '@material-ui/core/Drawer';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import IconButton from '@material-ui/core/IconButton';
import DisplayIcon from './Admin/Components/Components/DisplayIcon';
import ListItemText from '@material-ui/core/ListItemText';
import MenuIcon from '@material-ui/icons/Menu';
import Fab from '@material-ui/core/Fab';
import { TabsItens } from './Admin/Pages/AdminLabelTabs/LabelTabs';
import Welcome from './Admin/Components/Components/Welcome';
import NoteVariables from './Admin/Pages/Pages/SubPages/NoteVariables';
import Institution from './Admin/Pages/Pages/SubPages/Institutions';
import SendEmail from './Admin/Pages/Pages/SubPages/SendEmail';
import Inframe from './Admin/Pages/Pages/SubPages/Inframe';
import Languages from './Admin/Pages/Pages/SubPages/Languages';
import Activity from './Admin/Pages/Pages/SubPages/Activity';
import InstitutionCard from './Admin/Components/Components/DataCards/InstitutionsCard';
import InstitutionsInput from './Admin/Components/Components/Inputs/IntitutionsInputs';
import CreateInstitution from './Admin/Components/Components/Inputs/CreateInstitution';
import NoteVarCard from './Admin/Components/Components/DataCards/NoteVarCard';
import NoteVarInputs from './Admin/Components/Components/Inputs/NoteVarInputs';
import EditLanguage from './Admin/Components/Components/Inputs/EditLanguage';
import CreateLanguage from './Admin/Components/Components/Inputs/CreateLanguage';
import ActivityCard from './Admin/Components/Components/DataCards/ActivityCard';
import CommunityQuestions from './Admin/Pages/Pages/SubPages/CommunityQuestions';
import CommunityCard from './Admin/Components/Components/DataCards/CommunityQuestionCard';
import Collections from './Admin/Pages/Pages/SubPages/Collections';
import CollectionCard from './Admin/Components/Components/DataCards/CollectionCard';
import EditCollection from './Admin/Components/Components/Inputs/EditCollection';
import Ratings from './Admin/Pages/Pages/SubPages/Rating';
import RatingCard from './Admin/Components/Components/DataCards/RatingCard';
import EditRating from './Admin/Components/Components/Inputs/EditRating';
import CreateRating from './Admin/Components/Components/Inputs/CreateRating';
import Questions from './Admin/Pages/Pages/SubPages/Questions';
import CreateQuestions from './Admin/Components/Components/Inputs/CreateQuestion';
import EducationalObject from './Admin/Pages/Pages/SubPages/EducationalObjects';
import EducationalObjectCard from './Admin/Components/Components/DataCards/EducationalObjectsCard';
import EducationalObjectEdit from './Admin/Components/Components/Inputs/EditEducationalObect';
import Complaints from './Admin/Pages/Pages/SubPages/Complaints';
import ComplaintCard from './Admin/Components/Components/DataCards/ComplaintsCard';
import AproveTeacher from './Admin/Pages/Pages/SubPages/AproveTeacher';
import UserCard from './Admin/Components/Components/DataCards/UserCard';
import EditUser from './Admin/Components/Components/Inputs/EditUser';
import UserList from './Admin/Pages/Pages/SubPages/Users';
import UserPermissions from './Admin/Pages/Pages/SubPages/Permissions'
import EditRole from './Admin/Components/Components/Inputs/EditRoles';
import CreateRole from './Admin/Components/Components/Inputs/CreateRole'
import BlockedUser from './Admin/Pages/Pages/SubPages/BlockedUsers';
const useStyles = makeStyles({
list: {
width: 250,
},
fullList: {
width: 'auto',
},
});
const fab = {
margin: 0,
top: 'auto',
right: 20,
bottom: 20,
left: 'auto',
position: 'fixed',
}
export default function App() {
// eslint-disable-next-line
const { state, dispatch } = useContext(Store)
const [hideFooter, setHideFooter] = useState(false);
const classes = useStyles();
//State of the Drawer
const [State, setState] = React.useState({
left: false
});
const [IndexIcon, setIndexIcon] = useState(0);
{/**************** Controlls the state of the Drawer ****************/ }
const toggleDrawer = (anchor, open) => (event) => {
if (event.type === 'keydown' && (event.key === 'Tab' || event.key === 'Shift')) {
return;
}
setState({ ...State, [anchor]: open });
};
{/**************** Dsiplay the itens of the Drawer ****************/ }
const list = (anchor) => (
<div
className={clsx(classes.list, {
[classes.fullList]: anchor === 'top' || anchor === 'bottom',
})}
role="presentation"
onClick={toggleDrawer(anchor, false)}
onKeyDown={toggleDrawer(anchor, false)}
>
<List>
{TabsItens.map((text, index) => (
<Link to={text.href} key={text.label} style={{ color: "black" }}>
<ListItem button key={text.label} onClick={() => setIndexIcon(index)}>
<IconButton>
<DisplayIcon i={index} />
</IconButton>
<ListItemText primary={text.label} />
</ListItem>
</Link>
))}
</List>
</div>
);
useEffect(() => {
setHideFooter(String(window.location.href).includes('iframe-colecao'));
}, [window.location.href]);
......@@ -94,7 +208,6 @@ export default function App(){
<link href="https://fonts.googleapis.com/css?family=Kalam|Pompiere|Roboto&display=swap" rel="stylesheet" />
<Switch>
<Route path="/" exact={true} component={Home} />
<Route path="/admin" component={Admin}/>
<Route path="/busca" component={Search} />
<Route path="/perfil" component={UserPage} />
<Route path="/editarperfil" component={EditProfilePage} />
......@@ -124,6 +237,55 @@ export default function App(){
<Route path='/colecao' component={FormationMaterialPage} />
<Route path='/topico' component={FormationMaterialPage} />
<Route path='/iframe-colecao' component={FormationMaterialIframe} />
<div style={{ paddingTop: '2em', paddingLeft: '2em', paddingRight: '2em', paddingBottom: '2em', backgroundColor: ' #D3D3D3' }}>
<Route path='/admin/home' exact={true} component={Welcome} />
<Route path='/admin/intitutions' component={Institution} />
<Route path='/admin/institution/:id' component={InstitutionCard} />
<Route path='/admin/institutionEdit/:id' component={InstitutionsInput} />
<Route path='/admin/InstitutionCreate' component={CreateInstitution} />
<Route path='/admin/noteVars' component={NoteVariables} />
<Route path='/admin/noteVar/:id' component={NoteVarCard} />
<Route path='/admin/noteVarEdit/:id' component={NoteVarInputs} />
<Route path='/admin/languages' component={Languages} />
<Route path='/admin/languageEdit/:id' component={EditLanguage} />
<Route path='/admin/languageCreate' component={CreateLanguage} />
<Route path='/admin/CommunityQuestions' component={CommunityQuestions} />
<Route path='/admin/CommunityQuestion/:id' component={CommunityCard} />
<Route path='/admin/Collections' component={Collections} />
<Route path='/admin/Collection/:id' component={CollectionCard} />
<Route path='/admin/EditCollection/:id' component={EditCollection} />
<Route path='/admin/Ratings' component={Ratings} />
<Route path='/admin/Rating/:id' component={RatingCard} />
<Route path='/admin/EditRating/:id' component={EditRating} />
<Route path='/admin/CreateRating' component={CreateRating} />
<Route path='/admin/Questions' component={Questions} />
<Route path='/admin/CreateQuestion' component={CreateQuestions} />
<Route path='/admin/activities' component={Activity} />
<Route path='/admin/activity/:id' component={ActivityCard} />
<Route path='/admin/learningObjects' component={EducationalObject} />
<Route path='/admin/learningObject/:id' component={EducationalObjectCard} />
<Route path='/admin/learningObjectEdit/:id' component={EducationalObjectEdit} />
<Route path='/admin/complaints' component={Complaints} />
<Route path='/admin/complaint/:id' component={ComplaintCard} />
<Route path='/admin/users/teacher_requests' component={AproveTeacher} />
<Route path='/admin/usersList' component={UserList} />
<Route path='/admin/user/:id' component={UserCard} />
<Route path='/admin/EditUser/:id' component={EditUser} />
<Route path='/admin/permissions' component={UserPermissions} />
<Route path='/admin/EditPermissions/:id' component={EditRole} />
<Route path='/admin/CreateRole' component={CreateRole} />
<Route path='/admin/BlockedUsers' component={BlockedUser} />
<Route path='/admin/sendEmail/:email' component={SendEmail} />
<Route path='/admin/inframe' component={Inframe} />
<React.Fragment>
<Drawer anchor={'left'} open={State['left']} onClose={toggleDrawer('left', false)}>
{list('left')}
</Drawer>
</React.Fragment>
<Fab color="primary" aria-label="add" style={fab} onClick={toggleDrawer('left', true)}>
<MenuIcon />
</Fab>
</div>
</Switch>
{!hideFooter &&
<div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment