commit 02/10/2025

This commit is contained in:
2025-10-02 16:03:28 +07:00
parent 3768f4263b
commit 20dbc12b02
11 changed files with 410 additions and 273 deletions

View File

@@ -1,14 +1,4 @@
/**
* @typedef {Object} SoundChannel
* @property {number} index - The index of the sound channel.
* @property {string} channel - The name of the sound channel.
* @property {string} ip - The IP address associated with the sound channel.
*/
/**
* @type {SoundChannel[]}
*/
window.soundChannels = [];
// Currently selected sound channel row in the table
window.selectedSoundChannel = null;
@@ -51,22 +41,7 @@ function fill_soundchanneltablebody(vv) {
$tablesizeSoundChannel.text("Table Size: " + vv.length);
}
/**
* Reload sound channels from server
* @param {String} APIURL API URL endpoint (default "SoundChannel/")
*/
function reloadSoundChannel(APIURL = "SoundChannel/") {
window.soundChannels = [];
fetchAPI(APIURL + "List", "GET", {}, null, (okdata) => {
if (Array.isArray(okdata)) {
//console.log("reloadSoundChannel : ", okdata)
window.soundChannels.push(...okdata);
fill_soundchanneltablebody(window.soundChannels);
} else console.log("reloadSoundChannel: okdata is not array");
}, (errdata) => {
alert("Error loading sound channels : " + errdata.message);
});
}
$(document).ready(function () {
console.log("soundchannel.js loaded successfully");
@@ -108,11 +83,15 @@ $(document).ready(function () {
$soundchannelip.val('');
}
reloadSoundChannel(API_SoundChannel);
reloadSoundChannel(API_SoundChannel, () => {
fill_soundchanneltablebody(window.soundChannels);
});
$btnReinitializeSoundChannel.click(() => {
DoClear(API_SoundChannel, "SoundChannels", (okdata) => {
reloadSoundChannel(API_SoundChannel);
alert("Success clear sound channels: " + okdata.message);
reloadSoundChannel(API_SoundChannel, () => {
fill_soundchanneltablebody(window.soundChannels);
alert("Success clear sound channels: " + okdata.message);
});
}, (errdata) => {
alert("Error clear sound channels: " + errdata.message);
});
@@ -156,8 +135,10 @@ $(document).ready(function () {
fetchAPI(API_SoundChannel + "UpdateByIndex/" + newsc.index, "PATCH", {}, newsc, (okdata) => {
reloadSoundChannel(API_SoundChannel);
alert("Success edit sound channel: " + okdata.message);
reloadSoundChannel(API_SoundChannel, () => {
fill_soundchanneltablebody(window.soundChannels);
alert("Success edit sound channel: " + okdata.message);
});
}, (errdata) => {
alert("Error edit sound channel: " + errdata.message);
});
@@ -177,8 +158,10 @@ $(document).ready(function () {
$btnImportSoundChannel.click(() => {
DoImport(API_SoundChannel, (okdata) => {
reloadSoundChannel(API_SoundChannel);
alert("Success import sound channels: " + okdata.message);
reloadSoundChannel(API_SoundChannel, () => {
fill_soundchanneltablebody(window.soundChannels);
alert("Success import sound channels: " + okdata.message);
});
}, (errdata) => {
alert("Error importing sound channels from XLSX: " + errdata.message);
});