commit 09/02/2026
This commit is contained in:
@@ -37,6 +37,11 @@ dtSoundbank = null;
|
||||
*/
|
||||
window.select2data = [];
|
||||
|
||||
$btnRemove = null;
|
||||
$btnEdit = null;
|
||||
$btnExport = null;
|
||||
$btnfilecheck = null;
|
||||
|
||||
/**
|
||||
* Reload sound bank from server
|
||||
* @param {String} APIURL API URL endpoint, default "SoundBank/"
|
||||
@@ -62,7 +67,18 @@ function reloadSoundBank(APIURL = "SoundBank/") {
|
||||
*/
|
||||
function fill_soundbanktablebody(vv) {
|
||||
dtSoundbank.clear();
|
||||
if (!Array.isArray(vv) || vv.length === 0) return;
|
||||
if (!Array.isArray(vv) || vv.length === 0) {
|
||||
// kalau kosong, tidak bisa remove, edit, export dan filecheck
|
||||
$btnRemove.prop('disabled', true);
|
||||
$btnEdit.prop('disabled', true);
|
||||
$btnExport.prop('disabled', true);
|
||||
$btnfilecheck.prop('disabled', true);
|
||||
return;
|
||||
} else {
|
||||
// kalau ada isi, bisa export dan filecheck, tapi remove dan edit tetap tergantung selection
|
||||
$btnExport.prop('disabled', false);
|
||||
$btnfilecheck.prop('disabled', false);
|
||||
}
|
||||
dtSoundbank.rows.add(vv);
|
||||
dtSoundbank.draw();
|
||||
|
||||
@@ -77,8 +93,8 @@ function fill_soundbanktablebody(vv) {
|
||||
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);
|
||||
$btnRemove.prop('disabled', true);
|
||||
$btnEdit.prop('disabled', true);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -87,8 +103,8 @@ function fill_soundbanktablebody(vv) {
|
||||
|
||||
$(this).addClass('row-selected').find('td').css('background-color', '#ffeeba');
|
||||
window.selectedsoundrow = selected.data();
|
||||
$('#btnRemove').prop('disabled', false);
|
||||
$('#btnEdit').prop('disabled', false);
|
||||
$btnRemove.prop('disabled', false);
|
||||
$btnEdit.prop('disabled', false);
|
||||
})
|
||||
|
||||
$('#tablesize').text("Table Size: " + vv.length);
|
||||
@@ -146,7 +162,7 @@ function getFilenameFromPath(path) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
fileViewMode = 'all'; // all, valid, invalid
|
||||
|
||||
$(document).ready(function () {
|
||||
console.log("soundbank.js loaded successfully");
|
||||
@@ -154,9 +170,9 @@ $(document).ready(function () {
|
||||
window.selectedsoundrow = null;
|
||||
let $btnClear = $('#btnClear');
|
||||
let $btnAdd = $('#btnAdd');
|
||||
let $btnRemove = $('#btnRemove');
|
||||
let $btnEdit = $('#btnEdit');
|
||||
let $btnExport = $('#btnExport');
|
||||
$btnRemove = $('#btnRemove');
|
||||
$btnEdit = $('#btnEdit');
|
||||
$btnExport = $('#btnExport');
|
||||
let $btnImport = $('#btnImport');
|
||||
$btnRemove.prop('disabled', true);
|
||||
$btnEdit.prop('disabled', true);
|
||||
@@ -171,9 +187,11 @@ $(document).ready(function () {
|
||||
let selected_category = null;
|
||||
let selected_language = null;
|
||||
let selected_voicetype = null;
|
||||
$btnfilecheck = $('#btnFileCheck');
|
||||
|
||||
if (dtSoundbank === null) {
|
||||
dtSoundbank = new DataTable('#soundbanktable', {
|
||||
dom: 'Bfrtip',
|
||||
data: [],
|
||||
pageLength: 25,
|
||||
columns: [
|
||||
@@ -184,9 +202,29 @@ $(document).ready(function () {
|
||||
{ title: "Language", data: "language" },
|
||||
{ title: "Type", data: "voiceType" },
|
||||
{ title: "Filename", data: "path" }
|
||||
]
|
||||
],
|
||||
rowCallback: function (row, data) {
|
||||
row.classList.toggle('table-danger', !!data.filemissing);
|
||||
},
|
||||
buttons: ['print', 'pdf', {
|
||||
extend: 'collection',
|
||||
text: 'View',
|
||||
className: 'btn btn-outline-secondary',
|
||||
buttons: [
|
||||
{ text: 'All Files', className: 'btn btn-outline-primary', action() { fileViewMode = 'all'; dtSoundbank.draw(); } },
|
||||
{ text: 'Valid Files', className: 'btn btn-outline-success', action() { fileViewMode = 'valid'; dtSoundbank.draw(); } },
|
||||
{ text: 'Invalid Files', className: 'btn btn-outline-danger', action() { fileViewMode = 'invalid'; dtSoundbank.draw(); } }
|
||||
]
|
||||
}]
|
||||
});
|
||||
}
|
||||
$.fn.dataTable.ext.search.push(function (settings, data, dataIndex, rowData) {
|
||||
if (settings.nTable.id !== 'soundbanktable') return true;
|
||||
const isInvalid = !!rowData.filemissing;
|
||||
if (fileViewMode === 'invalid') return isInvalid;
|
||||
if (fileViewMode === 'valid') return !isInvalid;
|
||||
return true;
|
||||
})
|
||||
|
||||
|
||||
/**
|
||||
@@ -219,17 +257,6 @@ $(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);
|
||||
// }
|
||||
// });
|
||||
$btnClear.click(() => {
|
||||
DoClear(APIURL, "Soundbank", (okdata) => {
|
||||
reloadSoundBank(APIURL);
|
||||
@@ -447,4 +474,37 @@ $(document).ready(function () {
|
||||
alert("Error importing soundbank from XLSX : " + errdata.message);
|
||||
});
|
||||
});
|
||||
$btnfilecheck.click(() => {
|
||||
fetchAPI(APIURL + "FileCheck", "GET", {}, null, (okdata) => {
|
||||
console.log(okdata);
|
||||
let invalidList = Array.isArray(okdata.invalidfile) ? okdata.invalidfile : [];
|
||||
let validList = Array.isArray(okdata.validfile) ? okdata.validfile : [];
|
||||
const invalidSet = new Set(invalidList.map(f => f.path));
|
||||
dtSoundbank.rows().every(function () {
|
||||
const d = this.data();
|
||||
d.filemissing = invalidSet.has(d.path);
|
||||
this.data(d); // update row data
|
||||
});
|
||||
|
||||
dtSoundbank.draw(false);
|
||||
console.log(`File Check completed. ${validList.length} valid files, ${invalidList.length} invalid files.`);
|
||||
if (validList.length === 0) {
|
||||
if (invalidList.length === 0) {
|
||||
alert("No soundbank files found on server.");
|
||||
} else {
|
||||
alert(`File Check completed. All ${invalidList.length} soundbank files are missing on server.`);
|
||||
|
||||
}
|
||||
} else {
|
||||
if (invalidList.length === 0) {
|
||||
alert(`File Check completed. All ${validList.length} soundbank files are present on server.`);
|
||||
} else {
|
||||
alert(`File Check completed. ${validList.length} soundbank files are present, ${invalidList.length} soundbank files are missing on server.`);
|
||||
}
|
||||
}
|
||||
|
||||
}, (errdata) => {
|
||||
alert("Error checking soundbank files : " + errdata.message);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user