import React from 'react'; import superagent from 'superagent'; import { fromUnixTime, formatDistanceToNow } from "date-fns"; import { formatInTimeZone } from 'date-fns-tz' import { Button, Header, Label, Table, Image, Segment, Icon } from 'semantic-ui-react'; import AppsWrapper from './AppsWrapper.jsx'; import { DEFAULT_TIMEZONE } from '../CloudApi/Constants.js'; class RDCRow extends React.Component { constructor(props) { super(props); } render() { if (!this.props.file) { return
; } const createdAt = formatInTimeZone(new Date(this.props.file.lastModified), DEFAULT_TIMEZONE, 'PPPp z'); const fromNow = formatDistanceToNow(new Date(this.props.file.lastModified), { addSuffix: true }); const isActive = this.props.activeRDC && (_.startsWith(this.props.activeRDC.build, this.props.file.build)); return ( {this.props.file.build} {isActive && } {this.props.file.size} {fromNow} ) } } export default class RDC extends React.Component { constructor(props) { super(props); this.state = { files: [], activeRDC: null, loading: false }; } async componentDidMount() { await this.load(); } async load() { this.setState({ loading: true }); try { let res = await superagent.get(`/api/admin/rdc`).accept('json'); let files = res.body.sort((a, b) => new Date(b.lastModified) - new Date(a.lastModified)); this.setState({ files: res.body }); res = await superagent.get(`/api/admin/rdc/active`).accept('json'); this.setState({ activeRDC: res.body}); } catch (e) { console.error(e); } this.setState({ loading: false }); } async setRDCActive(build) { this.setState({ loading: true }); const res = await superagent.put(`/api/admin/rdc/active/${build}`); await this.load(); } render() { let activeClientBox =
Nothing active!
; if (this.state.activeRDC) { const timezone = "America/Los_Angeles"; //const lastModified = formatInTimeZone(new Date(this.state.activeRDC.lastModified), DEFAULT_TIMEZONE, 'PPPp z'); activeClientBox = (
Active Version (Windows)
Build: {this.state.activeRDC.build} Installer: {this.state.activeRDC.installer} Version: {this.state.activeRDC.version} Checksum: {this.state.activeRDC.checksum} Network: {this.state.activeRDC.network || "not specified"} Stage: {this.state.activeRDC.stage} Platform: {this.state.activeRDC.platform}
); } return ( {activeClientBox} File Size (bytes) Last Modified {this.state.files.map(file => { return ( ); })}
); } }