commit 22/01/2026

This commit is contained in:
2026-01-22 15:31:13 +07:00
parent ffd41ee225
commit 4aea9cb619
8 changed files with 73 additions and 36 deletions

View File

@@ -1,5 +1,5 @@
#Configuration saved on 2026-01-22T13:49:56.778957100 #Configuration saved on 2026-01-22T15:17:06.581736300
#Thu Jan 22 13:49:56 WIB 2026 #Thu Jan 22 15:17:06 WIB 2026
activemq_brokerurl=tcp\://localhost\:61616 activemq_brokerurl=tcp\://localhost\:61616
activemq_password=admin activemq_password=admin
activemq_queuename=TEST.QUEUE activemq_queuename=TEST.QUEUE

View File

@@ -9,7 +9,7 @@ $(document).ready(function() {
}); });
}); });
$(window).on('beforeunload', function() { $(window).on('unload', function() {
console.log("User is leaving home.html"); console.log("User is leaving home.html");
// Your cleanup code here // Your cleanup code here
}); });

View File

@@ -1,4 +1,4 @@
$(document).ready(function() { $(document).ready(function () {
// Your code here // Your code here
console.log("log.js is loaded and ready."); console.log("log.js is loaded and ready.");
let $logchooser = $('#logchooser'); let $logchooser = $('#logchooser');
@@ -7,19 +7,19 @@ $(document).ready(function() {
$logchooser.val(new Date().toISOString().split('T')[0]); $logchooser.val(new Date().toISOString().split('T')[0]);
} }
$('#logoutbtn').on('click', function() { $('#logoutbtn').on('click', function () {
// Clear session storage on logout // Clear session storage on logout
fetch('/logout').then(() => { fetch('/logout').then(() => {
window.location.href = '/login.html'; window.location.href = '/login.html';
}); });
}); });
$logchooser.on('change', function() { $logchooser.on('change', function () {
const selectedLog = $(this).val(); const selectedLog = $(this).val();
GetLog(selectedLog); GetLog(selectedLog);
}); });
}); });
$(window).on('beforeunload', function() { $(window).on('unload', function () {
console.log("User is leaving log.html"); console.log("User is leaving log.html");
// Your cleanup code here // Your cleanup code here
}); });
@@ -27,9 +27,42 @@ $(window).on('beforeunload', function() {
// function GetLog with date parameter in string, with default value today's date in format dd/mm/yyyy // function GetLog with date parameter in string, with default value today's date in format dd/mm/yyyy
function GetLog(date = new Date().toISOString().split('T')[0]) { function GetLog(date = new Date().toISOString().split('T')[0]) {
console.log("Fetching logs for date: " + date); console.log("Fetching logs for date: " + date);
Get('getLogs?'+new URLSearchParams({date: date}).toString(), function(data){ Get('getLogs?' + new URLSearchParams({ date: date }).toString(), function (data) {
console.log(data); console.log(data);
}, function(error){ fill_table(data);
}, function (error) {
fill_table(null);
alert(error); alert(error);
}) })
}
/**
* @typedef {Object} logdata
* @property {number} index Index number of the log entry
* @property {string} date Date string in format dd/mm/yyyy
* @property {string} time Time string in format HH:MM:SS
* @property {string} function Function name where the log was generated
* @property {string} message Log message
*/
/**
* Fill table with logdata
* @param {logdata[]} data
*/
function fill_table(data) {
let $logtablebody = $('#logtablebody');
$logtablebody.empty();
if (data && Array.isArray(data) && data.length > 0) {
data.forEach(function (logentry) {
let row = `<tr>
<td>${logentry.index}</td>
<td>${logentry.date}</td>
<td>${logentry.time}</td>
<td>${logentry.function}</td>
<td>${logentry.message}</td>
</tr>`;
$logtablebody.append(row);
});
}
} }

View File

@@ -7,7 +7,7 @@ $(document).ready(function() {
} }
}); });
$(window).on('beforeunload', function() { $(window).on('unload', function() {
console.log("User is leaving login.html"); console.log("User is leaving login.html");
// Your cleanup code here // Your cleanup code here
}); });

View File

@@ -20,7 +20,7 @@ $(document).ready(function () {
}); });
}); });
$(window).on('beforeunload', function () { $(window).on('unload', function () {
console.log("User is leaving setting.html"); console.log("User is leaving setting.html");
// Your cleanup code here // Your cleanup code here
}); });

View File

@@ -30,10 +30,10 @@
<table class="table"> <table class="table">
<thead> <thead>
<tr> <tr>
<th class="col-1">No</th> <th class="col-sm-1">No</th>
<th class="col-2">Date</th> <th class="col-sm-2 col-lg-1">Date</th>
<th class="col-2">Time</th> <th class="col-sm-2 col-lg-1">Time</th>
<th class="col-2">Category</th> <th class="col-sm-2 col-lg-2">Category</th>
<th>Message</th> <th>Message</th>
</tr> </tr>
</thead> </thead>

View File

