commit 10/10/2025
Broadcast Zones and Sound Channels
This commit is contained in:
@@ -1114,17 +1114,6 @@ class WebApp(val listenPort: Int, val userlist: List<Pair<String, String>>) {
|
||||
}
|
||||
path("BroadcastZones") {
|
||||
get("List") {
|
||||
// TODO : temporary, convert BroadcastZones to BroadcastZonesHtml, karena harus revisi javascript di Bootstrap Studio
|
||||
// val newlist: ArrayList<BroadcastZonesHtml> = db.broadcastDB.List.map { xx ->
|
||||
// BroadcastZonesHtml(
|
||||
// xx.index,
|
||||
// xx.description,
|
||||
// xx.SoundChannel,
|
||||
// xx.id,
|
||||
// xx.bp
|
||||
// )
|
||||
// } as ArrayList<BroadcastZonesHtml>
|
||||
|
||||
it.result(MariaDB.ArrayListtoString(db.broadcastDB.List))
|
||||
}
|
||||
get("BroadcastZoneDescriptions") { ctx ->
|
||||
@@ -1276,6 +1265,9 @@ class WebApp(val listenPort: Int, val userlist: List<Pair<String, String>>) {
|
||||
get("List") {
|
||||
it.result(MariaDB.ArrayListtoString(db.soundchannelDB.List))
|
||||
}
|
||||
get("SoundChannelDescriptions") {
|
||||
it.result(objectmapper.writeValueAsString(db.Get_SoundChannel_List()))
|
||||
}
|
||||
delete("List") {
|
||||
// truncate sound channel table
|
||||
if (db.soundchannelDB.Clear()) {
|
||||
@@ -1318,29 +1310,24 @@ class WebApp(val listenPort: Int, val userlist: List<Pair<String, String>>) {
|
||||
} else {
|
||||
|
||||
// cek apakah ada soundchannel lain yang pakai ip dan channel yang sama
|
||||
if (db.soundchannelDB.List.any { xx ->
|
||||
xx.index != index && _ip.equals(
|
||||
xx.ip
|
||||
) && _channel.equals(xx.channel, true)
|
||||
}) {
|
||||
println("Another sound channel already uses IP $_ip and channel $_channel")
|
||||
it.status(400)
|
||||
.result(objectmapper.writeValueAsString(resultMessage("Another sound channel already uses IP $_ip and channel $_channel")))
|
||||
return@patch
|
||||
val othersc = db.soundchannelDB.List.filter { sc -> sc.ip == _ip }.filter { sc -> sc.index != index }
|
||||
if (othersc.isNotEmpty()){
|
||||
it.status(400).result(objectmapper.writeValueAsString(resultMessage("This IP address is already used by another sound channel")))
|
||||
} else {
|
||||
// ada sesuatu yang ganti
|
||||
val newsc = SoundChannel(0u, _channel, _ip)
|
||||
if (db.soundchannelDB.UpdateByIndex(index.toInt(), newsc)) {
|
||||
println("Updated sound channel with index $index")
|
||||
db.soundchannelDB.Resort()
|
||||
it.result(objectmapper.writeValueAsString(resultMessage("OK")))
|
||||
} else {
|
||||
println("Failed to update sound channel with index $index")
|
||||
it.status(500)
|
||||
.result(objectmapper.writeValueAsString(resultMessage("Failed to update sound channel with index $index")))
|
||||
}
|
||||
}
|
||||
|
||||
// ada sesuatu yang ganti
|
||||
val newsc = SoundChannel(0u, _channel, _ip)
|
||||
if (db.soundchannelDB.UpdateByIndex(index.toInt(), newsc)) {
|
||||
println("Updated sound channel with index $index")
|
||||
db.soundchannelDB.Resort()
|
||||
it.result(objectmapper.writeValueAsString(resultMessage("OK")))
|
||||
} else {
|
||||
println("Failed to update sound channel with index $index")
|
||||
it.status(500)
|
||||
.result(objectmapper.writeValueAsString(resultMessage("Failed to update sound channel with index $index")))
|
||||
return@patch
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user