/* * Copyright 2007-2017 Charles du Jeu - Abstrium SAS * This file is part of Pydio. * * Pydio 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. * * Pydio 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 Pydio. If not, see . * * The latest code can be found at . */ const React = require('react') const ReactDOM = require('react-dom') const {asGridItem} = require('pydio').requireLib('components') const {MenuItem, IconMenu} = require('material-ui') import VideoPlayer from './VideoPlayer' import Palette from '../board/Palette' import ColorPaper from '../board/ColorPaper' const PALETTE_INDEX = 4; /** * Display a list of tutorial videos as a material card */ let VideoCard = React.createClass({ propTypes:{ youtubeId : React.PropTypes.string, contentMessageId : React.PropTypes.string }, getInitialState: function(){ this._videos = [ ['qvsSeLXr-T4', 'user_home.63'], ['HViCWPpyZ6k', 'user_home.79'], ['jBRNqwannJM', 'user_home.80'], ['2jl1EsML5v8', 'user_home.81'], ['28-t4dvhE6c', 'user_home.82'], ['fP0MVejnVZE', 'user_home.83'], ['TXFz4w4trlQ', 'user_home.84'], ['OjHtgnL_L7Y', 'user_home.85'], ['ot2Nq-RAnYE', 'user_home.66'] ]; const k = Math.floor(Math.random() * this._videos.length); const value = this._videos[k]; return { videoIndex : k, youtubeId : value[0], contentMessageId: value[1] }; }, launchVideo: function(){ const url = "//www.youtube.com/embed/"+this.state.youtubeId+"?list=PLxzQJCqzktEbYm3U_O1EqFru0LsEFBca5&autoplay=1"; this._videoDiv = document.createElement('div'); document.body.appendChild(this._videoDiv); ReactDOM.render(, this._videoDiv); }, closePlayer: function(){ ReactDOM.unmountComponentAtNode(this._videoDiv); document.body.removeChild(this._videoDiv); }, getTitle: function(messId){ const text = this.props.pydio.MessageHash[messId]; return text.split('\n').shift().replace('

', '').replace('

', ''); }, browse: function(direction = 'next', event){ let nextIndex; const {videoIndex} = this.state; if(direction === 'next'){ nextIndex = videoIndex < this._videos.length -1 ? videoIndex + 1 : 0; }else{ nextIndex = videoIndex > 0 ? videoIndex - 1 : this._videos.length - 1; } const value = this._videos[nextIndex]; this.setState({ videoIndex : nextIndex, youtubeId : value[0], contentMessageId: value[1] }); }, render: function(){ const MessageHash = this.props.pydio.MessageHash; const htmlMessage = function(id){ return {__html:MessageHash[id]}; }; const menus = this._videos.map(function(item, index){ return {this.setState({youtubeId:item[0], contentMessageId:item[1], videoIndex: index})} }/>; }.bind(this)); let props = {...this.props}; const {youtubeId, contentMessageId} = this.state; props.className += ' video-card'; const tint = MaterialUI.Color(Palette[PALETTE_INDEX]).alpha(0.8).toString(); return ( {return this.props.closeButton}}>
} anchorOrigin={{horizontal: 'right', vertical: 'top'}} targetOrigin={{horizontal: 'right', vertical: 'top'}} >{menus}
); } }); VideoCard = asGridItem(VideoCard,global.pydio.MessageHash['user_home.94'],{gridWidth:2,gridHeight:12},[]); export {VideoCard as default}