mirror of
https://github.com/craigerl/aprsd.git
synced 2025-06-26 05:55:26 -04:00
Added send-message to the main admin UI
This commit is contained in:
parent
266ae7f217
commit
c58031d772
@ -199,7 +199,7 @@ class SendMessageThread(threads.APRSDThread):
|
|||||||
SentMessages().ack(self.msg.id)
|
SentMessages().ack(self.msg.id)
|
||||||
socketio.emit(
|
socketio.emit(
|
||||||
"ack", SentMessages().get(self.msg.id),
|
"ack", SentMessages().get(self.msg.id),
|
||||||
namespace="/ws",
|
namespace="/sendmsg",
|
||||||
)
|
)
|
||||||
stats.APRSDStats().ack_rx_inc()
|
stats.APRSDStats().ack_rx_inc()
|
||||||
self.got_ack = True
|
self.got_ack = True
|
||||||
@ -224,7 +224,7 @@ class SendMessageThread(threads.APRSDThread):
|
|||||||
SentMessages().set_status(self.msg.id, "Got Reply")
|
SentMessages().set_status(self.msg.id, "Got Reply")
|
||||||
socketio.emit(
|
socketio.emit(
|
||||||
"reply", SentMessages().get(self.msg.id),
|
"reply", SentMessages().get(self.msg.id),
|
||||||
namespace="/ws",
|
namespace="/sendmsg",
|
||||||
)
|
)
|
||||||
|
|
||||||
# Send the ack back?
|
# Send the ack back?
|
||||||
@ -449,8 +449,8 @@ class SendMessageNamespace(Namespace):
|
|||||||
global socketio
|
global socketio
|
||||||
LOG.debug("Web socket connected")
|
LOG.debug("Web socket connected")
|
||||||
socketio.emit(
|
socketio.emit(
|
||||||
"connected", {"data": "Lets dance"},
|
"connected", {"data": "/sendmsg Connected"},
|
||||||
namespace="/ws",
|
namespace="/sendmsg",
|
||||||
)
|
)
|
||||||
|
|
||||||
def on_disconnect(self):
|
def on_disconnect(self):
|
||||||
@ -470,7 +470,7 @@ class SendMessageNamespace(Namespace):
|
|||||||
msgs.set_status(msg.id, "Sending")
|
msgs.set_status(msg.id, "Sending")
|
||||||
socketio.emit(
|
socketio.emit(
|
||||||
"sent", SentMessages().get(self.msg.id),
|
"sent", SentMessages().get(self.msg.id),
|
||||||
namespace="/ws",
|
namespace="/sendmsg",
|
||||||
)
|
)
|
||||||
|
|
||||||
socketio.start_background_task(self._start, self._config, data, msg, self)
|
socketio.start_background_task(self._start, self._config, data, msg, self)
|
||||||
@ -548,5 +548,5 @@ def init_flask(config, loglevel, quiet):
|
|||||||
# import eventlet
|
# import eventlet
|
||||||
# eventlet.monkey_patch()
|
# eventlet.monkey_patch()
|
||||||
|
|
||||||
socketio.on_namespace(SendMessageNamespace("/ws", config=config))
|
socketio.on_namespace(SendMessageNamespace("/sendmsg", config=config))
|
||||||
return socketio, flask_app
|
return socketio, flask_app
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
msgs_list = {};
|
|
||||||
var cleared = false;
|
var cleared = false;
|
||||||
|
|
||||||
function size_dict(d){c=0; for (i in d) ++c; return c}
|
function size_dict(d){c=0; for (i in d) ++c; return c}
|
||||||
|
|
||||||
function init_messages() {
|
function init_messages() {
|
||||||
const socket = io("/ws");
|
const socket = io("/sendmsg");
|
||||||
socket.on('connect', function () {
|
socket.on('connect', function () {
|
||||||
console.log("Connected to socketio");
|
console.log("Connected to socketio");
|
||||||
});
|
});
|
||||||
@ -62,7 +61,7 @@ function init_messages() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function add_msg(msg) {
|
function add_msg(msg) {
|
||||||
var msgsdiv = $("#msgsDiv");
|
var msgsdiv = $("#sendMsgsDiv");
|
||||||
|
|
||||||
ts_str = msg["ts"].toString();
|
ts_str = msg["ts"].toString();
|
||||||
ts = ts_str.split(".")[0]*1000;
|
ts = ts_str.split(".")[0]*1000;
|
||||||
@ -96,7 +95,7 @@ function add_msg(msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function update_msg(msg) {
|
function update_msg(msg) {
|
||||||
var msgsdiv = $("#msgsDiv");
|
var msgsdiv = $("#sendMsgsDiv");
|
||||||
// We have an existing entry
|
// We have an existing entry
|
||||||
ts_str = msg["ts"].toString();
|
ts_str = msg["ts"].toString();
|
||||||
id = ts_str.split('.')[0]
|
id = ts_str.split('.')[0]
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
|
||||||
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
|
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
|
||||||
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
|
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
|
||||||
|
<script src="https://cdn.socket.io/4.1.2/socket.io.min.js" integrity="sha384-toS6mmwu70G0fw54EGlWWeA4z3dyJ+dlXBtSURSKN4vyRFOcxd3Bzjj/AoOwY+Rg" crossorigin="anonymous"></script>
|
||||||
|
|
||||||
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/prism.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/prism.min.js"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/components/prism-json.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.23.0/components/prism-json.js"></script>
|
||||||
@ -17,6 +19,8 @@
|
|||||||
<script src="/static/js/main.js"></script>
|
<script src="/static/js/main.js"></script>
|
||||||
<script src="/static/js/charts.js"></script>
|
<script src="/static/js/charts.js"></script>
|
||||||
<script src="/static/js/tabs.js"></script>
|
<script src="/static/js/tabs.js"></script>
|
||||||
|
<script src="/static/js/send-message.js"></script>
|
||||||
|
<script src="/static/js/packets.js"></script>
|
||||||
|
|
||||||
|
|
||||||
<script type="text/javascript"">
|
<script type="text/javascript"">
|
||||||
@ -30,6 +34,7 @@
|
|||||||
console.log(initial_stats);
|
console.log(initial_stats);
|
||||||
start_update();
|
start_update();
|
||||||
start_charts();
|
start_charts();
|
||||||
|
init_messages();
|
||||||
|
|
||||||
$("#toggleStats").click(function() {
|
$("#toggleStats").click(function() {
|
||||||
$("#jsonstats").fadeToggle(1000);
|
$("#jsonstats").fadeToggle(1000);
|
||||||
@ -73,6 +78,7 @@
|
|||||||
<div class="item" data-tab="watch-tab">Watch List</div>
|
<div class="item" data-tab="watch-tab">Watch List</div>
|
||||||
<div class="item" data-tab="plugin-tab">Plugins</div>
|
<div class="item" data-tab="plugin-tab">Plugins</div>
|
||||||
<div class="item" data-tab="config-tab">Config</div>
|
<div class="item" data-tab="config-tab">Config</div>
|
||||||
|
<div class="item" data-tab="send-tab">Send Message</div>
|
||||||
<div class="item" data-tab="raw-tab">Raw JSON</div>
|
<div class="item" data-tab="raw-tab">Raw JSON</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -142,6 +148,29 @@
|
|||||||
<pre id="configjson" class="language-json">{{ config_json|safe }}</pre>
|
<pre id="configjson" class="language-json">{{ config_json|safe }}</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="ui bottom attached tab segment" data-tab="send-tab">
|
||||||
|
<h3 class="ui dividing header">Send Message</h3>
|
||||||
|
<div id="sendMsgDiv" class="ui mini text">
|
||||||
|
<form id="sendform" name="sendmsg" action="">
|
||||||
|
<p><label for="from_call">From Callsign:</label>
|
||||||
|
<input type="text" name="from_call" id="from" value="WB4BOR"></p>
|
||||||
|
<p><label for="from_call_password">Password:</label>
|
||||||
|
<input type="password" name="from_call_password" id='password' value="24496"></p>
|
||||||
|
<p><label for="to_call">To Callsign:</label>
|
||||||
|
<input type="text" name="to_call" id="to" value="WB4BOR-11"></p>
|
||||||
|
<p><label for="message">Message:</label>
|
||||||
|
<input type="text" name="message" id="message" value="ping"></p>
|
||||||
|
<p><label for="wait">Wait for Reply?</label>
|
||||||
|
<input type="checkbox" name="wait_reply" id="wait_reply" value="off" checked>
|
||||||
|
</p>
|
||||||
|
<input type="submit" name="submit" class="button" id="send_msg" value="Send" />
|
||||||
|
</form>
|
||||||
|
<div class="ui styled fluid accordion" id="accordion">
|
||||||
|
<div id="sendMsgsDiv" class="ui mini text">Messages</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="ui bottom attached tab segment" data-tab="raw-tab">
|
<div class="ui bottom attached tab segment" data-tab="raw-tab">
|
||||||
<h3 class="ui dividing header">Raw JSON</h3>
|
<h3 class="ui dividing header">Raw JSON</h3>
|
||||||
<pre id="jsonstats" class="language-json">{{ stats|safe }}</pre>
|
<pre id="jsonstats" class="language-json">{{ stats|safe }}</pre>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user