import React from 'react'; import superagent from 'superagent'; import cookie from 'react-cookies'; import MenuPageWrapper from '../Wrappers/MenuPageWrapper.jsx'; import RoomComponent from './RoomComponent.jsx'; import * as ApiUtils from '../CloudApi/ApiUtils.js'; import { Accordion, Segment, Grid, Header, Image, Icon, Button, Table, Form, Divider, Label, Modal, Statistic } from 'semantic-ui-react' const MAX_BAN_REASON_LENGTH = 10; export default class ModeratorRoomPage extends React.Component { constructor(props) { super(props); this.state = { room: null }; } async componentDidMount() { const cloudSchemas = await ApiUtils.getCloudSchemas(); this.setState({ cloudSchemas }); await this.reloadRoom(); setInterval(this.reloadRoom.bind(this), 5000); const environmentOptions = await ApiUtils.getEnvironmentOptions(); this.setState({ environmentOptions }); } async reloadRoom() { try { const roomId = this.props.match.params.roomId; const res = await superagent.get(`/cloud/admin/room/${roomId}`).accept('json'); console.log(res.body); this.setState({ room: res.body.storedRoom, liveRoom: res.body.liveRoom, roomInstances: res.body.roomInstances, history: res.body.history, ownerBigscreenAccount: res.body.ownerBigscreenAccount }); } catch (e) { console.log(e); } } async onUpdateRoom(roomIndex, event, { name, value }) { if (this.state.room) { let payload = {}; payload[name] = value; let room = this.state.room; if (name === 'environment') { room.environmentId = value; } else { room[name] = value; } this.setState({ room }); await superagent.put(`/cloud/admin/room/${room.roomId}`).send(payload).accept('json'); console.log("updated room"); } } onEjectParticipant(user, userIndex, room, roomIndex, e) { e.preventDefault(); if (this.state.liveRoom) { let liveRoom = this.state.liveRoom; delete liveRoom.participantsIndex[user.userSessionId]; this.setState({ liveRoom }); superagent.get(`/cloud/admin/room/${liveRoom.roomId}/users/${user.userSessionId}/eject`).accept('json').end(function(err, res) { console.log("User was ejected..."); }.bind(this)); } } onKickParticipant(user, userIndex, room, roomIndex, e) { e.preventDefault(); if (this.state.liveRoom) { let liveRoom = this.state.liveRoom; delete liveRoom.participantsIndex[user.userSessionId]; this.setState({ liveRoom }); superagent.get(`/cloud/admin/room/${liveRoom.roomId}/users/${user.userSessionId}/kick`).accept('json').end(function(err, res) { console.log("User was kicked..."); }.bind(this)); } } render() { if (this.state.room) { return (
); } else { return (
Room Info
); } } }