commit 10/09/2025
This commit is contained in:
11
.idea/libraries/mysql_connector_j.xml
generated
Normal file
11
.idea/libraries/mysql_connector_j.xml
generated
Normal file
@@ -0,0 +1,11 @@
|
||||
<component name="libraryTable">
|
||||
<library name="mysql.connector.j" type="repository">
|
||||
<properties maven-id="com.mysql:mysql-connector-j:8.4.0" />
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/mysql/mysql-connector-j/8.4.0/mysql-connector-j-8.4.0.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/google/protobuf/protobuf-java/3.25.1/protobuf-java-3.25.1.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
||||
@@ -16,7 +16,6 @@
|
||||
<orderEntry type="library" name="tinylog.impl" level="project" />
|
||||
<orderEntry type="library" name="net.java.dev.jna" level="project" />
|
||||
<orderEntry type="library" name="io.javalin" level="project" />
|
||||
<orderEntry type="library" name="mariadb.jdbc.java.client" level="project" />
|
||||
<orderEntry type="library" name="kotlinx-coroutines-core" level="project" />
|
||||
<orderEntry type="library" name="slf4j.simple" level="project" />
|
||||
<orderEntry type="library" name="fasterxml.jackson.module.kotlin" level="project" />
|
||||
@@ -35,5 +34,6 @@
|
||||
<jarDirectory url="file://C:/SLC/Apache POI" recursive="false" type="SOURCES" />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="library" name="mysql.connector.j" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -212,7 +212,7 @@ function fill_messagebanktablebody(vv) {
|
||||
});
|
||||
});
|
||||
|
||||
console.log("loaded " + vv.length + " messagebank items");
|
||||
$('#tablesize').text("Table Size: " + vv.length);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -246,7 +246,7 @@ function fill_languagebanktablebody(vv) {
|
||||
$('#btnEdit').prop('disabled', false);
|
||||
});
|
||||
});
|
||||
console.log("loaded " + vv.length + " languagebank items");
|
||||
$('#tablesize').text("Table Size: " + vv.length);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -286,7 +286,7 @@ function fill_schedulebanktablebody(vv) {
|
||||
$('#btnEdit').prop('disabled', false);
|
||||
});
|
||||
});
|
||||
console.log("loaded " + vv.length + " schedulebank items");
|
||||
$('#tablesize').text("Table Size: " + vv.length);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -306,7 +306,7 @@ function fill_logtablebody(vv) {
|
||||
</tr>`;
|
||||
$('#logtablebody').append(row);
|
||||
});
|
||||
console.log("loaded " + vv.length + " log items");
|
||||
$('#tablesize').text("Table Size: " + vv.length);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -349,21 +349,21 @@ function fetchAPI(endpoint, method, headers = {}, body = null, cbOK, cbError) {
|
||||
options.headers['Content-Type'] = 'application/json';
|
||||
}
|
||||
}
|
||||
console.log("About to fetch from " + url + " with options", options);
|
||||
//console.log("About to fetch from " + url + " with options", options);
|
||||
fetch(url, options)
|
||||
.then(response => {
|
||||
console.log("fetchAPI: received response", response);
|
||||
//console.log("fetchAPI: received response", response);
|
||||
if (!response.ok) {
|
||||
throw new Error('Network response was not ok ' + response.statusText);
|
||||
}
|
||||
return response.json();
|
||||
})
|
||||
.then(data => {
|
||||
console.log("fetchAPI: received data", data);
|
||||
//console.log("fetchAPI: received data", data);
|
||||
cbOK(data);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('There was a problem with the fetch operation:', error);
|
||||
// console.error('There was a problem with the fetch operation:', error);
|
||||
cbError(error);
|
||||
});
|
||||
}
|
||||
@@ -374,9 +374,7 @@ function fetchAPI(endpoint, method, headers = {}, body = null, cbOK, cbError) {
|
||||
*/
|
||||
function reloadSoundBank(APIURL) {
|
||||
soundbankdata = [];
|
||||
console.log("reloadSoundBank: fetching from " + APIURL + "List");
|
||||
fetchAPI(APIURL + "List", "GET", {}, null, (okdata) => {
|
||||
console.log("reloadSoundBank: received data", okdata);
|
||||
if (Array.isArray(okdata)) {
|
||||
soundbankdata = okdata;
|
||||
selectedsoundrow = null;
|
||||
@@ -441,12 +439,17 @@ function reloadTimerBank(APIURL) {
|
||||
/**
|
||||
* Reload logs from server with date and filter
|
||||
* @param {String} APIURL API URL endpoint
|
||||
* @param {String} date date in format dd/MM/yyyy
|
||||
* @param {String} date date in format dd-mm-yyyy
|
||||
* @param {String} filter log filter text
|
||||
*/
|
||||
function reloadLogs(APIURL, date, filter) {
|
||||
fetchAPI(APIURL + "List/" + date + "/" + filter, "GET", {}, null, (okdata) => {
|
||||
$('#logcontent').val(okdata.data);
|
||||
const params = new URLSearchParams({
|
||||
date: date,
|
||||
filter: filter
|
||||
})
|
||||
fetchAPI(APIURL + "List?" + params.toString(), "GET", {}, null, (okdata) => {
|
||||
//console.log("Logs data received", okdata);
|
||||
fill_logtablebody(okdata);
|
||||
}, (errdata) => {
|
||||
alert("Error loading logs: " + errdata.message);
|
||||
});
|
||||
@@ -536,6 +539,24 @@ function getScheduledDays() {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear database mechanism
|
||||
* @param {String} APIURL API URL endpoint
|
||||
* @param {String} whattoclear what to clear
|
||||
* @param {Function} cbOK callback function on success
|
||||
* @param {Function} cbError callback function on error
|
||||
*/
|
||||
function DoClear(APIURL, whattoclear, cbOK, cbError) {
|
||||
if (confirm(`Are you sure want to clear ${whattoclear} ? This procedure is not reversible`)) {
|
||||
fetchAPI(APIURL + "List", "DELETE", {}, null, (okdata) => {
|
||||
cbOK(okdata);
|
||||
}, (errdata) => {
|
||||
cbError(errdata);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Export mechanism to XLSX file
|
||||
* @param {String} APIURL API URL endpoint
|
||||
@@ -550,27 +571,25 @@ function DoExport(APIURL, filename) {
|
||||
method: "GET",
|
||||
headers: {}
|
||||
})
|
||||
.then(response => {
|
||||
if (!response.ok) throw new Error('Network response was not ok ' + response.statusText);
|
||||
return response.blob();
|
||||
})
|
||||
.then(blob => {
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = filename;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
a.remove();
|
||||
window.URL.revokeObjectURL(url);
|
||||
})
|
||||
.catch(error => {
|
||||
alert("Error export to " + filename + ": " + error.message);
|
||||
});
|
||||
.then(response => {
|
||||
if (!response.ok) throw new Error('Network response was not ok ' + response.statusText);
|
||||
return response.blob();
|
||||
})
|
||||
.then(blob => {
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = filename;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
a.remove();
|
||||
window.URL.revokeObjectURL(url);
|
||||
})
|
||||
.catch(error => {
|
||||
alert("Error export to " + filename + ": " + error.message);
|
||||
});
|
||||
return; // prevent the rest of the function from running
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -704,17 +723,26 @@ $(document).ready(function () {
|
||||
|
||||
|
||||
reloadSoundBank(APIURL);
|
||||
$('#findsoundbank').on('input', function () {
|
||||
let searchTerm = $(this).val().trim().toLowerCase();
|
||||
if (searchTerm.length>0){
|
||||
let filtered = soundbankdata.filter(item => item.description.toLowerCase().includes(searchTerm) || item.tag.toLowerCase().includes(searchTerm) || item.path.toLowerCase().includes(searchTerm));
|
||||
fill_soundbanktablebody(filtered);
|
||||
} else {
|
||||
selectedsoundrow = null;
|
||||
fill_soundbanktablebody(soundbankdata);
|
||||
}
|
||||
});
|
||||
$btnClear.click(() => {
|
||||
if (confirm(`Are you sure want to clear Soundbank ? This procedure is not reversible`)) {
|
||||
fetchAPI(APIURL + "List", "DELETE", {}, null, (okdata) => {
|
||||
alert("Success clear soundbank" + okdata.message);
|
||||
DoClear(APIURL, "Soundbank", (okdata) => {
|
||||
alert("Success clear soundbank" + okdata.message);
|
||||
soundbankdata = []
|
||||
selectedsoundrow = null;
|
||||
fill_soundbanktablebody(soundbankdata);
|
||||
}, (errdata) => {
|
||||
alert("Error clear soundbank: " + errdata.message);
|
||||
});
|
||||
}
|
||||
}, (errdata) => {
|
||||
alert("Error clear soundbank: " + errdata.message);
|
||||
});
|
||||
|
||||
});
|
||||
$btnAdd.click(() => {
|
||||
$('.js-example-basic-single').select2({
|
||||
@@ -817,16 +845,15 @@ $(document).ready(function () {
|
||||
|
||||
reloadMessageBank(APIURL);
|
||||
$btnClear.click(() => {
|
||||
if (confirm(`Are you sure want to clear Messagebank ? This procedure is not reversible`)) {
|
||||
fetchAPI(APIURL + "List", "DELETE", {}, null, (okdata) => {
|
||||
alert("Success clear messagebank" + okdata.message);
|
||||
messagebankdata = []
|
||||
selectedmessagerow = null;
|
||||
fill_messagebanktablebody(messagebankdata);
|
||||
}, (errdata) => {
|
||||
alert("Error clear messagebank: " + errdata.message);
|
||||
});
|
||||
}
|
||||
DoClear(APIURL, "Messagebank", (okdata) => {
|
||||
alert("Success clear messagebank" + okdata.message);
|
||||
messagebankdata = []
|
||||
selectedmessagerow = null;
|
||||
fill_messagebanktablebody(messagebankdata);
|
||||
}, (errdata) => {
|
||||
alert("Error clear messagebank: " + errdata.message);
|
||||
});
|
||||
|
||||
});
|
||||
$btnAdd.click(() => {
|
||||
let $modal = $('#messagebankmodal');
|
||||
@@ -921,22 +948,21 @@ $(document).ready(function () {
|
||||
let $btnImport = $('#btnImport');
|
||||
$btnRemove.prop('disabled', true);
|
||||
$btnEdit.prop('disabled', true);
|
||||
let APIURL = "LanguageBank/";
|
||||
let APIURL = "LanguageLink/";
|
||||
|
||||
|
||||
|
||||
reloadLanguageBank(APIURL);
|
||||
$btnClear.click(() => {
|
||||
if (confirm(`Are you sure want to clear Languagebank ? This procedure is not reversible`)) {
|
||||
fetchAPI(APIURL + "List", "DELETE", {}, null, (okdata) => {
|
||||
alert("Success clear languagebank" + okdata.message);
|
||||
languagebankdata = []
|
||||
selectedlanguagerow = null;
|
||||
fill_languagebanktablebody(languagebankdata);
|
||||
}, (errdata) => {
|
||||
alert("Error clear languagebank: " + errdata.message);
|
||||
});
|
||||
}
|
||||
DoClear(APIURL, "LanguageLink", (okdata) => {
|
||||
alert("Success clear languageLink" + okdata.message);
|
||||
languagebankdata = []
|
||||
selectedlanguagerow = null;
|
||||
fill_languagebanktablebody(languagebankdata);
|
||||
}, (errdata) => {
|
||||
alert("Error clear languagebank: " + errdata.message);
|
||||
});
|
||||
|
||||
});
|
||||
$btnAdd.click(() => {
|
||||
// show modal with id 'languagemodal'
|
||||
@@ -1107,16 +1133,15 @@ $(document).ready(function () {
|
||||
|
||||
reloadTimerBank(APIURL);
|
||||
$btnClear.click(() => {
|
||||
if (confirm(`Are you sure want to clear Timerbank ? This procedure is not reversible`)) {
|
||||
fetchAPI(APIURL + "List", "DELETE", {}, null, (okdata) => {
|
||||
alert("Success clear schedulebank" + okdata.message);
|
||||
schedulebankdata = []
|
||||
selectedschedulerow = null;
|
||||
fill_schedulebanktablebody(schedulebankdata);
|
||||
}, (errdata) => {
|
||||
alert("Error clear schedulebank: " + errdata.message);
|
||||
});
|
||||
}
|
||||
DoClear(APIURL, "Timerbank", (okdata) => {
|
||||
alert("Success clear schedulebank" + okdata.message);
|
||||
schedulebankdata = []
|
||||
selectedschedulerow = null;
|
||||
fill_schedulebanktablebody(schedulebankdata);
|
||||
}, (errdata) => {
|
||||
alert("Error clear schedulebank: " + errdata.message);
|
||||
});
|
||||
|
||||
});
|
||||
$btnAdd.click(() => {
|
||||
//TODO form add timer
|
||||
@@ -1190,9 +1215,11 @@ $(document).ready(function () {
|
||||
console.log("Log content loaded successfully");
|
||||
const $logdate = $('#logdate');
|
||||
const $searchfilter = $('#searchfilter');
|
||||
const $logtable = $('#logtablebody')
|
||||
let selectedlogdate = "";
|
||||
let logfilter = "";
|
||||
let APIURL = "/api/Logs/";
|
||||
let APIURL = "Log/";
|
||||
$logtable.empty();
|
||||
|
||||
|
||||
if (!$logdate.val()) {
|
||||
@@ -1201,13 +1228,14 @@ $(document).ready(function () {
|
||||
const mm = String(today.getMonth() + 1).padStart(2, '0');
|
||||
const yyyy = today.getFullYear();
|
||||
$logdate.val(`${yyyy}-${mm}-${dd}`);
|
||||
selectedlogdate = `${dd}/${mm}/${yyyy}`;
|
||||
selectedlogdate = `${dd}-${mm}-${yyyy}`;
|
||||
reloadLogs(APIURL, selectedlogdate, logfilter);
|
||||
}
|
||||
$logdate.off('change').on('change', function () {
|
||||
const selected = $(this).val();
|
||||
if (selected) {
|
||||
const [year, month, day] = selected.split('-');
|
||||
selectedlogdate = `${day}/${month}/${year}`;
|
||||
selectedlogdate = `${day}-${month}-${year}`;
|
||||
reloadLogs(APIURL, selectedlogdate, logfilter);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -24,40 +24,22 @@
|
||||
<div class="col-6 col-sm-6 col-md-6 col-lg-2 col-xl-2"><button class="btn w-100 pad-button btn-round-basic color-import" id="btnExport" type="button">Export</button></div>
|
||||
<div class="col-6 col-sm-6 col-md-6 col-lg-2 col-xl-2"><button class="btn w-100 pad-button btn-round-basic color-import" id="btnImport" type="button">Import</button></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<p id="tablesize" class="text-add" style="text-align: center;">Table Length : N/A</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="table-responsive">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="col-sm-1">No</th>
|
||||
<th>Description</th>
|
||||
<th class="col-sm-1">TAG</th>
|
||||
<th class="col-sm-1">Category</th>
|
||||
<th class="col-sm-1">Language</th>
|
||||
<th class="col-sm-1">Type</th>
|
||||
<th class="col-sm-3">Filename</th>
|
||||
<th class="col-sm-2">TAG</th>
|
||||
<th class="col">Languages</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="languagebanktablebody">
|
||||
<tr>
|
||||
<td>Cell 1</td>
|
||||
<td>Cell 2</td>
|
||||
<td>Cell 3</td>
|
||||
<td>Cell 3</td>
|
||||
<td>Cell 5</td>
|
||||
<td>Cell 6</td>
|
||||
<td>Cell 7</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Cell 3</td>
|
||||
<td>Cell 4</td>
|
||||
<td>Cell 3</td>
|
||||
<td>Cell 3</td>
|
||||
<td>Cell 5</td>
|
||||
<td>Cell 6</td>
|
||||
<td>Cell 7</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tbody id="languagebanktablebody"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -27,6 +27,11 @@
|
||||
</div>
|
||||
<div class="col-6 col-sm col-md-2 col-lg-2 col-xl-2"><input type="text" id="searchfilter" class="form-control" placeholder="Search Filter"></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<p id="tablesize" class="text-add" style="text-align: center;">Table Length : N/A</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="table-responsive">
|
||||
<table class="table">
|
||||
@@ -35,23 +40,11 @@
|
||||
<th class="col-1 col-md-1">No</th>
|
||||
<th class="col-2 col-md-2 col-lg-2">Date</th>
|
||||
<th class="col-2 col-md-2 col-lg-2">Time</th>
|
||||
<th class="col-2 col-md-2 col-lg-2">Machine</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="logtablebody">
|
||||
<tr>
|
||||
<td>Cell 1</td>
|
||||
<td>Cell 2</td>
|
||||
<td>Cell 3</td>
|
||||
<td>Cell 4</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Cell 3</td>
|
||||
<td>Cell 4</td>
|
||||
<td>Cell 3</td>
|
||||
<td>Cell 4</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tbody id="logtablebody"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -24,6 +24,11 @@
|
||||
<div class="col-6 col-sm-6 col-md-6 col-lg-2 col-xl-2"><button class="btn w-100 pad-button btn-round-basic color-import" id="btnExport" type="button">Export</button></div>
|
||||
<div class="col-6 col-sm-6 col-md-6 col-lg-2 col-xl-2"><button class="btn w-100 pad-button btn-round-basic color-import" id="btnImport" type="button">Import</button></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<p id="tablesize" class="text-add" style="text-align: center;">Table Length : N/A</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="table-responsive">
|
||||
<table class="table">
|
||||
@@ -38,26 +43,7 @@
|
||||
<th class="col-sm-3">Message Tags</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="messagebanktablebody">
|
||||
<tr>
|
||||
<td>Cell 1</td>
|
||||
<td>Cell 2</td>
|
||||
<td>Cell 3</td>
|
||||
<td>Cell 3</td>
|
||||
<td>Cell 5</td>
|
||||
<td>Cell 6</td>
|
||||
<td>Cell 7</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Cell 3</td>
|
||||
<td>Cell 4</td>
|
||||
<td>Cell 3</td>
|
||||
<td>Cell 3</td>
|
||||
<td>Cell 5</td>
|
||||
<td>Cell 6</td>
|
||||
<td>Cell 7</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tbody id="messagebanktablebody"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -50,26 +50,7 @@
|
||||
<th class="col-sm-3">Filename</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="soundbanktablebody">
|
||||
<tr>
|
||||
<td>Cell 1</td>
|
||||
<td>Cell 2</td>
|
||||
<td>Cell 3</td>
|
||||
<td>Cell 3</td>
|
||||
<td>Cell 5</td>
|
||||
<td>Cell 6</td>
|
||||
<td>Cell 7</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Cell 3</td>
|
||||
<td>Cell 4</td>
|
||||
<td>Cell 3</td>
|
||||
<td>Cell 3</td>
|
||||
<td>Cell 5</td>
|
||||
<td>Cell 6</td>
|
||||
<td>Cell 7</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tbody id="soundbanktablebody"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<body>
|
||||
<div class="row">
|
||||
<div class="col w-100 h-100 pad-header">
|
||||
<h2 style="text-align: center;">Timer</h2>
|
||||
<h2 style="text-align: center;">Schedule Bank</h2>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
@@ -24,40 +24,27 @@
|
||||
<div class="col-6 col-sm-6 col-md-6 col-lg-2 col-xl-2"><button class="btn w-100 pad-button btn-round-basic color-import" id="btnExport" type="button">Export</button></div>
|
||||
<div class="col-6 col-sm-6 col-md-6 col-lg-2 col-xl-2"><button class="btn w-100 pad-button btn-round-basic color-import" id="btnImport" type="button">Import</button></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<p id="tablesize" class="text-add" style="text-align: center;">Table Length : N/A</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="table-responsive">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="col-sm-1">No</th>
|
||||
<th>Description</th>
|
||||
<th class="col-sm-1">TAG</th>
|
||||
<th class="col-sm-1">Category</th>
|
||||
<th class="col-sm-1">Language</th>
|
||||
<th class="col-sm-1">Type</th>
|
||||
<th class="col-sm-3">Filename</th>
|
||||
<th class="col-sm-2">Description</th>
|
||||
<th class="col-sm-1">Day</th>
|
||||
<th class="col-sm-1">Time</th>
|
||||
<th class="col-sm-2">Sound Path</th>
|
||||
<th class="col-sm-1">Repeat</th>
|
||||
<th class="col-sm-1">Enable</th>
|
||||
<th>Broadcast Zones</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="schedulebanktablebody">
|
||||
<tr>
|
||||
<td>Cell 1</td>
|
||||
<td>Cell 2</td>
|
||||
<td>Cell 3</td>
|
||||
<td>Cell 3</td>
|
||||
<td>Cell 5</td>
|
||||
<td>Cell 6</td>
|
||||
<td>Cell 7</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Cell 3</td>
|
||||
<td>Cell 4</td>
|
||||
<td>Cell 3</td>
|
||||
<td>Cell 3</td>
|
||||
<td>Cell 5</td>
|
||||
<td>Cell 6</td>
|
||||
<td>Cell 7</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tbody id="schedulebanktablebody"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -32,14 +32,14 @@ fun main() {
|
||||
CoroutineScope(Dispatchers.Default).launch {
|
||||
while (isActive) {
|
||||
delay(1000)
|
||||
val broadcastzones = db.GetBroadcastZones()
|
||||
|
||||
// baca dulu queue paging, prioritas 1
|
||||
db.Read_Queue_Paging().forEach {
|
||||
// cek apakah queue paging ada broadcast zone nya
|
||||
if (it.BroadcastZones.isNotBlank()) {
|
||||
val zz = it.BroadcastZones.split(";")
|
||||
// cek apakah semua target broadcast zone dari queue paging ada di dalam database broadcast zones
|
||||
if (zz.all { z -> broadcastzones.any { bz -> bz.equals(z) } }) {
|
||||
if (zz.all { z -> db.BroadcastZoneList.any { bz -> bz.equals(z) } }) {
|
||||
// semua target broadcast zone valid, sekarang cek apakah semua target broadcast zone idle
|
||||
|
||||
} else {
|
||||
@@ -59,7 +59,7 @@ fun main() {
|
||||
if (it.BroadcastZones.isNotBlank()) {
|
||||
val zz = it.BroadcastZones.split(";")
|
||||
// cek apakah semua target broadcast zone dari queue table ada di dalam database broadcast zones
|
||||
if (zz.all { z -> broadcastzones.any { bz -> bz.equals(z) } }) {
|
||||
if (zz.all { z -> db.BroadcastZoneList.any { bz -> bz.equals(z) } }) {
|
||||
// semua target broadcast zone valid, sekarang cek apakah semua target broadcast zone idle
|
||||
|
||||
} else {
|
||||
|
||||
@@ -24,6 +24,7 @@ class Somecodes {
|
||||
val memory : GlobalMemory = si.hardware.memory
|
||||
val datetimeformat1: DateTimeFormatter = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm:ss")
|
||||
val dateformat1: DateTimeFormatter = DateTimeFormatter.ofPattern("dd/MM/yyyy")
|
||||
val dateformat2: DateTimeFormatter = DateTimeFormatter.ofPattern("dd-MM-yyyy")
|
||||
val timeformat1: DateTimeFormatter = DateTimeFormatter.ofPattern("hh:mm:ss")
|
||||
val timeformat2: DateTimeFormatter = DateTimeFormatter.ofPattern("hh:mm")
|
||||
const val KB_threshold = 1024.0
|
||||
@@ -180,6 +181,24 @@ class Somecodes {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a string is a valid date in the format "dd-MM-yyyy".
|
||||
* This format is used for log HTML files.
|
||||
* @param value The string to check.
|
||||
* @return True if the string is a valid date, false otherwise.
|
||||
*/
|
||||
fun ValiDateForLogHtml(value: String): Boolean{
|
||||
return try{
|
||||
if (ValidString(value)){
|
||||
dateformat2.parse(value)
|
||||
true
|
||||
} else throw Exception()
|
||||
|
||||
} catch (_: Exception){
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a string is a valid time in the format "hh:mm:ss".
|
||||
* @param value The string to check.
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package database
|
||||
|
||||
import codes.Somecodes.Companion.ValiDateForLogHtml
|
||||
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook
|
||||
import org.mariadb.jdbc.Connection
|
||||
import org.tinylog.Logger
|
||||
import java.sql.Connection
|
||||
import java.sql.DriverManager
|
||||
import java.util.function.Consumer
|
||||
|
||||
@@ -33,6 +34,7 @@ class MariaDB(
|
||||
var MessagebankList: ArrayList<Messagebank> = ArrayList()
|
||||
var LanguageLinkList: ArrayList<LanguageLink> = ArrayList()
|
||||
var SchedulebankList: ArrayList<ScheduleBank> = ArrayList()
|
||||
var BroadcastZoneList: ArrayList<BroadcastZones> = ArrayList()
|
||||
|
||||
companion object {
|
||||
fun ValidDate(date: String): Boolean {
|
||||
@@ -56,7 +58,7 @@ class MariaDB(
|
||||
*/
|
||||
fun <T> ArrayListtoString(list: ArrayList<T>): String {
|
||||
return try {
|
||||
objectMapper.writeValueAsString(list.toArray())
|
||||
objectMapper.writeValueAsString(list)
|
||||
} catch (e: Exception) {
|
||||
Logger.error("Error converting list to JSON: ${e.message}" as Any)
|
||||
"[]"
|
||||
@@ -68,7 +70,7 @@ class MariaDB(
|
||||
init {
|
||||
try {
|
||||
connection =
|
||||
DriverManager.getConnection("jdbc:mariadb://$address:$port/$dbName", username, password) as Connection
|
||||
DriverManager.getConnection("jdbc:mysql://$address:$port/$dbName?sslMode=REQUIRED", username, password) as Connection
|
||||
Logger.info("Connected to MariaDB" as Any)
|
||||
connected = true
|
||||
|
||||
@@ -78,6 +80,7 @@ class MariaDB(
|
||||
Reload_Soundbank()
|
||||
Reload_LanguageLink()
|
||||
Reload_Schedulebank()
|
||||
GetBroadcastZones()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,6 +91,7 @@ class MariaDB(
|
||||
Logger.info { "Messagebank count: ${MessagebankList.size}" }
|
||||
Logger.info { "LanguageLink count: ${LanguageLinkList.size}" }
|
||||
Logger.info { "Schedulebank count: ${SchedulebankList.size}" }
|
||||
Logger.info { "BroadcastZones count: ${BroadcastZoneList.size}" }
|
||||
|
||||
|
||||
} catch (e: Exception) {
|
||||
@@ -195,7 +199,7 @@ class MariaDB(
|
||||
val logList = ArrayList<Log>()
|
||||
try {
|
||||
val statement = connection?.createStatement()
|
||||
val resultSet = statement?.executeQuery("SELECT * FROM log")
|
||||
val resultSet = statement?.executeQuery("SELECT * FROM logs")
|
||||
while (resultSet?.next() == true) {
|
||||
val log = Log(
|
||||
resultSet.getLong("index").toULong(),
|
||||
@@ -213,16 +217,18 @@ class MariaDB(
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Log from database by date
|
||||
* @param date The date to filter logs by (format: DD/MM/YYYY)
|
||||
* Get Log from database by date for HTML usage
|
||||
* @param date The date to filter logs by (format: DD-MM-YYYY)
|
||||
* @param consumer A Consumer that will receive the list of logs for the specified date
|
||||
*/
|
||||
fun GetLog(date: String, consumer: Consumer<ArrayList<Log>>) {
|
||||
fun GetLogForHtml(date: String, consumer: Consumer<ArrayList<Log>>) {
|
||||
val logList = ArrayList<Log>()
|
||||
if (ValidDate(date)) {
|
||||
if (ValiDateForLogHtml(date)) {
|
||||
try {
|
||||
val statement = connection?.prepareStatement("SELECT * FROM log WHERE datenya = ?")
|
||||
statement?.setString(1, date)
|
||||
// must convert from DD-MM-YYYY to DD/MM/YYYY, because in database we use DD/MM/YYYY
|
||||
val adjusteddate = date.replace("-", "/")
|
||||
val statement = connection?.prepareStatement("SELECT * FROM logs WHERE datenya = ?")
|
||||
statement?.setString(1, adjusteddate)
|
||||
val resultSet = statement?.executeQuery()
|
||||
while (resultSet?.next() == true) {
|
||||
val log = Log(
|
||||
@@ -242,13 +248,21 @@ class MariaDB(
|
||||
consumer.accept(logList)
|
||||
}
|
||||
|
||||
fun GetLog(date: String, filter: String, consumer: Consumer<ArrayList<Log>>) {
|
||||
/**
|
||||
* Get Log from database by date and filter for HTML usage
|
||||
* @param date The date to filter logs by (format: DD-MM-YYYY)
|
||||
* @param filter The filter string to search in description or machine
|
||||
* @param consumer A Consumer that will receive the list of logs for the specified date and filter
|
||||
*/
|
||||
fun GetLogForHtml(date: String, filter: String, consumer: Consumer<ArrayList<Log>>) {
|
||||
val logList = ArrayList<Log>()
|
||||
if (ValidDate(date)) {
|
||||
if (ValiDateForLogHtml(date)) {
|
||||
try {
|
||||
// must convert from DD-MM-YYYY to DD/MM/YYYY, because in database we use DD/MM/YYYY
|
||||
val adjusteddate = date.replace("-", "/")
|
||||
val statement =
|
||||
connection?.prepareStatement("SELECT * FROM log WHERE datenya = ? AND description LIKE ?")
|
||||
statement?.setString(1, date)
|
||||
connection?.prepareStatement("SELECT * FROM logs WHERE datenya = ? AND description LIKE ?")
|
||||
statement?.setString(1, adjusteddate)
|
||||
statement?.setString(2, "%$filter%")
|
||||
val resultSet = statement?.executeQuery()
|
||||
while (resultSet?.next() == true) {
|
||||
@@ -559,7 +573,7 @@ class MariaDB(
|
||||
LanguageLinkList.clear()
|
||||
try {
|
||||
val statement = connection?.createStatement()
|
||||
val resultSet = statement?.executeQuery("SELECT * FROM languagelink")
|
||||
val resultSet = statement?.executeQuery("SELECT * FROM languagelinking")
|
||||
while (resultSet?.next() == true) {
|
||||
val languageLink = LanguageLink(
|
||||
resultSet.getLong("index").toUInt(),
|
||||
@@ -1378,11 +1392,11 @@ class MariaDB(
|
||||
* Get All Broadcast Zones from database
|
||||
* @return A list of BroadcastZones entries.
|
||||
*/
|
||||
fun GetBroadcastZones(): List<BroadcastZones> {
|
||||
val zonesList = ArrayList<BroadcastZones>()
|
||||
fun GetBroadcastZones(){
|
||||
BroadcastZoneList.clear()
|
||||
try {
|
||||
val statement = connection?.createStatement()
|
||||
val resultSet = statement?.executeQuery("SELECT * FROM broadcast_zones")
|
||||
val resultSet = statement?.executeQuery("SELECT * FROM broadcastzones")
|
||||
while (resultSet?.next() == true) {
|
||||
val zone = BroadcastZones(
|
||||
resultSet.getLong("index").toUInt(),
|
||||
@@ -1391,12 +1405,11 @@ class MariaDB(
|
||||
resultSet.getString("Box"),
|
||||
resultSet.getString("Relay")
|
||||
)
|
||||
zonesList.add(zone)
|
||||
BroadcastZoneList.add(zone)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Logger.error("Error fetching broadcast zones: ${e.message}" as Any)
|
||||
}
|
||||
return zonesList
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,6 +2,7 @@ package web
|
||||
|
||||
import codes.Somecodes
|
||||
import codes.Somecodes.Companion.ListAudioFiles
|
||||
import codes.Somecodes.Companion.ValiDateForLogHtml
|
||||
import codes.Somecodes.Companion.ValidDate
|
||||
import codes.Somecodes.Companion.ValidFile
|
||||
import codes.Somecodes.Companion.ValidScheduleDay
|
||||
@@ -123,11 +124,11 @@ class WebApp(val listenPort: Int, val userlist: List<Pair<String, String>>, val
|
||||
}
|
||||
|
||||
"getPagingQueue" ->{
|
||||
SendReply(wsMessageContext, cmd.command, MariaDB.ArrayListtoString(db.Read_Queue_Paging()))
|
||||
SendReply(wsMessageContext, cmd.command, objectmapper.writeValueAsString(db.Read_Queue_Paging()))
|
||||
}
|
||||
|
||||
"getAASQueue" ->{
|
||||
SendReply(wsMessageContext, cmd.command, MariaDB.ArrayListtoString(db.Read_Queue_Table()))
|
||||
SendReply(wsMessageContext, cmd.command, objectmapper.writeValueAsString(db.Read_Queue_Table()))
|
||||
}
|
||||
|
||||
else -> {
|
||||
@@ -187,7 +188,6 @@ class WebApp(val listenPort: Int, val userlist: List<Pair<String, String>>, val
|
||||
}
|
||||
path("SoundBank") {
|
||||
get("List") {
|
||||
// get soundbank list
|
||||
it.result(MariaDB.ArrayListtoString(db.SoundbankList))
|
||||
}
|
||||
get("ListFiles"){
|
||||
@@ -719,21 +719,24 @@ class WebApp(val listenPort: Int, val userlist: List<Pair<String, String>>, val
|
||||
}
|
||||
}
|
||||
path("Log") {
|
||||
get("List/<logdate>/<logfilter>") { get1 ->
|
||||
val logdate = get1.pathParam("logdate")
|
||||
val logfilter = get1.pathParam("logfilter")
|
||||
if (ValidDate(logdate)) {
|
||||
get("List") { get1 ->
|
||||
val logdate = get1.queryParam("date") ?: ""
|
||||
val logfilter = get1.queryParam("filter") ?: ""
|
||||
if (ValiDateForLogHtml(logdate)) {
|
||||
if (ValidString(logfilter)) {
|
||||
// ada log filter
|
||||
db.GetLog(logdate, logfilter) {
|
||||
db.GetLogForHtml(logdate, logfilter) {
|
||||
get1.result(MariaDB.ArrayListtoString(it))
|
||||
}
|
||||
} else {
|
||||
db.GetLog(logdate) {
|
||||
db.GetLogForHtml(logdate) {
|
||||
get1.result(MariaDB.ArrayListtoString(it))
|
||||
}
|
||||
}
|
||||
} else get1.status(400).result("Invalid logdate")
|
||||
} else {
|
||||
println("Invalid logdate=$logdate")
|
||||
get1.status(400).result("Invalid logdate")
|
||||
}
|
||||
}
|
||||
get("ExportXLSX/<logdate>/<logfilter>") { get1 ->
|
||||
val logdate = get1.pathParam("logdate")
|
||||
|
||||
Reference in New Issue
Block a user