diff --git a/config.properties b/config.properties
index 0075de8..e226ee4 100644
--- a/config.properties
+++ b/config.properties
@@ -1,5 +1,5 @@
-#Configuration saved on 2026-01-22T13:49:56.778957100
-#Thu Jan 22 13:49:56 WIB 2026
+#Configuration saved on 2026-01-22T15:17:06.581736300
+#Thu Jan 22 15:17:06 WIB 2026
activemq_brokerurl=tcp\://localhost\:61616
activemq_password=admin
activemq_queuename=TEST.QUEUE
diff --git a/html/assets/js/home.js b/html/assets/js/home.js
index e873aea..22b980e 100644
--- a/html/assets/js/home.js
+++ b/html/assets/js/home.js
@@ -9,7 +9,7 @@ $(document).ready(function() {
});
});
-$(window).on('beforeunload', function() {
+$(window).on('unload', function() {
console.log("User is leaving home.html");
// Your cleanup code here
});
\ No newline at end of file
diff --git a/html/assets/js/log.js b/html/assets/js/log.js
index fd32f56..9f62d27 100644
--- a/html/assets/js/log.js
+++ b/html/assets/js/log.js
@@ -1,4 +1,4 @@
-$(document).ready(function() {
+$(document).ready(function () {
// Your code here
console.log("log.js is loaded and ready.");
let $logchooser = $('#logchooser');
@@ -7,19 +7,19 @@ $(document).ready(function() {
$logchooser.val(new Date().toISOString().split('T')[0]);
}
- $('#logoutbtn').on('click', function() {
+ $('#logoutbtn').on('click', function () {
// Clear session storage on logout
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();
GetLog(selectedLog);
});
});
-$(window).on('beforeunload', function() {
+$(window).on('unload', function () {
console.log("User is leaving log.html");
// 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(date = new Date().toISOString().split('T')[0]) {
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);
- }, function(error){
+ fill_table(data);
+ }, function (error) {
+ fill_table(null);
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 = `
+ | ${logentry.index} |
+ ${logentry.date} |
+ ${logentry.time} |
+ ${logentry.function} |
+ ${logentry.message} |
+
`;
+ $logtablebody.append(row);
+ });
+ }
+
}
\ No newline at end of file
diff --git a/html/assets/js/login.js b/html/assets/js/login.js
index d13ba5e..1e67c32 100644
--- a/html/assets/js/login.js
+++ b/html/assets/js/login.js
@@ -7,7 +7,7 @@ $(document).ready(function() {
}
});
-$(window).on('beforeunload', function() {
+$(window).on('unload', function() {
console.log("User is leaving login.html");
// Your cleanup code here
});
\ No newline at end of file
diff --git a/html/assets/js/setting.js b/html/assets/js/setting.js
index 622d351..6c38d05 100644
--- a/html/assets/js/setting.js
+++ b/html/assets/js/setting.js
@@ -20,7 +20,7 @@ $(document).ready(function () {
});
});
-$(window).on('beforeunload', function () {
+$(window).on('unload', function () {
console.log("User is leaving setting.html");
// Your cleanup code here
});
diff --git a/html/log.html b/html/log.html
index 2aa284e..3d94146 100644
--- a/html/log.html
+++ b/html/log.html
@@ -30,10 +30,10 @@
- | No |
- Date |
- Time |
- Category |
+ No |
+ Date |
+ Time |
+ Category |
Message |
diff --git a/src/Other/Config.kt b/src/Other/Config.kt
index 0b3239e..e040844 100644
--- a/src/Other/Config.kt
+++ b/src/Other/Config.kt
@@ -5,6 +5,7 @@ import java.io.FileInputStream
import java.io.FileNotFoundException
import java.io.FileOutputStream
import java.nio.file.Files
+import java.nio.file.Paths
import java.time.LocalDateTime
import java.util.Properties
import kotlin.io.path.Path
@@ -12,7 +13,8 @@ import kotlin.io.path.Path
@Suppress("unused")
class Config {
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
get() = prop.getProperty("webport").toInt()
set(value) {prop.setProperty("webport", value.toString())}
@@ -64,24 +66,24 @@ class Config {
fun Load(){
try{
- if (Files.isRegularFile(Path(filename))){
- prop.load(FileInputStream(filename))
- if (!prop.contains("webport")) throw Exception("Invalid config file: missing 'webport'")
- if (!prop.contains("webusername")) throw Exception("Invalid config file: missing 'webusername'")
- if (!prop.contains("webpassword")) throw Exception("Invalid config file: missing 'webpassword'")
- if (!prop.contains("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.contains("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.contains("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.contains("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.contains("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.contains("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.contains("mysql_aas3_password")) throw Exception("Invalid config file: missing 'mysql_aas3_password'")
+ if (Files.isRegularFile(filename)){
+ prop.load(FileInputStream(filename.toString()))
+ if (!prop.containsKey("webport")) throw Exception("Invalid config file: missing 'webport'")
+ if (!prop.containsKey("webusername")) throw Exception("Invalid config file: missing 'webusername'")
+ if (!prop.containsKey("webpassword")) throw Exception("Invalid config file: missing 'webpassword'")
+ if (!prop.containsKey("activemq_brokerurl")) throw Exception("Invalid config file: missing 'activemq_brokerurl'")
+ if (!prop.containsKey("activemq_username")) throw Exception("Invalid config file: missing 'activemq_username'")
+ if (!prop.containsKey("activemq_password")) throw Exception("Invalid config file: missing 'activemq_password'")
+ if (!prop.containsKey("activemq_queuename")) throw Exception("Invalid config file: missing 'activemq_queuename'")
+ if (!prop.containsKey("mysql_aas1")) throw Exception("Invalid config file: missing 'mysql_aas1'")
+ if (!prop.containsKey("mysql_aas2")) throw Exception("Invalid config file: missing 'mysql_aas2'")
+ if (!prop.containsKey("mysql_aas3")) throw Exception("Invalid config file: missing 'mysql_aas3'")
+ if (!prop.containsKey("mysql_aas1_username")) throw Exception("Invalid config file: missing 'mysql_aas1_username'")
+ if (!prop.containsKey("mysql_aas1_password")) throw Exception("Invalid config file: missing 'mysql_aas1_password'")
+ if (!prop.containsKey("mysql_aas2_username")) throw Exception("Invalid config file: missing 'mysql_aas2_username'")
+ if (!prop.containsKey("mysql_aas2_password")) throw Exception("Invalid config file: missing 'mysql_aas2_password'")
+ if (!prop.containsKey("mysql_aas3_username")) throw Exception("Invalid config file: missing 'mysql_aas3_username'")
+ if (!prop.containsKey("mysql_aas3_password")) throw Exception("Invalid config file: missing 'mysql_aas3_password'")
Logger.info { "Configuration loaded from config.properties" }
} else throw FileNotFoundException("Config file not found")
} catch (e: FileNotFoundException){
@@ -102,7 +104,7 @@ class Config {
// comment is save date and time
val comment = "Configuration saved on ${LocalDateTime.now()}"
try{
- prop.store(FileOutputStream(filename), comment)
+ prop.store(FileOutputStream(filename.toString()), comment)
Logger.info { "Configuration saved to config.properties" }
} catch (ex: Exception){
Logger.error(ex) { "Error while saving config, Message : ${ex.message}" }
diff --git a/src/simplelogger.properties b/src/simplelogger.properties
new file mode 100644
index 0000000..dd35ce8
--- /dev/null
+++ b/src/simplelogger.properties
@@ -0,0 +1,2 @@
+# gak mau lihat log javalin
+org.slf4j.simpleLogger.defaultLogLevel=error