2017-05-18 01:21:02 +03:00
|
|
|
/*
|
|
|
|
Copyright 2015, 2016 OpenMarket Ltd
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const React = require('react');
|
|
|
|
const AddAppDialog = require('../dialogs/AddAppDialog');
|
2017-05-22 14:34:27 +03:00
|
|
|
const AppTile = require('../elements/AppTile');
|
|
|
|
const Modal = require("../../../Modal");
|
2017-05-18 01:21:02 +03:00
|
|
|
|
2017-05-30 15:47:17 +03:00
|
|
|
// FIXME -- Hard coded widget config
|
|
|
|
const roomWidgetConfig = {
|
2017-05-30 17:32:53 +03:00
|
|
|
// Cooking room
|
2017-05-30 15:47:17 +03:00
|
|
|
'!IAkkwswSrOSzPRWksX:matrix.org': [
|
|
|
|
{
|
|
|
|
id: "youtube",
|
2017-05-30 17:32:53 +03:00
|
|
|
url: "https://www.youtube.com/embed/ZJy1ajvMU1k?controls=0&enablejsapi=1&iv_load_policy=3&modestbranding=1&playsinline=1&autoplay=1",
|
2017-05-30 15:47:17 +03:00
|
|
|
name: "Live stream - Boeuf Bourguignon",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "recipie",
|
2017-06-07 01:45:17 +03:00
|
|
|
url: "http://10.9.64.55:8000/recepie.html",
|
2017-05-30 15:47:17 +03:00
|
|
|
name: "Ingredients - Boeuf Bourguignon",
|
|
|
|
},
|
|
|
|
],
|
2017-05-30 17:32:53 +03:00
|
|
|
// Grafana room
|
|
|
|
'!JWeMRscvtWqfNuzmSf:matrix.org': [
|
|
|
|
{
|
|
|
|
id: "grafana",
|
2017-06-07 01:45:17 +03:00
|
|
|
url: "http://10.9.64.55:8000/grafana.html",
|
2017-05-30 17:32:53 +03:00
|
|
|
name: "Monitoring our Single-Point-Of-Failure DB",
|
|
|
|
},
|
|
|
|
],
|
2017-06-05 20:21:31 +03:00
|
|
|
// Camgirl room - https://www.youtube.com/watch?v=ZfkwW4GgAiU
|
2017-05-30 17:32:53 +03:00
|
|
|
'!wQqrqwOipOOWALxJNe:matrix.org': [
|
|
|
|
{
|
|
|
|
id: "youtube",
|
|
|
|
url: "https://www.youtube.com/embed/ZfkwW4GgAiU?controls=0&enablejsapi=1&iv_load_policy=3&modestbranding=1&playsinline=1&autoplay=1",
|
|
|
|
name: "Live stream - ChatGirl86",
|
|
|
|
},
|
2017-05-30 20:39:51 +03:00
|
|
|
{
|
|
|
|
id: "thermometer",
|
2017-06-07 01:45:17 +03:00
|
|
|
url: "http://10.9.64.55:8000/index.html",
|
2017-05-30 20:39:51 +03:00
|
|
|
name: "Tip Me!!! -- Send me cash $$$",
|
|
|
|
},
|
2017-05-30 17:32:53 +03:00
|
|
|
],
|
|
|
|
// Game room - https://www.youtube.com/watch?v=Dm2Ma1dOFO4
|
|
|
|
'!dYSCwtVljhTdBlgNxq:matrix.org': [
|
|
|
|
{
|
|
|
|
id: "youtube",
|
|
|
|
url: "https://www.youtube.com/embed/Dm2Ma1dOFO4?controls=0&enablejsapi=1&iv_load_policy=3&modestbranding=1&playsinline=1&autoplay=1",
|
|
|
|
name: "Live stream - Overwatch Balle Royale",
|
|
|
|
},
|
2017-05-30 20:39:51 +03:00
|
|
|
{
|
|
|
|
id: "thermometer",
|
2017-06-07 01:45:17 +03:00
|
|
|
url: "http://10.9.64.55:8000/index.html",
|
2017-05-30 20:39:51 +03:00
|
|
|
name: "Tip Me!!! -- Send me cash $$$",
|
|
|
|
},
|
2017-05-30 17:32:53 +03:00
|
|
|
],
|
2017-06-05 20:21:31 +03:00
|
|
|
// Game room - !BLQjREzUgbtIsgrvRn:matrix.org
|
|
|
|
'!BLQjREzUgbtIsgrvRn:matrix.org': [
|
|
|
|
{
|
|
|
|
id: "etherpad",
|
2017-06-07 01:45:17 +03:00
|
|
|
url: "http://10.9.64.55:8000/etherpad.html",
|
2017-06-05 20:21:31 +03:00
|
|
|
name: "Etherpad",
|
|
|
|
},
|
|
|
|
],
|
2017-05-30 15:47:17 +03:00
|
|
|
};
|
|
|
|
|
2017-05-18 01:21:02 +03:00
|
|
|
module.exports = React.createClass({
|
|
|
|
displayName: 'AppsDrawer',
|
|
|
|
|
|
|
|
propTypes: {
|
|
|
|
},
|
|
|
|
|
|
|
|
componentDidMount: function() {
|
|
|
|
},
|
|
|
|
|
2017-06-05 20:21:31 +03:00
|
|
|
initAppConfig: function(appConfig) {
|
|
|
|
console.log("App props: ", this.props);
|
|
|
|
appConfig = appConfig.map(
|
|
|
|
(app, index, arr) => {
|
|
|
|
switch(app.id) {
|
|
|
|
case 'etherpad':
|
|
|
|
app.url = app.url + '?userName=' + this.props.userId +
|
|
|
|
'&padId=' + this.props.room.roomId;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return app;
|
|
|
|
});
|
|
|
|
return appConfig;
|
|
|
|
},
|
|
|
|
|
2017-05-18 01:21:02 +03:00
|
|
|
getInitialState: function() {
|
2017-05-30 15:47:17 +03:00
|
|
|
for (const key in roomWidgetConfig) {
|
|
|
|
if(key == this.props.room.roomId) {
|
|
|
|
return {
|
2017-06-05 20:21:31 +03:00
|
|
|
apps: this.initAppConfig(roomWidgetConfig[key]),
|
2017-05-30 15:47:17 +03:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
2017-05-18 01:21:02 +03:00
|
|
|
return {
|
2017-05-30 15:47:17 +03:00
|
|
|
apps: [],
|
2017-05-18 01:21:02 +03:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
onClickAddWidget: function() {
|
2017-05-22 14:34:27 +03:00
|
|
|
Modal.createDialog(AddAppDialog, {
|
|
|
|
onFinished: (proceed, reason) => {
|
|
|
|
if (!proceed) return;
|
|
|
|
|
|
|
|
this.state.apps.push();
|
|
|
|
},
|
2017-05-18 01:21:02 +03:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
render: function() {
|
2017-05-22 14:34:27 +03:00
|
|
|
const apps = this.state.apps.map(
|
2017-05-31 12:08:39 +03:00
|
|
|
(app, index, arr) => <AppTile
|
|
|
|
key={app.id}
|
|
|
|
id={app.id}
|
|
|
|
url={app.url}
|
|
|
|
name={app.name}
|
|
|
|
fullWdith={arr.length<2 ? true : false}
|
2017-06-05 20:21:31 +03:00
|
|
|
roomId={this.props.roomId}
|
|
|
|
userId={this.props.userId}
|
2017-05-31 12:08:39 +03:00
|
|
|
/>);
|
2017-05-22 14:34:27 +03:00
|
|
|
|
2017-06-06 16:50:43 +03:00
|
|
|
const addWidget = this.state.apps && this.state.apps.length < 2 &&
|
|
|
|
(<div onClick={this.onClickAddWidget}
|
|
|
|
role="button"
|
|
|
|
tabIndex="0"
|
|
|
|
className="mx_AddWidget_button"
|
|
|
|
title="Add a widget">
|
|
|
|
[+] Add a widget
|
|
|
|
</div>);
|
|
|
|
|
2017-05-18 01:21:02 +03:00
|
|
|
return (
|
|
|
|
<div className="mx_AppsDrawer">
|
2017-05-22 14:34:27 +03:00
|
|
|
<div id="apps" className="mx_AppsContainer">
|
|
|
|
{apps}
|
|
|
|
</div>
|
2017-06-06 16:50:43 +03:00
|
|
|
{addWidget}
|
2017-05-18 01:21:02 +03:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
});
|