@@ -5,6 +5,7 @@ import java.io.FileInputStream
import java.io.FileNotFoundException import java.io.FileNotFoundException
import java.io.FileOutputStream import java.io.FileOutputStream
import java.nio.file.Files import java.nio.file.Files
import java.nio.file.Paths
import java.time.LocalDateTime import java.time.LocalDateTime
import java.util.Properties import java.util.Properties
import kotlin.io.path.Path import kotlin.io.path.Path
@@ -12,7 +13,8 @@ import kotlin.io.path.Path
@Suppress("unused") @Suppress("unused")
class Config { class Config {
private val prop = Properties() private val prop = Properties()
private val filename = "config.properties" // config.properties is saved in current working directory
private val filename = Paths.get(System.getProperty("user.dir"), "config.properties")
var WebPort : Int var WebPort : Int
get() = prop.getProperty("webport").toInt() get() = prop.getProperty("webport").toInt()
set(value) {prop.setProperty("webport", value.toString())} set(value) {prop.setProperty("webport", value.toString())}
@@ -64,24 +66,24 @@ class Config {
fun Load(){ fun Load(){
try{ try{
if (Files.isRegularFile(Path(filename))){ if (Files.isRegularFile(filename)){
prop.load(FileInputStream(filename)) prop.load(FileInputStream(filename.toString()))
if (!prop.contains("webport")) throw Exception("Invalid config file: missing 'webport'") if (!prop.containsKey("webport")) throw Exception("Invalid config file: missing 'webport'")
if (!prop.contains("webusername")) throw Exception("Invalid config file: missing 'webusername'") if (!prop.containsKey("webusername")) throw Exception("Invalid config file: missing 'webusername'")
if (!prop.contains("webpassword")) throw Exception("Invalid config file: missing 'webpassword'") if (!prop.containsKey("webpassword")) throw Exception("Invalid config file: missing 'webpassword'")
if (!prop.contains("activemq_brokerurl")) throw Exception("Invalid config file: missing 'activemq_brokerurl'") if (!prop.containsKey("activemq_brokerurl")) throw Exception("Invalid config file: missing 'activemq_brokerurl'")
if (!prop.contains("activemq_username")) throw Exception("Invalid config file: missing 'activemq_username'") if (!prop.containsKey("activemq_username")) throw Exception("Invalid config file: missing 'activemq_username'")
if (!prop.contains("activemq_password")) throw Exception("Invalid config file: missing 'activemq_password'") if (!prop.containsKey("activemq_password")) throw Exception("Invalid config file: missing 'activemq_password'")
if (!prop.contains("activemq_queuename")) throw Exception("Invalid config file: missing 'activemq_queuename'") if (!prop.containsKey("activemq_queuename")) throw Exception("Invalid config file: missing 'activemq_queuename'")
if (!prop.contains("mysql_aas1")) throw Exception("Invalid config file: missing 'mysql_aas1'") if (!prop.containsKey("mysql_aas1")) throw Exception("Invalid config file: missing 'mysql_aas1'")
if (!prop.contains("mysql_aas2")) throw Exception("Invalid config file: missing 'mysql_aas2'") if (!prop.containsKey("mysql_aas2")) throw Exception("Invalid config file: missing 'mysql_aas2'")
if (!prop.contains("mysql_aas3")) throw Exception("Invalid config file: missing 'mysql_aas3'") if (!prop.containsKey("mysql_aas3")) throw Exception("Invalid config file: missing 'mysql_aas3'")
if (!prop.contains("mysql_aas1_username")) throw Exception("Invalid config file: missing 'mysql_aas1_username'") if (!prop.containsKey("mysql_aas1_username")) throw Exception("Invalid config file: missing 'mysql_aas1_username'")
if (!prop.contains("mysql_aas1_password")) throw Exception("Invalid config file: missing 'mysql_aas1_password'") if (!prop.containsKey("mysql_aas1_password")) throw Exception("Invalid config file: missing 'mysql_aas1_password'")
if (!prop.contains("mysql_aas2_username")) throw Exception("Invalid config file: missing 'mysql_aas2_username'") if (!prop.containsKey("mysql_aas2_username")) throw Exception("Invalid config file: missing 'mysql_aas2_username'")
if (!prop.contains("mysql_aas2_password")) throw Exception("Invalid config file: missing 'mysql_aas2_password'") if (!prop.containsKey("mysql_aas2_password")) throw Exception("Invalid config file: missing 'mysql_aas2_password'")
if (!prop.contains("mysql_aas3_username")) throw Exception("Invalid config file: missing 'mysql_aas3_username'") if (!prop.containsKey("mysql_aas3_username")) throw Exception("Invalid config file: missing 'mysql_aas3_username'")
if (!prop.contains("mysql_aas3_password")) throw Exception("Invalid config file: missing 'mysql_aas3_password'") if (!prop.containsKey("mysql_aas3_password")) throw Exception("Invalid config file: missing 'mysql_aas3_password'")
Logger.info { "Configuration loaded from config.properties" } Logger.info { "Configuration loaded from config.properties" }
} else throw FileNotFoundException("Config file not found") } else throw FileNotFoundException("Config file not found")
} catch (e: FileNotFoundException){ } catch (e: FileNotFoundException){
@@ -102,7 +104,7 @@ class Config {
// comment is save date and time // comment is save date and time
val comment = "Configuration saved on ${LocalDateTime.now()}" val comment = "Configuration saved on ${LocalDateTime.now()}"
try{ try{
prop.store(FileOutputStream(filename), comment) prop.store(FileOutputStream(filename.toString()), comment)
Logger.info { "Configuration saved to config.properties" } Logger.info { "Configuration saved to config.properties" }
} catch (ex: Exception){ } catch (ex: Exception){
Logger.error(ex) { "Error while saving config, Message : ${ex.message}" } Logger.error(ex) { "Error while saving config, Message : ${ex.message}" }

View File

@@ -0,0 +1,2 @@
# gak mau lihat log javalin
org.slf4j.simpleLogger.defaultLogLevel=error