Newer
Older
/*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, { useContext, useEffect, useState } from "react";
import { Store } from './Store'
import Unauthorized from './Admin/Components/Components/Unauthorized'
import Home from "./Pages/HomeFunction";
import Search from "./Pages/Search";
import Header from "./Components/Header";
import EcFooter from "./Components/EcFooter";
import GNUAGPLfooter from "./Components/AGPLFooter";
import UserPage from "./Pages/UserPage";
import UserTerms from "./Pages/UserTerms";
import Contact from "./Pages/Contact";
import Teste from "./Pages/Teste";
import AboutPage from "./Pages/AboutPage";
import HelpCenter from "./Pages/HelpCenter";
import TabResoursePub from "./Pages/TabsHelp/TabResoursePub";
import TabResourseFind from "./Pages/TabsHelp/TabResourseFind";
import TabNetPart from "./Pages/TabsHelp/TabNetPart";
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, Redirect } from "react-router-dom";
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import TermsPage from "./Pages/TermsPage.js";
import PublicationPermissionsPage from "./Pages/PublicationPermissionsPage.js";
import TabPlataformaMEC from "./Pages/TabsHelp/TabPlataformaMEC";
import ItemStore from "./Pages/ItemStore.js";
import EditProfilePage from "./Pages/EditProfilePage.js";
import PublicUserPage from "./Pages/PublicUserPage.js";
import UploadPage from "./Pages/UploadPage.js";
import EditLearningObjectPage from "./Pages/EditLearningObjectPage.js";
import SiteMap from "./Pages/SiteMap";
import Accessibility from "./Pages/Accessibility";
import CollectionPage from "./Pages/CollectionPage.js";
import FormationMaterialPage from "./Pages/FormationMaterialPage.js";
import FormationMaterialIframe from "./Pages/FormationMaterialIframe.js";
import MaterialPage from "./Pages/MaterialPage";
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";
import AppBarAdmin from './Admin/Components/Components/AppBar'
Vinícius de Lima Gonçalves
committed
// eslint-disable-next-line
const [hideFooter, setHideFooter] = useState(false);
const PiwikReactRouter = require('piwik-react-router');
const piwik = PiwikReactRouter({
url: '//piwik.c3sl.ufpr.br/',
siteId: 5
});
const customHistory = createBrowserHistory()
const CheckUserPermission = () => {
let canUserEdit = false;
if (state.userIsLoggedIn) {
const roles = [...state.currentUser.roles];
for (let i = 0; i < roles.length; i++)
if (roles[i].name === 'admin' || roles[i].name === 'editor')
canUserEdit = true;
}
else {
canUserEdit = false;
}
return canUserEdit;
}
setHideFooter(String(window.location.href).includes("iframe-colecao"));
}, [window.location.href]);
useEffect(() => {
dispatch({
height: window.innerHeight,
},
});
}, []);
Vinícius de Lima Gonçalves
committed
const setWindowSize = () => {
dispatch({
Vinícius de Lima Gonçalves
committed
innerWindow: {
width: window.innerWidth,
height: window.innerHeight,
},
});
};
Vinícius de Lima Gonçalves
committed
window.addEventListener("resize", setWindowSize);
Vinícius de Lima Gonçalves
committed
return () => window.removeEventListener("resize", setWindowSize);
}, [window.innerWidth, window.innerHeight]);
Vinícius de Lima Gonçalves
committed
// add piwik later
// history={piwik.connectToHistory(customHistory)}
<BrowserRouter>
Vinícius de Lima Gonçalves
committed
<Header />
<div
style={{
backgroundImage:
"linear-gradient(to right,#ff7f00,#e81f4f,#673ab7,#00bcd4)",
height: "5px",
}}
></div>
<link
href="https://fonts.googleapis.com/css?family=Kalam|Pompiere|Roboto&display=swap"
rel="stylesheet"
/>
Vinícius de Lima Gonçalves
committed
<Switch>
<Redirect from="/home" to="/" />
<Route path="/" exact={true} component={Home} />
Vinícius de Lima Gonçalves
committed
<Route path="/busca" component={Search} />
<Route path="/perfil" component={UserPage} />
<Route path="/editarperfil" component={EditProfilePage} />
<Route path="/recurso/:recursoId" component={ResourcePage} />
<Route path="/termos-publicar-recurso" component={TermsPage} />
<Route path="/permission" component={PublicationPermissionsPage} />

Lucas Eduardo Schoenfelder
committed
{/*<Route path="termos-de-uso#publicacoes-de-usuario" component={}*/}
<Route path="/ajuda" component={HelpCenter} />
<Route path="/contato" component={Contact} />
<Route path="/termos" component={UserTerms} />
<Route path="/teste" component={Teste} />
<Route path="/sobre" component={AboutPage} />
<Route path="/mapa-site" component={SiteMap} />
<Route path="/acessibilidade" component={Accessibility} />
<Route path="/publicando-recurso" component={TabResoursePub} />
<Route path="/encontrando-recurso" component={TabResourseFind} />
<Route path="/participando-da-rede" component={TabNetPart} />
<Route path="/gerenciando-conta" component={TabManageAc} />
<Route path="/plataforma-mec" component={TabPlataformaMEC} />
<Route path="/recuperar-senha" component={PasswordRecoveryPage} />
<Route path="/usuario-publico/:userId" component={PublicUserPage} />
<Route
path="/editar-recurso/:recursoId"
component={EditLearningObjectPage}
/>
<Route path="/professor" component={PageProfessor} />
<Route path="/upload" component={UploadPage} />
<Route path="/loja" component={ItemStore} />
<Route path="/colecao-do-usuario/:id" component={CollectionPage} />
<Route path="/colecao" component={FormationMaterialPage} />
<Route path="/topico" component={FormationMaterialPage} />
<Route path="/iframe-colecao" component={FormationMaterialIframe} />
<Route path="/material-formacao" component={MaterialPage} />
<div style={{ backgroundColor: " #D3D3D3" }}>
if (CheckUserPermission())
return <Inframe />
else
return <Unauthorized />
}} />
<Route path="/admin/intitutions" render={() => {
if (CheckUserPermission())
return <Institution />
else
return <Unauthorized />
}} />
if (CheckUserPermission())
return <InstitutionCard />
else
return <Unauthorized />
}} />
render={() => {
if (CheckUserPermission())
return <InstitutionsInput />
else
return <Unauthorized />
}}
/>
<Route
path="/admin/InstitutionCreate"
render={() => {
if (CheckUserPermission())
return <CreateInstitution />
else
return <Unauthorized />
}}
<Route path="/admin/noteVars" render={() => {
if (CheckUserPermission())
return <NoteVariables />
else
return <Unauthorized />
}} />
if (CheckUserPermission())
return <NoteVarCard />
else
return <Unauthorized />
}} />
if (CheckUserPermission())
return <NoteVarInputs />
else
return <Unauthorized />
}} />
<Route path="/admin/languages" render={() => {
if (CheckUserPermission())
return <Languages />
else
return <Unauthorized />
}} />
if (CheckUserPermission())
return <EditLanguage />
else
return <Unauthorized />
}} />
<Route path="/admin/languageCreate" render={() => {
if (CheckUserPermission())
return <CreateLanguage />
else
return <Unauthorized />
}} />
render={() => {
if (CheckUserPermission())
return <CommunityQuestions />
else
return <Unauthorized />
}}
render={() => {
if (CheckUserPermission())
return <CommunityCard />
else
return <Unauthorized />
}}
<Route path="/admin/Collections" render={() => {
if (CheckUserPermission())
return <Collections />
else
return <Unauthorized />
}} />
if (CheckUserPermission())
return <CollectionCard />
else
return <Unauthorized />
}} />
render={() => {
if (CheckUserPermission())
return <EditCollection />
else
return <Unauthorized />
}}
<Route path="/admin/Ratings" render={() => {
if (CheckUserPermission())
return <Ratings />
else
return <Unauthorized />
}} />
if (CheckUserPermission())
return <RatingCard />
else
return <Unauthorized />
}} />
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
if (CheckUserPermission())
return <EditRating />
else
return <Unauthorized />
}} />
<Route path="/admin/CreateRating" render={() => {
if (CheckUserPermission())
return <CreateRating />
else
return <Unauthorized />
}} />
<Route path="/admin/Questions" render={() => {
if (CheckUserPermission())
return <Questions />
else
return <Unauthorized />
}} />
<Route path="/admin/CreateQuestion" render={() => {
if (CheckUserPermission())
return <CreateQuestions />
else
return <Unauthorized />
}} />
<Route path="/admin/activities" render={() => {
if (CheckUserPermission())
return <Activity />
else
return <Unauthorized />
}} />
if (CheckUserPermission())
return <ActivityCard />
else
return <Unauthorized />
}} />
render={() => {
if (CheckUserPermission())
return <EducationalObject />
else
return <Unauthorized />
}} />
render={() => {
if (CheckUserPermission())
return <EducationalObjectCard />
else
return <Unauthorized />
}} />
render={() => {
if (CheckUserPermission())
return <EducationalObjectEdit />
else
return <Unauthorized />
}} />
<Route path="/admin/complaints" render={() => {
if (CheckUserPermission())
return <Complaints />
else
return <Unauthorized />
}} />
if (CheckUserPermission())
return <ComplaintCard />
else
return <Unauthorized />
}} />
render={() => {
if (CheckUserPermission())
return <AproveTeacher />
else
return <Unauthorized />
}} />
<Route path="/admin/usersList" render={() => {
if (CheckUserPermission())
return <UserList />
else
return <Unauthorized />
}} />
if (CheckUserPermission())
return <UserCard />
else
return <Unauthorized />
}} />
if (CheckUserPermission())
return <EditUser />
else
return <Unauthorized />
}} />
<Route path="/admin/permissions" render={() => {
if (CheckUserPermission())
return <UserPermissions />
else
return <Unauthorized />
}} />
<Route path="/admin/EditPermissions" render={() => {
if (CheckUserPermission())
return <EditRole />
else
return <Unauthorized />
}} />
<Route path="/admin/CreateRole" render={() => {
if (CheckUserPermission())
return <CreateRole />
else
return <Unauthorized />
}} />
<Route path="/admin/BlockedUsers" render={() => {
if (CheckUserPermission())
return <BlockedUser />
else
return <Unauthorized />
}} />
if (CheckUserPermission())
return <SendEmail />
else
return <Unauthorized />
}} />
Vinícius de Lima Gonçalves
committed
</Switch>
<div>
<EcFooter />
<GNUAGPLfooter />
</div>
Vinícius de Lima Gonçalves
committed
</BrowserRouter>