From 5fe50101d897348878f2d9e976bf62513b5bb22a Mon Sep 17 00:00:00 2001 From: Graphictoria Date: Sat, 2 Oct 2021 15:59:32 -0400 Subject: [PATCH] Fix game status check. --- web/resources/js/pages/Games.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/web/resources/js/pages/Games.js b/web/resources/js/pages/Games.js index 01465ec..0517cfc 100644 --- a/web/resources/js/pages/Games.js +++ b/web/resources/js/pages/Games.js @@ -1,27 +1,53 @@ // © XlXi 2021 // Graphictoria 5 +import axios from 'axios'; import React from "react"; import { Link, useHistory } from "react-router-dom"; +import Config from '../config.js'; + import SetTitle from "../Helpers/Title.js"; import { GenericErrorModal } from './Errors.js'; +var url = Config.BaseUrl.replace('http://', ''); +var protocol = Config.Protocol; + class Games extends React.Component { + constructor(props) { + super(props); + this.state = {offline: false}; + } + componentDidMount() { + var app = this; + SetTitle("Games"); + + function updateBanners() + { + axios.get(protocol + 'api.' + url + '/web/games/status').then((response) => { + app.setState({offline: !response.data.available}); + }); + } + + updateBanners(); } render() { return ( + this.state.offline + ?
Seems like XlXi tripped over the game server's power cord again. Games are temporarily unavailable and administrators have been notified of the issue. Sorry for the inconvenience!
+ : + <> ); } }