This commit is contained in:
Jan Naahs 2020-08-21 11:28:13 +02:00
parent 2d84b582cc
commit 081bfd9ba8
2 changed files with 11 additions and 12 deletions

View File

@ -13,14 +13,12 @@ const Console = ({serverStatus}) => {
const socket = new WebSocket(ws_scheme + "://" + window.location.host + "/ws");
socket.onopen = function (e) {
console.log("Socket Open")
socket.send(JSON.stringify({name: "log subscribe"}));
setSocket(socket)
};
socket.onmessage = e => {
const {name, data} = JSON.parse(e.data)
console.log(name)
switch (name) {
case 'log update':
setLogs(oldLogs => [...oldLogs, data])
@ -31,7 +29,7 @@ const Console = ({serverStatus}) => {
}
socket.onerror = e => {
console.log(e)
console.error(e)
}
consoleInput.current?.focus();

View File

@ -1,8 +1,6 @@
import React, {useEffect, useState} from "react";
import saveClient from "../../../api/resources/saves";
import savesResource from "../../../api/resources/saves";
import Panel from "../../components/Panel";
import ButtonLink from "../../components/ButtonLink";
import Button from "../../components/Button";
import CreateSaveForm from "./components/CreateSaveForm";
import UploadSaveForm from "./components/UploadSaveForm";
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
@ -12,11 +10,14 @@ const Saves = ({serverStatus}) => {
const [saves, setSaves] = useState([]);
const updateList = async () => {
const res = await saveClient.list();
if (res.success) {
setSaves(res.data);
}
const updateList = () => {
savesResource.list()
.then(res => {
if (res.success) {
setSaves(res.data);
}
})
}
useEffect(() => {
@ -24,7 +25,7 @@ const Saves = ({serverStatus}) => {
}, []);
const deleteSave = async (save) => {
const res = await saveClient.delete(save);
const res = await savesResource.delete(save);
if (res.success) {
updateList()
}