Merge branch 'master' of https://gitea.rdkartono.my.id/rdkartono/AAS_NewGeneration into feature-webapp
This commit is contained in:
@@ -50,9 +50,12 @@ function getCardByIndex(index) {
|
||||
*/
|
||||
function UpdateStreamerCard(values) {
|
||||
if (!Array.isArray(values) || values.length === 0) return;
|
||||
function setProgress($bar, value, max = 100) {
|
||||
|
||||
function setProgress(index, $bar, value, max = 100) {
|
||||
const v = Number(value ?? 0);
|
||||
const pct = Math.max(0, Math.min(100, Math.round((v / max) * 100)));
|
||||
//if (index!==1) return; // only update index 1 for testing
|
||||
//console.log(`setProgress: index=${index}, value=${v}, pct=${pct}`);
|
||||
$bar
|
||||
.attr('aria-valuenow', v) // semantic value
|
||||
.css('width', pct + '%') // visual width
|
||||
@@ -68,7 +71,7 @@ function UpdateStreamerCard(values) {
|
||||
if (card.buffer) card.buffer.text(`Buffer: ${vv.bufferRemain !== undefined && vv.bufferRemain !== null ? vv.bufferRemain.toString() : 'N/A'}`);
|
||||
if (card.status) card.status.text(`Status: ${vv.isPlaying ? 'Playing' : 'Stopped'}`);
|
||||
if (card.vu) {
|
||||
setProgress(card.vu, vv.vu, 100);
|
||||
setProgress(i, card.vu, vv.vu, 100);
|
||||
}
|
||||
} else {
|
||||
// no value for this index, disable the card
|
||||
@@ -77,7 +80,7 @@ function UpdateStreamerCard(values) {
|
||||
if (card.buffer) card.buffer.text(`Buffer: N/A`);
|
||||
if (card.status) card.status.text(`Status: Disconnected`);
|
||||
if (card.vu) {
|
||||
setProgress(card.vu, 0, 100);
|
||||
setProgress(i, card.vu, 0, 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -124,10 +127,13 @@ function fill_pagingqueuetablebody(vv) {
|
||||
if (!Array.isArray(vv) || vv.length === 0) return;
|
||||
vv.forEach(item => {
|
||||
// fill index and description columns using item properties
|
||||
let description = `${item.Date_Time}_${item.Source}_${item.Type}_${item.Message}_${item.BroadcastZones}`;
|
||||
$('#pagingqueuetable').append(`<tr>
|
||||
<td>${item.index}</td>
|
||||
<td>${description}</td>
|
||||
<td>${item.date_Time}</td>
|
||||
<td>${item.source}</td>
|
||||
<td>${item.type}</td>
|
||||
<td>${item.message}</td>
|
||||
<td>${item.broadcastZones}</td>
|
||||
</tr>`);
|
||||
let $addedrow = $('#pagingqueuetable tr:last');
|
||||
$addedrow.off('click').on('click', function () {
|
||||
@@ -156,10 +162,14 @@ function fill_automaticqueuetablebody(vv) {
|
||||
if (!Array.isArray(vv) || vv.length === 0) return;
|
||||
vv.forEach(item => {
|
||||
// fill index and description columns using item properties
|
||||
let description = `${item.Date_Time}_${item.Source}_${item.Type}_${item.Message}_${item.BroadcastZones}`;
|
||||
//console.log("fill_automaticqueuetablebody: item", item);
|
||||
$('#automaticqueuetable').append(`<tr>
|
||||
<td>${item.index}</td>
|
||||
<td>${description}</td>
|
||||
<td>${item.date_Time}</td>
|
||||
<td>${item.source}</td>
|
||||
<td>${item.type}</td>
|
||||
<td>${item.message}</td>
|
||||
<td>${item.broadcastZones}</td>
|
||||
</tr>`);
|
||||
let $addedrow = $('#automaticqueuetable tr:last');
|
||||
$addedrow.off('click').on('click', function () {
|
||||
@@ -277,14 +287,18 @@ $(document).ready(function () {
|
||||
}
|
||||
});
|
||||
|
||||
let intervaljob = null;
|
||||
let intervaljob1 = null;
|
||||
let intervaljob2 = null;
|
||||
function runIntervalJob() {
|
||||
if (intervaljob) clearInterval(intervaljob);
|
||||
intervaljob = setInterval(() => {
|
||||
if (intervaljob1) clearInterval(intervaljob1);
|
||||
intervaljob1 = setInterval(() => {
|
||||
sendCommand("getStreamerOutputs", "");
|
||||
}, 100);
|
||||
if (intervaljob2) clearInterval(intervaljob2);
|
||||
intervaljob2 = setInterval(() => {
|
||||
sendCommand("getPagingQueue", "");
|
||||
sendCommand("getAASQueue", "");
|
||||
sendCommand("getStreamerOutputs", "");
|
||||
}, 1000);
|
||||
}, 2000);
|
||||
console.log("overview.js interval job started");
|
||||
}
|
||||
|
||||
@@ -309,22 +323,20 @@ $(document).ready(function () {
|
||||
case "getPagingQueue":
|
||||
let pq = JSON.parse(data);
|
||||
//console.log("getPagingQueue:", pq);
|
||||
window.PagingQueue = [];
|
||||
if (Array.isArray(pq) && pq.length > 0) {
|
||||
window.PagingQueue = [];
|
||||
window.PagingQueue.push(...pq);
|
||||
console.log(`PagingQueue length: ${window.PagingQueue.length}`);
|
||||
fill_pagingqueuetablebody(window.PagingQueue);
|
||||
}
|
||||
fill_pagingqueuetablebody(window.PagingQueue);
|
||||
break;
|
||||
case "getAASQueue":
|
||||
let aq = JSON.parse(data);
|
||||
//console.log("getAASQueue:", aq);
|
||||
window.QueueTable = [];
|
||||
if (Array.isArray(aq) && aq.length > 0) {
|
||||
window.QueueTable = [];
|
||||
window.QueueTable.push(...aq);
|
||||
console.log(`QueueTable length: ${window.QueueTable.length}`);
|
||||
fill_automaticqueuetablebody(window.QueueTable);
|
||||
}
|
||||
fill_automaticqueuetablebody(window.QueueTable);
|
||||
break;
|
||||
case "getStreamerOutputs":
|
||||
/**
|
||||
@@ -337,13 +349,11 @@ $(document).ready(function () {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$(window).on('beforeunload', function () {
|
||||
console.log("overview.js beforeunload event triggered");
|
||||
clearInterval(intervaljob);
|
||||
intervaljob = null;
|
||||
clearInterval(intervaljob1);
|
||||
clearInterval(intervaljob2);
|
||||
intervaljob1 = null;
|
||||
intervaljob2 = null;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
</div>
|
||||
<div class="accordion" role="tablist" id="accordion-1">
|
||||
<div class="accordion-item pad-accordion">
|
||||
<h2 class="accordion-header" role="tab"><button class="accordion-button bg-heading1" type="button" data-bs-toggle="collapse" data-bs-target="#accordion-1 .item-1" aria-expanded="true" aria-controls="accordion-1 .item-1">Channel Status</button></h2>
|
||||
<div class="accordion-collapse collapse show item-1 bg-accordion" role="tabpanel" data-bs-parent="#accordion-1">
|
||||
<h2 class="accordion-header" role="tab"><button class="accordion-button collapsed bg-heading1" type="button" data-bs-toggle="collapse" data-bs-target="#accordion-1 .item-1" aria-expanded="false" aria-controls="accordion-1 .item-1">Channel Status</button></h2>
|
||||
<div class="accordion-collapse collapse item-1 bg-accordion" role="tabpanel" data-bs-parent="#accordion-1">
|
||||
<div class="accordion-body">
|
||||
<div class="row">
|
||||
<div class="col-12 col-sm-6 col-md-3 col-lg-3 col-xl-3 pad-card">
|
||||
@@ -1263,7 +1263,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<p class="card-text" id="streamerstatus64">Status : Idle</p>
|
||||
<div class="progress" id="streamervu-63">
|
||||
<div class="progress" id="streamervu64">
|
||||
<div class="progress-bar" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100" style="width: 50%;">50%</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1274,16 +1274,20 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="accordion-item pad-accordion pad-2">
|
||||
<h2 class="accordion-header" role="tab"><button class="accordion-button collapsed bg-heading2" type="button" data-bs-toggle="collapse" data-bs-target="#accordion-1 .item-2" aria-expanded="false" aria-controls="accordion-1 .item-2">Paging Queue</button></h2>
|
||||
<div class="accordion-collapse collapse item-2 pad-2" role="tabpanel" data-bs-parent="#accordion-1">
|
||||
<h2 class="accordion-header" role="tab"><button class="accordion-button bg-heading2" type="button" data-bs-toggle="collapse" data-bs-target="#accordion-1 .item-2" aria-expanded="true" aria-controls="accordion-1 .item-2">Paging Queue</button></h2>
|
||||
<div class="accordion-collapse collapse show item-2 pad-2" role="tabpanel" data-bs-parent="#accordion-1">
|
||||
<div class="accordion-body">
|
||||
<div class="row">
|
||||
<div class="table-responsive">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Index</th>
|
||||
<th>Description</th>
|
||||
<th class="col-sm-1">Index</th>
|
||||
<th class="col-sm-2">Date Time</th>
|
||||
<th class="col-sm-1">Source</th>
|
||||
<th class="col-sm-1">Type</th>
|
||||
<th class="col-sm-3">Message</th>
|
||||
<th class="col-sm-4">Broadcast Zones</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="pagingqueuetable"></tbody>
|
||||
@@ -1306,8 +1310,12 @@
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Index</th>
|
||||
<th>Description</th>
|
||||
<th class="col-sm-1">Index</th>
|
||||
<th class="col-sm-2">Date Time</th>
|
||||
<th class="col-sm-1">Source</th>
|
||||
<th class="col-sm-1">Type</th>
|
||||
<th class="col-sm-3">Message</th>
|
||||
<th class="col-sm-4">Broadcast Zones</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="automaticqueuetable"></tbody>
|
||||
|
||||
@@ -31,7 +31,7 @@ lateinit var audioPlayer: AudioPlayer
|
||||
val StreamerOutputs: MutableMap<String, BarixConnection> = HashMap()
|
||||
lateinit var udpreceiver: UDPReceiver
|
||||
lateinit var tcpreceiver: TCPReceiver
|
||||
const val version = "0.0.7 (15/10/2025)"
|
||||
const val version = "0.0.8 (16/10/2025)"
|
||||
// AAS 64 channels
|
||||
const val max_channel = 64
|
||||
|
||||
@@ -167,7 +167,6 @@ fun main() {
|
||||
|
||||
val barixserver = TCP_Barix_Command_Server()
|
||||
barixserver.StartTcpServer { cmd ->
|
||||
//Logger.info { cmd }
|
||||
val _tcp = barixserver.getSocket(cmd.ipaddress)
|
||||
val _streamer = StreamerOutputs[cmd.ipaddress]
|
||||
val _sc = db.soundchannelDB.List.find { it.ip == cmd.ipaddress }
|
||||
@@ -177,7 +176,8 @@ fun main() {
|
||||
if (_sc != null) {
|
||||
|
||||
val _bc = BarixConnection(_sc.index, _sc.channel, cmd.ipaddress)
|
||||
_bc.vu = cmd.vu
|
||||
// cmd.vu 0 - 32767, kita convert ke 0 - 100
|
||||
_bc.vu = ((1.0 * cmd.vu / 32767.0)* 100.0).toInt()
|
||||
_bc.bufferRemain = cmd.buffremain
|
||||
_bc.statusData = cmd.statusdata
|
||||
_bc.commandsocket = _tcp
|
||||
@@ -191,7 +191,8 @@ fun main() {
|
||||
if (_sc != null && _sc.channel != _streamer.channel) {
|
||||
_streamer.channel = _sc.channel
|
||||
}
|
||||
_streamer.vu = cmd.vu
|
||||
// cmd.vu 0 - 32767, kita convert ke 0 - 100
|
||||
_streamer.vu = ((1.0 * cmd.vu / 32767.0)* 100.0).toInt()
|
||||
_streamer.bufferRemain = cmd.buffremain
|
||||
_streamer.statusData = cmd.statusdata
|
||||
|
||||
|
||||
@@ -561,7 +561,7 @@ class MainExtension01 {
|
||||
.filter { it.Type=="PAGING" }
|
||||
|
||||
list.forEach { qp ->
|
||||
println("Processing $qp")
|
||||
//println("Processing $qp")
|
||||
if (qp.BroadcastZones.isNotBlank()){
|
||||
if (ValidFile(qp.Message)){
|
||||
val zz = qp.BroadcastZones.split(";")
|
||||
@@ -883,7 +883,7 @@ class MainExtension01 {
|
||||
db.queuetableDB.Get()
|
||||
val list = db.queuetableDB.List.filter { it.Type=="SOUNDBANK" }
|
||||
list.forEach { qa ->
|
||||
println("Processing $qa")
|
||||
//println("Processing $qa")
|
||||
if (qa.BroadcastZones.isNotEmpty()){
|
||||
val zz = qa.BroadcastZones.split(";")
|
||||
if (AllBroadcastZonesValid(zz)){
|
||||
|
||||
@@ -69,7 +69,7 @@ class TCP_Android_Command_Server {
|
||||
din.read(bb)
|
||||
// B4A format, 4 bytes di depan adalah size
|
||||
val str = String(bb, 4, bb.size - 4)
|
||||
println("Received command from $key : $str")
|
||||
//println("Received command from $key : $str")
|
||||
str.split("@").map { it.trim() }.filter { ValidString(it) }
|
||||
.forEach {
|
||||
process_command(key,it) { reply ->
|
||||
@@ -308,7 +308,7 @@ class TCP_Android_Command_Server {
|
||||
if (userlogin != null){
|
||||
val userdb = db.userDB.List.find { it.username == username }
|
||||
if (userdb != null){
|
||||
println("Sending initialization data to $key with username $username")
|
||||
//println("Sending initialization data to $key with username $username")
|
||||
val result = StringBuilder()
|
||||
// kirim Zone
|
||||
result.append("ZONE")
|
||||
|
||||
@@ -1411,9 +1411,9 @@ class MariaDB(
|
||||
// use a temporary table to reorder the index
|
||||
statement?.executeUpdate("CREATE TABLE IF NOT EXISTS $tempdb_name LIKE ${super.dbName}")
|
||||
statement?.executeUpdate("TRUNCATE TABLE $tempdb_name")
|
||||
statement?.executeUpdate("INSERT INTO $tempdb_name (Date_Time, Source, Type, Message, SB_TAGS) SELECT Date_Time, Source, Type, Message, SB_TAGS FROM ${super.dbName} ORDER BY `index` ")
|
||||
statement?.executeUpdate("INSERT INTO $tempdb_name (Date_Time, Source, Type, Message, BroadcastZones) SELECT Date_Time, Source, Type, Message, BroadcastZones FROM ${super.dbName} ")
|
||||
statement?.executeUpdate("TRUNCATE TABLE ${super.dbName}")
|
||||
statement?.executeUpdate("INSERT INTO ${super.dbName} (Date_Time, Source, Type, Message, SB_TAGS) SELECT Date_Time, Source, Type, Message, SB_TAGS FROM $tempdb_name")
|
||||
statement?.executeUpdate("INSERT INTO ${super.dbName} (Date_Time, Source, Type, Message, BroadcastZones) SELECT Date_Time, Source, Type, Message, BroadcastZones FROM $tempdb_name")
|
||||
statement?.executeUpdate("DROP TABLE $tempdb_name")
|
||||
Logger.info("${super.dbName} table resorted by index" as Any)
|
||||
// reload the local list
|
||||
@@ -1436,7 +1436,7 @@ class MariaDB(
|
||||
val workbook = XSSFWorkbook()
|
||||
val sheet = workbook.createSheet("QueuePaging")
|
||||
val headerRow = sheet.createRow(0)
|
||||
val headers = arrayOf("Index", "Date_Time", "Source", "Type", "Message", "SB_TAGS")
|
||||
val headers = arrayOf("Index", "Date_Time", "Source", "Type", "Message", "BroadcastZones")
|
||||
for ((colIndex, header) in headers.withIndex()) {
|
||||
val cell = headerRow.createCell(colIndex)
|
||||
cell.setCellValue(header)
|
||||
@@ -1449,7 +1449,7 @@ class MariaDB(
|
||||
row.createCell(2).setCellValue(resultSet.getString("Source"))
|
||||
row.createCell(3).setCellValue(resultSet.getString("Type"))
|
||||
row.createCell(4).setCellValue(resultSet.getString("Message"))
|
||||
row.createCell(5).setCellValue(resultSet.getString("SB_TAGS"))
|
||||
row.createCell(5).setCellValue(resultSet.getString("BroadcastZones"))
|
||||
}
|
||||
for (i in headers.indices) {
|
||||
sheet.autoSizeColumn(i)
|
||||
|
||||
@@ -88,7 +88,7 @@ class WebApp(val listenPort: Int, val userlist: List<Pair<String, String>>) {
|
||||
}
|
||||
// Set user session
|
||||
it.sessionAttribute("user", user.first)
|
||||
println("User ${user.first} logged in")
|
||||
//println("User ${user.first} logged in")
|
||||
// Redirect to home page
|
||||
it.redirect("home.html")
|
||||
}
|
||||
@@ -98,10 +98,7 @@ class WebApp(val listenPort: Int, val userlist: List<Pair<String, String>>) {
|
||||
before { CheckUsers(it) }
|
||||
ws("/ws") { ws ->
|
||||
// WebSocket endpoint for home
|
||||
ws.onClose { wsCloseContext ->
|
||||
// TODO Handle WebSocket close event
|
||||
println("WebSocket closed: ${wsCloseContext.session.remoteAddress}")
|
||||
}
|
||||
//
|
||||
ws.onMessage { wsMessageContext ->
|
||||
try {
|
||||
val cmd =
|
||||
@@ -157,10 +154,9 @@ class WebApp(val listenPort: Int, val userlist: List<Pair<String, String>>) {
|
||||
}
|
||||
|
||||
}
|
||||
ws.onConnect { wsConnectContext ->
|
||||
// TODO Handle WebSocket connect event
|
||||
println("WebSocket connected: ${wsConnectContext.session.remoteAddress}")
|
||||
}
|
||||
// ws.onConnect { wsConnectContext ->
|
||||
// println("WebSocket connected: ${wsConnectContext.session.remoteAddress}")
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user