Merge pull request #13 from mesacarlos/feature/full-logs
Feature/full logs
This commit is contained in:
commit
39b4ea5592
@ -230,6 +230,10 @@
|
||||
<input type="checkbox" class="custom-control-input" id="showDateSettingsSwitch">
|
||||
<label class="custom-control-label" for="showDateSettingsSwitch" id="showDateSettingsSwitchLabel">Show date and time on each console line</label>
|
||||
</div>
|
||||
<div class="custom-control custom-switch">
|
||||
<input type="checkbox" class="custom-control-input" id="readLogFileSwitch">
|
||||
<label class="custom-control-label" for="readLogFileSwitch" id="readLogFileSwitchLabel">Retrieve full log file from server after login</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal" id="settingsModalCloseButton">Done</button>
|
||||
@ -241,7 +245,7 @@
|
||||
<!-- Webpage footer -->
|
||||
<footer class="footer mt-auto py-3">
|
||||
<div class="container">
|
||||
<span class="text-muted">WebConsole v1.4 (rev. 6) - <a href="https://github.com/mesacarlos/WebConsole">GitHub</a></span>
|
||||
<span class="text-muted">WebConsole v1.5 - <a href="https://github.com/mesacarlos/WebConsole">GitHub</a></span>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@ -251,11 +255,11 @@
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- WebConsole JS Scripts -->
|
||||
<script src="scripts/WebConsoleLanguage.js?v=1.4.6"></script>
|
||||
<script src="scripts/WebConsoleConnector.js?v=1.4.6"></script>
|
||||
<script src="scripts/WebConsoleManager.js?v=1.4.6"></script>
|
||||
<script src="scripts/WebConsolePersistenceManager.js?v=1.4.6"></script>
|
||||
<script src="scripts/WebConsole.js?v=1.4.6"></script>
|
||||
<script src="scripts/WebConsoleJqueryHandler.js?v=1.4.6"></script>
|
||||
<script src="scripts/WebConsoleLanguage.js?v=1.5.0"></script>
|
||||
<script src="scripts/WebConsoleConnector.js?v=1.5.0"></script>
|
||||
<script src="scripts/WebConsoleManager.js?v=1.5.0"></script>
|
||||
<script src="scripts/WebConsolePersistenceManager.js?v=1.5.0"></script>
|
||||
<script src="scripts/WebConsole.js?v=1.5.0"></script>
|
||||
<script src="scripts/WebConsoleJqueryHandler.js?v=1.5.0"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -57,6 +57,11 @@ function onWebSocketsMessage(message){
|
||||
case 200:
|
||||
//Processed
|
||||
writeToWebConsole(message.message);
|
||||
if(connectionManager.activeConnection.isLogged === false){
|
||||
connectionManager.activeConnection.isLogged = true;
|
||||
if(persistenceManager.getSetting("retrieveLogFile") === true)
|
||||
connectionManager.askForLogs();
|
||||
}
|
||||
break;
|
||||
case 400:
|
||||
//Unknown Command
|
||||
@ -155,7 +160,7 @@ function writeToWebConsole(msg){
|
||||
|
||||
//Append datetime if enabled
|
||||
if(persistenceManager.getSetting("dateTimePrefix"))
|
||||
msg = "[" + new Date().toLocaleString() + "] " + msg;
|
||||
msg = "[" + new Date().toLocaleTimeString() + "] " + msg;
|
||||
|
||||
$("#consoleTextArea").append(msg + "<br>");
|
||||
|
||||
|
@ -13,6 +13,7 @@ class WebConsoleConnector {
|
||||
this.messages = []; //All messages retrieved since connection start
|
||||
this.commands = []; //EXEC Commands sent by user to this server
|
||||
this.players = []; //Connected users.
|
||||
this.isLogged = false; //Is logged in with valid pasword or not
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -195,6 +195,7 @@ $("#disconnectionModalWelcomeScreenButton").click(function() {
|
||||
$("#settingsLink").click(function() {
|
||||
//Update modal switches and boxes with saved settings
|
||||
$("#showDateSettingsSwitch").prop("checked", persistenceManager.getSetting("dateTimePrefix"));
|
||||
$("#readLogFileSwitch").prop("checked", persistenceManager.getSetting("retrieveLogFile"));
|
||||
});
|
||||
|
||||
/**
|
||||
@ -203,4 +204,12 @@ $("#settingsLink").click(function() {
|
||||
$("#showDateSettingsSwitch").click(function() {
|
||||
//Update modal switches and boxes with saved settings
|
||||
persistenceManager.setSetting("dateTimePrefix", $("#showDateSettingsSwitch").is(":checked"));
|
||||
});
|
||||
|
||||
/**
|
||||
* On readLogFileSwitch switched
|
||||
*/
|
||||
$("#readLogFileSwitch").click(function() {
|
||||
//Update modal switches and boxes with saved settings
|
||||
persistenceManager.setSetting("retrieveLogFile", $("#readLogFileSwitch").is(":checked"));
|
||||
});
|
@ -38,6 +38,7 @@ function setLanguage(locale){
|
||||
"settingsLink": "Settings",
|
||||
"settingsModalLongTitle": "WebConsole Settings",
|
||||
"showDateSettingsSwitchLabel": "Show date and time on each console line",
|
||||
"readLogFileSwitchLabel": "Retrieve full log file from server after login",
|
||||
"settingsModalCloseButton": "Done",
|
||||
"players_online": "Players Online",
|
||||
"cpu_title": "CPU",
|
||||
@ -75,6 +76,7 @@ function setLanguage(locale){
|
||||
"settingsLink": "Configuración",
|
||||
"settingsModalLongTitle": "Configuración de WebConsole",
|
||||
"showDateSettingsSwitchLabel": "Mostrar fecha y hora en cada linea de consola",
|
||||
"readLogFileSwitchLabel": "Leer log completo al iniciar sesión",
|
||||
"settingsModalCloseButton": "Hecho",
|
||||
"players_online": "Jugadores en línea",
|
||||
"cpu_title": "CPU",
|
||||
@ -112,6 +114,7 @@ function setLanguage(locale){
|
||||
"settingsLink": "настройки",
|
||||
"settingsModalLongTitle": "настройки WebConsole",
|
||||
"showDateSettingsSwitchLabel": "Показать дату и время в каждой строке консоли",
|
||||
"readLogFileSwitchLabel": "Получить полный файл журнала с сервера после входа в систему",
|
||||
"settingsModalCloseButton": "Выполнено",
|
||||
"players_online": "Игроки",
|
||||
"cpu_title": "CPU",
|
||||
@ -149,6 +152,7 @@ function setLanguage(locale){
|
||||
"settingsLink": "Configurações",
|
||||
"settingsModalLongTitle": "Configurações do WebConsole",
|
||||
"showDateSettingsSwitchLabel": "Mostrar data e hora em cada linha do console",
|
||||
"readLogFileSwitchLabel": "Recuperar arquivo de log completo do servidor após o login",
|
||||
"settingsModalCloseButton": "Feito",
|
||||
"players_online": "Jogadores online",
|
||||
"cpu_title": "Consumo de CPU",
|
||||
@ -186,6 +190,7 @@ function setLanguage(locale){
|
||||
"settingsLink": "设定值",
|
||||
"settingsModalLongTitle": "WebConsole 设定值",
|
||||
"showDateSettingsSwitchLabel": "在每个控制台行上显示日期和时间",
|
||||
"readLogFileSwitchLabel": "登录后从服务器检索完整的日志文件",
|
||||
"settingsModalCloseButton": "完成",
|
||||
"players_online": "在线人数",
|
||||
"cpu_title": "CPU",
|
||||
@ -223,6 +228,7 @@ function setLanguage(locale){
|
||||
"settingsLink": "Réglages",
|
||||
"settingsModalLongTitle": "Réglages de WebConsole",
|
||||
"showDateSettingsSwitchLabel": "Afficher la date et l'heure sur chaque ligne de console",
|
||||
"readLogFileSwitchLabel": "Récupérer le fichier journal complet du serveur après la connexion",
|
||||
"settingsModalCloseButton": "Terminé",
|
||||
"players_online": "Joueurs en ligne",
|
||||
"cpu_title": "Utilisation de la CPU",
|
||||
@ -260,6 +266,7 @@ function setLanguage(locale){
|
||||
"settingsLink": "Nastavení",
|
||||
"settingsModalLongTitle": "Nastavení WebConsole",
|
||||
"showDateSettingsSwitchLabel": "Zobrazit datum a čas na každé řádce konzoly",
|
||||
"readLogFileSwitchLabel": "Po přihlášení načtěte úplný soubor protokolu ze serveru",
|
||||
"settingsModalCloseButton": "Hotovo",
|
||||
"players_online": "Počet hráčů online",
|
||||
"cpu_title": "CPU",
|
||||
@ -281,31 +288,4 @@ function setLanguage(locale){
|
||||
}
|
||||
});
|
||||
|
||||
// document.getElementById("navbarHomeLink").textContent = lang.navbarHomeLink;
|
||||
// document.getElementById("home_header").textContent = lang.home_header;
|
||||
// document.getElementById("home_description").textContent = lang.home_description;
|
||||
// document.getElementById("serversDropdown").textContent = lang.serversDropdown;
|
||||
// document.getElementById("add_server").textContent = lang.add_server;
|
||||
// document.getElementById("lang_dropdown").textContent = lang.lang_dropdown;
|
||||
// document.getElementById("addServerModalLongTitle").textContent = lang.addServerModalLongTitle;
|
||||
// document.getElementById("addServerModalSvName").textContent = lang.addServerModalSvName;
|
||||
// document.getElementById("addServerModalSvIp").textContent = lang.addServerModalSvIp;
|
||||
// document.getElementById("addServerModalSvPort").textContent = lang.addServerModalSvPort;
|
||||
// document.getElementById("addServerModalSvSsl").textContent = lang.addServerModalSvSsl;
|
||||
// document.getElementById("addServerModalSslAdvice").textContent = lang.addServerModalSslAdvice;
|
||||
// document.getElementById("addServerModalClose").textContent = lang.addServerModalClose;
|
||||
// document.getElementById("saveAndConnectServerButton").textContent = lang.saveAndConnectServerButton;
|
||||
// document.getElementById("passwordModalLongTitle").textContent = lang.passwordModalLongTitle;
|
||||
// document.getElementById("passwordModalLabel").textContent = lang.passwordModalLabel;
|
||||
// document.getElementById("passwordModalRememberLabel").textContent = lang.passwordModalRememberLabel;
|
||||
// document.getElementById("passwordModalCloseButton").textContent = lang.passwordModalCloseButton;
|
||||
// document.getElementById("passwordSendButton").textContent = lang.passwordSendButton;
|
||||
// document.getElementById("disconnectionModalLongTitle").textContent = lang.disconnectionModalLongTitle;
|
||||
// document.getElementById("disconnectionModalDescription").textContent = lang.disconnectionModalDescription;
|
||||
// document.getElementById("disconnectionModalCloseButton").textContent = lang.disconnectionModalCloseButton;
|
||||
// document.getElementById("players_online").textContent = lang.players_online;
|
||||
// document.getElementById("cpu_title").textContent = lang.cpu_title;
|
||||
// document.getElementById("ram_title").textContent = lang.ram_title;
|
||||
// document.getElementById("deleteServerButton").textContent = lang.deleteServerButton;
|
||||
// document.getElementById("sendCommandButton").textContent = lang.sendCommandButton;
|
||||
}
|
@ -79,5 +79,12 @@ class WebConsoleManager {
|
||||
this.activeConnection.sendToServer("CPUUSAGE");
|
||||
this.activeConnection.sendToServer("RAMUSAGE");
|
||||
}
|
||||
|
||||
/**
|
||||
* Asks server for full latest.log
|
||||
*/
|
||||
askForLogs(){
|
||||
this.activeConnection.sendToServer("READLOGFILE");
|
||||
}
|
||||
|
||||
}
|
@ -135,8 +135,10 @@ class WebConsolePersistenceManager{
|
||||
currentSettings = new Object();
|
||||
}
|
||||
|
||||
//Setting array initialization. If you need to add more settings, add them here. Any object is valid as a value (not only bool)
|
||||
var settings = {
|
||||
dateTimePrefix : new Setting("dateTimePrefix", true)
|
||||
dateTimePrefix : new Setting("dateTimePrefix", true),
|
||||
retrieveLogFile : new Setting("retrieveLogFile", true)
|
||||
}
|
||||
|
||||
//Set settings
|
||||
|
@ -20,7 +20,7 @@ cpu-usage-message = Usage is {0}%
|
||||
# ExecCommand.java
|
||||
cmd-executed-console = [WebConsole] {0} executed "{1}".
|
||||
|
||||
#LogInCommand.java
|
||||
# LogInCommand.java
|
||||
login-sucessful-message = Logged in
|
||||
login-sucessful-console = [WebConsole] Successfully logged in from {0}
|
||||
login-failed-message = Incorrect password, try again
|
||||
@ -35,4 +35,7 @@ ram-usage-message = {0} free, {1} used, {2} maximum memory
|
||||
# WebConsoleCommand.java
|
||||
webconsole-version = WebConsole version {0}.
|
||||
webconsole-no-connections = There are no logged in WebConsole connections now.
|
||||
webconsole-active-connections = Connected to WebConsole from:
|
||||
webconsole-active-connections = Connected to WebConsole from:
|
||||
|
||||
# ReadLogFileCommand.java
|
||||
log-read-error = Error trying to read latest.log file
|
@ -35,4 +35,7 @@ ram-usage-message = {0} volné, {1} použité, {2} maximální paměti
|
||||
# WebConsoleCommand.java
|
||||
webconsole-version = WebConsole verze {0}.
|
||||
webconsole-no-connections = Nejsou žádné WebConsole připojení.
|
||||
webconsole-active-connections = Připojeno k WebConsole z:
|
||||
webconsole-active-connections = Připojeno k WebConsole z:
|
||||
|
||||
# ReadLogFileCommand.java
|
||||
log-read-error = Chyba při čtení souboru latest.log
|
@ -35,4 +35,7 @@ ram-usage-message = {0} free, {1} used, {2} maximum memory
|
||||
# WebConsoleCommand.java
|
||||
webconsole-version = WebConsole version {0}.
|
||||
webconsole-no-connections = There are no logged in WebConsole connections now.
|
||||
webconsole-active-connections = Connected to WebConsole from:
|
||||
webconsole-active-connections = Connected to WebConsole from:
|
||||
|
||||
# ReadLogFileCommand.java
|
||||
log-read-error = Error trying to read latest.log file
|
@ -20,7 +20,7 @@ cpu-usage-message = En uso {0}%
|
||||
# ExecCommand.java
|
||||
cmd-executed-console = [WebConsole] {0} ejecutó "{1}".
|
||||
|
||||
#LogInCommand.java
|
||||
# LogInCommand.java
|
||||
login-sucessful-message = Sesión iniciada
|
||||
login-sucessful-console = [WebConsole] Sesión iniciada con éxito desde {0}
|
||||
login-failed-message = Contraña incorrecta, inténtalo de nuevo
|
||||
@ -35,4 +35,7 @@ ram-usage-message = Memoria: {0} libre, {1} usada, {2} maxima
|
||||
# WebConsoleCommand.java
|
||||
webconsole-version = WebConsole version {0}.
|
||||
webconsole-no-connections = No hay ninguna conexión activa a WebConsole en este momento.
|
||||
webconsole-active-connections = Conectado a WebConsole desde:
|
||||
webconsole-active-connections = Conectado a WebConsole desde:
|
||||
|
||||
# ReadLogFileCommand.java
|
||||
log-read-error = Error leyendo el fichero latest.log
|
@ -35,4 +35,7 @@ ram-usage-message = {0} gratuit, {1} utilisé, {2} mémoire maximale
|
||||
# WebConsoleCommand.java
|
||||
webconsole-version = version WebConsole {0}.
|
||||
webconsole-no-connections = Aucune connexion WebConsole n'est connectée maintenant.
|
||||
webconsole-active-connections = Connecté à WebConsole depuis:
|
||||
webconsole-active-connections = Connecté à WebConsole depuis:
|
||||
|
||||
# ReadLogFileCommand.java
|
||||
log-read-error = Erreur lors de la lecture du fichier latest.log
|
@ -20,7 +20,7 @@ cpu-usage-message = Consumindo {0}%
|
||||
# ExecCommand.java
|
||||
cmd-executed-console = [WebConsole] {0} executou "{1}".
|
||||
|
||||
#LogInCommand.java
|
||||
# LogInCommand.java
|
||||
login-sucessful-message = Você foi autênticado.
|
||||
login-sucessful-console = [WebConsole] {0} acabou de se conectar.
|
||||
login-failed-message = Senha incorreta, porfavor, contate algum responsável.
|
||||
@ -35,4 +35,7 @@ ram-usage-message = Disponível: {0}, Consumo de RAM: {1} / {2}
|
||||
# WebConsoleCommand.java
|
||||
webconsole-version = WebConsole versão {0}.
|
||||
webconsole-no-connections = Atualmente não tem nenhum usuário conectado.
|
||||
webconsole-active-connections = Atualmente temos:
|
||||
webconsole-active-connections = Atualmente temos:
|
||||
|
||||
# ReadLogFileCommand.java
|
||||
log-read-error = Erro ao ler o arquivo latest.log
|
@ -20,7 +20,7 @@ cpu-usage-message = Использование {0}%
|
||||
# ExecCommand.java
|
||||
cmd-executed-console = [WebConsole] {0} выполнил "{1}".
|
||||
|
||||
#LogInCommand.java
|
||||
# LogInCommand.java
|
||||
login-sucessful-message = Войти в систему
|
||||
login-sucessful-console = [WebConsole] Успешно вошел в систему с {0}
|
||||
login-failed-message = Неверный пароль, попробуйте еще раз
|
||||
@ -35,4 +35,7 @@ ram-usage-message = {0} свободно, {1} используется, {2} ма
|
||||
# WebConsoleCommand.java
|
||||
webconsole-version = Версия WebConsole {0}.
|
||||
webconsole-no-connections = В настоящее время нет подключений к WebConsole.
|
||||
webconsole-active-connections = Подключен к веб-консоли из :
|
||||
webconsole-active-connections = Подключен к веб-консоли из :
|
||||
|
||||
# ReadLogFileCommand.java
|
||||
log-read-error = ошибка чтения последнего latest.log
|
@ -20,7 +20,7 @@ cpu-usage-message = 已使用 {0}%
|
||||
# ExecCommand.java
|
||||
cmd-executed-console = [網站控制台] {0} 執行 '{1}'.
|
||||
|
||||
#LogInCommand.java
|
||||
# LogInCommand.java
|
||||
login-sucessful-message = 登錄
|
||||
login-sucessful-console = [網站控制台] 成功登錄 {0}
|
||||
login-failed-message = 密碼不正確,請重試
|
||||
@ -35,4 +35,7 @@ ram-usage-message = 空閒{0} , 已使用{1} , 最大內存{2}
|
||||
# WebConsoleCommand.java
|
||||
webconsole-version = 網站控制台版本 {0}.
|
||||
webconsole-no-connections = 現在沒有連接登錄網站控制台。
|
||||
webconsole-active-connections = 從以下位置連接到網站控制台:
|
||||
webconsole-active-connections = 從以下位置連接到網站控制台:
|
||||
|
||||
# ReadLogFileCommand.java
|
||||
log-read-error = 读取Latest.log文件时出错
|
@ -1,7 +1,7 @@
|
||||
name: WebConsole
|
||||
main: com.mesacarlos.webconsole.WebConsole
|
||||
api-version: 1.13
|
||||
version: 1.4
|
||||
version: 1.5
|
||||
description: WebSockets-based web console
|
||||
author: Carlos Mesa
|
||||
commands:
|
||||
|
2
pom.xml
2
pom.xml
@ -4,7 +4,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>WebConsole</groupId>
|
||||
<artifactId>WebConsole</artifactId>
|
||||
<version>1.4</version>
|
||||
<version>1.5</version>
|
||||
<build>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<plugins>
|
||||
|
@ -11,6 +11,7 @@ public class CommandFactory {
|
||||
commands.put("PLAYERS", new PlayersCommand());
|
||||
commands.put("CPUUSAGE", new CpuUsageCommand());
|
||||
commands.put("RAMUSAGE", new RamUsageCommand());
|
||||
commands.put("READLOGFILE", new ReadLogFileCommand());
|
||||
return commands;
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package com.mesacarlos.webconsole.websocket.command;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.java_websocket.WebSocket;
|
||||
|
||||
import com.mesacarlos.webconsole.util.Internationalization;
|
||||
import com.mesacarlos.webconsole.websocket.WSServer;
|
||||
import com.mesacarlos.webconsole.websocket.response.ConsoleOutput;
|
||||
|
||||
public class ReadLogFileCommand implements WSCommand{
|
||||
|
||||
@Override
|
||||
public void execute(WSServer wsServer, WebSocket conn, String params) {
|
||||
List<String> lines = null;
|
||||
try {
|
||||
lines = Files.readAllLines(Paths.get("logs/latest.log"), StandardCharsets.UTF_8);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if(lines == null) {
|
||||
Bukkit.getLogger().info(Internationalization.getPhrase("log-read-error"));
|
||||
return;
|
||||
}
|
||||
|
||||
for(String line : lines)
|
||||
wsServer.sendToClient(conn, new ConsoleOutput(line));
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user