commit 24/10/2025

This commit is contained in:
2025-10-24 16:29:33 +07:00
parent fe4e73ff98
commit 2986433706
10 changed files with 738 additions and 456 deletions

View File

@@ -1,15 +1,15 @@
#Configuration file
#Thu Oct 23 15:01:47 WIB 2025
#Fri Oct 24 10:57:19 WIB 2025
database.host=localhost
database.name=aas
database.password=admin
database.port=3306
database.user=admin
remark.FLD=
remark.GBD=
remark.GFC=
remark.GOP=
soundbank.directory=C\:\\Users\\rdkar\\OneDrive\\Documents\\IntelliJ Project\\AAS_NewGen\\soundbank
remark.FLD=Gate Change [4]
remark.GBD=Second Call [2]
remark.GFC=Last Call [3]
remark.GOP=First Call [1]
soundbank.directory=C\:\\soundbank
webapp.admin.password=password
webapp.admin.username=admin
webapp.port=3030

View File

@@ -66,8 +66,8 @@ function fill_schedulebanktablebody(vv) {
* @param {String} value from input date, which is in format yyyy-mm-dd
* @returns {String} converted date in format dd/mm/yyyy
*/
function Convert_input_date_to_string(value){
if (value && value.length>0 && value.includes('-')){
function Convert_input_date_to_string(value) {
if (value && value.length > 0 && value.includes('-')) {
let parts = value.split('-');
if (parts.length === 3) {
let year = parts[0];
@@ -84,8 +84,8 @@ function Convert_input_date_to_string(value){
* @param {String} value string date in format dd/mm/yyyy
* @returns {String} converted date in format yyyy-mm-dd
*/
function Convert_string_to_input_date(value){
if (value && value.length>0 && value.includes('/')){
function Convert_string_to_input_date(value) {
if (value && value.length > 0 && value.includes('/')) {
let parts = value.split('/');
if (parts.length === 3) {
let day = parts[0];
@@ -190,7 +190,7 @@ $(document).ready(function () {
width: '100%',
dropdownParent: $('#schedulemodal')
});
$scheduledate.prop('disabled', true).val('');
$schedulezones.empty().select2({
data: window.BroadcastZoneList.map(zone => ({ id: zone.description, text: zone.description })),
@@ -295,7 +295,6 @@ $(document).ready(function () {
const hour = parseInt($schedulehour.val(), 10);
const minute = parseInt($scheduleminute.val(), 10);
const _Time = `${hour.toString().padStart(2, '0')}:${minute.toString().padStart(2, '0')}`;
console.log(`Adding schedule: Description=${Description}, Day=${_Day}, Time=${_Time}, Message=${Message}, Repeat=${Repeat}, Enable=${Enable}, BroadcastZones=${broadcastZones}, Language=${Language}`);
if (Description.length > 0) {
if (_Day.length > 0) {
if (Message.length > 0) {
@@ -367,7 +366,6 @@ $(document).ready(function () {
BroadcastZones: cells.eq(7).text(),
Language: cells.eq(8).text()
}
console.log('Editing schedule:', sr);
if (confirm(`Are you sure to edit schedule [${sr.index}] Description=${sr.Description}?`)) {
$schedulemodal.modal('show');
clearScheduleModal();
@@ -387,8 +385,13 @@ $(document).ready(function () {
case 'Everyday':
$scheduleeveryday.click();
break;
case 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday':
console.log(`Setting weekly schedule for day: ${sr.Day}`);
case 'Sunday' :
case 'Monday':
case 'Tuesday':
case 'Wednesday':
case 'Thursday':
case 'Friday':
case 'Saturday':
$scheduleweekly.click();
$weeklyselect.val(sr.Day).trigger('change');
break;
@@ -415,49 +418,50 @@ $(document).ready(function () {
if ($scheduleeveryday.is(':checked')) {
Day = "Everyday";
} else if ($schedulespecialdate.is(':checked')) {
Day = $scheduledate.val();
} else {
if ($schedulesunday.is(':checked')) Day = "Sunday";
if ($schedulemonday.is(':checked')) Day = "Monday";
if ($scheduletuesday.is(':checked')) Day = "Tuesday";
if ($schedulewednesday.is(':checked')) Day = "Wednesday";
if ($schedulethursday.is(':checked')) Day = "Thursday";
if ($schedulefriday.is(':checked')) Day = "Friday";
if ($schedulesaturday.is(':checked')) Day = "Saturday";
// convert date from yyyy-mm-dd to dd/mm/yyyy
Day = Convert_input_date_to_string($scheduledate.val());
} else if ($scheduleweekly.is(':checked')) {
Day = $weeklyselect.val();
}
// Broadcast zones (assuming comma-separated string)
const BroadcastZones = $schedulezones.val();
// Validate required fields
if (!Description || !Soundpath || Day === "") {
alert("Description, sound path, and day are required.");
return;
}
const BroadcastZones = $schedulezones.val().join(';');
const Language = $languageselect.val().join(';');
// Format time as HH:mm
const hour = parseInt($schedulehour.val(), 10);
const minute = parseInt($scheduleminute.val(), 10);
const Time = `${hour.toString().padStart(2, '0')}:${minute.toString().padStart(2, '0')}`;
if (Description && Description.length > 0) {
if (Day && Day.length > 0) {
if (Soundpath && Soundpath.length > 0) {
if (Time && Time.length > 0) {
if (Language && Language.length > 0) {
if (BroadcastZones && BroadcastZones.length > 0) {
// Prepare object
const scheduleObj = {
Description,
Day,
Time,
Soundpath,
Repeat,
Enable,
BroadcastZones,
Language
};
// Prepare object
const scheduleObj = {
Description,
Day,
Time,
Soundpath,
Repeat,
Enable,
BroadcastZones
};
fetchAPI(APIURL + "UpdateByIndex/" + sr.index, "PATCH", {}, scheduleObj, (okdata) => {
alert("Success edit schedule: " + okdata.message);
reloadTimerBank(APIURL);
}, (errdata) => {
alert("Error edit schedule: " + errdata.message);
});
$schedulemodal.modal('hide');
} else alert("At least one Broadcast Zone is required");
} else alert("At least one Language is required");
} else alert("Time is invalid");
} else alert("Message is not selected");
} else alert("Day is invalid");
} else alert("Description is empty");
fetchAPI(APIURL + "UpdateByIndex/" + sr.index, "PATCH", {}, scheduleObj, (okdata) => {
alert("Success edit schedule: " + okdata.message);
reloadTimerBank(APIURL);
}, (errdata) => {
alert("Error edit schedule: " + errdata.message);
});
$schedulemodal.modal('hide');
});
}
}

View File

@@ -1,21 +1,16 @@
let selected_language = null;
let selected_category = null;
let selected_voice = null;
/**
* Load setting language dropdown
*/
function load_setting_language(){
selected_language = null;
function load_setting_language() {
$("#setting_language").empty().off('change');
getLanguages( () => {
window.languages.forEach( (lang) => {
getLanguages(() => {
window.languages.forEach((lang) => {
let $option = $("<option></option>").attr("value", lang).text(lang);
$("#setting_language").append($option);
});
$("#setting_language").on('change', function() {
selected_language = $(this).val();
$("#setting_language").on('change', function () {
change_droparea_enable();
});
});
@@ -24,16 +19,14 @@ function load_setting_language(){
/**
* Load setting category dropdown
*/
function load_setting_category(){
selected_category = null;
function load_setting_category() {
$("#setting_category").empty().off('change');
getCategories( () => {
window.categories.forEach( (cat) => {
getCategories(() => {
window.categories.forEach((cat) => {
let $option = $("<option></option>").attr("value", cat).text(cat);
$("#setting_category").append($option);
});
$("#setting_category").on('change', function() {
selected_category = $(this).val();
$("#setting_category").on('change', function () {
change_droparea_enable();
});
});
@@ -42,25 +35,30 @@ function load_setting_category(){
/**
* Load setting voice dropdown
*/
function load_setting_voice(){
selected_voice = null;
function load_setting_voice() {
$("#setting_voice").empty().off('change');
getVoiceTypes( () => {
window.voiceTypes.forEach( (voice) => {
getVoiceTypes(() => {
window.voiceTypes.forEach((voice) => {
let $option = $("<option></option>").attr("value", voice).text(voice);
$("#setting_voice").append($option);
});
$("#setting_voice").on('change', function() {
selected_voice = $(this).val();
$("#setting_voice").on('change', function () {
change_droparea_enable();
});
});
}
function get_soundbank_path(){
/**
* Get Soundbank path from server
*/
function get_soundbank_path() {
$("#setting_path").val("");
fetchAPI("Settings/SoundbankDirectory", "GET", {}, null, (okdata) => {
console.log("Soundbank path : " + okdata);
$("#setting_path").val(okdata);
if (okdata.message && okdata.message.trim().length > 0) {
let path = okdata.message.trim();
//console.log("Soundbank path retrieved: " + path);
$("#setting_path").val(path);
}
}, (errdata) => {
alert("Error getting soundbank path : " + errdata.message);
});
@@ -69,7 +67,10 @@ function get_soundbank_path(){
/**
* Enable or disable drop area based on selections
*/
function change_droparea_enable(){
function change_droparea_enable() {
let selected_category = $("#setting_category").val();
let selected_language = $("#setting_language").val();
let selected_voice = $("#setting_voice").val();
if (selected_category && selected_language && selected_voice) {
$("#drop-area").removeClass("disabled");
} else {
@@ -77,45 +78,49 @@ function change_droparea_enable(){
}
}
function load_messagebank(cbOK = null){
/**
* Load message bank data into selection dropdowns
* @param {Function || null} cbOK callback when complete
*/
function load_messagebank(cbOK = null) {
$("#input_GOP").empty();
$("#input_GBD").empty();
$("#input_GFC").empty();
$("#input_FLD").empty();
// get messagebank data from server
reloadMessageBank(()=>{
console.log("Will load " + window.messagebankdata.length + " message bank items into selection.");
window.messagebankdata.forEach((item)=>{
let opt = `${item.description} [${item.aNN_ID}]`;
console.log("Adding option: " + opt);
$("#input_GOP").append($("<option></option>").attr("value", opt).text(opt));
$("#input_GBD").append($("<option></option>").attr("value", opt).text(opt));
$("#input_GFC").append($("<option></option>").attr("value", opt).text(opt));
$("#input_FLD").append($("<option></option>").attr("value", opt).text(opt));
});
if (window.messagebankdata.length > 0) {
if (cbOK) cbOK();
}
// get messagebank data from server, which contains [FLIGHT_NUMBER]
let messageData = [...new Set(window.messagebankdata.filter(mb => mb.message_Detail.includes('[FLIGHT_NUMBER]')).map(mb => `${mb.description} [${mb.aNN_ID}]`))];
//console.log("Message bank data with [FLIGHT_NUMBER]: ", messageData);
messageData.forEach((item) => {
//console.log("Adding option: " + item);
$("#input_GOP").append($("<option></option>").attr("value", item).text(item));
$("#input_GBD").append($("<option></option>").attr("value", item).text(item));
$("#input_GFC").append($("<option></option>").attr("value", item).text(item));
$("#input_FLD").append($("<option></option>").attr("value", item).text(item));
});
if (window.messagebankdata.length > 0) {
if (cbOK) cbOK();
}
}
function load_remark_selection(){
function load_remark_selection() {
fetchAPI("Settings/FISCode", "GET", {}, null, (okdata) => {
$("#input_GOP").val(okdata.GOP);
$("#input_GBD").val(okdata.GBD);
$("#input_GFC").val(okdata.GFC);
$("#input_FLD").val(okdata.FLD);
//console.log("FIS codes retrieved: ", JSON.stringify(okdata));
$("#input_GOP").val(okdata.gop)
$("#input_GBD").val(okdata.gbd);
$("#input_GFC").val(okdata.gfc);
$("#input_FLD").val(okdata.fld);
}, (errdata) => {
alert("Error getting FIS codes : " + errdata.message);
});
}
$(document).ready(function() {
$(document).ready(function () {
console.log("setting.js loaded");
$("#save_directory").off('click').on('click', function() {
$("#save_directory").off('click').on('click', function () {
let new_path = $("#setting_path").val();
if (new_path && new_path.trim().length > 0) {
fetchAPI("Settings/SoundbankDirectory", "POST", {}, { directory: new_path }, (okdata) => {
@@ -126,15 +131,15 @@ $(document).ready(function() {
} else {
alert("Please enter a valid soundbank directory path.");
}
});
});
// get_soundbank_path();
get_soundbank_path();
load_setting_category();
load_setting_language();
load_setting_voice();
load_messagebank(()=> load_remark_selection());
$("#fiscodesave").off('click').on('click', function() {
load_messagebank(() => load_remark_selection());
$("#fiscodesave").off('click').on('click', function () {
let gop = $("#input_GOP").val();
let gbd = $("#input_GBD").val();
let gfc = $("#input_GFC").val();
@@ -154,7 +159,73 @@ $(document).ready(function() {
} else {
alert("Please select all FIS codes (GOP, GBD, GFC, FLD) before saving.");
}
});
$("#drop-area").on('dragover', function (e) {
e.preventDefault();
e.stopPropagation();
$(this).addClass('dragover');
}).on('dragleave', function (e) {
e.preventDefault();
e.stopPropagation();
$(this).removeClass('dragover');
}).on('drop', function (e) {
e.preventDefault();
e.stopPropagation();
$(this).removeClass('dragover');
if ($(this).hasClass('disabled')) {
alert("Please select Category, Language, and Voice Type before uploading files.");
return;
}
let lang = $("#setting_language").val().trim();
let category = $("#setting_category").val().trim();
let voice = $("#setting_voice").val().trim();
let files = e.originalEvent.dataTransfer.files;
if (lang && lang.length > 0) {
if (category && category.length > 0) {
if (voice && voice.length > 0) {
if (files.length > 0) {
// check if each file have type audio/wav , size more than 0, and name ends with .wav
let allValid = true;
for (let i = 0; i < files.length; i++) {
let file = files[i];
if (file.type !== 'audio/wav' && !file.name.toLowerCase().endsWith('.wav')) {
allValid = false;
}
if (file.size <= 0) {
allValid = false;
}
}
if (allValid) {
if (confirm(`Are you sure want to upload ${files.length} file(s) to the soundbank directory for Category: ${$("#setting_category").val()}, Language: ${$("#setting_language").val()}, Voice Type: ${$("#setting_voice").val()}?`)) {
let url = `api/Settings/UploadSoundbank/${lang}/${voice}/${category}`;
const formdata = new FormData();
for (let i = 0; i < files.length; i++) {
formdata.append('files', files[i]);
}
try{
fetch(url, {
method: 'POST',
body: formdata
})
.then(response => response.json())
.then(okdata => {
console.log("Upload result: ", JSON.stringify(okdata));
})
.catch(errdata => {
alert("Error uploading files to soundbank directory : " + errdata.message);
});
} catch(err){
alert("Error preparing file upload: " + err.message);
}
}
} else alert("Please upload only valid WAV audio files. Type must be audio/wav and size must be more than 0 bytes.");
} else alert("No files detected for upload.");
} else alert("Please select Voice Type before uploading files.");
} else alert("Please select Category before uploading files.");
} else alert("Please select Language before uploading files.");
});
});

View File

@@ -38,7 +38,7 @@
</div>
<div class="row">
<div class="col-12 col-sm-12 col-md-6 col-lg-6 col-xl-6">
<div class="bg-white w-100" id="drop-area" multiple=""><input type="file" id="file-input"><label class="form-label d">Drop files here or click to select</label></div>
<div class="bg-white w-100" id="drop-area" multiple=""><input type="file" id="file-input" multiple=""><label class="form-label d">Drop files here or click to select</label></div>
</div>
<div class="col-12 col-sm-12 col-md-6 col-lg-6 col-xl-6">
<div class="row"></div>
@@ -80,7 +80,6 @@
</div>
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
<script src="assets/js/bs-init.js"></script>
<script src="assets/js/dragdrop.js"></script>
<script src="assets/js/setting.js"></script>
</body>

View File

@@ -33,7 +33,7 @@ lateinit var audioPlayer: AudioPlayer
val StreamerOutputs: MutableMap<String, BarixConnection> = HashMap()
lateinit var udpreceiver: UDPReceiver
lateinit var tcpreceiver: TCPReceiver
const val version = "0.0.10 (20/10/2025)"
const val version = "0.0.11 (24/10/2025)"
// AAS 64 channels
const val max_channel = 64
@@ -59,6 +59,8 @@ fun folder_preparation(){
// sementara diset begini, nanti pake config file
//Somecodes.Soundbank_directory = Paths.get("c:\\soundbank")
Somecodes.Soundbank_directory = Paths.get(config.Get(configKeys.SOUNDBANK_DIRECTORY.key))
Somecodes.SoundbankResult_directory = Somecodes.Soundbank_directory.resolve("SoundbankResult")
Somecodes.PagingResult_directory = Somecodes.Soundbank_directory.resolve("PagingResult")
Files.createDirectories(Somecodes.SoundbankResult_directory)
Files.createDirectories(Somecodes.PagingResult_directory)
Files.createDirectories(Somecodes.Soundbank_directory)

View File

@@ -901,22 +901,22 @@ class MainExtension01 {
when(remark){
"GOP" -> {
//TODO Combobox First_Call_Message_Chooser.
val remarkMsg = config.Get(configKeys.REMARK_GOP.toString())
val remarkMsg = config.Get(configKeys.REMARK_GOP.key)
ann_id = Regex("\\[(\\d+)]").find(remarkMsg)?.value?.toIntOrNull() ?: 0
}
"GBD" ->{
// TODO Combobox Second_Call_Message_Chooser
val remarkMsg = config.Get(configKeys.REMARK_GBD.toString())
val remarkMsg = config.Get(configKeys.REMARK_GBD.key)
ann_id = Regex("\\[(\\d+)]").find(remarkMsg)?.value?.toIntOrNull() ?: 0
}
"GFC" ->{
// TODO Combobox Final_Call_Message_Chooser
val remarkMsg = config.Get(configKeys.REMARK_GFC.toString())
val remarkMsg = config.Get(configKeys.REMARK_GFC.key)
ann_id = Regex("\\[(\\d+)]").find(remarkMsg)?.value?.toIntOrNull() ?: 0
}
"FLD" ->{
// TODO Combobox Landed_Message_Chooser
val remarkMsg = config.Get(configKeys.REMARK_FLD.toString())
val remarkMsg = config.Get(configKeys.REMARK_FLD.key)
ann_id = Regex("\\[(\\d+)]").find(remarkMsg)?.value?.toIntOrNull() ?: 0
}
}

View File

@@ -1,5 +1,6 @@
package codes
import codes.Somecodes.Companion.Soundbank_directory
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import content.Category
@@ -32,8 +33,8 @@ class Somecodes {
val current_directory : String = System.getProperty("user.dir")
var Soundbank_directory : Path = Path.of(current_directory,"Soundbank")
val SoundbankResult_directory : Path = Path.of(current_directory,"SoundbankResult")
val PagingResult_directory : Path = Path.of(current_directory,"PagingResult")
var SoundbankResult_directory : Path = Soundbank_directory.resolve("SoundbankResult")
var PagingResult_directory : Path = Soundbank_directory.resolve("PagingResult")
val si = SystemInfo()
val processor: CentralProcessor = si.hardware.processor

View File

@@ -805,7 +805,7 @@ class MariaDB(
"INSERT INTO ${super.dbName} (Description, Day, Time, Soundpath, `Repeat`, Enable, BroadcastZones, Language) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"
val statement = connection.prepareStatement(sql)
for (sb in data) {
if (!ValidDate(sb.Day) || !ValidTime(sb.Time)) {
if (!ValidScheduleDay(sb.Day) || !ValidTime(sb.Time)) {
Logger.error("Invalid date or time format for schedulebank: ${sb.Description}" as Any)
continue
}
@@ -834,7 +834,7 @@ class MariaDB(
override fun UpdateByIndex(index: Int, data: ScheduleBank): Boolean {
if (!ValidDate(data.Day)) {
if (!ValidScheduleDay(data.Day)) {
Logger.error("Error updating schedulebank entry: Invalid date format ${data.Day}" as Any)
return false
}
@@ -915,16 +915,27 @@ class MariaDB(
Clear()
// read each row and insert into database
val _schedulebankList = ArrayList<ScheduleBank>()
//Logger.info{"Sheet last row num: ${sheet.lastRowNum}"}
for (rowIndex in 1..sheet.lastRowNum) {
val row = sheet.getRow(rowIndex) ?: continue
//println(row)
val description = row.getCell(1)?.stringCellValue ?: continue
//println(description.toString())
val day = row.getCell(2)?.stringCellValue ?: continue
//println(day.toString())
val time = row.getCell(3)?.stringCellValue ?: continue
//println(time.toString())
val soundpath = row.getCell(4)?.stringCellValue ?: continue
//println(soundpath.toString())
val repeat = row.getCell(5)?.stringCellValue?.toUByteOrNull() ?: continue
val enable = row.getCell(6)?.stringCellValue?.toBooleanStrictOrNull() ?: continue
// println(repeat.toString())
//val enable = row.getCell(6)?.stringCellValue?.toBooleanStrictOrNull() ?: continue
val enable = row.getCell(6)?.stringCellValue?.toBoolean() ?: continue
//println(enable.toString())
val broadcastZones = row.getCell(7)?.stringCellValue ?: continue
//println(broadcastZones.toString())
val language = row.getCell(8)?.stringCellValue ?: continue
//println(language.toString())
val schedulebank =
ScheduleBank(
0u,
@@ -937,9 +948,10 @@ class MariaDB(
broadcastZones,
language
)
Logger.info{"SchedulebankList added 1"}
_schedulebankList.add(schedulebank)
}
return scheduleDB.AddAll(_schedulebankList)
} catch (e: Exception) {
Logger.error { "Error importing Schedulebank, Msg: ${e.message}" }

View File

@@ -16,7 +16,24 @@ data class ScheduleBank(
return "ScheduleBank(index=$index, Description='$Description', Day='$Day', Time='$Time', Soundpath='$Soundpath', Repeat=$Repeat, Enable=$Enable, BroadcastZones='$BroadcastZones', Language='$Language')"
}
/**
* Check if all string properties of the ScheduleBank are not empty.
*/
fun isNotEmpty() : Boolean{
return Description.isNotEmpty() && Day.isNotEmpty() && Time.isNotEmpty() && Soundpath.isNotEmpty() && BroadcastZones.isNotEmpty() && Language.isNotEmpty()
}
/**
* Compare two ScheduleBank objects for equality based on their properties.
*/
fun isEqual(other: ScheduleBank) : Boolean {
return Description == other.Description &&
Day == other.Day &&
Time == other.Time &&
Soundpath == other.Soundpath &&
Repeat == other.Repeat &&
Enable == other.Enable &&
BroadcastZones == other.BroadcastZones &&
Language == other.Language
}
}

File diff suppressed because it is too large Load Diff