commit 20/10/2025

TODO Schedule belum beres
This commit is contained in:
2025-10-20 16:12:12 +07:00
parent 2dfc095f04
commit 19e587fc36
9 changed files with 250 additions and 146 deletions

View File

@@ -1,17 +1,4 @@
/**
* @typedef {Object} BroadcastZone
* @property {number} index
* @property {string} description
* @property {String} SoundChannel
* @property {String} Box
* @property {String} Relay
*/
/**
* List of broadcast zones available
* @type {BroadcastZone[]}
*/
window.BroadcastZoneList ??= [];
/** /**
* Currently selected broadcast zone row in the table * Currently selected broadcast zone row in the table
@@ -61,22 +48,7 @@ function fill_broadcastzonetablebody(vv) {
$('#tablesize').text("Table Size: " + vv.length); $('#tablesize').text("Table Size: " + vv.length);
} }
/**
* Reload broadcast zones from server
* @param {String} APIURL API URL endpoint (default "BroadcastZones/")
*/
function reloadBroadcastZones(APIURL = "BroadcastZones/") {
window.BroadcastZoneList = [];
fetchAPI(APIURL + "List", "GET", {}, null, (okdata) => {
if (Array.isArray(okdata)) {
//console.log("reloadBroadcastZones : ", okdata)
window.BroadcastZoneList.push(...okdata);
fill_broadcastzonetablebody(window.BroadcastZoneList);
} else console.log("reloadBroadcastZones: okdata is not array");
}, (errdata) => {
alert("Error loading broadcast zones : " + errdata.message);
});
}
function fetchSoundChannels(APIURL = "SoundChannel/") { function fetchSoundChannels(APIURL = "SoundChannel/") {
window.SoundChannelList = []; window.SoundChannelList = [];
@@ -160,11 +132,11 @@ $(document).ready(function () {
} }
fetchSoundChannels(); fetchSoundChannels();
reloadBroadcastZones(APIURL_BroadcastZone); reloadBroadcastZones(APIURL_BroadcastZone, () => fill_broadcastzonetablebody(window.BroadcastZoneList));
$btnClear.off('click').on('click', () => { $btnClear.off('click').on('click', () => {
DoClear(APIURL_BroadcastZone, "BroadcastZones", (okdata) => { DoClear(APIURL_BroadcastZone, "BroadcastZones", (okdata) => {
reloadBroadcastZones(APIURL_BroadcastZone); reloadBroadcastZones(APIURL_BroadcastZone, () => fill_broadcastzonetablebody(window.BroadcastZoneList));
alert("Success clear broadcast zones: " + okdata.message); alert("Success clear broadcast zones: " + okdata.message);
}, (errdata) => { }, (errdata) => {
alert("Error clear broadcast zones: " + errdata.message); alert("Error clear broadcast zones: " + errdata.message);
@@ -210,7 +182,7 @@ $(document).ready(function () {
Relay: relay Relay: relay
}; };
fetchAPI(APIURL_BroadcastZone + "Add", "POST", {}, bz, (okdata) => { fetchAPI(APIURL_BroadcastZone + "Add", "POST", {}, bz, (okdata) => {
reloadBroadcastZones(APIURL_BroadcastZone); reloadBroadcastZones(APIURL_BroadcastZone, () => fill_broadcastzonetablebody(window.BroadcastZoneList));
alert("Success add new broadcast zone: " + okdata.message); alert("Success add new broadcast zone: " + okdata.message);
}, (errdata) => { }, (errdata) => {
alert("Error add new broadcast zone: " + errdata.message); alert("Error add new broadcast zone: " + errdata.message);
@@ -236,7 +208,7 @@ $(document).ready(function () {
}; };
if (confirm(`Are you sure to delete broadcast zone [${bz.index}] Description=${bz.description}?`)) { if (confirm(`Are you sure to delete broadcast zone [${bz.index}] Description=${bz.description}?`)) {
fetchAPI(APIURL_BroadcastZone + "DeleteByIndex/" + bz.index, "DELETE", {}, null, (okdata) => { fetchAPI(APIURL_BroadcastZone + "DeleteByIndex/" + bz.index, "DELETE", {}, null, (okdata) => {
reloadBroadcastZones(APIURL_BroadcastZone); reloadBroadcastZones(APIURL_BroadcastZone, () => fill_broadcastzonetablebody(window.BroadcastZoneList));
alert("Success delete broadcast zone: " + okdata.message); alert("Success delete broadcast zone: " + okdata.message);
}, (errdata) => { }, (errdata) => {
alert("Error delete broadcast zone: " + errdata.message); alert("Error delete broadcast zone: " + errdata.message);
@@ -303,7 +275,7 @@ $(document).ready(function () {
Relay: relay Relay: relay
}; };
fetchAPI(APIURL_BroadcastZone + "UpdateByIndex/" + bz.index, "PATCH", {}, bzUpdate, (okdata) => { fetchAPI(APIURL_BroadcastZone + "UpdateByIndex/" + bz.index, "PATCH", {}, bzUpdate, (okdata) => {
reloadBroadcastZones(APIURL_BroadcastZone); reloadBroadcastZones(APIURL_BroadcastZone, () => fill_broadcastzonetablebody(window.BroadcastZoneList));
alert("Success edit broadcast zone: " + okdata.message); alert("Success edit broadcast zone: " + okdata.message);
}, (errdata) => { }, (errdata) => {
alert("Error edit broadcast zone: " + errdata.message); alert("Error edit broadcast zone: " + errdata.message);
@@ -323,7 +295,7 @@ $(document).ready(function () {
$btnImport.off('click').on('click', () => { $btnImport.off('click').on('click', () => {
DoImport(APIURL_BroadcastZone, (okdata) => { DoImport(APIURL_BroadcastZone, (okdata) => {
reloadBroadcastZones(APIURL_BroadcastZone); reloadBroadcastZones(APIURL_BroadcastZone, () => fill_broadcastzonetablebody(window.BroadcastZoneList));
alert("Success import broadcast zones: " + okdata.message); alert("Success import broadcast zones: " + okdata.message);
}, (errdata) => { }, (errdata) => {
alert("Error importing broadcast zones from XLSX: " + errdata.message); alert("Error importing broadcast zones from XLSX: " + errdata.message);

View File

@@ -1,19 +1,4 @@
/**
* @typedef {Object} MessageBank
* @property {number} index
* @property {string} description
* @property {string} language
* @property {number} aNN_ID
* @property {string} voice_Type
* @property {string} message_Detail
* @property {string} message_TAGS
*/
/**
* List of Messagebank data loaded from server
* @type {MessageBank[]}
*/
window.messagebankdata ??= [];
/** /**
* Currently selected messagebank row in the table * Currently selected messagebank row in the table
* @type {JQuery<HTMLElement>|null} * @type {JQuery<HTMLElement>|null}
@@ -59,22 +44,7 @@ function fill_messagebanktablebody(vv) {
$('#tablesize').text("Table Size: " + vv.length); $('#tablesize').text("Table Size: " + vv.length);
} }
/**
* Reload message bank from server
* @param {string} APIURL API URL endpoint, default "MessageBank/"
*/
function reloadMessageBank(APIURL = "MessageBank/") {
window.messagebankdata ??= [];
fetchAPI(APIURL + "List", "GET", {}, null, (okdata) => {
if (Array.isArray(okdata)) {
window.messagebankdata.push(...okdata);
window.selectedmessagerow = null;
fill_messagebanktablebody(window.messagebankdata);
}
}, (errdata) => {
alert("Error loading messagebank : " + errdata.message);
});
}
$(document).ready(function () { $(document).ready(function () {
console.log("messagebank.js loaded"); console.log("messagebank.js loaded");
@@ -223,10 +193,10 @@ $(document).ready(function () {
}); });
reloadMessageBank(APIURL); reloadMessageBank(APIURL, () => fill_messagebanktablebody(window.messagebankdata));
$btnClear.click(() => { $btnClear.click(() => {
DoClear(APIURL, "Messagebank", (okdata) => { DoClear(APIURL, "Messagebank", (okdata) => {
reloadMessageBank(APIURL); reloadMessageBank(APIURL, () => fill_messagebanktablebody(window.messagebankdata) );
alert("Success clear messagebank : " + okdata.message); alert("Success clear messagebank : " + okdata.message);
}, (errdata) => { }, (errdata) => {
alert("Error clear messagebank : " + errdata.message); alert("Error clear messagebank : " + errdata.message);
@@ -302,7 +272,7 @@ $(document).ready(function () {
}; };
// send to server using fetchAPI // send to server using fetchAPI
fetchAPI(APIURL + "Add", "POST", mb, null, (okdata) => { fetchAPI(APIURL + "Add", "POST", mb, null, (okdata) => {
reloadMessageBank(APIURL); reloadMessageBank(APIURL, () => fill_messagebanktablebody(window.messagebankdata) );
alert("Success add new messagebank : " + okdata.message); alert("Success add new messagebank : " + okdata.message);
}, (errdata) => { }, (errdata) => {
alert("Error add new messagebank : " + errdata.message); alert("Error add new messagebank : " + errdata.message);
@@ -331,7 +301,7 @@ $(document).ready(function () {
if (confirm(`Are you sure to delete messagebank [${mb.index}] Description=${mb.description}? ANN_ID=${mb.aNN_ID} Language=${mb.language} Voice_Type=${mb.voice_Type} `)) { if (confirm(`Are you sure to delete messagebank [${mb.index}] Description=${mb.description}? ANN_ID=${mb.aNN_ID} Language=${mb.language} Voice_Type=${mb.voice_Type} `)) {
fetchAPI(APIURL + "DeleteByIndex/" + mb.index, "DELETE", {}, null, (okdata) => { fetchAPI(APIURL + "DeleteByIndex/" + mb.index, "DELETE", {}, null, (okdata) => {
reloadMessageBank(APIURL); reloadMessageBank(APIURL, () => fill_messagebanktablebody(window.messagebankdata) );
alert("Success delete messagebank : " + okdata.message); alert("Success delete messagebank : " + okdata.message);
}, (errdata) => { }, (errdata) => {
alert("Error delete messagebank : " + errdata.message); alert("Error delete messagebank : " + errdata.message);
@@ -427,7 +397,7 @@ $(document).ready(function () {
Message_TAGS: messagetags Message_TAGS: messagetags
}; };
fetchAPI(APIURL + "UpdateByIndex/" + mb.index, "PATCH", mbUpdate, null, (okdata) => { fetchAPI(APIURL + "UpdateByIndex/" + mb.index, "PATCH", mbUpdate, null, (okdata) => {
reloadMessageBank(APIURL); reloadMessageBank(APIURL, () => fill_messagebanktablebody(window.messagebankdata) );
alert("Success edit messagebank : " + okdata.message); alert("Success edit messagebank : " + okdata.message);
}, (errdata) => { }, (errdata) => {
alert("Error edit messagebank : " + errdata.message); alert("Error edit messagebank : " + errdata.message);
@@ -447,7 +417,7 @@ $(document).ready(function () {
}); });
$btnImport.click(() => { $btnImport.click(() => {
DoImport(APIURL, (okdata) => { DoImport(APIURL, (okdata) => {
reloadMessageBank(APIURL); reloadMessageBank(APIURL, () => fill_messagebanktablebody(window.messagebankdata) );
alert("Success import messagebank : " + okdata.message); alert("Success import messagebank : " + okdata.message);
}, (errdata) => { }, (errdata) => {
alert("Error importing messagebank from XLSX : " + errdata.message); alert("Error importing messagebank from XLSX : " + errdata.message);

View File

@@ -103,30 +103,26 @@ $(document).ready(function () {
let $scheduleminute = $schedulemodal.find('#scheduleminute'); let $scheduleminute = $schedulemodal.find('#scheduleminute');
// select2 for message // select2 for message
let $schedulemessage = $schedulemodal.find('#schedulemessage'); let $schedulemessage = $schedulemodal.find('#schedulemessage');
$schedulemessage.select2({});
// number input 0-5 // number input 0-5
let $schedulerepeat = $schedulemodal.find('#schedulerepeat'); let $schedulerepeat = $schedulemodal.find('#schedulerepeat');
// checkbox // checkbox
let $scheduleenable = $schedulemodal.find('#scheduleenable'); let $scheduleenable = $schedulemodal.find('#scheduleenable');
// select2 for broadcastzones // select2 for broadcastzones
let $schedulezones = $schedulemodal.find('#schedulezones'); let $schedulezones = $schedulemodal.find('#schedulezones');
$schedulezones.select2({});
// radio button for everyday // radio button for everyday
let $scheduleeveryday = $schedulemodal.find('#scheduleeveryday'); let $scheduleeveryday = $schedulemodal.find('#scheduleeveryday');
// radio button for weekly // radio button for weekly
let $scheduleweekly = $schedulemodal.find('#scheduleweekly'); let $scheduleweekly = $schedulemodal.find('#scheduleweekly');
// select2 for weekly selection // select2 for weekly selection
let $weeklyselect = $schedulemodal.find('#weeklyselect'); let $weeklyselect = $schedulemodal.find('#weeklyselect');
$weeklyselect.select2({});
// radio button for specific date // radio button for specific date
let $schedulespecialdate = $schedulemodal.find('#schedulespecialdate'); let $schedulespecialdate = $schedulemodal.find('#schedulespecialdate');
// date input // date input
let $scheduledate = $schedulemodal.find('#scheduledate'); let $scheduledate = $schedulemodal.find('#scheduledate');
// select2 for language // select2 for language
let $languageselect = $schedulemodal.find('#languageselect'); let $languageselect = $schedulemodal.find('#languageselect');
$languageselect.select2({});
$schedulespecialdate.on('change', function () { $schedulespecialdate.off('change').on('change', function () {
if ($(this).is(':checked')) { if ($(this).is(':checked')) {
$scheduledate.prop('disabled', false); $scheduledate.prop('disabled', false);
} else { } else {
@@ -139,18 +135,73 @@ $(document).ready(function () {
$scheduledescription.val(''); $scheduledescription.val('');
$schedulehour.val('0'); $schedulehour.val('0');
$scheduleminute.val('0'); $scheduleminute.val('0');
$schedulerepeat.val('0'); $schedulerepeat.val('1');
$scheduleenable.prop('checked', true); $scheduleenable.prop('checked', true);
$scheduleeveryday.prop('checked', false); $scheduleeveryday.prop('checked', false);
$scheduleweekly.prop('checked', false);
$schedulespecialdate.prop('checked', false); $schedulespecialdate.prop('checked', false);
$weeklyselect.empty().select2({
data: window.scheduledays.filter(day => day !== 'Everyday').map(day => ({ id: day, text: day })),
placeholder: 'Select days of the week',
multiple: false,
width: '100%',
dropdownParent: $('#schedulemodal')
});
$languageselect.empty().select2({
data: window.languages.map(lang => ({ id: lang, text: lang })),
placeholder: 'Select languages',
multiple: true,
width: '100%',
dropdownParent: $('#schedulemodal')
});
$scheduledate.prop('disabled', true).val(''); $scheduledate.prop('disabled', true).val('');
$schedulezones.empty().select2({
data: window.BroadcastZoneList.map(zone => ({ id: zone.description, text: zone.description })),
placeholder: 'Select broadcast zones',
multiple: true,
width: '100%',
dropdownParent: $('#schedulemodal')
});
let messageData = [...new Set(window.messagebankdata.filter(mb => !mb.message_Detail.includes('[')).map(mb => `${mb.description} [${mb.aNN_ID}]`))];
$schedulemessage.empty().select2({
placeholder: 'Select message',
multiple: false,
width: '100%',
dropdownParent: $('#schedulemodal'),
data: messageData.map(mb => ({ id: mb, text: mb }))
});
$scheduleeveryday.off('change').on('change', function () {
if ($(this).is(':checked')) {
$weeklyselect.prop('disabled', true);
$scheduledate.prop('disabled', true);
}
});
$scheduleweekly.off('change').on('change', function () {
if ($(this).is(':checked')) {
$weeklyselect.prop('disabled', false);
$scheduledate.prop('disabled', true);
} else {
$weeklyselect.prop('disabled', true);
}
});
$schedulespecialdate.off('change').on('change', function () {
if ($(this).is(':checked')) {
$weeklyselect.prop('disabled', true);
$scheduledate.prop('disabled', false);
} else {
$scheduledate.prop('disabled', true);
}
});
} }
let $findschedule = $('#findschedule'); let $findschedule = $('#findschedule');
$findschedule.on('input', function () { $findschedule.off('input').on('input', function () {
let searchTerm = $findschedule.val().toLowerCase(); let searchTerm = $findschedule.val().toLowerCase();
if (searchTerm.length > 0) { if (searchTerm.length > 0) {
window.selectedschedulerow = null; window.selectedschedulerow = null;
@@ -167,6 +218,10 @@ $(document).ready(function () {
reloadTimerBank(APIURL); reloadTimerBank(APIURL);
reloadBroadcastZones();
getLanguages();
getScheduledDays();
reloadMessageBank();
$btnClear.click(() => { $btnClear.click(() => {
DoClear(APIURL, "Timerbank", (okdata) => { DoClear(APIURL, "Timerbank", (okdata) => {
reloadTimerBank(APIURL); reloadTimerBank(APIURL);
@@ -186,58 +241,54 @@ $(document).ready(function () {
$schedulemodal.off('click.schedulesave').on('click.schedulesave', '#schedulesave', function () { $schedulemodal.off('click.schedulesave').on('click.schedulesave', '#schedulesave', function () {
// Gather form values // Gather form values
const Description = $scheduledescription.val(); const Description = $scheduledescription.val();
const Soundpath = $schedulesoundpath.val(); const Message = $schedulemessage.val();
const Repeat = parseInt($schedulerepeat.val(), 10); const Repeat = parseInt($schedulerepeat.val(), 10);
const Enable = $scheduleenable.is(':checked'); const Enable = $scheduleenable.is(':checked');
// Collect selected days // Collect selected days
let Day = ""; let _Day = "";
if ($scheduleeveryday.is(':checked')) { if ($scheduleeveryday.is(':checked')) {
Day = "Everyday"; _Day = "Everyday";
} else if ($schedulespecialdate.is(':checked')) { } else if ($schedulespecialdate.is(':checked')) {
Day = $scheduledate.val(); _Day = $scheduledate.val();
} else { } else if ($scheduleweekly.is(':checked')) {
_Day = $weeklyselect.val();
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";
} }
// Broadcast zones (assuming comma-separated string) const Language = $languageselect.val().join(';');
const BroadcastZones = $schedulezones.val(); const broadcastZones = $schedulezones.val().join(';');
// Validate required fields
if (!Description || !Soundpath || Day === "") {
alert("Description, sound path, and day are required.");
return;
}
// Format time as HH:mm // Format time as HH:mm
const hour = parseInt($schedulehour.val(), 10); const hour = parseInt($schedulehour.val(), 10);
const minute = parseInt($scheduleminute.val(), 10); const minute = parseInt($scheduleminute.val(), 10);
const Time = `${hour.toString().padStart(2, '0')}:${minute.toString().padStart(2, '0')}`; 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) {
if (Language.length > 0) {
if (broadcastZones.length > 0) {
// Prepare object
const scheduleObj = {
Description: Description,
Day: _Day,
Time: _Time,
Soundpath: Message,
Repeat: Repeat,
Enable: Enable,
BroadcastZones: broadcastZones,
Language: Language
};
// Prepare object fetchAPI(APIURL + "Add", "POST", {}, scheduleObj, (okdata) => {
const scheduleObj = { alert("Success add schedule: " + okdata.message);
Description, reloadTimerBank(APIURL);
Day, }, (errdata) => {
Time, alert("Error add schedule: " + errdata.message);
Soundpath, });
Repeat, $schedulemodal.modal('hide');
Enable, } else alert("At least one Broadcast Zone is required");
BroadcastZones } else alert("Language is required");
}; } else alert("Message is required");
} else alert("Day is required");
fetchAPI(APIURL + "Add", "POST", {}, scheduleObj, (okdata) => { } else alert("Description is required");
alert("Success add schedule: " + okdata.message);
reloadTimerBank(APIURL);
}, (errdata) => {
alert("Error add schedule: " + errdata.message);
});
$schedulemodal.modal('hide');
}); });
}); });
$btnRemove.click(() => { $btnRemove.click(() => {
@@ -282,13 +333,15 @@ $(document).ready(function () {
} }
if (confirm(`Are you sure to edit schedule [${sr.index}] Description=${sr.description}?`)) { if (confirm(`Are you sure to edit schedule [${sr.index}] Description=${sr.description}?`)) {
$schedulemodal.modal('show'); $schedulemodal.modal('show');
clearScheduleModal();
// fill the form with existing data // fill the form with existing data
$scheduleid.val(sr.index); $scheduleid.val(sr.index);
$scheduledescription.val(sr.description); $scheduledescription.val(sr.description);
let [hour, minute] = sr.time.split(':').map(num => parseInt(num, 10)); let [hour, minute] = sr.time.split(':').map(num => parseInt(num, 10));
$schedulehour.val(hour.toString()); $schedulehour.val(hour.toString());
$scheduleminute.val(minute.toString()); $scheduleminute.val(minute.toString());
$schedulesoundpath.val(sr.soundpath); $schedulemessage.val(sr.soundpath);
$schedulerepeat.val(sr.repeat.toString()); $schedulerepeat.val(sr.repeat.toString());
$scheduleenable.prop('checked', sr.enable.toLowerCase() === 'true'); $scheduleenable.prop('checked', sr.enable.toLowerCase() === 'true');
switch (sr.day) { switch (sr.day) {
@@ -331,7 +384,7 @@ $(document).ready(function () {
$schedulemodal.off('click.schedulesave').on('click.schedulesave', '#schedulesave', function () { $schedulemodal.off('click.schedulesave').on('click.schedulesave', '#schedulesave', function () {
// Gather form values // Gather form values
const Description = $scheduledescription.val(); const Description = $scheduledescription.val();
const Soundpath = $schedulesoundpath.val(); const Soundpath = $schedulemessage.val();
const Repeat = parseInt($schedulerepeat.val(), 10); const Repeat = parseInt($schedulerepeat.val(), 10);
const Enable = $scheduleenable.is(':checked'); const Enable = $scheduleenable.is(':checked');
// Collect selected days // Collect selected days

View File

@@ -20,6 +20,76 @@ window.languages = [];
*/ */
window.scheduledays = [] window.scheduledays = []
/**
* @typedef {Object} BroadcastZone
* @property {number} index
* @property {string} description
* @property {String} SoundChannel
* @property {String} Box
* @property {String} Relay
*/
/**
* List of broadcast zones available
* @type {BroadcastZone[]}
*/
window.BroadcastZoneList ??= [];
/**
* @typedef {Object} MessageBank
* @property {number} index
* @property {string} description
* @property {string} language
* @property {number} aNN_ID
* @property {string} voice_Type
* @property {string} message_Detail
* @property {string} message_TAGS
*/
/**
* List of Messagebank data loaded from server
* @type {MessageBank[]}
*/
window.messagebankdata ??= [];
/**
* Reload message bank from server
* @param {string} APIURL API URL endpoint, default "MessageBank/"
* @param {function|null} cbOK callback on success, default null
*/
function reloadMessageBank(APIURL = "MessageBank/", cbOK = null) {
window.messagebankdata ??= [];
fetchAPI(APIURL + "List", "GET", {}, null, (okdata) => {
if (Array.isArray(okdata)) {
window.messagebankdata.push(...okdata);
window.selectedmessagerow = null;
//fill_messagebanktablebody(window.messagebankdata);
if (cbOK) cbOK();
}
}, (errdata) => {
alert("Error loading messagebank : " + errdata.message);
});
}
/**
* Reload broadcast zones from server
* @param {String} APIURL API URL endpoint (default "BroadcastZones/")
* @param {Function} cbOK callback function on success
*/
function reloadBroadcastZones(APIURL = "BroadcastZones/", cbOK = null) {
window.BroadcastZoneList = [];
fetchAPI(APIURL + "List", "GET", {}, null, (okdata) => {
if (Array.isArray(okdata)) {
//console.log("reloadBroadcastZones : ", okdata)
window.BroadcastZoneList.push(...okdata);
if (cbOK) cbOK();
//fill_broadcastzonetablebody(window.BroadcastZoneList);
} else console.log("reloadBroadcastZones: okdata is not array");
}, (errdata) => {
alert("Error loading broadcast zones : " + errdata.message);
});
}
/** /**
* Create a list item element * Create a list item element
* @param {String} text Text Content for the list item * @param {String} text Text Content for the list item
@@ -311,6 +381,8 @@ $(document).ready(function () {
getCategories(); getCategories();
getLanguages(); getLanguages();
getScheduledDays(); getScheduledDays();
reloadBroadcastZones();
reloadMessageBank();
// reconnect handle // reconnect handle

View File

@@ -74,7 +74,7 @@
<div class="col-4 col-sm-4 col-md-4 col-lg-4 col-xl-4"> <div class="col-4 col-sm-4 col-md-4 col-lg-4 col-xl-4">
<p class="text-add">Description</p> <p class="text-add">Description</p>
</div> </div>
<div class="col"><input type="text" id="scheduledescription" class="input-add form-control"></div> <div class="col"><input class="w-100 input-add form-control" type="text" id="scheduledescription"></div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-4 col-sm-4 col-md-4 col-lg-4 col-xl-4"> <div class="col-4 col-sm-4 col-md-4 col-lg-4 col-xl-4">
@@ -83,12 +83,12 @@
<div class="col"> <div class="col">
<div class="row pad-day"> <div class="row pad-day">
<div class="col"> <div class="col">
<div class="form-check"><input class="form-check-input" type="radio" id="scheduleeveryday" name="dayselection" value="Everyday"><label class="form-check-label" for="formCheck-1">Everyday</label></div> <div class="form-check"><input class="form-check-input" type="radio" id="scheduleeveryday" name="dayselect"><label class="form-check-label" for="scheduleeveryday">Everyday</label></div>
</div> </div>
</div> </div>
<div class="row pad-day"> <div class="row pad-day">
<div class="col"> <div class="col">
<div class="form-check"><input class="form-check-input" type="radio" id="scheduleweekly"><label class="form-check-label" for="formCheck-1">Weekly</label></div><select class="w-100 input-add form-select" id="weeklyselect"> <div class="form-check"><input class="form-check-input" type="radio" id="scheduleweekly" name="dayselect"><label class="form-check-label" for="scheduleweekly">Weekly</label></div><select class="w-100 input-add form-select" id="weeklyselect">
<optgroup label="This is a group"> <optgroup label="This is a group">
<option value="12" selected="">This is item 1</option> <option value="12" selected="">This is item 1</option>
<option value="13">This is item 2</option> <option value="13">This is item 2</option>
@@ -99,7 +99,7 @@
</div> </div>
<div class="row"> <div class="row">
<div class="col-7 col-sm-7 col-md-7 col-lg-6 col-xl-6 pad-day"> <div class="col-7 col-sm-7 col-md-7 col-lg-6 col-xl-6 pad-day">
<div class="form-check"><input class="form-check-input" type="radio" id="schedulespecialdate" name="dayselection"><label class="form-check-label" for="formCheck-9">Special Date</label></div> <div class="form-check"><input class="form-check-input" type="radio" id="schedulespecialdate" name="dayselect"><label class="form-check-label" for="schedulespecialdate">Special Date</label></div>
</div> </div>
<div class="col-sm-5 col-md-5 col-lg-6 col-xl-6"><input id="scheduledate" class="form-control" type="date"></div> <div class="col-sm-5 col-md-5 col-lg-6 col-xl-6"><input id="scheduledate" class="form-control" type="date"></div>
</div> </div>
@@ -126,7 +126,7 @@
<div class="col-4 col-sm-4 col-md-4 col-lg-4 col-xl-4"> <div class="col-4 col-sm-4 col-md-4 col-lg-4 col-xl-4">
<p class="text-add">Message</p> <p class="text-add">Message</p>
</div> </div>
<div class="col-8 col-sm-8 col-md-8 col-lg-8 col-xl-8"><select id="schedulemessage" class="input-add form-select"></select></div> <div class="col-8 col-sm-8 col-md-8 col-lg-8 col-xl-8"><select class="w-100 input-add form-select" id="schedulemessage"></select></div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-4 col-sm-4 col-md-4 col-lg-4 col-xl-4"> <div class="col-4 col-sm-4 col-md-4 col-lg-4 col-xl-4">
@@ -148,7 +148,7 @@
<div class="col-4 col-sm-4 col-md-4 col-lg-4 col-xl-4"> <div class="col-4 col-sm-4 col-md-4 col-lg-4 col-xl-4">
<p class="text-add">Repeat</p> <p class="text-add">Repeat</p>
</div> </div>
<div class="col-8 col-sm-8 col-md-8 col-lg-8 col-xl-8"><input class="w-25 form-select input-add" type="number" id="schedulerepeat" min="0" max="5" step="1" value="0"></div> <div class="col-8 col-sm-8 col-md-8 col-lg-8 col-xl-8"><input class="w-25 form-select input-add" type="number" id="schedulerepeat" min="1" max="5" step="1" value="1"></div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-4 col-sm-4 col-md-4 col-lg-4 col-xl-4"> <div class="col-4 col-sm-4 col-md-4 col-lg-4 col-xl-4">
@@ -160,7 +160,7 @@
<div class="col-4 col-sm-4 col-md-4 col-lg-4 col-xl-4"> <div class="col-4 col-sm-4 col-md-4 col-lg-4 col-xl-4">
<p class="text-add">Broadcast Zones</p> <p class="text-add">Broadcast Zones</p>
</div> </div>
<div class="col-8 col-sm-8 col-md-8 col-lg-9 col-xl-8 border"><select class="w-100 input-add form-select" id="schedulezones"> <div class="col-8 col-sm-8 col-md-8 col-lg-8 col-xl-8 border"><select class="w-100 input-add form-select" id="schedulezones">
<optgroup label="This is a group"> <optgroup label="This is a group">
<option value="12" selected="">This is item 1</option> <option value="12" selected="">This is item 1</option>
<option value="13">This is item 2</option> <option value="13">This is item 2</option>

View File

@@ -31,7 +31,7 @@ lateinit var audioPlayer: AudioPlayer
val StreamerOutputs: MutableMap<String, BarixConnection> = HashMap() val StreamerOutputs: MutableMap<String, BarixConnection> = HashMap()
lateinit var udpreceiver: UDPReceiver lateinit var udpreceiver: UDPReceiver
lateinit var tcpreceiver: TCPReceiver lateinit var tcpreceiver: TCPReceiver
const val version = "0.0.8 (16/10/2025)" const val version = "0.0.9 (20/10/2025)"
// AAS 64 channels // AAS 64 channels
const val max_channel = 64 const val max_channel = 64

View File

@@ -476,7 +476,9 @@ class Somecodes {
return true return true
} }
// check if value is in format dd/MM/yyyy // check if value is in format dd/MM/yyyy
return ValidDate(value) if (ValidDate(value)) {
return true
}
} }
return false return false
} }

View File

@@ -1,6 +1,7 @@
package database package database
import codes.Somecodes.Companion.ValiDateForLogHtml import codes.Somecodes.Companion.ValiDateForLogHtml
import codes.Somecodes.Companion.ValidScheduleDay
import codes.Somecodes.Companion.toJsonString import codes.Somecodes.Companion.toJsonString
import content.Category import content.Category
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
@@ -155,6 +156,7 @@ class MariaDB(
statement?.setString(6, data.Path) statement?.setString(6, data.Path)
val rowsAffected = statement?.executeUpdate() val rowsAffected = statement?.executeUpdate()
if (rowsAffected != null && rowsAffected > 0) { if (rowsAffected != null && rowsAffected > 0) {
Add_Log("AAS", "Soundbank added: ${data.Description}; TAG: ${data.TAG}; Category: ${data.Category}; Language: ${data.Language}; VoiceType: ${data.VoiceType}; Path: ${data.Path}")
Logger.info("Soundbank added: ${data.Description}" as Any) Logger.info("Soundbank added: ${data.Description}" as Any)
return true return true
} else { } else {
@@ -207,6 +209,7 @@ class MariaDB(
val rowsAffected = statement?.executeUpdate() val rowsAffected = statement?.executeUpdate()
if (rowsAffected != null && rowsAffected > 0) { if (rowsAffected != null && rowsAffected > 0) {
Logger.info("Soundbank updated at index $index: ${data.Description}" as Any) Logger.info("Soundbank updated at index $index: ${data.Description}" as Any)
Add_Log("AAS", "Soundbank updated at index $index: ${data.Description}; TAG: ${data.TAG}; Category: ${data.Category}; Language: ${data.Language}; VoiceType: ${data.VoiceType}; Path: ${data.Path}")
return true return true
} else { } else {
Logger.warn("No soundbank entry updated at index $index for: ${data.Description}" as Any) Logger.warn("No soundbank entry updated at index $index for: ${data.Description}" as Any)
@@ -359,6 +362,7 @@ class MariaDB(
val rowsAffected = statement?.executeUpdate() val rowsAffected = statement?.executeUpdate()
if (rowsAffected != null && rowsAffected > 0) { if (rowsAffected != null && rowsAffected > 0) {
Logger.info("Messagebank added: ${data.Description}" as Any) Logger.info("Messagebank added: ${data.Description}" as Any)
Add_Log("AAS", "Messagebank added: ${data.Description}; Language: ${data.Language}; ANN_ID: ${data.ANN_ID}; Voice_Type: ${data.Voice_Type}")
return true return true
} else { } else {
Logger.warn("No messagebank entry added for: ${data.Description}" as Any) Logger.warn("No messagebank entry added for: ${data.Description}" as Any)
@@ -565,6 +569,7 @@ class MariaDB(
val rowsAffected = statement.executeUpdate() val rowsAffected = statement.executeUpdate()
if (rowsAffected > 0) { if (rowsAffected > 0) {
Logger.info("Language link added: ${data.TAG} -> ${data.Language}" as Any) Logger.info("Language link added: ${data.TAG} -> ${data.Language}" as Any)
Add_Log("AAS", "Language link added: ${data.TAG} -> ${data.Language}")
return true return true
} else { } else {
Logger.warn("No language link entry added for: ${data.TAG} -> ${data.Language}" as Any) Logger.warn("No language link entry added for: ${data.TAG} -> ${data.Language}" as Any)
@@ -606,6 +611,7 @@ class MariaDB(
val rowsAffected = statement?.executeUpdate() val rowsAffected = statement?.executeUpdate()
if (rowsAffected != null && rowsAffected > 0) { if (rowsAffected != null && rowsAffected > 0) {
Logger.info("Language link updated at index $index: ${data.TAG} -> ${data.Language}" as Any) Logger.info("Language link updated at index $index: ${data.TAG} -> ${data.Language}" as Any)
Add_Log("AAS", "Language link updated at index $index: ${data.TAG} -> ${data.Language}")
return true return true
} else { } else {
Logger.warn("No language link entry updated at index $index for: ${data.TAG} -> ${data.Language}" as Any) Logger.warn("No language link entry updated at index $index for: ${data.TAG} -> ${data.Language}" as Any)
@@ -670,7 +676,7 @@ class MariaDB(
val statement = connection.createStatement() val statement = connection.createStatement()
val resultSet = statement?.executeQuery("SELECT * FROM ${super.dbName}") val resultSet = statement?.executeQuery("SELECT * FROM ${super.dbName}")
val workbook = XSSFWorkbook() val workbook = XSSFWorkbook()
val sheet = workbook.createSheet("languagelinking") val sheet = workbook.createSheet("LanguageLink")
val headerRow = sheet.createRow(0) val headerRow = sheet.createRow(0)
val headers = arrayOf("Index", "TAG", "Language") val headers = arrayOf("Index", "TAG", "Language")
for ((colIndex, header) in headers.withIndex()) { for ((colIndex, header) in headers.withIndex()) {
@@ -737,7 +743,7 @@ class MariaDB(
} }
override fun Add(data: ScheduleBank): Boolean { override fun Add(data: ScheduleBank): Boolean {
if (!ValidDate(data.Day)) { if (!ValidScheduleDay(data.Day)) {
Logger.error("Error adding schedulebank entry: Invalid date format ${data.Day}" as Any) Logger.error("Error adding schedulebank entry: Invalid date format ${data.Day}" as Any)
return false return false
} }
@@ -759,6 +765,7 @@ class MariaDB(
val rowsAffected = statement?.executeUpdate() val rowsAffected = statement?.executeUpdate()
if (rowsAffected != null && rowsAffected > 0) { if (rowsAffected != null && rowsAffected > 0) {
Logger.info("Schedulebank added: ${data.Description}" as Any) Logger.info("Schedulebank added: ${data.Description}" as Any)
Add_Log("AAS", "Schedulebank added: ${data.Description}; Day: ${data.Day}; Time: ${data.Time}; Soundpath: ${data.Soundpath}; Repeat: ${data.Repeat}; Enable: ${data.Enable}; BroadcastZones: ${data.BroadcastZones}; Language: ${data.Language}")
return true return true
} else { } else {
Logger.warn("No schedulebank entry added for: ${data.Description}" as Any) Logger.warn("No schedulebank entry added for: ${data.Description}" as Any)
@@ -826,6 +833,7 @@ class MariaDB(
val rowsAffected = statement?.executeUpdate() val rowsAffected = statement?.executeUpdate()
if (rowsAffected != null && rowsAffected > 0) { if (rowsAffected != null && rowsAffected > 0) {
Logger.info("Schedulebank updated at index $index: ${data.Description}" as Any) Logger.info("Schedulebank updated at index $index: ${data.Description}" as Any)
Add_Log("AAS", "Schedulebank updated at index $index: ${data.Description}; Day: ${data.Day}; Time: ${data.Time}; Soundpath: ${data.Soundpath}; Repeat: ${data.Repeat}; Enable: ${data.Enable}; BroadcastZones: ${data.BroadcastZones}; Language: ${data.Language}")
return true return true
} else { } else {
Logger.warn("No schedulebank entry updated at index $index for: ${data.Description}" as Any) Logger.warn("No schedulebank entry updated at index $index for: ${data.Description}" as Any)
@@ -1003,6 +1011,7 @@ class MariaDB(
val rowsAffected = statement?.executeUpdate() val rowsAffected = statement?.executeUpdate()
if (rowsAffected != null && rowsAffected > 0) { if (rowsAffected != null && rowsAffected > 0) {
Logger.info("Broadcast zone added: ${data.description}" as Any) Logger.info("Broadcast zone added: ${data.description}" as Any)
Add_Log("AAS", "Broadcast zone added: ${data.description}; SoundChannel: ${data.SoundChannel}; id: ${data.id}; bp: ${data.bp}")
return true return true
} else { } else {
Logger.warn("No broadcast zone entry added for: ${data.description}" as Any) Logger.warn("No broadcast zone entry added for: ${data.description}" as Any)
@@ -1049,6 +1058,7 @@ class MariaDB(
val rowsAffected = statement?.executeUpdate() val rowsAffected = statement?.executeUpdate()
if (rowsAffected != null && rowsAffected > 0) { if (rowsAffected != null && rowsAffected > 0) {
Logger.info("Broadcast zone updated at index $index: ${data.description}" as Any) Logger.info("Broadcast zone updated at index $index: ${data.description}" as Any)
Add_Log("AAS", "Broadcast zone updated at index $index: ${data.description}; SoundChannel: ${data.SoundChannel}; id: ${data.id}; bp: ${data.bp}")
return true return true
} else { } else {
Logger.warn("No broadcast zone entry updated at index $index for: ${data.description}" as Any) Logger.warn("No broadcast zone entry updated at index $index for: ${data.description}" as Any)
@@ -1516,6 +1526,7 @@ class MariaDB(
val rowsAffected = statement?.executeUpdate() val rowsAffected = statement?.executeUpdate()
if (rowsAffected != null && rowsAffected > 0) { if (rowsAffected != null && rowsAffected > 0) {
Logger.info("SoundChannel updated: ${data.channel} -> ${data.ip}" as Any) Logger.info("SoundChannel updated: ${data.channel} -> ${data.ip}" as Any)
Add_Log("AAS", "SoundChannel updated: ${data.channel} -> ${data.ip}")
return true return true
} else { } else {
Logger.warn("No SoundChannel entry updated for: ${data.channel} -> ${data.ip}" as Any) Logger.warn("No SoundChannel entry updated for: ${data.channel} -> ${data.ip}" as Any)
@@ -1557,6 +1568,7 @@ class MariaDB(
val rowsAffected = statement?.executeUpdate() val rowsAffected = statement?.executeUpdate()
if (rowsAffected != null && rowsAffected > 0) { if (rowsAffected != null && rowsAffected > 0) {
Logger.info("SoundChannel updated at index $index: ${data.channel} -> ${data.ip}" as Any) Logger.info("SoundChannel updated at index $index: ${data.channel} -> ${data.ip}" as Any)
Add_Log("AAS", "SoundChannel updated at index $index: ${data.channel} -> ${data.ip}")
return true return true
} else { } else {
Logger.warn("No SoundChannel entry updated at index $index for: ${data.channel} -> ${data.ip}" as Any) Logger.warn("No SoundChannel entry updated at index $index for: ${data.channel} -> ${data.ip}" as Any)
@@ -1687,6 +1699,7 @@ class MariaDB(
val rowsAffected = statement?.executeUpdate() val rowsAffected = statement?.executeUpdate()
if (rowsAffected != null && rowsAffected > 0) { if (rowsAffected != null && rowsAffected > 0) {
Logger.info("${super.dbName} IP cleared for index $index" as Any) Logger.info("${super.dbName} IP cleared for index $index" as Any)
Add_Log("AAS", "${super.dbName} IP cleared for index $index")
return true return true
} else { } else {
Logger.warn("No ${super.dbName} entry cleared for index $index" as Any) Logger.warn("No ${super.dbName} entry cleared for index $index" as Any)
@@ -1901,6 +1914,7 @@ class MariaDB(
val rowsAffected = statement?.executeUpdate() val rowsAffected = statement?.executeUpdate()
if (rowsAffected != null && rowsAffected > 0) { if (rowsAffected != null && rowsAffected > 0) {
Logger.info("User added: ${data.username}" as Any) Logger.info("User added: ${data.username}" as Any)
Add_Log("AAS", "User added: ${data.username}")
return true return true
} else { } else {
Logger.warn("No user entry added for: ${data.username}" as Any) Logger.warn("No user entry added for: ${data.username}" as Any)
@@ -1951,6 +1965,7 @@ class MariaDB(
val rowsAffected = statement?.executeUpdate() val rowsAffected = statement?.executeUpdate()
if (rowsAffected != null && rowsAffected > 0) { if (rowsAffected != null && rowsAffected > 0) {
Logger.info("User updated at index $index: ${data.username}" as Any) Logger.info("User updated at index $index: ${data.username}" as Any)
Add_Log("AAS", "User updated at index $index: ${data.username}")
return true return true
} else { } else {
Logger.warn("No user entry updated at index $index for: ${data.username}" as Any) Logger.warn("No user entry updated at index $index for: ${data.username}" as Any)

View File

@@ -319,6 +319,7 @@ class WebApp(val listenPort: Int, val userlist: List<Pair<String, String>>) {
if (db.soundDB.DeleteByIndex(index.toInt())) { if (db.soundDB.DeleteByIndex(index.toInt())) {
db.soundDB.Resort() db.soundDB.Resort()
it.result(objectmapper.writeValueAsString(resultMessage("OK"))) it.result(objectmapper.writeValueAsString(resultMessage("OK")))
db.Add_Log("AAS","Deleted sound bank with index $index")
} else { } else {
it.status(500).result(objectmapper.writeValueAsString(resultMessage("Failed to delete soundbank with index $index"))) it.status(500).result(objectmapper.writeValueAsString(resultMessage("Failed to delete soundbank with index $index")))
} }
@@ -490,6 +491,7 @@ class WebApp(val listenPort: Int, val userlist: List<Pair<String, String>>) {
if (db.messageDB.DeleteByIndex(index.toInt())) { if (db.messageDB.DeleteByIndex(index.toInt())) {
db.messageDB.Resort() db.messageDB.Resort()
it.result(objectmapper.writeValueAsString(resultMessage("OK"))) it.result(objectmapper.writeValueAsString(resultMessage("OK")))
db.Add_Log("AAS","Deleted message bank with index $index")
} else { } else {
it.status(500).result(objectmapper.writeValueAsString(resultMessage("Failed to delete messagebank with index $index"))) it.status(500).result(objectmapper.writeValueAsString(resultMessage("Failed to delete messagebank with index $index")))
} }
@@ -645,6 +647,7 @@ class WebApp(val listenPort: Int, val userlist: List<Pair<String, String>>) {
if (db.languageDB.DeleteByIndex(index.toInt())) { if (db.languageDB.DeleteByIndex(index.toInt())) {
db.languageDB.Resort() db.languageDB.Resort()
it.result(objectmapper.writeValueAsString(resultMessage("OK"))) it.result(objectmapper.writeValueAsString(resultMessage("OK")))
db.Add_Log("AAS","Deleted language link with index $index")
} else { } else {
it.status(500).result(objectmapper.writeValueAsString(resultMessage("Failed to delete language link with index $index"))) it.status(500).result(objectmapper.writeValueAsString(resultMessage("Failed to delete language link with index $index")))
} }
@@ -736,8 +739,6 @@ class WebApp(val listenPort: Int, val userlist: List<Pair<String, String>>) {
} }
} }
post("Add"){ post("Add"){
// TODO add new schedule
// recheck lagi tambahan steph
val json: JsonNode = objectmapper.readTree(it.body()) val json: JsonNode = objectmapper.readTree(it.body())
val description = json.get("Description")?.asText("") ?: "" val description = json.get("Description")?.asText("") ?: ""
val day = json.get("Day")?.asText("") ?: "" val day = json.get("Day")?.asText("") ?: ""
@@ -747,15 +748,16 @@ class WebApp(val listenPort: Int, val userlist: List<Pair<String, String>>) {
val enable = json.get("Enable")?.asBoolean() ?: false val enable = json.get("Enable")?.asBoolean() ?: false
val broadcast_zones = json.get("BroadcastZones")?.asText("") ?: "" val broadcast_zones = json.get("BroadcastZones")?.asText("") ?: ""
val language = json.get("Language")?.asText("") ?: "" val language = json.get("Language")?.asText("") ?: ""
println("Add ScheduleBank, description=$description, day=$day, time=$time, soundpath=$soundpath, repeat=$repeat, enable=$enable, broadcast_zones=$broadcast_zones, language=$language")
if (ValidString(description)){ if (ValidString(description)){
if (ValidString(day) && ValidScheduleDay(day)){ if (ValidScheduleDay(day)){
if (ValidString(time) && ValidScheduleTime(time)){ if (ValidScheduleTime(time)){
if (ValidString(soundpath) && ValidFile(soundpath)){ if (ValidString(soundpath)){
if (repeat in 0u..127u){ if (repeat in 0u..127u){
if (ValidString(broadcast_zones)){ if (ValidString(broadcast_zones)){
val zones = broadcast_zones.split(";") val zones = broadcast_zones.split(";")
if (zones.all { zz -> db.broadcastDB.List.any { xx -> xx.description.equals(zz,true) } }){ if (zones.all { zz -> db.broadcastDB.List.any { xx -> xx.description.equals(zz,true) } }){
if (ValidString(language) && Language.entries.any{ lang -> lang.name == language }){ if (ValidString(language)){
val newvalue = ScheduleBank( val newvalue = ScheduleBank(
0u, 0u,
description, description,
@@ -789,6 +791,7 @@ class WebApp(val listenPort: Int, val userlist: List<Pair<String, String>>) {
if (db.scheduleDB.DeleteByIndex(index.toInt())) { if (db.scheduleDB.DeleteByIndex(index.toInt())) {
db.scheduleDB.Resort() db.scheduleDB.Resort()
it.result(objectmapper.writeValueAsString(resultMessage("OK"))) it.result(objectmapper.writeValueAsString(resultMessage("OK")))
db.Add_Log("AAS","Deleted schedule bank with index $index")
} else { } else {
it.status(500).result(objectmapper.writeValueAsString(resultMessage("Failed to delete schedule with index $index"))) it.status(500).result(objectmapper.writeValueAsString(resultMessage("Failed to delete schedule with index $index")))
} }
@@ -911,6 +914,24 @@ class WebApp(val listenPort: Int, val userlist: List<Pair<String, String>>) {
.result(objectmapper.writeValueAsString(resultMessage("Invalid XLSX file"))) .result(objectmapper.writeValueAsString(resultMessage("Invalid XLSX file")))
} }
} }
get("GetMessageAndBroadcastZones") {
val result = object {
val messages = db.messageDB.List
.filter { mb -> !mb.Message_Detail.contains("[") && !mb.Message_Detail.contains("]")}
.map { mb -> "${mb.Description} [${mb.ANN_ID}]" }
val broadcastzones = db.broadcastDB.List
}
it.result(objectmapper.writeValueAsString(result))
}
// Kirim list language dari Messagebank berdasarkan ANN_ID
get("GetLanguageList/{ANN_ID}") { get1 ->
val langlist = db.messageDB.List
.filter { it.ANN_ID == get1.pathParam("ANN_ID").toInt().toUInt() }
.map { it.Language }.distinct()
get1.result(objectmapper.writeValueAsString(langlist))
}
} }
path("UserManagement") { path("UserManagement") {
get("List") { get("List") {
@@ -988,6 +1009,7 @@ class WebApp(val listenPort: Int, val userlist: List<Pair<String, String>>) {
if (db.userDB.DeleteByIndex(index.toInt())) { if (db.userDB.DeleteByIndex(index.toInt())) {
db.userDB.Resort() db.userDB.Resort()
it.result(objectmapper.writeValueAsString(resultMessage("OK"))) it.result(objectmapper.writeValueAsString(resultMessage("OK")))
db.Add_Log("AAS", "Deleted user with index $index")
} else it.status(500).result(objectmapper.writeValueAsString(resultMessage("Failed to delete user with index $index"))) } else it.status(500).result(objectmapper.writeValueAsString(resultMessage("Failed to delete user with index $index")))
} }
} }
@@ -1078,12 +1100,9 @@ class WebApp(val listenPort: Int, val userlist: List<Pair<String, String>>) {
} }
} }
//TODO kirim list message dan broadcast zones untuk ADD/Edit schedule
get("GetMessageAndBroadcastZones") { get("GetMessageAndBroadcastZones") {
val result = object { val result = object {
//TODO filter message without input variable
val messages = db.messageDB.List val messages = db.messageDB.List
val broadcastzones = db.broadcastDB.List val broadcastzones = db.broadcastDB.List
} }
it.result(objectmapper.writeValueAsString(result)) it.result(objectmapper.writeValueAsString(result))
@@ -1183,6 +1202,7 @@ class WebApp(val listenPort: Int, val userlist: List<Pair<String, String>>) {
if (db.broadcastDB.DeleteByIndex(index.toInt())) { if (db.broadcastDB.DeleteByIndex(index.toInt())) {
db.broadcastDB.Resort() db.broadcastDB.Resort()
it.result(objectmapper.writeValueAsString(resultMessage("OK"))) it.result(objectmapper.writeValueAsString(resultMessage("OK")))
db.Add_Log("AAS","Deleted broadcast zone with index $index")
} else { } else {
it.status(500).result(objectmapper.writeValueAsString(resultMessage("Failed to delete broadcast zone with index $index"))) it.status(500).result(objectmapper.writeValueAsString(resultMessage("Failed to delete broadcast zone with index $index")))
} }
@@ -1387,7 +1407,6 @@ class WebApp(val listenPort: Int, val userlist: List<Pair<String, String>>) {
} }
} }
// Steph : coba tambah untuk QueuePaging Table. Belum ada di JS file(?)
path("QueuePaging"){ path("QueuePaging"){
get("List"){ get("List"){
it.result(MariaDB.ArrayListtoString(db.queuepagingDB.List)) it.result(MariaDB.ArrayListtoString(db.queuepagingDB.List))
@@ -1410,6 +1429,7 @@ class WebApp(val listenPort: Int, val userlist: List<Pair<String, String>>) {
if (db.queuepagingDB.DeleteByIndex(index.toInt())) { if (db.queuepagingDB.DeleteByIndex(index.toInt())) {
db.queuepagingDB.Resort() db.queuepagingDB.Resort()
it.result(objectmapper.writeValueAsString(resultMessage("OK"))) it.result(objectmapper.writeValueAsString(resultMessage("OK")))
db.Add_Log("AAS", "Deleted queue paging with index $index")
} else { } else {
it.status(500).result(objectmapper.writeValueAsString(resultMessage("Failed to delete queue paging with index $index"))) it.status(500).result(objectmapper.writeValueAsString(resultMessage("Failed to delete queue paging with index $index")))
} }
@@ -1419,7 +1439,6 @@ class WebApp(val listenPort: Int, val userlist: List<Pair<String, String>>) {
} }
// Steph : coba tambah untuk QueueTable Table. Belum ada di JS file(?)
path("QueueTable"){ path("QueueTable"){
get("List"){ get("List"){
it.result(MariaDB.ArrayListtoString(db.queuetableDB.List)) it.result(MariaDB.ArrayListtoString(db.queuetableDB.List))
@@ -1442,6 +1461,7 @@ class WebApp(val listenPort: Int, val userlist: List<Pair<String, String>>) {
if (db.queuetableDB.DeleteByIndex(index.toInt())) { if (db.queuetableDB.DeleteByIndex(index.toInt())) {
db.queuetableDB.Resort() db.queuetableDB.Resort()
it.result(objectmapper.writeValueAsString(resultMessage("OK"))) it.result(objectmapper.writeValueAsString(resultMessage("OK")))
db.Add_Log("AAS", "Deleted queue sound with index $index")
} else { } else {
it.status(500).result(objectmapper.writeValueAsString(resultMessage("Failed to delete queue sound with index $index"))) it.status(500).result(objectmapper.writeValueAsString(resultMessage("Failed to delete queue sound with index $index")))
} }