Skip to content

Commit

Permalink
Merge pull request #13 from mesacarlos/feature/full-logs
Browse files Browse the repository at this point in the history
Feature/full logs
  • Loading branch information
mesacarlos authored Feb 22, 2020
2 parents a54230b + 67f2827 commit 39b4ea5
Show file tree
Hide file tree
Showing 19 changed files with 120 additions and 51 deletions.
18 changes: 11 additions & 7 deletions client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ <h5 class="modal-title" id="settingsModalLongTitle">WebConsole Settings</h5>
<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>
Expand All @@ -241,7 +245,7 @@ <h5 class="modal-title" id="settingsModalLongTitle">WebConsole Settings</h5>
<!-- 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>

Expand All @@ -251,11 +255,11 @@ <h5 class="modal-title" id="settingsModalLongTitle">WebConsole Settings</h5>
<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>
7 changes: 6 additions & 1 deletion client/scripts/WebConsole.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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>");

Expand Down
1 change: 1 addition & 0 deletions client/scripts/WebConsoleConnector.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

/**
Expand Down
9 changes: 9 additions & 0 deletions client/scripts/WebConsoleJqueryHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
});

/**
Expand All @@ -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"));
});
34 changes: 7 additions & 27 deletions client/scripts/WebConsoleLanguage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -112,6 +114,7 @@ function setLanguage(locale){
"settingsLink": "настройки",
"settingsModalLongTitle": "настройки WebConsole",
"showDateSettingsSwitchLabel": "Показать дату и время в каждой строке консоли",
"readLogFileSwitchLabel": "Получить полный файл журнала с сервера после входа в систему",
"settingsModalCloseButton": "Выполнено",
"players_online": "Игроки",
"cpu_title": "CPU",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -186,6 +190,7 @@ function setLanguage(locale){
"settingsLink": "设定值",
"settingsModalLongTitle": "WebConsole 设定值",
"showDateSettingsSwitchLabel": "在每个控制台行上显示日期和时间",
"readLogFileSwitchLabel": "登录后从服务器检索完整的日志文件",
"settingsModalCloseButton": "完成",
"players_online": "在线人数",
"cpu_title": "CPU",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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;
}
7 changes: 7 additions & 0 deletions client/scripts/WebConsoleManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

}
4 changes: 3 additions & 1 deletion client/scripts/WebConsolePersistenceManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions phrases.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
5 changes: 4 additions & 1 deletion phrases_cs.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 4 additions & 1 deletion phrases_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 5 additions & 2 deletions phrases_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
5 changes: 4 additions & 1 deletion phrases_fr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 5 additions & 2 deletions phrases_pt.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
7 changes: 5 additions & 2 deletions phrases_ru.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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 = Неверный пароль, попробуйте еще раз
Expand All @@ -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
7 changes: 5 additions & 2 deletions phrases_zh.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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 = 密碼不正確,請重試
Expand All @@ -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文件时出错
2 changes: 1 addition & 1 deletion plugin.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public static HashMap<String, WSCommand> getCommandsHashMap() {
commands.put("PLAYERS", new PlayersCommand());
commands.put("CPUUSAGE", new CpuUsageCommand());
commands.put("RAMUSAGE", new RamUsageCommand());
commands.put("READLOGFILE", new ReadLogFileCommand());
return commands;
}
}
Loading

0 comments on commit 39b4ea5

Please sign in to comment.