diff --git a/server/model/monitor.js b/server/model/monitor.js index 62d788a93..2fcb08758 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -502,7 +502,7 @@ class Monitor extends BeanModel { bean.status = UP; bean.ping = state.ping; } catch (e) { - throw new Error("Server is offline"); + throw new Error(e.message); } } else if (this.type === "docker") { log.debug(`[${this.name}] Prepare Options for Axios`); diff --git a/server/socket-handlers/general-socket-handler.js b/server/socket-handlers/general-socket-handler.js index 700b4a384..11b47a5bf 100644 --- a/server/socket-handlers/general-socket-handler.js +++ b/server/socket-handlers/general-socket-handler.js @@ -2,6 +2,30 @@ const { log } = require("../../src/util"); const { Settings } = require("../settings"); const { sendInfo } = require("../client"); const { checkLogin } = require("../util-server"); +const GameResolver = require("gamedig/lib/GameResolver"); + +let gameResolver = new GameResolver(); +let gameList = null; + +/** + * Get a game list via GameDig + * @returns {any[]} + */ +function getGameList() { + if (!gameList) { + gameList = gameResolver._readGames().games.sort((a, b) => { + if ( a.pretty < b.pretty ) { + return -1; + } + if ( a.pretty > b.pretty ) { + return 1; + } + return 0; + }); + } else { + return gameList; + } +} module.exports.generalSocketHandler = (socket, server) => { @@ -17,4 +41,11 @@ module.exports.generalSocketHandler = (socket, server) => { } }); + socket.on("getGameList", async (callback) => { + callback({ + ok: true, + gameList: getGameList(), + }); + }); + }; diff --git a/src/pages/EditMonitor.vue b/src/pages/EditMonitor.vue index 3003f3a93..16ecb887b 100644 --- a/src/pages/EditMonitor.vue +++ b/src/pages/EditMonitor.vue @@ -114,7 +114,11 @@