commit 26/01/2026

This commit is contained in:
2026-01-26 17:12:48 +07:00
parent 9b6c714e53
commit 8744a47cb3
37 changed files with 109125 additions and 582 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -12,44 +12,46 @@ window.selectedBroadcastZoneRow = null;
*/
window.SoundChannelList = []
dtBroadcastZone = null;
/**
* Fill broadcast zone table body with values
* @param {BroadcastZone[]} vv values to fill
*/
function fill_broadcastzonetablebody(vv) {
$('#broadcastzonetablebody').empty();
dtBroadcastZone.clear();
if (!Array.isArray(vv) || vv.length === 0) return;
vv.forEach(item => {
const row = `<tr>
<td>${item.index}</td>
<td>${item.description}</td>
<td>${item.soundChannel}</td>
<td>${item.id}</td>
<td>${item.bp}</td>
</tr>`;
$('#broadcastzonetablebody').append(row);
let $addedrow = $('#broadcastzonetablebody tr:last');
$addedrow.off('click').on('click', function () {
if (window.selectedBroadcastZoneRow) {
window.selectedBroadcastZoneRow.find('td').css('background-color', '');
if (window.selectedBroadcastZoneRow.is($(this))) {
window.selectedBroadcastZoneRow = null;
$('#btnRemove').prop('disabled', true);
$('#btnEdit').prop('disabled', true);
return;
}
}
$(this).find('td').css('background-color', '#ffeeba');
window.selectedBroadcastZoneRow = $(this);
$('#btnRemove').prop('disabled', false);
$('#btnEdit').prop('disabled', false);
});
dtBroadcastZone.rows.add(vv);
dtBroadcastZone.draw();
$('#broadcastzonetable tbody').off('click').on('click', 'tr', function () {
// if no data
if (!dtBroadcastZone) return;
// if user click an empty row
if (!dtBroadcastZone.data().any()) return;
const selected = dtBroadcastZone.row(this)
// toggle behaviour - unselect if already selected
if ($(this).hasClass('row-selected')) {
$(this).removeClass('row-selected').find('td').css('background-color', '');
window.selectedBroadcastZoneRow = null;
$('#btnRemove').prop('disabled', true);
$('#btnEdit').prop('disabled', true);
return;
}
// unselect previously selected row
$('#broadcastzonetable tbody tr.row-selected').removeClass('row-selected').find('td').css('background-color', '');
$(this).addClass('row-selected').find('td').css('background-color', '#ffeeba');
window.selectedBroadcastZoneRow = selected.data();
$('#btnRemove').prop('disabled', false);
$('#btnEdit').prop('disabled', false);
});
$('#tablesize').text("Table Size: " + vv.length);
}
function fetchSoundChannels(APIURL = "SoundChannel/") {
window.SoundChannelList = [];
fetchAPI(APIURL + "SoundChannelDescriptions", "GET", {}, null, (okdata) => {
@@ -82,20 +84,33 @@ $(document).ready(function () {
let $broadcastzonesoundchannel = $broadcastzonemodal.find('#broadcastzonesoundchannel');
let $broadcastzonebox = $broadcastzonemodal.find('#broadcastzonebox');
if (dtBroadcastZone === null) {
dtBroadcastZone = new DataTable('#broadcastzonetable', {
data: [],
pageLength: 25,
columns: [
{ title: "No", data: "index" },
{ title: "Description", data: "description" },
{ title: "Sound Channel", data: "soundChannel" },
{ title: "Address", data: "id" },
{ title: "Contact Output", data: "bp" },
]
});
}
let $findzone = $('#findzone');
$findzone.off('input').on('input', function () {
let searchTerm = $findzone.val().trim().toLowerCase();
if (searchTerm.length > 0) {
window.selectedBroadcastZoneRow = null;
let filtered = window.BroadcastZoneList.filter(item => item.description.toLowerCase().includes(searchTerm) || item.id.toLowerCase().includes(searchTerm) || item.soundChannel.toLowerCase().includes(searchTerm) || item.bp.toLowerCase().includes(searchTerm));
fill_broadcastzonetablebody(filtered);
} else {
window.selectedBroadcastZoneRow = null;
fill_broadcastzonetablebody(window.BroadcastZoneList);
}
});
// let $findzone = $('#findzone');
// $findzone.off('input').on('input', function () {
// let searchTerm = $findzone.val().trim().toLowerCase();
// if (searchTerm.length > 0) {
// window.selectedBroadcastZoneRow = null;
// let filtered = window.BroadcastZoneList.filter(item => item.description.toLowerCase().includes(searchTerm) || item.id.toLowerCase().includes(searchTerm) || item.soundChannel.toLowerCase().includes(searchTerm) || item.bp.toLowerCase().includes(searchTerm));
// fill_broadcastzonetablebody(filtered);
// } else {
// window.selectedBroadcastZoneRow = null;
// fill_broadcastzonetablebody(window.BroadcastZoneList);
// }
// });
/**
* Find Checkbox for relays 1 to 32
@@ -115,14 +130,14 @@ $(document).ready(function () {
$broadcastzonedescription.val('');
// fill broadcastzonesoundchannel from SoundChannelList
$broadcastzonesoundchannel.empty();
console.log("SoundChannelList:", window.SoundChannelList);
//console.log("SoundChannelList:", window.SoundChannelList);
if (Array.isArray(window.SoundChannelList) && window.SoundChannelList.length > 0) {
// SoundChannelList ada isinya
window.SoundChannelList.forEach(ch => {
if (ch && ch.length>0){
if (ch && ch.length > 0) {
$broadcastzonesoundchannel.append($('<option>').val(ch).text(ch));
}
});
}
$broadcastzonebox.val('1').prop('disabled', true);
@@ -197,14 +212,13 @@ $(document).ready(function () {
$btnRemove.off('click').on('click', () => {
if (window.selectedBroadcastZoneRow) {
let cells = window.selectedBroadcastZoneRow.find('td');
/** @type {BroadcastZone} */
let bz = {
index: Number(cells.eq(0).text()),
description: cells.eq(1).text(),
SoundChannel: cells.eq(2).text(),
Box: cells.eq(3).text(),
Relay: cells.eq(4).text()
index: window.selectedBroadcastZoneRow.index,
description: window.selectedBroadcastZoneRow.description,
SoundChannel: window.selectedBroadcastZoneRow.soundChannel,
Box: window.selectedBroadcastZoneRow.id,
Relay: window.selectedBroadcastZoneRow.bp
};
if (confirm(`Are you sure to delete broadcast zone [${bz.index}] Description=${bz.description}?`)) {
fetchAPI(APIURL_BroadcastZone + "DeleteByIndex/" + bz.index, "DELETE", {}, null, (okdata) => {
@@ -219,14 +233,13 @@ $(document).ready(function () {
$btnEdit.off('click').on('click', () => {
if (window.selectedBroadcastZoneRow) {
let cells = window.selectedBroadcastZoneRow.find('td');
/** @type {BroadcastZone} */
let bz = {
index: Number(cells.eq(0).text()),
description: cells.eq(1).text(),
SoundChannel: cells.eq(2).text(),
Box: cells.eq(3).text(),
Relay: cells.eq(4).text()
index: window.selectedBroadcastZoneRow.index,
description: window.selectedBroadcastZoneRow.description,
SoundChannel: window.selectedBroadcastZoneRow.soundChannel,
Box: window.selectedBroadcastZoneRow.id,
Relay: window.selectedBroadcastZoneRow.bp
};
if (confirm(`Are you sure to edit broadcast zone [${bz.index}] Description=${bz.description} SoundChannel=${bz.SoundChannel} Box=${bz.id} Relay=${bz.bp}?`)) {
$broadcastzonemodal.modal('show');
@@ -236,10 +249,10 @@ $(document).ready(function () {
$broadcastzonesoundchannel.val(bz.SoundChannel);
$broadcastzonebox.val(bz.Box);
if (bz.Relay && bz.Relay.length > 0) {
bz.Relay.split(';').map(Number).filter(n => !isNaN(n) && n>=1 && n<=8).forEach(relayId => {
bz.Relay.split(';').map(Number).filter(n => !isNaN(n) && n >= 1 && n <= 8).forEach(relayId => {
cbRelay(relayId).prop('checked', true);
});
}
$broadcastzonemodal.off('click.broadcastzonesave').on('click.broadcastzonesave', '#broadcastzonesave', function () {
let description = $broadcastzonedescription.val().trim();

File diff suppressed because one or more lines are too long

View File

@@ -6,6 +6,8 @@
*
*/
dtLanguageLink = null;
/** List of Languagebank data loaded from server
* @type {LanguageBank[]}
*/
@@ -21,32 +23,36 @@ window.selectedlanguagerow = null;
* @param {LanguageBank[]} vv values to fill
*/
function fill_languagebanktablebody(vv) {
$('#languagebanktablebody').empty();
dtLanguageLink.clear();
if (!Array.isArray(vv) || vv.length === 0) return;
vv.forEach(item => {
const row = `<tr>
<td>${item.index}</td>
<td>${item.tag}</td>
<td>${item.language}</td>
</tr>`;
$('#languagebanktablebody').append(row);
let $addedrow = $('#languagebanktablebody tr:last');
$addedrow.click(function () {
if (window.selectedlanguagerow) {
window.selectedlanguagerow.find('td').css('background-color', '');
if (window.selectedlanguagerow.is($(this))) {
window.selectedlanguagerow = null;
$('#btnRemove').prop('disabled', true);
$('#btnEdit').prop('disabled', true);
return;
}
}
$addedrow.find('td').css('background-color', '#ffeeba');
window.selectedlanguagerow = $addedrow;
$('#btnRemove').prop('disabled', false);
$('#btnEdit').prop('disabled', false);
});
});
dtLanguageLink.rows.add(vv);
dtLanguageLink.draw();
$('#languagebanktable tbody').off('click').on('click', 'tr', function () {
// if no data
if (!dtLanguageLink) return;
// if user click an empty row
if (!dtLanguageLink.data().any()) return;
const selected = dtLanguageLink.row(this)
// toggle behaviour - unselect if already selected
if ($(this).hasClass('row-selected')) {
$(this).removeClass('row-selected').find('td').css('background-color', '');
window.selectedlanguagerow = null;
$('#btnRemove').prop('disabled', true);
$('#btnEdit').prop('disabled', true);
return;
}
// unselect previously selected row
$('#languagebanktable tbody tr.row-selected').removeClass('row-selected').find('td').css('background-color', '');
$(this).addClass('row-selected').find('td').css('background-color', '#ffeeba');
window.selectedlanguagerow = selected.data();
$('#btnRemove').prop('disabled', false);
$('#btnEdit').prop('disabled', false);
})
$('#tablesize').text("Table Size: " + vv.length);
}
@@ -69,7 +75,6 @@ function reloadLanguageBank(APIURL = "LanguageLink/") {
$(document).ready(function () {
console.log('languagebank.js loaded');
$('#languagebanktablebody').empty();
window.selectedlanguagerow = null;
let $btnClear = $('#btnClear');
@@ -92,6 +97,19 @@ $(document).ready(function () {
let $cbJap = $modal.find('#langJap');
let $cbChi = $modal.find('#langChi');
if (dtLanguageLink === null) {
dtLanguageLink = new DataTable('#languagebanktable', {
data: [],
pageLength: 25,
columns: [
{ title: "No", data: "index" },
{ title: "TAG", data: "tag" },
{ title: "Languages", data: "language" }
]
});
}
function clearLanguageModal() {
$langid.prop('disabled', true).val('');
$langtag.val('');
@@ -103,17 +121,17 @@ $(document).ready(function () {
$cbChi.prop('checked', false);
}
$findlanguage.on('input', function () {
let searchTerm = $findlanguage.val().toLowerCase();
if (searchTerm.length > 0) {
window.selectedlanguagerow = null;
let filtered = window.languagebankdata.filter(item => item.tag.toLowerCase().includes(searchTerm) || item.language.toLowerCase().includes(searchTerm));
fill_languagebanktablebody(filtered);
} else {
window.selectedlanguagerow = null;
fill_languagebanktablebody(window.languagebankdata);
}
});
// $findlanguage.on('input', function () {
// let searchTerm = $findlanguage.val().toLowerCase();
// if (searchTerm.length > 0) {
// window.selectedlanguagerow = null;
// let filtered = window.languagebankdata.filter(item => item.tag.toLowerCase().includes(searchTerm) || item.language.toLowerCase().includes(searchTerm));
// fill_languagebanktablebody(filtered);
// } else {
// window.selectedlanguagerow = null;
// fill_languagebanktablebody(window.languagebankdata);
// }
// });
reloadLanguageBank(APIURL);
$btnClear.click(() => {
@@ -172,12 +190,11 @@ $(document).ready(function () {
});
$btnRemove.click(() => {
if (window.selectedlanguagerow) {
let cells = window.selectedlanguagerow.find('td');
/** @type {Language} */
let ll = {
index: Number(cells.eq(0).text()),
tag: cells.eq(1).text(),
language: cells.eq(2).text()
index: window.selectedlanguagerow.index,
tag: window.selectedlanguagerow.tag,
language: window.selectedlanguagerow.language
}
if (confirm(`Are you sure to delete language [${ll.index}] Tag=${ll.tag} Language=${ll.language}?`)) {
fetchAPI(APIURL + "DeleteByIndex/" + ll.index, "DELETE", {}, null, (okdata) => {
@@ -191,12 +208,11 @@ $(document).ready(function () {
});
$btnEdit.click(() => {
if (window.selectedlanguagerow) {
let cells = window.selectedlanguagerow.find('td');
/** @type {Language} */
let ll = {
index: Number(cells.eq(0).text()),
tag: cells.eq(1).text(),
language: cells.eq(2).text()
index: window.selectedlanguagerow.index,
tag: window.selectedlanguagerow.tag,
language: window.selectedlanguagerow.language
}
if (confirm(`Are you sure to edit language [${ll.index}] Tag=${ll.tag} Language=${ll.language}?`)) {

View File

@@ -12,27 +12,22 @@
*/
window.logdata = [];
dtLog = null;
/**
* Fill log table body with values
* @param {Log[]} vv values to fill
*/
function fill_logtablebody(vv) {
$('#logtablebody').empty();
dtLog.clear();
if (!Array.isArray(vv) || vv.length === 0) {
$('#btnExport').prop('disabled', true);
return;
}
vv.forEach(item => {
const row = `<tr>
<td>${item.index}</td>
<td>${item.datenya}</td>
<td>${item.timenya}</td>
<td>${item.machine}</td>
<td>${item.description}</td>
</tr>`;
$('#logtablebody').append(row);
});
dtLog.rows.add(vv);
dtLog.draw();
$('#tablesize').text("Table Size: " + vv.length);
$('#btnExport').prop('disabled', false);
}
@@ -64,7 +59,20 @@ $(document).ready(function () {
let selectedlogdate = "";
let logfilter = "";
let APIURL = "Log/";
$('#logtablebody').empty();
if (dtLog === null) {
dtLog = new DataTable('#logtable', {
data: [],
pageLength: 25,
columns: [
{ title: "No", data: "index" },
{ title: "Date", data: "datenya" },
{ title: "Time", data: "timenya" },
{ title: "Machine", data: "machine" },
{ title: "Description", data: "description" }
]
});
}
if (!$('#logdate').val()) {

View File

@@ -5,41 +5,43 @@
*/
window.selectedmessagerow = null;
dtMessageBank = null;
/**
* Fill messagebank table body with values
* @param {MessageBank[]} vv values to fill
*/
function fill_messagebanktablebody(vv) {
$('#messagebanktablebody').empty();
dtMessageBank.clear();
if (!Array.isArray(vv) || vv.length === 0) return;
vv.forEach(item => {
const row = `<tr>
<td>${item.index}</td>
<td>${item.description}</td>
<td>${item.language}</td>
<td>${item.aNN_ID}</td>
<td>${item.voice_Type}</td>
<td>${item.message_Detail}</td>
<td>${item.message_TAGS}</td>
</tr>`;
$('#messagebanktablebody').append(row);
let $addedrow = $('#messagebanktablebody tr:last');
$addedrow.click(function () {
if (window.selectedmessagerow) {
window.selectedmessagerow.find('td').css('background-color', '');
if (window.selectedmessagerow.is($(this))) {
window.selectedmessagerow = null;
$('#btnRemove').prop('disabled', true);
$('#btnEdit').prop('disabled', true);
return;
}
}
$addedrow.find('td').css('background-color', '#ffeeba');
window.selectedmessagerow = $addedrow;
$('#btnRemove').prop('disabled', false);
$('#btnEdit').prop('disabled', false);
});
});
dtMessageBank.rows.add(vv);
dtMessageBank.draw();
$('#messagebanktable tbody').off('click').on('click', 'tr', function () {
// if no data
if (!dtMessageBank) return;
// if user click an empty row
if (!dtMessageBank.data().any()) return;
const selected = dtMessageBank.row(this)
// toggle behaviour - unselect if already selected
if ($(this).hasClass('row-selected')) {
$(this).removeClass('row-selected').find('td').css('background-color', '');
window.selectedmessagerow = null;
$('#btnRemove').prop('disabled', true);
$('#btnEdit').prop('disabled', true);
return;
}
// unselect previously selected row
$('#messagebanktable tbody tr.row-selected').removeClass('row-selected').find('td').css('background-color', '');
$(this).addClass('row-selected').find('td').css('background-color', '#ffeeba');
window.selectedmessagerow = selected.data();
$('#btnRemove').prop('disabled', false);
$('#btnEdit').prop('disabled', false);
})
$('#tablesize').text("Table Size: " + vv.length);
}
@@ -59,7 +61,6 @@ function fill_messagebanktablebody(vv) {
$(document).ready(function () {
console.log("messagebank.js loaded");
$('#messagebanktablebody').empty();
window.selectedmessagerow = null;
let $btnClear = $('#btnClear');
let $btnAdd = $('#btnAdd');
@@ -72,6 +73,23 @@ $(document).ready(function () {
let APIURL = "MessageBank/";
let $findmessage = $('#findmessage');
if (dtMessageBank === null) {
dtMessageBank = new DataTable('#messagebanktable', {
data: [],
pageLength: 25,
columns: [
{ title: "Index", data: "index" },
{ title: "Description", data: "description" },
{ title: "Language", data: "language" },
{ title: "ANN ID", data: "aNN_ID" },
{ title: "Type", data: "voice_Type" },
{ title: "Message Details", data: "message_Detail" },
{ title: "Message TAGS", data: "message_TAGS" }
]
});
}
// modal for add / edit messagebank
let $modal = $('#messagebankmodal');
// text input, disabled by default
@@ -106,43 +124,43 @@ $(document).ready(function () {
if ("Phrase" === cat) return; // skip Phrase category
if ("Airline_Code" === cat) cat = "Flight_Number"; // revisi 15012026 karena inconsistensi penamaan tag
let displayCat = `[${cat}]`.toUpperCase();
$messageavailablevariables.append(new Option(text=displayCat, value=displayCat));
$messageavailablevariables.append(new Option(text = displayCat, value = displayCat));
});
// tambah [ETAD], [BCB] revisi 19012026
$messageavailablevariables.append(new Option(text='[ETAD]', value='[ETAD]'));
$messageavailablevariables.append(new Option(text='[BCB]', value='[BCB]'));
$messageavailablevariables.append(new Option(text = '[ETAD]', value = '[ETAD]'));
$messageavailablevariables.append(new Option(text = '[BCB]', value = '[BCB]'));
let lang = $messagelanguage.val();
let vt = $messagevoicetype.val();
if (lang && lang.length > 0 && vt && vt.length > 0) {
fetchAPI(`SoundBank/GetPhrases/${lang}/${vt}`, "GET", {}, null, (okdata) => {
if (Array.isArray(okdata) && okdata.length > 0) {
console.log(`Loaded ${okdata.length} phrases from soundbank for language=${lang} and voiceType=${vt}`);
//console.log(JSON.stringify(okdata));
okdata.forEach(sb => {
if (sb.description && sb.description.length > 0) {
let v1 = sb.tag.toUpperCase();
let t1 = sb.description+` [${v1}]`;
let t2 = sb.description;
$messageavailablevariables.append($('<option>', { value: v1, text: t1, title: t2 }));
}
});
if (cbLoaded && typeof cbLoaded === 'function') {
cbLoaded();
if (Array.isArray(okdata) && okdata.length > 0) {
console.log(`Loaded ${okdata.length} phrases from soundbank for language=${lang} and voiceType=${vt}`);
//console.log(JSON.stringify(okdata));
okdata.forEach(sb => {
if (sb.description && sb.description.length > 0) {
let v1 = sb.tag.toUpperCase();
let t1 = sb.description + ` [${v1}]`;
let t2 = sb.description;
$messageavailablevariables.append($('<option>', { value: v1, text: t1, title: t2 }));
}
}
}, (errdata) => {
//alert("Error loading phrases from soundbank : " + errdata.message);
});
if (cbLoaded && typeof cbLoaded === 'function') {
cbLoaded();
}
});
}
}, (errdata) => {
//alert("Error loading phrases from soundbank : " + errdata.message);
if (cbLoaded && typeof cbLoaded === 'function') {
cbLoaded();
}
});
} else {
if (cbLoaded && typeof cbLoaded === 'function') {
cbLoaded();
}
}
}
@@ -267,17 +285,17 @@ $(document).ready(function () {
}
$findmessage.on('input', function () {
let searchTerm = $findmessage.val().toLowerCase();
if (searchTerm.length > 0) {
window.selectedmessagerow = null;
let filtered = window.messagebankdata.filter(item => item.description.toLowerCase().includes(searchTerm) || item.message_Detail.toLowerCase().includes(searchTerm) || item.message_TAGS.toLowerCase().includes(searchTerm));
fill_messagebanktablebody(filtered);
} else {
window.selectedmessagerow = null;
fill_messagebanktablebody(window.messagebankdata);
}
});
// $findmessage.on('input', function () {
// let searchTerm = $findmessage.val().toLowerCase();
// if (searchTerm.length > 0) {
// window.selectedmessagerow = null;
// let filtered = window.messagebankdata.filter(item => item.description.toLowerCase().includes(searchTerm) || item.message_Detail.toLowerCase().includes(searchTerm) || item.message_TAGS.toLowerCase().includes(searchTerm));
// fill_messagebanktablebody(filtered);
// } else {
// window.selectedmessagerow = null;
// fill_messagebanktablebody(window.messagebankdata);
// }
// });
reloadMessageBank(APIURL, () => fill_messagebanktablebody(window.messagebankdata));
@@ -296,7 +314,7 @@ $(document).ready(function () {
$modal.modal('show');
clearMessageModal();
$('#closemodalbutton').off('click').on('click', function () {
console.log('Close button clicked')
@@ -322,16 +340,15 @@ $(document).ready(function () {
});
$btnRemove.click(() => {
if (window.selectedmessagerow) {
let cells = window.selectedmessagerow.find('td');
/** @type {MessageBank} */
let mb = {
index: Number(cells.eq(0).text()),
description: cells.eq(1).text(),
language: cells.eq(2).text(),
aNN_ID: parseInt(cells.eq(3).text()),
voice_Type: cells.eq(4).text(),
message_Detail: cells.eq(5).text(),
message_TAGS: cells.eq(6).text()
index: window.selectedmessagerow.index,
description: window.selectedmessagerow.description,
language: window.selectedmessagerow.language,
aNN_ID: window.selectedmessagerow.aNN_ID,
voice_Type: window.selectedmessagerow.voice_Type,
message_Detail: window.selectedmessagerow.message_Detail,
message_TAGS: window.selectedmessagerow.message_TAGS
}
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} `)) {
@@ -346,16 +363,15 @@ $(document).ready(function () {
});
$btnEdit.click(() => {
if (window.selectedmessagerow) {
let cells = window.selectedmessagerow.find('td');
/** @type {MessageBank} */
let mb = {
index: Number(cells.eq(0).text()),
description: cells.eq(1).text(),
language: cells.eq(2).text(),
aNN_ID: parseInt(cells.eq(3).text()),
voice_Type: cells.eq(4).text(),
message_Detail: cells.eq(5).text(),
message_TAGS: cells.eq(6).text()
index: window.selectedmessagerow.index,
description: window.selectedmessagerow.description,
language: window.selectedmessagerow.language,
aNN_ID: window.selectedmessagerow.aNN_ID,
voice_Type: window.selectedmessagerow.voice_Type,
message_Detail: window.selectedmessagerow.message_Detail,
message_TAGS: window.selectedmessagerow.message_TAGS
}
if (confirm(`Are you sure to edit messagebank [${mb.index}] Description=${mb.description} ANN_ID=${mb.aNN_ID} Language=${mb.language} Voice_Type=${mb.voice_Type} `)) {
$modal.modal('show');
@@ -370,41 +386,41 @@ $(document).ready(function () {
$messageannid.val(mb.aNN_ID).prop('disabled', true);
// Refill message available variables
refill_messageavailablevariables(() => {
// Fill messageselectedvariables from message_Detail and message_TAGS
$messageselectedvariables.empty();
if (mb.message_Detail && mb.message_Detail.length > 0) {
if (mb.message_TAGS && mb.message_TAGS.length > 0) {
let tags = mb.message_TAGS.split(" ");
tags.forEach((tag, idx) => {
//console.log(`Restoring tag[${idx}]: ${tag}`);
let tagLower = tag.toLowerCase();
let isfound = false;
if (tagLower==="[airline_code]") {
tagLower = "[flight_number]";
}
if (tagLower==="[gatenumber]") {
tagLower = "[gate]";
}
// find <option> in messageavailablevariables with value=tag
$messageavailablevariables.find('option').each(function () {
let valx = $(this).val().toLowerCase();
//console.log(`Available option value: ${valx}`);
if (valx === tagLower) {
isfound = true;
//console.log(`Found matching option for tag: ${tag}`);
$messageselectedvariables.append($(this).clone());
// Fill messageselectedvariables from message_Detail and message_TAGS
$messageselectedvariables.empty();
if (mb.message_Detail && mb.message_Detail.length > 0) {
if (mb.message_TAGS && mb.message_TAGS.length > 0) {
let tags = mb.message_TAGS.split(" ");
tags.forEach((tag, idx) => {
//console.log(`Restoring tag[${idx}]: ${tag}`);
let tagLower = tag.toLowerCase();
let isfound = false;
if (tagLower === "[airline_code]") {
tagLower = "[flight_number]";
}
if (tagLower === "[gatenumber]") {
tagLower = "[gate]";
}
// find <option> in messageavailablevariables with value=tag
$messageavailablevariables.find('option').each(function () {
let valx = $(this).val().toLowerCase();
//console.log(`Available option value: ${valx}`);
if (valx === tagLower) {
isfound = true;
//console.log(`Found matching option for tag: ${tag}`);
$messageselectedvariables.append($(this).clone());
}
});
// if (isfound) {
// console.log(`Appended tag to selected variables: ${tag}`);
// } else {
// console.log(`Tag not found in available variables: ${tag}`);
// }
});
// if (isfound) {
// console.log(`Appended tag to selected variables: ${tag}`);
// } else {
// console.log(`Tag not found in available variables: ${tag}`);
// }
});
}
}
}
});
// Save button event
$('#savemodalbutton').off('click').on('click', function () {

View File

@@ -461,6 +461,7 @@ $(document).ready(function () {
* @type {StreamerOutputData[]}
*/
let so = JSON.parse(data);
console.log(so);
UpdateStreamerCard(so);
break;
}

View File

@@ -21,46 +21,50 @@ window.schedulebankdata = [];
*/
window.selectedschedulerow = null;
dtScheduleBank = null;
/**
* Fill schedulebank table body with values
* @param {ScheduleBank[]} vv values to fill
*/
function fill_schedulebanktablebody(vv) {
$('#schedulebanktablebody').empty();
dtScheduleBank.clear();
if (!Array.isArray(vv) || vv.length === 0) return;
vv.forEach(item => {
const row = `<tr>
<td>${item.index}</td>
<td>${item.description}</td>
<td>${item.day}</td>
<td>${item.time}</td>
<td>${item.soundpath}</td>
<td>${item.repeat}</td>
<td>${item.enable}</td>
<td>${item.broadcastZones}</td>
<td>${item.language}</td>
</tr>`;
$('#schedulebanktablebody').append(row);
let $addedrow = $('#schedulebanktablebody tr:last');
$addedrow.click(function () {
if (selectedschedulerow) {
selectedschedulerow.find('td').css('background-color', '');
if (selectedschedulerow.is($(this))) {
selectedschedulerow = null;
$('#btnRemove').prop('disabled', true);
$('#btnEdit').prop('disabled', true);
return;
}
}
$addedrow.find('td').css('background-color', '#ffeeba');
selectedschedulerow = $addedrow;
$('#btnRemove').prop('disabled', false);
$('#btnEdit').prop('disabled', false);
});
dtScheduleBank.rows.add(vv);
dtScheduleBank.draw();
$('#schedulebanktable tbody').off('click').on('click', 'tr', function () {
// if no data
if (!dtScheduleBank) return;
// if user click an empty row
if (!dtScheduleBank.data().any()) return;
const selected = dtScheduleBank.row(this)
// toggle behaviour - unselect if already selected
if ($(this).hasClass('row-selected')) {
$(this).removeClass('row-selected').find('td').css('background-color', '');
window.selectedschedulerow = null;
$('#btnRemove').prop('disabled', true);
$('#btnEdit').prop('disabled', true);
return;
}
// unselect previously selected row
$('#schedulebanktable tbody tr.row-selected').removeClass('row-selected').find('td').css('background-color', '');
$(this).addClass('row-selected').find('td').css('background-color', '#ffeeba');
window.selectedschedulerow = selected.data();
$('#btnRemove').prop('disabled', false);
$('#btnEdit').prop('disabled', false);
});
$('#tablesize').text("Table Size: " + vv.length);
}
/**
* Convert input date string yyyy-mm-dd to dd/mm/yyyy
* @param {String} value from input date, which is in format yyyy-mm-dd
@@ -128,6 +132,25 @@ $(document).ready(function () {
$btnRemove.prop('disabled', true);
let APIURL = "ScheduleBank/";
if (dtScheduleBank === null) {
dtScheduleBank = new DataTable('#schedulebanktable', {
data: [],
pageLength: 25,
columns: [
{ title: "No", data: "index" },
{ title: "Description", data: "description" },
{ title: "Day", data: "day" },
{ title: "Time", data: "time" },
{ title: "Sound Path", data: "soundpath" },
{ title: "Repeat", data: "repeat" },
{ title: "Enable", data: "enable" },
{ title: "Broadcast Zones", data: "broadcastZones" },
{ title: "Language", data: "language" }
]
});
}
let $schedulemodal = $('#schedulemodal');
// text input
let $scheduleid = $schedulemodal.find('#scheduleid');
@@ -237,20 +260,20 @@ $(document).ready(function () {
}
let $findschedule = $('#findschedule');
$findschedule.off('input').on('input', function () {
let searchTerm = $findschedule.val().toLowerCase();
if (searchTerm.length > 0) {
window.selectedschedulerow = null;
let filtered = window.schedulebankdata.filter(item =>
item.description.toLowerCase().includes(searchTerm)
|| item.soundpath.toLowerCase().includes(searchTerm)
|| item.broadcastZones.toLowerCase().includes(searchTerm));
fill_schedulebanktablebody(filtered);
} else {
window.selectedschedulerow = null;
fill_schedulebanktablebody(window.schedulebankdata);
}
});
// $findschedule.off('input').on('input', function () {
// let searchTerm = $findschedule.val().toLowerCase();
// if (searchTerm.length > 0) {
// window.selectedschedulerow = null;
// let filtered = window.schedulebankdata.filter(item =>
// item.description.toLowerCase().includes(searchTerm)
// || item.soundpath.toLowerCase().includes(searchTerm)
// || item.broadcastZones.toLowerCase().includes(searchTerm));
// fill_schedulebanktablebody(filtered);
// } else {
// window.selectedschedulerow = null;
// fill_schedulebanktablebody(window.schedulebankdata);
// }
// });
reloadTimerBank(APIURL);
@@ -328,18 +351,17 @@ $(document).ready(function () {
});
$btnRemove.click(() => {
if (window.selectedschedulerow) {
let cells = window.selectedschedulerow.find('td');
/** @type {ScheduleBank} */
let sr = {
index: Number(cells.eq(0).text()),
description: cells.eq(1).text(),
day: cells.eq(2).text(),
time: cells.eq(3).text(),
soundpath: cells.eq(4).text(),
repeat: cells.eq(5).text(),
enable: cells.eq(6).text(),
broadcastZones: cells.eq(7).text(),
language: cells.eq(8).text()
index: window.selectedschedulerow.index,
description: window.selectedschedulerow.description,
day: window.selectedschedulerow.day,
time: window.selectedschedulerow.time,
soundpath: window.selectedschedulerow.soundpath,
repeat: window.selectedschedulerow.repeat,
enable: window.selectedschedulerow.enable,
broadcastZones: window.selectedschedulerow.broadcastZones,
language: window.selectedschedulerow.language
}
if (confirm(`Are you sure to delete schedule [${sr.index}] Description=${sr.description}?`)) {
fetchAPI(APIURL + "DeleteByIndex/" + sr.index, "DELETE", {}, null, (okdata) => {
@@ -353,18 +375,17 @@ $(document).ready(function () {
});
$btnEdit.click(() => {
if (window.selectedschedulerow) {
let cells = window.selectedschedulerow.find('td');
/** @type {ScheduleBank} */
let sr = {
index: Number(cells.eq(0).text()),
Description: cells.eq(1).text(),
Day: cells.eq(2).text(),
Time: cells.eq(3).text(),
Soundpath: cells.eq(4).text(),
Repeat: cells.eq(5).text(),
Enable: cells.eq(6).text(),
BroadcastZones: cells.eq(7).text(),
Language: cells.eq(8).text()
index: window.selectedschedulerow.index,
Description: window.selectedschedulerow.description,
Day: window.selectedschedulerow.day,
Time: window.selectedschedulerow.time,
Soundpath: window.selectedschedulerow.soundpath,
Repeat: window.selectedschedulerow.repeat,
Enable: window.selectedschedulerow.enable,
BroadcastZones: window.selectedschedulerow.broadcastZones,
Language: window.selectedschedulerow.language
}
if (confirm(`Are you sure to edit schedule [${sr.index}] Description=${sr.Description}?`)) {
$schedulemodal.modal('show');
@@ -385,7 +406,7 @@ $(document).ready(function () {
case 'Everyday':
$scheduleeveryday.click();
break;
case 'Sunday' :
case 'Sunday':
case 'Monday':
case 'Tuesday':
case 'Wednesday':

View File

@@ -400,7 +400,7 @@ $(document).ready(function () {
if (window.ws && window.ws.readyState === WebSocket.OPEN) return;
const s = new WebSocket(wsURL);
s.addEventListener('open', () => {
console.log('WebSocket connection established');
//console.log('WebSocket connection established');
$('#onlineindicator').attr('src', window.greencircle);
if (ws_reconnect) {
@@ -411,7 +411,7 @@ $(document).ready(function () {
window.dispatchEvent(new Event('ws_connected'));
});
s.addEventListener('close', () => {
console.log('WebSocket connection closed');
//console.log('WebSocket connection closed');
window.dispatchEvent(new Event('ws_disconnected'));
resetStatusIndicators();
if (!ws_reconnect) {

View File

@@ -28,7 +28,7 @@ window.soundbankdata = [];
*/
window.selectedsoundrow = null;
dtSoundbank = null;
/**
* Select2 data source
@@ -46,6 +46,7 @@ function reloadSoundBank(APIURL = "SoundBank/") {
fetchAPI(APIURL + "List", "GET", {}, null, (okdata) => {
if (Array.isArray(okdata)) {
//console.log("reloadSoundBank: got " + okdata.length + " items");
window.soundbankdata.push(...okdata);
window.selectedsoundrow = null;
fill_soundbanktablebody(window.soundbankdata);
@@ -60,41 +61,41 @@ function reloadSoundBank(APIURL = "SoundBank/") {
* @param {SoundBank[]} vv values to fill
*/
function fill_soundbanktablebody(vv) {
$('#soundbanktablebody').empty();
dtSoundbank.clear();
if (!Array.isArray(vv) || vv.length === 0) return;
vv.forEach(item => {
const row = `<tr>
<td>${item.index}</td>
<td>${item.description}</td>
<td>${item.tag}</td>
<td>${item.category}</td>
<td>${item.language}</td>
<td>${item.voiceType}</td>
<td>${item.path}</td>
</tr>`;
$('#soundbanktablebody').append(row);
let $addedrow = $('#soundbanktablebody tr:last');
$addedrow.on('click', function () {
if (window.selectedsoundrow) {
window.selectedsoundrow.find('td').css('background-color', '');
if (window.selectedsoundrow.is($(this))) {
window.selectedsoundrow = null;
$('#btnRemove').prop('disabled', true);
$('#btnEdit').prop('disabled', true);
return;
}
}
$(this).find('td').css('background-color', '#ffeeba');
window.selectedsoundrow = $(this);
$('#btnRemove').prop('disabled', false);
$('#btnEdit').prop('disabled', false);
});
});
dtSoundbank.rows.add(vv);
dtSoundbank.draw();
$('#soundbanktable tbody').off('click').on('click', 'tr', function () {
// if no data
if (!dtSoundbank) return;
// if user click an empty row
if (!dtSoundbank.data().any()) return;
const selected = dtSoundbank.row(this)
// toggle behaviour - unselect if already selected
if ($(this).hasClass('row-selected')) {
$(this).removeClass('row-selected').find('td').css('background-color', '');
window.selectedsoundrow = null;
$('#btnRemove').prop('disabled', true);
$('#btnEdit').prop('disabled', true);
return;
}
// unselect previously selected row
$('#soundbanktable tbody tr.row-selected').removeClass('row-selected').find('td').css('background-color', '');
$(this).addClass('row-selected').find('td').css('background-color', '#ffeeba');
window.selectedsoundrow = selected.data();
$('#btnRemove').prop('disabled', false);
$('#btnEdit').prop('disabled', false);
})
$('#tablesize').text("Table Size: " + vv.length);
}
/**
* Reload soundbank files from server and filter by language, category, and voiceType
* @param {String} language
@@ -102,17 +103,17 @@ function fill_soundbanktablebody(vv) {
* @param {String} voiceType
* @param {Function} cb callback function when done
*/
function reloadSoundbankFiles(language, category, voiceType, cb=null) {
function reloadSoundbankFiles(language, category, voiceType, cb = null) {
window.select2data = [];
$('#modalpath').empty().trigger('change');
if (language && language.length > 0) {
if (category && category.length > 0) {
if (voiceType && voiceType.length > 0) {
fetchAPI(`ListFiles/${language}/${voiceType}/${category}`, "GET", {}, null, (okdata) => {
console.log("reloadSoundbankFiles: got " + okdata.length + " items");
if (Array.isArray(okdata)){
window.select2data = okdata.map(p => ({id: getFilenameFromPath(p), text: getFilenameFromPath(p)}));
//console.log("reloadSoundbankFiles: got " + okdata.length + " items");
if (Array.isArray(okdata)) {
window.select2data = okdata.map(p => ({ id: getFilenameFromPath(p), text: getFilenameFromPath(p) }));
$('#modalpath').select2({
data: window.select2data,
placeholder: 'Select a sound file',
@@ -141,7 +142,7 @@ function getFilenameFromPath(path) {
let parts = path.split('/');
return parts[parts.length - 1];
}
}
@@ -171,6 +172,23 @@ $(document).ready(function () {
let selected_language = null;
let selected_voicetype = null;
if (dtSoundbank === null) {
dtSoundbank = new DataTable('#soundbanktable', {
data: [],
pageLength: 25,
columns: [
{ title: "Index", data: "index" },
{ title: "Description", data: "description" },
{ title: "Tag", data: "tag" },
{ title: "Category", data: "category" },
{ title: "Language", data: "language" },
{ title: "Type", data: "voiceType" },
{ title: "Filename", data: "path" }
]
});
}
/**
* Clear soundbank modal inputs
*/
@@ -201,17 +219,17 @@ $(document).ready(function () {
}
reloadSoundBank(APIURL);
$('#findsoundbank').on('input', function () {
let searchTerm = $(this).val().trim().toLowerCase();
if (searchTerm.length > 0) {
window.selectedsoundrow = null;
let filtered = window.soundbankdata.filter(item => item.description.toLowerCase().includes(searchTerm) || item.tag.toLowerCase().includes(searchTerm) || item.path.toLowerCase().includes(searchTerm));
fill_soundbanktablebody(filtered);
} else {
window.selectedsoundrow = null;
fill_soundbanktablebody(window.soundbankdata);
}
});
// $('#findsoundbank').on('input', function () {
// let searchTerm = $(this).val().trim().toLowerCase();
// if (searchTerm.length > 0) {
// window.selectedsoundrow = null;
// let filtered = window.soundbankdata.filter(item => item.description.toLowerCase().includes(searchTerm) || item.tag.toLowerCase().includes(searchTerm) || item.path.toLowerCase().includes(searchTerm));
// fill_soundbanktablebody(filtered);
// } else {
// window.selectedsoundrow = null;
// fill_soundbanktablebody(window.soundbankdata);
// }
// });
$btnClear.click(() => {
DoClear(APIURL, "Soundbank", (okdata) => {
reloadSoundBank(APIURL);
@@ -304,16 +322,16 @@ $(document).ready(function () {
});
$btnRemove.click(() => {
if (window.selectedsoundrow) {
let cells = window.selectedsoundrow.find('td');
//console.log(window.selectedsoundrow);
/** @type {SoundBank} */
let sb = {
index: Number(cells.eq(0).text()),
description: cells.eq(1).text(),
tag: cells.eq(2).text(),
category: cells.eq(3).text(),
language: cells.eq(4).text(),
voiceType: cells.eq(5).text(),
path: cells.eq(6).text()
index: window.selectedsoundrow.index,
description: window.selectedsoundrow.description,
tag: window.selectedsoundrow.tag,
category: window.selectedsoundrow.category,
language: window.selectedsoundrow.language,
voiceType: window.selectedsoundrow.voiceType,
path: window.selectedsoundrow.path
}
if (confirm(`Are you sure to delete soundbank [${sb.index}] Description=${sb.description} Tag=${sb.tag}?`)) {
fetchAPI(APIURL + "DeleteByIndex/" + sb.index, "DELETE", {}, null, (okdata) => {
@@ -327,16 +345,16 @@ $(document).ready(function () {
});
$btnEdit.click(() => {
if (window.selectedsoundrow) {
let cells = window.selectedsoundrow.find('td');
//console.log(window.selectedsoundrow);
/** @type {SoundBank} */
let sb = {
index: Number(cells.eq(0).text()),
Description: cells.eq(1).text(),
TAG: cells.eq(2).text(),
Category: cells.eq(3).text(),
Language: cells.eq(4).text(),
VoiceType: cells.eq(5).text(),
Path: cells.eq(6).text()
index: window.selectedsoundrow.index,
Description: window.selectedsoundrow.description,
TAG: window.selectedsoundrow.tag,
Category: window.selectedsoundrow.category,
Language: window.selectedsoundrow.language,
VoiceType: window.selectedsoundrow.voiceType,
Path: window.selectedsoundrow.path
}
if (confirm(`Are you sure to edit soundbank [${sb.index}] Description=${sb.Description} Tag=${sb.TAG}?`)) {
$modal.modal('show');
@@ -358,63 +376,63 @@ $(document).ready(function () {
});
// event on Click save button
$modal.off('click.soundbanksave').on('click.soundbanksave', '#soundbanksave', function () {
let description = $modaldescription.val().trim();
let tag = $modaltag.val().trim();
let category = $modalcategory.val();
let language = $modallanguage.val();
let voiceType = $modalvoicetype.val();
let path = $('#soundbankmodal #modalpath').val();
if (!description || description.length === 0) {
alert("Description is required");
return;
}
if (!tag || tag.length === 0) {
alert("Tag is required");
return;
}
if (!category || category.length === 0) {
alert("Category is required");
return;
}
if (!language || language.length === 0) {
alert("Language is required");
return;
}
if (!voiceType || voiceType.length === 0) {
alert("Voice Type is required");
return;
}
if (!path || path.length === 0) {
alert("Path is required");
return;
}
if (description === sb.Description && tag === sb.TAG && category === sb.Category && language === sb.Language && voiceType === sb.VoiceType && path === sb.Path) {
alert("No changes detected");
return;
}
sb.Description = description;
sb.TAG = tag;
sb.Category = category;
sb.Language = language;
sb.VoiceType = voiceType;
sb.Path = path;
fetchAPI(APIURL + "UpdateByIndex/" + sb.index, "PATCH", {}, sb, (okdata) => {
reloadSoundBank(APIURL);
alert("Success update soundbank : " + okdata.message);
}, (errdata) => {
alert("Error update soundbank : " + errdata.message);
});
$modal.modal('hide');
// event on Click save button
$modal.off('click.soundbanksave').on('click.soundbanksave', '#soundbanksave', function () {
let description = $modaldescription.val().trim();
let tag = $modaltag.val().trim();
let category = $modalcategory.val();
let language = $modallanguage.val();
let voiceType = $modalvoicetype.val();
let path = $('#soundbankmodal #modalpath').val();
if (!description || description.length === 0) {
alert("Description is required");
return;
}
if (!tag || tag.length === 0) {
alert("Tag is required");
return;
}
if (!category || category.length === 0) {
alert("Category is required");
return;
}
if (!language || language.length === 0) {
alert("Language is required");
return;
}
if (!voiceType || voiceType.length === 0) {
alert("Voice Type is required");
return;
}
if (!path || path.length === 0) {
alert("Path is required");
return;
}
if (description === sb.Description && tag === sb.TAG && category === sb.Category && language === sb.Language && voiceType === sb.VoiceType && path === sb.Path) {
alert("No changes detected");
return;
}
sb.Description = description;
sb.TAG = tag;
sb.Category = category;
sb.Language = language;
sb.VoiceType = voiceType;
sb.Path = path;
fetchAPI(APIURL + "UpdateByIndex/" + sb.index, "PATCH", {}, sb, (okdata) => {
reloadSoundBank(APIURL);
alert("Success update soundbank : " + okdata.message);
}, (errdata) => {
alert("Error update soundbank : " + errdata.message);
});
// event on Click close button
$modal.off('click.soundbankclose').on('click.soundbankclose', '#soundbankclose', function () {
$modal.modal('hide');
});
$modal.modal('hide');
});
// event on Click close button
$modal.off('click.soundbankclose').on('click.soundbankclose', '#soundbankclose', function () {
$modal.modal('hide');
});
}
}
});

View File

@@ -13,6 +13,8 @@ window.soundChannels = [];
// Currently selected sound channel row in the table
window.selectedSoundChannel = null;
dtSoundChannel = null;
/**
* Fills the sound channel table body with the provided data.
* @param {SoundChannel[]} vv Sound channel data to populate the table.
@@ -20,36 +22,41 @@ window.selectedSoundChannel = null;
function fill_soundchanneltablebody(vv) {
let $btnEditSoundChannel = $('#btnEditSoundChannel');
let $tablesizeSoundChannel = $('#tablesizeSoundChannel');
$('#soundchanneltablebody').empty();
$tablesizeSoundChannel.text('Table Length : N/A');
if (!Array.isArray(vv) || vv.length === 0) return;
dtSoundChannel.clear();
if (!Array.isArray(vv) || vv.length === 0) return;
dtSoundChannel.rows.add(vv);
dtSoundChannel.draw();
$('#soundchanneltable tbody').off('click').on('click', 'tr', function () {
// if no data
if (!dtSoundChannel) return;
// if user click an empty row
if (!dtSoundChannel.data().any()) return;
const selected = dtSoundChannel.row(this)
// toggle behaviour - unselect if already selected
if ($(this).hasClass('row-selected')) {
$(this).removeClass('row-selected').find('td').css('background-color', '');
window.selectedSoundChannel = null;
$btnEditSoundChannel.prop('disabled', true);
return;
}
// unselect previously selected row
$('#soundchanneltable tbody tr.row-selected').removeClass('row-selected').find('td').css('background-color', '');
$(this).addClass('row-selected').find('td').css('background-color', '#ffeeba');
window.selectedSoundChannel = selected.data();
$btnEditSoundChannel.prop('disabled', false);
})
vv.forEach(item => {
const row = `<tr>
<td>${item.index}</td>
<td>${item.channel}</td>
<td>${item.ip}</td>
</tr>`;
$('#soundchanneltablebody').append(row);
let $addedrow = $('#soundchanneltablebody tr:last');
$addedrow.off('click').on('click', function () {
if (selectedSoundChannel) {
selectedSoundChannel.find('td').css('background-color', '');
if (selectedSoundChannel.is($(this))) {
selectedSoundChannel = null;
$btnEditSoundChannel.prop('disabled', true);
return;
}
}
$(this).find('td').css('background-color', '#ffeeba');
selectedSoundChannel = $(this);
$btnEditSoundChannel.prop('disabled', false);
});
});
$tablesizeSoundChannel.text("Table Size: " + vv.length);
}
/**
* Reload sound channels from server
* @param {String} APIURL API URL endpoint (default "SoundChannel/")
@@ -66,7 +73,7 @@ function reloadSoundChannel(APIURL = "SoundChannel/") {
alert("Error loading sound channels : " + errdata.message);
});
}
$(document).ready(function () {
console.log("soundchannel.js loaded successfully");
let $soundchannelmodal = $('#soundchannelmodal');
@@ -82,21 +89,35 @@ $(document).ready(function () {
$btnEditSoundChannel.prop('disabled', true);
let API_SoundChannel = "SoundChannel/";
$findsoundchannel.off('input').on('input', function () {
let searchTerm = $(this).val().toLowerCase();
if (searchTerm.length==0){
window.selectedSoundChannel = null;
fill_soundchanneltablebody(window.soundChannels);
} else {
window.selectedSoundChannel = null;
let filteredChannels = window.soundChannels.filter(xx =>
xx.index.toString().includes(searchTerm) ||
xx.channel.toLowerCase().includes(searchTerm) ||
xx.ip.toLowerCase().includes(searchTerm)
);
fill_soundchanneltablebody(filteredChannels);
}
});
if (dtSoundChannel === null) {
dtSoundChannel = new DataTable('#soundchanneltable', {
data: [],
pageLength: 25,
columns: [
{ title: "No", data: "index" },
{ title: "Channel", data: "channel" },
{ title: "IP", data: "ip" }
]
});
}
// $findsoundchannel.off('input').on('input', function () {
// let searchTerm = $(this).val().toLowerCase();
// if (searchTerm.length == 0) {
// window.selectedSoundChannel = null;
// fill_soundchanneltablebody(window.soundChannels);
// } else {
// window.selectedSoundChannel = null;
// let filteredChannels = window.soundChannels.filter(xx =>
// xx.index.toString().includes(searchTerm) ||
// xx.channel.toLowerCase().includes(searchTerm) ||
// xx.ip.toLowerCase().includes(searchTerm)
// );
// fill_soundchanneltablebody(filteredChannels);
// }
// });
/**
* Clear sound channel modal inputs
@@ -117,13 +138,12 @@ $(document).ready(function () {
});
});
$btnEditSoundChannel.off('click').on('click', () => {
if (selectedSoundChannel) {
let cells = selectedSoundChannel.find('td');
if (window.selectedSoundChannel) {
/** @type {SoundChannel} */
let sc = {
index: parseInt(cells.eq(0).text(), 10),
description: cells.eq(1).text(),
ip: cells.eq(2).text()
index: window.selectedSoundChannel.index,
description: window.selectedSoundChannel.channel,
ip: window.selectedSoundChannel.ip
};
if (confirm(`Are you sure to edit sound channel [${sc.index}] Description=${sc.description} IP=${sc.ip}?`)) {
$soundchannelmodal.modal('show');
@@ -147,12 +167,12 @@ $(document).ready(function () {
alert("IP cannot be empty");
return;
}
if (newsc.description===sc.description && newsc.ip===sc.ip){
if (newsc.description === sc.description && newsc.ip === sc.ip) {
alert("No changes detected");
return;
}
fetchAPI(API_SoundChannel + "UpdateByIndex/" + newsc.index, "PATCH", {}, newsc, (okdata) => {
reloadSoundChannel(API_SoundChannel);
@@ -161,8 +181,8 @@ $(document).ready(function () {
alert("Error edit sound channel: " + errdata.message);
});
$soundchannelmodal.modal('hide');
});
$soundchannelmodal.off('click.soundchannelclose').on('click.soundchannelclose', '#soundchannelclose', function () {
$soundchannelmodal.modal('hide');

View File

@@ -48,6 +48,8 @@ window.messagebankids = [];
*/
window.broadcastzones = [];
dtUserManagement = null;
/**
* Get Messagebank ANN_IDs from server
*/
@@ -109,40 +111,42 @@ function get_broadcastzones_descriptions() {
* @param {UserDB[]} vv values to fill
*/
function fill_usertablebody(vv) {
$('#usertablebody').empty();
dtUserManagement.clear();
if (!Array.isArray(vv) || vv.length === 0) {
$('#btnExport').prop('disabled', true);
return;
}
vv.forEach(item => {
const row = `<tr>
<td>${item.index}</td>
<td>${item.username}</td>
<td>${item.location}</td>
<td>${item.airline_tags}</td>
<td>${item.city_tags}</td>
<td>${item.messagebank_ann_id}</td>
<td>${item.broadcastzones}</td>
</tr>`;
$('#usertablebody').append(row);
let $addedrow = $('#usertablebody tr:last');
$addedrow.off('click').on('click', function () {
if (window.selecteduserrow) {
window.selecteduserrow.find('td').css('background-color', '');
if (window.selecteduserrow.is($(this))) {
window.selecteduserrow = null;
$('#btnRemove').prop('disabled', true);
$('#btnEdit').prop('disabled', true);
return;
}
}
$(this).find('td').css('background-color', '#ffeeba');
window.selecteduserrow = $(this);
$('#btnRemove').prop('disabled', false);
$('#btnEdit').prop('disabled', false);
});
dtUserManagement.rows.add(vv);
dtUserManagement.draw();
$('#usertable tbody').off('click').on('click', 'tr', function () {
// if no data
if (!dtUserManagement) return;
// if user click an empty row
if (!dtUserManagement.data().any()) return;
const selected = dtUserManagement.row(this)
// toggle behaviour - unselect if already selected
if ($(this).hasClass('row-selected')) {
$(this).removeClass('row-selected').find('td').css('background-color', '');
window.selecteduserrow = null;
$('#btnRemove').prop('disabled', true);
$('#btnEdit').prop('disabled', true);
return;
}
// unselect previously selected row
$('#usertable tbody tr.row-selected').removeClass('row-selected').find('td').css('background-color', '');
$(this).addClass('row-selected').find('td').css('background-color', '#ffeeba');
window.selecteduserrow = selected.data();
$('#btnRemove').prop('disabled', false);
$('#btnEdit').prop('disabled', false);
});
$('#tablesize').text("Table Size: " + vv.length);
$('#btnExport').prop('disabled', false);
}
@@ -170,6 +174,23 @@ $(document).ready(function () {
get_messagebankids();
get_broadcastzones_descriptions();
if (dtUserManagement === null) {
dtUserManagement = new DataTable('#usertable', {
data: [],
pageLength: 25,
columns: [
{ title: "No", data: "index" },
{ title: "Username", data: "username" },
{ title: "Location", data: "location" },
{ title: "Airline", data: "airline_tags" },
{ title: "City", data: "city_tags" },
{ title: "Messagebank", data: "messagebank_ann_id" },
{ title: "Broadcast Zones", data: "broadcastzones" }
]
});
}
let APIURL = "UserManagement/";
function clearAddModal() {
@@ -247,29 +268,29 @@ $(document).ready(function () {
$('#usertablebody').empty();
reloaduserDB();
$('#finduser').off('input').on('input', function () {
let searchTerm = $(this).val().toLowerCase();
if (searchTerm.length > 0) {
let filteredUsers = window.userdb.filter(user =>
user.username.toLowerCase().includes(searchTerm) ||
user.airline_tags.toLowerCase().includes(searchTerm) ||
user.city_tags.toLowerCase().includes(searchTerm)
//user.messagebank_ann_id.toLowerCase().includes(searchTerm) ||
//user.broadcastzones.toLowerCase().includes(searchTerm)
);
fill_usertablebody(filteredUsers);
} else {
fill_usertablebody(window.userdb);
}
// $('#finduser').off('input').on('input', function () {
// let searchTerm = $(this).val().toLowerCase();
// if (searchTerm.length > 0) {
// let filteredUsers = window.userdb.filter(user =>
// user.username.toLowerCase().includes(searchTerm) ||
// user.airline_tags.toLowerCase().includes(searchTerm) ||
// user.city_tags.toLowerCase().includes(searchTerm)
// //user.messagebank_ann_id.toLowerCase().includes(searchTerm) ||
// //user.broadcastzones.toLowerCase().includes(searchTerm)
// );
// fill_usertablebody(filteredUsers);
// } else {
// fill_usertablebody(window.userdb);
// }
});
// });
/**
* Show modal dialog for soundbank, messagebank, broadcastzone selection
* @param {boolean} editmode if true, edit mode, else add mode
* @param {number} index index of user to edit, default 0
*/
function modalshow(editmode = false, index=0) {
function modalshow(editmode = false, index = 0) {
// event on click btnShowSoundbankModal
$('#btnShowSoundbankModal').off('click').on('click', function () {
$('#soundbankmodal').modal('show');
@@ -485,20 +506,15 @@ $(document).ready(function () {
$('#btnAdd').off('click').on('click', () => {
$('#addmodal').modal('show');
clearAddModal();
modalshow(false,0);
modalshow(false, 0);
});
$('#btnRemove').off('click').on('click', () => {
if (window.selecteduserrow) {
let cells = window.selecteduserrow.find('td');
/** @type {UserDB} */
let user = {
index: parseInt(cells.eq(0).text()),
username: cells.eq(1).text(),
password: cells.eq(2).text(),
airline_tags: cells.eq(3).text(),
city_tags: cells.eq(4).text(),
messagebank_ann_id: cells.eq(5).text(),
broadcastzones: cells.eq(6).text()
index: window.selecteduserrow.index,
username: window.selecteduserrow.username
}
if (confirm(`Are you sure to delete user [${user.index}] Username=${user.username} ?`)) {
fetchAPI(APIURL + "DeleteByIndex/" + user.index, "DELETE", {}, null, (okdata) => {
@@ -514,8 +530,7 @@ $(document).ready(function () {
});
$('#btnEdit').off('click').on('click', () => {
if (window.selecteduserrow) {
let cells = window.selecteduserrow.find('td');
let index = parseInt(cells.eq(0).text());
let index = window.selecteduserrow.index;
if (isNaN(index) || index <= 0) {
alert("Invalid user index");
return;