commit 26/01/2026
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user