Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PortalMEC-React
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
PortalMEC
PortalMEC-React
Commits
035a2913
Commit
035a2913
authored
4 years ago
by
Lucas Eduardo Schoenfelder
Browse files
Options
Downloads
Patches
Plain Diff
now with vimeo player!
parent
55254551
No related branches found
No related tags found
3 merge requests
!57
Merge of develop into master
,
!56
Fixed buttons reportar, seguir, compartilhar, guardar and entrar (in comments...
,
!24
Tela recurso
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Pages/ResourcePage.js
+77
-14
77 additions, 14 deletions
src/Pages/ResourcePage.js
with
77 additions
and
14 deletions
src/Pages/ResourcePage.js
+
77
−
14
View file @
035a2913
...
...
@@ -16,7 +16,8 @@ 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
,
{
useEffect
,
useState
}
from
'
react
'
import
React
,
{
useEffect
,
useState
,
useContext
}
from
'
react
'
import
{
Store
}
from
'
../Store.js
'
import
styled
from
'
styled-components
'
import
axios
from
'
axios
'
import
{
apiUrl
,
apiDomain
}
from
'
../env
'
;
...
...
@@ -33,22 +34,59 @@ export function Alert(props) {
return
<
MuiAlert
elevation
=
{
6
}
variant
=
"
filled
"
{...
props
}
/>
;
}
function
GetEmbeddedLink
(
link
)
{
if
(
link
.
indexOf
(
"
youtube
"
)
!=
-
1
)
{
//plain youtebe.com/ link
if
(
link
.
indexOf
(
"
embed/
"
)
!=
-
1
)
{
//if it's already an embedded link, return it
return
link
}
link
=
link
.
split
(
"
&
"
)[
0
]
//else remove features and other queries
var
link
=
link
.
split
(
"
v=
"
)[
1
]
//get video id
var
embed
=
"
https://www.youtube.com/embed/
"
+
link
;
//create embedded link
}
else
if
(
link
.
indexOf
(
"
youtu.be
"
)
!=
-
1
)
{
//if it's a youtu.be link
link
=
link
.
split
(
"
&
"
)[
0
].
split
(
"
?
"
)[
0
]
//remove queries and features if existent
link
=
link
.
split
(
"
.be/
"
)[
1
]
//get video id
var
embed
=
"
https://www.youtube.com/embed/
"
+
link
;
//create embedded link
}
else
if
(
link
.
indexOf
(
"
vimeo
"
)
!=
-
1
)
{
//if the 13th character = o (vimeo videos)
link
=
link
.
split
(
"
?
"
)[
0
].
split
(
"
/
"
)
console
.
log
(
link
)
//key # = from 19th character on
var
embed
=
"
https://player.vimeo.com/video/
"
+
link
.
pop
();
//Add vimeo link before key #
}
return
embed
}
export
default
function
LearningObjectPage
(
props
){
const
{
state
}
=
useContext
(
Store
)
const
id
=
props
.
match
.
params
.
recursoId
const
[
carregando
,
toggle
]
=
useState
(
true
)
const
[
recurso
,
setRecurso
]
=
useState
({})
useEffect
(
()
=>
{
axios
.
get
(
(
`
${
apiUrl
}
/learning_objects/`
+
id
)
).
then
(
(
response
)
=>
{
if
(
response
.
headers
[
'
access-token
'
]
)
{
sessionStorage
.
setItem
(
'
@portalmec/accessToken
'
,
response
.
headers
[
'
access-token
'
])
let
config
=
{
headers
:
{
'
Accept
'
:
'
application/json
'
,
'
Content-Type
'
:
'
application/json
'
,
}
}
if
(
state
.
currentUser
.
id
!==
""
)
{
config
.
headers
[
"
Access-Token
"
]
=
sessionStorage
.
getItem
(
'
@portalmec/accessToken
'
);
config
.
headers
.
Client
=
sessionStorage
.
getItem
(
'
@portalmec/clientToken
'
)
config
.
headers
.
Uid
=
sessionStorage
.
getItem
(
'
@portalmec/uid
'
)
}
console
.
log
(
response
)
setRecurso
(
response
.
data
)
axios
.
get
(
(
`
${
apiUrl
}
/learning_objects/`
+
id
),
config
).
then
(
(
response
)
=>
{
if
(
response
.
headers
[
'
access-token
'
]
)
{
sessionStorage
.
setItem
(
'
@portalmec/accessToken
'
,
response
.
headers
[
'
access-token
'
])
}
console
.
log
(
response
)
setRecurso
(
response
.
data
)
},
(
error
)
=>
{
console
.
log
(
error
)})
toggle
(
false
)
},
(
error
)
=>
{
console
.
log
(
error
)}
)
},
[])
},
[,
state
.
currentUser
]
)
const
[
snackbarOpen
,
toggleSnackbar
]
=
useState
(
false
)
const
handleSnackbar
=
(
index
)
=>
{
setIndex
(
index
);
toggleSnackbar
(
true
)}
...
...
@@ -80,6 +118,16 @@ export default function LearningObjectPage (props){
:
(
<
Grid
container
spacing
=
{
2
}
>
{(
recurso
.
object_type
===
"
Vídeo
"
&&
recurso
.
link
)
&&
<
Grid
item
xs
=
{
12
}
>
<
Card
>
<
div
className
=
"
video-container
"
>
<
iframe
src
=
{
GetEmbeddedLink
(
recurso
.
link
)}
frameBorder
=
"
0
"
allowFullScreen
className
=
"
video
"
><
/iframe
>
<
/div
>
<
/Card
>
<
/Grid
>
}
<
Grid
item
xs
=
{
12
}
>
<
Card
>
<
div
>
...
...
@@ -100,7 +148,7 @@ export default function LearningObjectPage (props){
educationalStages
=
{
recurso
.
educational_stages
}
viewCount
=
{
recurso
.
views_count
}
downloadCount
=
{
recurso
.
downloads_count
}
id
=
{
recurso
.
publisher
.
i
d
}
id
=
{
recurso
.
publisher
?
recurso
.
publisher
.
id
:
undefine
d
}
stateRecurso
=
{
recurso
.
state
}
/
>
<
/div
>
...
...
@@ -124,9 +172,9 @@ export default function LearningObjectPage (props){
{
/*add option to MoreVertIcon*/
}
{
/*change render method on additional item info*/
}
<
Sobre
avatar
=
{
recurso
.
publisher
.
avatar
?
(
apiDomain
+
recurso
.
publisher
.
avatar
)
:
noAvatar
}
publisher
=
{
recurso
.
publisher
.
name
}
id
=
{
recurso
.
publisher
.
i
d
}
avatar
=
{
recurso
.
publisher
?
(
recurso
.
publisher
.
avatar
?
(
apiDomain
+
recurso
.
publisher
.
avatar
)
:
noAvatar
)
:
noAvatar
}
publisher
=
{
recurso
.
publisher
?
recurso
.
publisher
.
name
:
undefined
}
id
=
{
recurso
.
publisher
?
recurso
.
publisher
.
id
:
undefine
d
}
description
=
{
recurso
.
description
}
author
=
{
recurso
.
author
}
tags
=
{
recurso
.
tags
}
...
...
@@ -140,7 +188,7 @@ export default function LearningObjectPage (props){
<
/Card
>
<
/Grid
>
<
Grid
item
xs
=
{
12
}
>
<
Card
>
{
/*adicionar funcionalidade ao botao de entrar*/
}
...
...
@@ -198,4 +246,19 @@ const Card = styled.div`
width : 100%;
}
}
.video-container {
position : relative;
width : 100%;
height : 0;
padding-bottom : 56.25%;
}
.video {
width : 100%;
height : 100%;
position : absolute;
top : 0;
left : 0;
}
`
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment