Merge remote-tracking branch 'origin/master' into feature-webapp
# Conflicts: # src/web/WebApp.kt
This commit is contained in:
@@ -260,7 +260,7 @@ class MainExtension01 {
|
|||||||
val value = variables["AL"].orEmpty()
|
val value = variables["AL"].orEmpty()
|
||||||
if (ValidString(value)) {
|
if (ValidString(value)) {
|
||||||
val airplane =
|
val airplane =
|
||||||
sb.firstOrNull { it.Category == Category.Airline_Name.name && it.TAG == value }
|
sb.firstOrNull { it.Category == Category.Airplane_Name.name && it.TAG == value }
|
||||||
if (airplane != null) {
|
if (airplane != null) {
|
||||||
if (ValidFile(airplane.Path)) {
|
if (ValidFile(airplane.Path)) {
|
||||||
files.add(airplane.Path)
|
files.add(airplane.Path)
|
||||||
@@ -588,11 +588,12 @@ class MainExtension01 {
|
|||||||
Logger.info { logmessage }
|
Logger.info { logmessage }
|
||||||
db.Add_Log("AAS", logmessage)
|
db.Add_Log("AAS", logmessage)
|
||||||
db.queuepagingDB.DeleteByIndex(qp.index.toInt())
|
db.queuepagingDB.DeleteByIndex(qp.index.toInt())
|
||||||
|
db.queuepagingDB.Resort()
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
// file tidak valid, delete from queue paging
|
// file tidak valid, delete from queue paging
|
||||||
db.queuepagingDB.DeleteByIndex(qp.index.toInt())
|
db.queuepagingDB.DeleteByIndex(qp.index.toInt())
|
||||||
|
db.queuepagingDB.Resort()
|
||||||
db.Add_Log(
|
db.Add_Log(
|
||||||
"AAS",
|
"AAS",
|
||||||
"Cancelled paging message with index ${qp.index} due to invalid audio file"
|
"Cancelled paging message with index ${qp.index} due to invalid audio file"
|
||||||
@@ -602,11 +603,13 @@ class MainExtension01 {
|
|||||||
} else {
|
} else {
|
||||||
// ada broadcast zone yang tidak valid, delete from queue paging
|
// ada broadcast zone yang tidak valid, delete from queue paging
|
||||||
db.queuepagingDB.DeleteByIndex(qp.index.toInt())
|
db.queuepagingDB.DeleteByIndex(qp.index.toInt())
|
||||||
|
db.queuepagingDB.Resort()
|
||||||
db.Add_Log("AAS", "Cancelled paging message with index ${qp.index} due to invalid broadcast zone")
|
db.Add_Log("AAS", "Cancelled paging message with index ${qp.index} due to invalid broadcast zone")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// file tidak valid, delete from queue paging
|
// file tidak valid, delete from queue paging
|
||||||
db.queuepagingDB.DeleteByIndex(qp.index.toInt())
|
db.queuepagingDB.DeleteByIndex(qp.index.toInt())
|
||||||
|
db.queuepagingDB.Resort()
|
||||||
db.Add_Log(
|
db.Add_Log(
|
||||||
"AAS",
|
"AAS",
|
||||||
"Cancelled paging message with index ${qp.index} due to invalid audio file"
|
"Cancelled paging message with index ${qp.index} due to invalid audio file"
|
||||||
@@ -615,6 +618,7 @@ class MainExtension01 {
|
|||||||
} else {
|
} else {
|
||||||
// invalid broadcast zone, delete from queue paging
|
// invalid broadcast zone, delete from queue paging
|
||||||
db.queuepagingDB.DeleteByIndex(qp.index.toInt())
|
db.queuepagingDB.DeleteByIndex(qp.index.toInt())
|
||||||
|
db.queuepagingDB.Resort()
|
||||||
db.Add_Log("AAS", "Cancelled paging message with index ${qp.index} due to empty broadcast zone")
|
db.Add_Log("AAS", "Cancelled paging message with index ${qp.index} due to empty broadcast zone")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -688,6 +692,7 @@ class MainExtension01 {
|
|||||||
Logger.info { logmsg }
|
Logger.info { logmsg }
|
||||||
db.Add_Log("AAS", logmsg)
|
db.Add_Log("AAS", logmsg)
|
||||||
db.queuepagingDB.DeleteByIndex(qp.index.toInt())
|
db.queuepagingDB.DeleteByIndex(qp.index.toInt())
|
||||||
|
db.queuepagingDB.Resort()
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
db.Add_Log(
|
db.Add_Log(
|
||||||
@@ -698,6 +703,7 @@ class MainExtension01 {
|
|||||||
}
|
}
|
||||||
} else{
|
} else{
|
||||||
db.queuepagingDB.DeleteByIndex(qp.index.toInt())
|
db.queuepagingDB.DeleteByIndex(qp.index.toInt())
|
||||||
|
db.queuepagingDB.Resort()
|
||||||
db.Add_Log("AAS", result.message)
|
db.Add_Log("AAS", result.message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -706,6 +712,7 @@ class MainExtension01 {
|
|||||||
} else {
|
} else {
|
||||||
// tidak ada messagebank dengan ann_id ini, delete from queue paging
|
// tidak ada messagebank dengan ann_id ini, delete from queue paging
|
||||||
db.queuepagingDB.DeleteByIndex(qp.index.toInt())
|
db.queuepagingDB.DeleteByIndex(qp.index.toInt())
|
||||||
|
db.queuepagingDB.Resort()
|
||||||
db.Add_Log(
|
db.Add_Log(
|
||||||
"AAS",
|
"AAS",
|
||||||
"Cancelled Shalat message with index ${qp.index} due to ANN_ID $ann_id not found in Messagebank"
|
"Cancelled Shalat message with index ${qp.index} due to ANN_ID $ann_id not found in Messagebank"
|
||||||
@@ -716,16 +723,19 @@ class MainExtension01 {
|
|||||||
} else {
|
} else {
|
||||||
// invalid ann_id, delete from queue paging
|
// invalid ann_id, delete from queue paging
|
||||||
db.queuepagingDB.DeleteByIndex(qp.index.toInt())
|
db.queuepagingDB.DeleteByIndex(qp.index.toInt())
|
||||||
|
db.queuepagingDB.Resort()
|
||||||
db.Add_Log("AAS", "Cancelled shalat message with index ${qp.index} due to invalid ANN_ID")
|
db.Add_Log("AAS", "Cancelled shalat message with index ${qp.index} due to invalid ANN_ID")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// ada broadcast zone yang tidak valid, delete from queue paging
|
// ada broadcast zone yang tidak valid, delete from queue paging
|
||||||
db.queuepagingDB.DeleteByIndex(qp.index.toInt())
|
db.queuepagingDB.DeleteByIndex(qp.index.toInt())
|
||||||
|
db.queuepagingDB.Resort()
|
||||||
db.Add_Log("AAS", "Cancelled shalat message with index ${qp.index} due to invalid broadcast zone")
|
db.Add_Log("AAS", "Cancelled shalat message with index ${qp.index} due to invalid broadcast zone")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// invalid broadcast zone, delete from queue paging
|
// invalid broadcast zone, delete from queue paging
|
||||||
db.queuepagingDB.DeleteByIndex(qp.index.toInt())
|
db.queuepagingDB.DeleteByIndex(qp.index.toInt())
|
||||||
|
db.queuepagingDB.Resort()
|
||||||
db.Add_Log("AAS", "Cancelled shalat message with index ${qp.index} due to empty broadcast zone")
|
db.Add_Log("AAS", "Cancelled shalat message with index ${qp.index} due to empty broadcast zone")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -789,14 +799,17 @@ class MainExtension01 {
|
|||||||
Logger.info { logmsg }
|
Logger.info { logmsg }
|
||||||
db.Add_Log("AAS", logmsg)
|
db.Add_Log("AAS", logmsg)
|
||||||
db.queuetableDB.DeleteByIndex(qa.index.toInt())
|
db.queuetableDB.DeleteByIndex(qa.index.toInt())
|
||||||
|
db.queuetableDB.Resort()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
} else{
|
} else{
|
||||||
db.queuetableDB.DeleteByIndex(qa.index.toInt())
|
db.queuetableDB.DeleteByIndex(qa.index.toInt())
|
||||||
|
db.queuetableDB.Resort()
|
||||||
db.Add_Log("AAS", result.message)
|
db.Add_Log("AAS", result.message)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
db.queuetableDB.DeleteByIndex(qa.index.toInt())
|
db.queuetableDB.DeleteByIndex(qa.index.toInt())
|
||||||
|
db.queuetableDB.Resort()
|
||||||
db.Add_Log("AAS", result.message)
|
db.Add_Log("AAS", result.message)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -805,6 +818,7 @@ class MainExtension01 {
|
|||||||
} else {
|
} else {
|
||||||
// tidak ada messagebank dengan ann_id ini, delete from queue table
|
// tidak ada messagebank dengan ann_id ini, delete from queue table
|
||||||
db.queuetableDB.DeleteByIndex(qa.index.toInt())
|
db.queuetableDB.DeleteByIndex(qa.index.toInt())
|
||||||
|
db.queuetableDB.Resort()
|
||||||
db.Add_Log(
|
db.Add_Log(
|
||||||
"AAS",
|
"AAS",
|
||||||
"Cancelled TIMER with index ${qa.index} due to ANN_ID $ann_id not found in Messagebank"
|
"Cancelled TIMER with index ${qa.index} due to ANN_ID $ann_id not found in Messagebank"
|
||||||
@@ -815,16 +829,19 @@ class MainExtension01 {
|
|||||||
} else {
|
} else {
|
||||||
// invalid ann_id, delete from queue table
|
// invalid ann_id, delete from queue table
|
||||||
db.queuetableDB.DeleteByIndex(qa.index.toInt())
|
db.queuetableDB.DeleteByIndex(qa.index.toInt())
|
||||||
|
db.queuetableDB.Resort()
|
||||||
db.Add_Log("AAS", "Cancelled TIMER message with index ${qa.index} due to invalid ANN_ID")
|
db.Add_Log("AAS", "Cancelled TIMER message with index ${qa.index} due to invalid ANN_ID")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// ada broadcast zone yang tidak valid, delete from queue table
|
// ada broadcast zone yang tidak valid, delete from queue table
|
||||||
db.queuetableDB.DeleteByIndex(qa.index.toInt())
|
db.queuetableDB.DeleteByIndex(qa.index.toInt())
|
||||||
|
db.queuetableDB.Resort()
|
||||||
db.Add_Log("AAS", "Cancelled TIMER message with index ${qa.index} due to invalid broadcast zone")
|
db.Add_Log("AAS", "Cancelled TIMER message with index ${qa.index} due to invalid broadcast zone")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// invalid broadcast zone, delete from queue table
|
// invalid broadcast zone, delete from queue table
|
||||||
db.queuetableDB.DeleteByIndex(qa.index.toInt())
|
db.queuetableDB.DeleteByIndex(qa.index.toInt())
|
||||||
|
db.queuetableDB.Resort()
|
||||||
db.Add_Log("AAS", "Cancelled TIMER message with index ${qa.index} due to empty broadcast zone")
|
db.Add_Log("AAS", "Cancelled TIMER message with index ${qa.index} due to empty broadcast zone")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -903,6 +920,7 @@ class MainExtension01 {
|
|||||||
"Cancelled SOUNDBANK message with index ${qa.index} due to missing or invalid ANN_ID in SB_TAGS"
|
"Cancelled SOUNDBANK message with index ${qa.index} due to missing or invalid ANN_ID in SB_TAGS"
|
||||||
)
|
)
|
||||||
db.queuetableDB.DeleteByIndex(qa.index.toInt())
|
db.queuetableDB.DeleteByIndex(qa.index.toInt())
|
||||||
|
db.queuetableDB.Resort()
|
||||||
return@forEach
|
return@forEach
|
||||||
}
|
}
|
||||||
// sampe sini punya ann_id valid
|
// sampe sini punya ann_id valid
|
||||||
@@ -930,12 +948,14 @@ class MainExtension01 {
|
|||||||
} else {
|
} else {
|
||||||
db.Add_Log("AAS", result.message)
|
db.Add_Log("AAS", result.message)
|
||||||
db.queuetableDB.DeleteByIndex(qa.index.toInt())
|
db.queuetableDB.DeleteByIndex(qa.index.toInt())
|
||||||
|
db.queuetableDB.Resort()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (listafi.isNotEmpty()){
|
if (listafi.isNotEmpty()){
|
||||||
db.queuetableDB.DeleteByIndex(qa.index.toInt())
|
db.queuetableDB.DeleteByIndex(qa.index.toInt())
|
||||||
|
db.queuetableDB.Resort()
|
||||||
// bikin nama file ada postifx nya dari SB_TAGS, tapi spasi diganti underscore
|
// bikin nama file ada postifx nya dari SB_TAGS, tapi spasi diganti underscore
|
||||||
// dan titik dua diganti dash
|
// dan titik dua diganti dash
|
||||||
val postfix = qa.SB_TAGS.replace(" ","_").replace(":","-")
|
val postfix = qa.SB_TAGS.replace(" ","_").replace(":","-")
|
||||||
@@ -972,6 +992,7 @@ class MainExtension01 {
|
|||||||
} else {
|
} else {
|
||||||
println("Failed to write WAV file: ${result.message}")
|
println("Failed to write WAV file: ${result.message}")
|
||||||
db.queuetableDB.DeleteByIndex(qa.index.toInt())
|
db.queuetableDB.DeleteByIndex(qa.index.toInt())
|
||||||
|
db.queuetableDB.Resort()
|
||||||
db.Add_Log("AAS", result.message)
|
db.Add_Log("AAS", result.message)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -979,6 +1000,7 @@ class MainExtension01 {
|
|||||||
} else {
|
} else {
|
||||||
// tidak ada messagebank dengan ann_id ini, delete from queue table
|
// tidak ada messagebank dengan ann_id ini, delete from queue table
|
||||||
db.queuetableDB.DeleteByIndex(qa.index.toInt())
|
db.queuetableDB.DeleteByIndex(qa.index.toInt())
|
||||||
|
db.queuetableDB.Resort()
|
||||||
db.Add_Log(
|
db.Add_Log(
|
||||||
"AAS",
|
"AAS",
|
||||||
"Cancelled SOUNDBANK message with index ${qa.index} due to ANN_ID $ann_id not found in Messagebank"
|
"Cancelled SOUNDBANK message with index ${qa.index} due to ANN_ID $ann_id not found in Messagebank"
|
||||||
@@ -990,11 +1012,13 @@ class MainExtension01 {
|
|||||||
} else {
|
} else {
|
||||||
// ada broadcast zone yang tidak valid, delete from queue table
|
// ada broadcast zone yang tidak valid, delete from queue table
|
||||||
db.queuetableDB.DeleteByIndex(qa.index.toInt())
|
db.queuetableDB.DeleteByIndex(qa.index.toInt())
|
||||||
|
db.queuetableDB.Resort()
|
||||||
db.Add_Log("AAS", "Cancelled SOUNDBANK message with index ${qa.index} due to invalid broadcast zone")
|
db.Add_Log("AAS", "Cancelled SOUNDBANK message with index ${qa.index} due to invalid broadcast zone")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// invalid broadcast zone, delete from queue table
|
// invalid broadcast zone, delete from queue table
|
||||||
db.queuetableDB.DeleteByIndex(qa.index.toInt())
|
db.queuetableDB.DeleteByIndex(qa.index.toInt())
|
||||||
|
db.queuetableDB.Resort()
|
||||||
db.Add_Log("AAS", "Cancelled SOUNDBANK message with index ${qa.index} due to empty broadcast zone")
|
db.Add_Log("AAS", "Cancelled SOUNDBANK message with index ${qa.index} due to empty broadcast zone")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,11 +111,13 @@ class BarixConnection(val index: UInt, var channel: String, val ipaddress: Strin
|
|||||||
try {
|
try {
|
||||||
val chunk = ByteArray(if (bb.remaining() > maxUDPsize) maxUDPsize else bb.remaining())
|
val chunk = ByteArray(if (bb.remaining() > maxUDPsize) maxUDPsize else bb.remaining())
|
||||||
bb.get(chunk)
|
bb.get(chunk)
|
||||||
|
//println("Buffer remain: $bufferRemain, sending chunk size: ${chunk.size}")
|
||||||
while(bufferRemain<chunk.size){
|
while(bufferRemain<chunk.size){
|
||||||
delay(10)
|
delay(10)
|
||||||
|
//println("Waiting until buffer enough..")
|
||||||
}
|
}
|
||||||
udp.send(DatagramPacket(chunk, chunk.size, inet))
|
udp.send(DatagramPacket(chunk, chunk.size, inet))
|
||||||
delay(1)
|
delay(2)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
cbFail.accept("SendData to $ipaddress:$port failed, message: ${e.message}")
|
cbFail.accept("SendData to $ipaddress:$port failed, message: ${e.message}")
|
||||||
return@launch
|
return@launch
|
||||||
|
|||||||
@@ -37,31 +37,37 @@ class TCP_Barix_Command_Server {
|
|||||||
val key : String = socket.inetAddress.hostAddress
|
val key : String = socket.inetAddress.hostAddress
|
||||||
socketMap[key] = socket
|
socketMap[key] = socket
|
||||||
Logger.info { "Start communicating with Streamer Output with IP : $key" }
|
Logger.info { "Start communicating with Streamer Output with IP : $key" }
|
||||||
val din = socket.getInputStream()
|
try{
|
||||||
while (isActive) {
|
val din = socket.getInputStream()
|
||||||
if (din.available()>0){
|
while (isActive) {
|
||||||
val bb = ByteArray(din.available())
|
|
||||||
din.read(bb)
|
if (din.available()>0){
|
||||||
// B4A format, 4 bytes di depan adalah size
|
val bb = ByteArray(din.available())
|
||||||
val str = String(bb, 4, bb.size - 4)
|
din.read(bb)
|
||||||
if (ValidString(str)) {
|
// B4A format, 4 bytes di depan adalah size
|
||||||
// Valid command from Barix is in format $"STATUSBARIX;VU;BuffRemain;StatusData"$
|
val str = String(bb, 4, bb.size - 4)
|
||||||
pattern.find(str)?.let { matchResult ->
|
if (ValidString(str)) {
|
||||||
val (vu, buffremain, statusdata) = matchResult.destructured
|
// Valid command from Barix is in format $"STATUSBARIX;VU;BuffRemain;StatusData"$
|
||||||
val status = BarixStatus(
|
pattern.find(str)?.let { matchResult ->
|
||||||
socket.inetAddress.hostAddress,
|
val (vu, buffremain, statusdata) = matchResult.destructured
|
||||||
vu.toInt(),
|
val status = BarixStatus(
|
||||||
buffremain.toInt(),
|
socket.inetAddress.hostAddress,
|
||||||
statusdata.toIntOrNull() ?: 0
|
vu.toInt(),
|
||||||
)
|
buffremain.toInt(),
|
||||||
//Logger.info { "Received valid command from $key : $status" }
|
statusdata.toIntOrNull() ?: 0
|
||||||
cb.accept(status)
|
)
|
||||||
} ?: run {
|
//Logger.info { "Received valid command from $key : $status" }
|
||||||
Logger.warn { "Invalid command format from $key : $str" }
|
cb.accept(status)
|
||||||
|
} ?: run {
|
||||||
|
Logger.warn { "Invalid command format from $key : $str" }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (ex:Exception){
|
||||||
|
Logger.error { "Error in communication with Streamer Output with IP $key, Message : ${ex.message}" }
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.info { "Finished communicating with Streamer Output with IP $key" }
|
Logger.info { "Finished communicating with Streamer Output with IP $key" }
|
||||||
socketMap.remove(key)
|
socketMap.remove(key)
|
||||||
|
|
||||||
|
|||||||
@@ -220,6 +220,7 @@ class TCP_Android_Command_Server {
|
|||||||
pj.broadcastzones
|
pj.broadcastzones
|
||||||
)
|
)
|
||||||
if (db.queuepagingDB.Add(qp)) {
|
if (db.queuepagingDB.Add(qp)) {
|
||||||
|
db.queuepagingDB.Resort()
|
||||||
logcb.accept("Paging audio inserted to queue paging table from Android $key, file ${pj.filePath.absolutePathString()}")
|
logcb.accept("Paging audio inserted to queue paging table from Android $key, file ${pj.filePath.absolutePathString()}")
|
||||||
cb.accept("PCMFILE_STOP;OK@")
|
cb.accept("PCMFILE_STOP;OK@")
|
||||||
return
|
return
|
||||||
@@ -274,6 +275,7 @@ class TCP_Android_Command_Server {
|
|||||||
pj.broadcastzones
|
pj.broadcastzones
|
||||||
)
|
)
|
||||||
if (db.queuepagingDB.Add(qp)){
|
if (db.queuepagingDB.Add(qp)){
|
||||||
|
db.queuepagingDB.Resort()
|
||||||
logcb.accept("Paging audio inserted to queue paging table from IPM $key, file ${pj.filePath.absolutePathString()}")
|
logcb.accept("Paging audio inserted to queue paging table from IPM $key, file ${pj.filePath.absolutePathString()}")
|
||||||
cb.accept("STOPPAGINGAND;OK@")
|
cb.accept("STOPPAGINGAND;OK@")
|
||||||
return
|
return
|
||||||
@@ -349,7 +351,7 @@ class TCP_Android_Command_Server {
|
|||||||
.filter { it.isNotBlank() }
|
.filter { it.isNotBlank() }
|
||||||
.forEach { al ->
|
.forEach { al ->
|
||||||
val sb = db.soundDB.List
|
val sb = db.soundDB.List
|
||||||
.filter { it.Category.equals(Category.Airline_Name.name, true) }
|
.filter { it.Category.equals(Category.Airplane_Name.name, true) }
|
||||||
.filter { it.TAG.equals(al, true)}
|
.filter { it.TAG.equals(al, true)}
|
||||||
.distinctBy { it.TAG }
|
.distinctBy { it.TAG }
|
||||||
VARAPTOTAL.addAll(sb)
|
VARAPTOTAL.addAll(sb)
|
||||||
@@ -627,6 +629,7 @@ class TCP_Android_Command_Server {
|
|||||||
lang
|
lang
|
||||||
)
|
)
|
||||||
if (db.queuetableDB.Add(qt)){
|
if (db.queuetableDB.Add(qt)){
|
||||||
|
db.queuetableDB.Resort()
|
||||||
logcb.accept("Broadcast request from Android $key username=${listUserLogin.find { it.ip==key }?.username ?: "UNKNOWN"} inserted. Message: $desc;$lang;$tags;$zone")
|
logcb.accept("Broadcast request from Android $key username=${listUserLogin.find { it.ip==key }?.username ?: "UNKNOWN"} inserted. Message: $desc;$lang;$tags;$zone")
|
||||||
cb.accept("BROADCASTAND;OK@")
|
cb.accept("BROADCASTAND;OK@")
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package content
|
|||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
enum class Category(name: String) {
|
enum class Category(name: String) {
|
||||||
Airline_Code("Airline_Code"),
|
Airline_Code("Airline_Code"),
|
||||||
Airline_Name("Airline_Name"),
|
Airplane_Name("Airplane_Name"),
|
||||||
AlphabetNumeric("AlphabetNumeric"),
|
AlphabetNumeric("AlphabetNumeric"),
|
||||||
City("City"),
|
City("City"),
|
||||||
Phrase("Phrase"),
|
Phrase("Phrase"),
|
||||||
|
|||||||
@@ -2280,7 +2280,7 @@ class MariaDB(
|
|||||||
|
|
||||||
fun Find_Soundbank_AirplaneName(tag: String) : List<Soundbank>{
|
fun Find_Soundbank_AirplaneName(tag: String) : List<Soundbank>{
|
||||||
return soundDB.List
|
return soundDB.List
|
||||||
.filter{ it.Category== Category.Airline_Name.name }
|
.filter{ it.Category== Category.Airplane_Name.name }
|
||||||
.filter { it.TAG.equals(tag,true)}
|
.filter { it.TAG.equals(tag,true)}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,10 +19,11 @@ import database.BroadcastZones
|
|||||||
import database.LanguageLink
|
import database.LanguageLink
|
||||||
import database.MariaDB
|
import database.MariaDB
|
||||||
import database.Messagebank
|
import database.Messagebank
|
||||||
|
import database.ScheduleBank
|
||||||
import database.SoundChannel
|
import database.SoundChannel
|
||||||
import database.Soundbank
|
import database.Soundbank
|
||||||
import database.UserDB
|
import database.UserDB
|
||||||
import database.ScheduleBank
|
>>>>>>>>> Temporary merge branch 2
|
||||||
import db
|
import db
|
||||||
import io.javalin.Javalin
|
import io.javalin.Javalin
|
||||||
import io.javalin.apibuilder.ApiBuilder.before
|
import io.javalin.apibuilder.ApiBuilder.before
|
||||||
@@ -236,7 +237,7 @@ class WebApp(val listenPort: Int, val userlist: List<Pair<String, String>>) {
|
|||||||
}
|
}
|
||||||
get("AirlineTags") { ctx ->
|
get("AirlineTags") { ctx ->
|
||||||
val value = db.soundDB.List
|
val value = db.soundDB.List
|
||||||
.filter { it.Category == Category.Airline_Name.name }
|
.filter { it.Category == Category.Airplane_Name.name }
|
||||||
.distinctBy { it.TAG }
|
.distinctBy { it.TAG }
|
||||||
.sortedBy { it.TAG }
|
.sortedBy { it.TAG }
|
||||||
.map { KeyValueMessage(it.TAG, it.Description) }
|
.map { KeyValueMessage(it.TAG, it.Description) }
|
||||||
@@ -266,32 +267,20 @@ class WebApp(val listenPort: Int, val userlist: List<Pair<String, String>>) {
|
|||||||
if (ValidFile(addvalue.Path)) {
|
if (ValidFile(addvalue.Path)) {
|
||||||
if (db.soundDB.Add(addvalue)) {
|
if (db.soundDB.Add(addvalue)) {
|
||||||
db.soundDB.Resort()
|
db.soundDB.Resort()
|
||||||
it.result(
|
it.result(objectmapper.writeValueAsString(resultMessage("OK")))
|
||||||
objectmapper.writeValueAsString(
|
|
||||||
resultMessage(
|
|
||||||
"OK"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
} else it.status(500)
|
} else it.status(500)
|
||||||
.result(objectmapper.writeValueAsString(resultMessage("Failed to add soundbank to database")))
|
.result(objectmapper.writeValueAsString(resultMessage("Failed to add soundbank to database")))
|
||||||
} else it.status(400)
|
} else it.status(400)
|
||||||
.result(objectmapper.writeValueAsString(resultMessage("Invalid Path, file does not exist")))
|
.result(objectmapper.writeValueAsString(resultMessage("Invalid Path, file does not exist")))
|
||||||
} else it.status(400)
|
} else it.status(400)
|
||||||
.result(objectmapper.writeValueAsString(resultMessage("TAG=${addvalue.TAG} already exists for the same Language=${addvalue.Language} and Category=${addvalue.Category}")))
|
.result(objectmapper.writeValueAsString(resultMessage("TAG=${addvalue.TAG} already exists for the same Language=${addvalue.Language} and Category=${addvalue.Category}")))
|
||||||
} else it.status(400)
|
} else it.status(400).result(objectmapper.writeValueAsString(resultMessage("Invalid Path")))
|
||||||
.result(objectmapper.writeValueAsString(resultMessage("Invalid Path")))
|
} else it.status(400).result(objectmapper.writeValueAsString(resultMessage("Invalid Language")))
|
||||||
} else it.status(400)
|
} else it.status(400).result(objectmapper.writeValueAsString(resultMessage("Invalid Category")))
|
||||||
.result(objectmapper.writeValueAsString(resultMessage("Invalid Language")))
|
} else it.status(400).result(objectmapper.writeValueAsString(resultMessage("Invalid TAG")))
|
||||||
} else it.status(400)
|
} else it.status(400).result(objectmapper.writeValueAsString(resultMessage("Invalid Description")))
|
||||||
.result(objectmapper.writeValueAsString(resultMessage("Invalid Category")))
|
|
||||||
} else it.status(400)
|
|
||||||
.result(objectmapper.writeValueAsString(resultMessage("Invalid TAG")))
|
|
||||||
} else it.status(400)
|
|
||||||
.result(objectmapper.writeValueAsString(resultMessage("Invalid Description")))
|
|
||||||
} catch (_: Exception) {
|
} catch (_: Exception) {
|
||||||
it.status(400)
|
it.status(400).result(objectmapper.writeValueAsString(resultMessage("Invalid request body")))
|
||||||
.result(objectmapper.writeValueAsString(resultMessage("Invalid request body")))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete("List") {
|
delete("List") {
|
||||||
@@ -300,8 +289,7 @@ class WebApp(val listenPort: Int, val userlist: List<Pair<String, String>>) {
|
|||||||
db.soundDB.Get()
|
db.soundDB.Get()
|
||||||
it.result(objectmapper.writeValueAsString(resultMessage("OK")))
|
it.result(objectmapper.writeValueAsString(resultMessage("OK")))
|
||||||
} else {
|
} else {
|
||||||
it.status(500)
|
it.status(500).result(objectmapper.writeValueAsString(resultMessage("Failed to truncate soundbank table")))
|
||||||
.result(objectmapper.writeValueAsString(resultMessage("Failed to truncate soundbank table")))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete("DeleteByIndex/{index}") {
|
delete("DeleteByIndex/{index}") {
|
||||||
@@ -314,8 +302,7 @@ class WebApp(val listenPort: Int, val userlist: List<Pair<String, String>>) {
|
|||||||
db.soundDB.Resort()
|
db.soundDB.Resort()
|
||||||
it.result(objectmapper.writeValueAsString(resultMessage("OK")))
|
it.result(objectmapper.writeValueAsString(resultMessage("OK")))
|
||||||
} else {
|
} else {
|
||||||
it.status(500)
|
it.status(500).result(objectmapper.writeValueAsString(resultMessage("Failed to delete soundbank with index $index")))
|
||||||
.result(objectmapper.writeValueAsString(resultMessage("Failed to delete soundbank with index $index")))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -329,14 +316,12 @@ class WebApp(val listenPort: Int, val userlist: List<Pair<String, String>>) {
|
|||||||
val sb = db.soundDB.List.find { xx -> xx.index == index }
|
val sb = db.soundDB.List.find { xx -> xx.index == index }
|
||||||
if (sb == null) {
|
if (sb == null) {
|
||||||
// soundbank dengan index tersebut tidak ditemukan
|
// soundbank dengan index tersebut tidak ditemukan
|
||||||
it.status(404)
|
it.status(404).result(objectmapper.writeValueAsString(resultMessage("Soundbank with index $index not found")))
|
||||||
.result(objectmapper.writeValueAsString(resultMessage("Soundbank with index $index not found")))
|
|
||||||
} else {
|
} else {
|
||||||
// soundbank dengan index tersebut ditemukan, sekarang update
|
// soundbank dengan index tersebut ditemukan, sekarang update
|
||||||
val json: JsonNode = objectmapper.readTree(it.body())
|
val json: JsonNode = objectmapper.readTree(it.body())
|
||||||
if (json.isEmpty) {
|
if (json.isEmpty) {
|
||||||
it.status(400)
|
it.status(400).result(objectmapper.writeValueAsString(resultMessage("UpdateByIndex with index=$index has empty body")))
|
||||||
.result(objectmapper.writeValueAsString(resultMessage("UpdateByIndex with index=$index has empty body")))
|
|
||||||
} else {
|
} else {
|
||||||
val _description = json.get("Description").asText("")
|
val _description = json.get("Description").asText("")
|
||||||
val _tag = json.get("TAG").asText("")
|
val _tag = json.get("TAG").asText("")
|
||||||
@@ -359,8 +344,7 @@ class WebApp(val listenPort: Int, val userlist: List<Pair<String, String>>) {
|
|||||||
sb.Category = _category
|
sb.Category = _category
|
||||||
changed = true
|
changed = true
|
||||||
} else {
|
} else {
|
||||||
it.status(400)
|
it.status(400).result(objectmapper.writeValueAsString(resultMessage("Invalid Category")))
|
||||||
.result(objectmapper.writeValueAsString(resultMessage("Invalid Category")))
|
|
||||||
return@patch
|
return@patch
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -373,8 +357,7 @@ class WebApp(val listenPort: Int, val userlist: List<Pair<String, String>>) {
|
|||||||
sb.Path = _path
|
sb.Path = _path
|
||||||
changed = true
|
changed = true
|
||||||
} else {
|
} else {
|
||||||
it.status(400)
|
it.status(400).result(objectmapper.writeValueAsString(resultMessage("Invalid Path, file does not exist")))
|
||||||
.result(objectmapper.writeValueAsString(resultMessage("Invalid Path, file does not exist")))
|
|
||||||
return@patch
|
return@patch
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -382,8 +365,7 @@ class WebApp(val listenPort: Int, val userlist: List<Pair<String, String>>) {
|
|||||||
if (db.soundDB.UpdateByIndex(index.toInt(), sb)) {
|
if (db.soundDB.UpdateByIndex(index.toInt(), sb)) {
|
||||||
db.soundDB.Resort()
|
db.soundDB.Resort()
|
||||||
it.result(objectmapper.writeValueAsString(resultMessage("OK")))
|
it.result(objectmapper.writeValueAsString(resultMessage("OK")))
|
||||||
} else it.status(500)
|
} else it.status(500).result(objectmapper.writeValueAsString(resultMessage("Failed to update soundbank with index $index")))
|
||||||
.result(objectmapper.writeValueAsString(resultMessage("Failed to update soundbank with index $index")))
|
|
||||||
} else it.status(400)
|
} else it.status(400)
|
||||||
.result(objectmapper.writeValueAsString(resultMessage("Nothing has changed for soundbank with index $index")))
|
.result(objectmapper.writeValueAsString(resultMessage("Nothing has changed for soundbank with index $index")))
|
||||||
}
|
}
|
||||||
@@ -402,15 +384,13 @@ class WebApp(val listenPort: Int, val userlist: List<Pair<String, String>>) {
|
|||||||
xlsxdata.write(out)
|
xlsxdata.write(out)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
it.status(500)
|
it.status(500).result(objectmapper.writeValueAsString(resultMessage("Failed to export soundbank to XLSX")))
|
||||||
.result(objectmapper.writeValueAsString(resultMessage("Failed to export soundbank to XLSX")))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
post("ImportXLSX") {
|
post("ImportXLSX") {
|
||||||
val uploaded = it.uploadedFile("file")
|
val uploaded = it.uploadedFile("file")
|
||||||
if (uploaded == null) {
|
if (uploaded == null) {
|
||||||
it.status(400)
|
it.status(400).result(objectmapper.writeValueAsString(resultMessage("No file uploaded")))
|
||||||
.result(objectmapper.writeValueAsString(resultMessage("No file uploaded")))
|
|
||||||
return@post
|
return@post
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -419,12 +399,10 @@ class WebApp(val listenPort: Int, val userlist: List<Pair<String, String>>) {
|
|||||||
db.soundDB.Resort()
|
db.soundDB.Resort()
|
||||||
it.result(objectmapper.writeValueAsString(resultMessage("OK")))
|
it.result(objectmapper.writeValueAsString(resultMessage("OK")))
|
||||||
} else {
|
} else {
|
||||||
it.status(500)
|
it.status(500).result(objectmapper.writeValueAsString(resultMessage("Failed to import soundbank from XLSX")))
|
||||||
.result(objectmapper.writeValueAsString(resultMessage("Failed to import soundbank from XLSX")))
|
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
it.status(400)
|
it.status(400).result(objectmapper.writeValueAsString(resultMessage("Invalid XLSX file")))
|
||||||
.result(objectmapper.writeValueAsString(resultMessage("Invalid XLSX file")))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -713,7 +691,6 @@ class WebApp(val listenPort: Int, val userlist: List<Pair<String, String>>) {
|
|||||||
// get timer list
|
// get timer list
|
||||||
it.result(MariaDB.ArrayListtoString(db.scheduleDB.List))
|
it.result(MariaDB.ArrayListtoString(db.scheduleDB.List))
|
||||||
}
|
}
|
||||||
|
|
||||||
delete("List") {
|
delete("List") {
|
||||||
// truncate timer table
|
// truncate timer table
|
||||||
if (db.scheduleDB.Clear()) {
|
if (db.scheduleDB.Clear()) {
|
||||||
@@ -744,7 +721,17 @@ class WebApp(val listenPort: Int, val userlist: List<Pair<String, String>>) {
|
|||||||
val zones = broadcast_zones.split(";")
|
val zones = broadcast_zones.split(";")
|
||||||
if (zones.all { zz -> db.broadcastDB.List.any { xx -> xx.description.equals(zz,true) } }){
|
if (zones.all { zz -> db.broadcastDB.List.any { xx -> xx.description.equals(zz,true) } }){
|
||||||
if (ValidString(language) && Language.entries.any{ lang -> lang.name == language }){
|
if (ValidString(language) && Language.entries.any{ lang -> lang.name == language }){
|
||||||
val newvalue = ScheduleBank(0u, description, day, time, soundpath, repeat, enable, broadcast_zones, language)
|
val newvalue = ScheduleBank(
|
||||||
|
0u,
|
||||||
|
description,
|
||||||
|
day,
|
||||||
|
time,
|
||||||
|
soundpath,
|
||||||
|
repeat,
|
||||||
|
enable,
|
||||||
|
broadcast_zones,
|
||||||
|
language
|
||||||
|
)
|
||||||
if (db.scheduleDB.Add(newvalue)){
|
if (db.scheduleDB.Add(newvalue)){
|
||||||
db.scheduleDB.Resort()
|
db.scheduleDB.Resort()
|
||||||
it.result(objectmapper.writeValueAsString(resultMessage("OK")))
|
it.result(objectmapper.writeValueAsString(resultMessage("OK")))
|
||||||
@@ -1231,6 +1218,7 @@ class WebApp(val listenPort: Int, val userlist: List<Pair<String, String>>) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Steph : coba tambah untuk QueueTable Table. Belum ada di JS file(?)
|
// Steph : coba tambah untuk QueueTable Table. Belum ada di JS file(?)
|
||||||
path("QueueTable"){
|
path("QueueTable"){
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user