diff --git a/src/App.js b/src/App.js index 85124a18683056979ce8f29cb47e177e5e7d792f..6f480bcf8e4f6edcaae712b9c985dde5162a41c5 100644 --- a/src/App.js +++ b/src/App.js @@ -16,7 +16,7 @@ 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 } from 'react'; +import React, { useContext, useEffect, useState } from 'react'; import Home from './Pages/Home'; import Search from './Pages/Search' import Header from './Components/Header' @@ -35,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, useLocation } from 'react-router-dom'; import { Store } from './Store' import TermsPage from './Pages/TermsPage.js' import PublicationPermissionsPage from './Pages/PublicationPermissionsPage.js' @@ -44,10 +44,16 @@ import ItemStore from './Pages/ItemStore.js' import EditProfilePage from './Pages/EditProfilePage.js' import PublicUserPage from './Pages/PublicUserPage.js' import FormationMaterialPage from './Pages/FormationMaterialPage.js'; +import FormationMaterialIframe from './Pages/FormationMaterialIframe.js'; export default function App(){ // eslint-disable-next-line const { state, dispatch } = useContext(Store) + const [ hideFooter, setHideFooter ] = useState(false); + + useEffect(() => { + setHideFooter(String(window.location.href).includes('iframe-colecao')); + }, [ window.location.href ]); useEffect(()=>{ dispatch({ @@ -104,9 +110,14 @@ export default function App(){ <Route path='/loja' component={ItemStore} /> <Route path='/colecao' component={FormationMaterialPage} /> <Route path='/topico' component={FormationMaterialPage} /> + <Route path='/iframe-colecao' component={FormationMaterialIframe} /> </Switch> - <EcFooter/> - <GNUAGPLfooter/> + { !hideFooter && + <div> + <EcFooter/> + <GNUAGPLfooter/> + </div> + } </BrowserRouter> ) } diff --git a/src/Pages/FormationMaterialIframe.js b/src/Pages/FormationMaterialIframe.js new file mode 100644 index 0000000000000000000000000000000000000000..496a0dbc796a1130d62b4d753bf8f3fafd442d7e --- /dev/null +++ b/src/Pages/FormationMaterialIframe.js @@ -0,0 +1,57 @@ +/*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 from 'react'; +import styled from 'styled-components'; +import colecoes_obj from '../Components/FormationMaterialsResources/formationMaterials.js'; + +export default function FormationMaterialIframe(props) { + const colecao = props.location.pathname == "/colecao"; + const colecoes = colecoes_obj(); + + const colecao_id = Number( + colecao ? + props.location.search.split('=')[1] + : props.location.search.split('&')[0].split('=')[1] + ); + const topico_id = Number(colecao ? 0 : props.location.search.split('&')[1].split('=')[1]); + + const colecao_obj = ((id) => { + for (const c in colecoes) { + if (id == colecoes[c].id) + return colecoes[c]; + } + })(colecao_id); + + const topico_obj = ((id) => { + for (const t in colecao_obj.topics) { + if (id == colecao_obj.topics[t].id) + return colecao_obj.topics[t]; + } + })(topico_id); + + return ( + <StyledIframe src={topico_obj.url} + /> + ); +} + +const StyledIframe=styled.iframe` + width: 98.vw; + height: 83.5vh; + min-height: 300px; +`