diff --git a/aprsd/cmds/webchat.py b/aprsd/cmds/webchat.py index 6bcddc5..b58ff14 100644 --- a/aprsd/cmds/webchat.py +++ b/aprsd/cmds/webchat.py @@ -216,17 +216,8 @@ def _get_transport(stats): @auth.login_required @flask_app.route("/") def index(): - # ua_str = request.headers.get("User-Agent") - # this takes about 2 seconds :( - # user_agent = ua_parse(ua_str) - # LOG.debug(f"Is mobile? {user_agent.is_mobile}") stats = _stats() - # if user_agent.is_mobile: - # html_template = "mobile.html" - # else: - # html_template = "index.html" - # For development html_template = "index.html" LOG.debug(f"Template {html_template}") diff --git a/aprsd/web/chat/static/js/send-message-mobile.js b/aprsd/web/chat/static/js/send-message-mobile.js deleted file mode 100644 index b8e6c03..0000000 --- a/aprsd/web/chat/static/js/send-message-mobile.js +++ /dev/null @@ -1,246 +0,0 @@ -var cleared = false; -var callsign_list = {}; -var message_list = {}; -var from_msg_list = {}; -const socket = io("/sendmsg"); - -function size_dict(d){c=0; for (i in d) ++c; return c} - -function init_chat() { - socket.on('connect', function () { - console.log("Connected to socketio"); - }); - socket.on('connected', function(msg) { - console.log("Connected!"); - console.log(msg); - }); - - socket.on("sent", function(msg) { - if (cleared == false) { - var msgsdiv = $("#msgsTabsDiv"); - msgsdiv.html('') - cleared = true - } - sent_msg(msg); - }); - - socket.on("ack", function(msg) { - update_msg(msg); - }); - - socket.on("new", function(msg) { - if (cleared == false) { - var msgsdiv = $("#msgsTabsDiv"); - msgsdiv.html('') - cleared = true - } - from_msg(msg); - }); - - $("#sendform").submit(function(event) { - event.preventDefault(); - msg = {'to': $('#to_call').val().toUpperCase(), - 'message': $('#message').val(), - } - socket.emit("send", msg); - $('#message').val(''); - }); - - init_gps(); -} - - -function add_callsign(callsign) { - /* Ensure a callsign exists in the left hand nav */ - dropdown = $('#callsign_dropdown') - - if (callsign in callsign_list) { - console.log(callsign+' already in list.') - return false - } - - var callsignTabs = $("#callsignTabs"); - tab_name = tab_string(callsign); - tab_content = tab_content_name(callsign); - divname = content_divname(callsign); - - item_html = '
'+callsign+'
'; - callsignTabs.append(item_html); - - callsign_list[callsign] = {'name': callsign, 'value': callsign, 'text': callsign} - return true -} - -function append_message(callsign, msg, msg_html) { - console.log('append_message'); - new_callsign = false - if (!message_list.hasOwnProperty(callsign)) { - message_list[callsign] = new Array(); - } - message_list[callsign].push(msg); - - // Find the right div to place the html - new_callsign = add_callsign(callsign); - append_message_html(callsign, msg_html, new_callsign); - if (new_callsign) { - //click on the new tab - click_div = '#'+tab_string(callsign); - console.log("Click on "+click_div); - $(click_div).click(); - } -} - -function tab_string(callsign) { - return "msgs"+callsign; -} - -function tab_content_name(callsign) { - return tab_string(callsign)+"Content"; -} - -function content_divname(callsign) { - return "#"+tab_content_name(callsign); -} - -function append_message_html(callsign, msg_html, new_callsign) { - var msgsTabs = $('#msgsTabsDiv'); - divname_str = tab_content_name(callsign); - divname = content_divname(callsign); - if (new_callsign) { - // we have to add a new DIV - msg_div_html = '
'+msg_html+'
'; - msgsTabs.append(msg_div_html); - } else { - var msgDiv = $(divname); - msgDiv.append(msg_html); - } - - $(divname).animate({scrollTop: $(divname)[0].scrollHeight}, "slow"); -} - -function create_message_html(time, from, to, message, ack, msg) { - div_id = from + "_" + msg.id; - msg_html = '
'; - msg_html += '
'+time+'
'; - msg_html += '
'; - msg_html += '
'+from+'
'; - if (ack) { - msg_html += ''; - } else { - msg_html += ''; - } - msg_html += '
>   
'; - msg_html += '
'; - msg_html += '
'+message+'
'; - msg_html += '

'; - - return msg_html -} - -function flash_message(msg) { - // Callback function to bring a hidden box back - id = msg.from + "_" + msg.id; - var msgid = $('#'+id); - msgid.effect("pulsate", { times:3 }, 2000); -} - -function sent_msg(msg) { - var msgsdiv = $("#sendMsgsDiv"); - - ts_str = msg["ts"].toString(); - ts = ts_str.split(".")[0]*1000; - id = ts_str.split('.')[0] - ack_id = "ack_" + id - - var d = new Date(ts).toLocaleDateString("en-US") - var t = new Date(ts).toLocaleTimeString("en-US") - - msg_html = create_message_html(t, msg['from'], msg['to'], msg['message'], ack_id, msg); - append_message(msg['to'], msg, msg_html); -} - -function from_msg(msg) { - var msgsdiv = $("#sendMsgsDiv"); - console.log(msg); - if (!from_msg_list.hasOwnProperty(msg.from)) { - from_msg_list[msg.from] = new Array(); - } - - if (msg.id in from_msg_list[msg.from]) { - // We already have this message - console.log("We already have this message " + msg); - // Do some flashy thing? - flash_message(msg); - return false - } else { - console.log("Adding message " + msg.id + " to " + msg.from); - from_msg_list[msg.from][msg.id] = msg - } - - // We have an existing entry - ts_str = msg["ts"].toString(); - ts = ts_str.split(".")[0]*1000; - id = ts_str.split('.')[0] - ack_id = "ack_" + id - - var d = new Date(ts).toLocaleDateString("en-US") - var t = new Date(ts).toLocaleTimeString("en-US") - - from = msg['from'] - msg_html = create_message_html(t, from, false, msg['message'], false, msg); - append_message(from, msg, msg_html); -} - -function update_msg(msg) { - var msgsdiv = $("#sendMsgsDiv"); - // We have an existing entry - ts_str = msg["ts"].toString(); - id = ts_str.split('.')[0] - pretty_id = "pretty_" + id - loader_id = "loader_" + id - ack_id = "ack_" + id - span_id = "span_" + id - - - - if (msg['ack'] == true) { - var loader_div = $('#' + loader_id); - var ack_div = $('#' + ack_id); - loader_div.removeClass('ui active inline loader'); - loader_div.addClass('ui disabled loader'); - ack_div.removeClass('thumbs up outline icon'); - ack_div.addClass('thumbs up outline icon'); - } - - $('.ui.accordion').accordion('refresh'); -} - -function callsign_select(callsign) { - var tocall = $("#to_call"); - tocall.val(callsign); -} - -function reset_Tabs() { - tabcontent = document.getElementsByClassName("tabcontent"); - for (i = 0; i < tabcontent.length; i++) { - tabcontent[i].style.display = "none"; - } -} - -function openCallsign(evt, callsign) { - var i, tabcontent, tablinks; - - tab_content = tab_content_name(callsign); - - tabcontent = document.getElementsByClassName("tabcontent"); - for (i = 0; i < tabcontent.length; i++) { - tabcontent[i].style.display = "none"; - } - tablinks = document.getElementsByClassName("tablinks"); - for (i = 0; i < tablinks.length; i++) { - tablinks[i].className = tablinks[i].className.replace(" active", ""); - } - document.getElementById(tab_content).style.display = "block"; - evt.target.className += " active"; - callsign_select(callsign); -} diff --git a/aprsd/web/chat/templates/mobile.html b/aprsd/web/chat/templates/mobile.html deleted file mode 100644 index 091c315..0000000 --- a/aprsd/web/chat/templates/mobile.html +++ /dev/null @@ -1,98 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

APRSD WebChat {{ version }}

-
- -
-
- {{ callsign }} - connected to - {{ aprs_connection|safe }} -
- -
- NONE -
-
- -
-

Send Message

-
-
-
Callsign
- - -
-
- - - -
-
- - -
- -
-
- -
- -
-   -
-
- -
- PyPI version - -
- - diff --git a/dev-requirements.txt b/dev-requirements.txt index 8d55f81..0330cf3 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,34 +1,33 @@ # -# This file is autogenerated by pip-compile with Python 3.10 +# This file is autogenerated by pip-compile with Python 3.11 # by the following command: # # pip-compile --annotation-style=line dev-requirements.in # -add-trailing-comma==3.0.1 # via gray +add-trailing-comma==3.1.0 # via gray alabaster==0.7.13 # via sphinx attrs==23.1.0 # via jsonschema, referencing autoflake==1.5.3 # via gray babel==2.12.1 # via sphinx black==23.7.0 # via gray -build==0.10.0 # via pip-tools +build==1.0.3 # via pip-tools cachetools==5.3.1 # via tox certifi==2023.7.22 # via requests cfgv==3.4.0 # via pre-commit chardet==5.2.0 # via tox charset-normalizer==3.2.0 # via requests -click==8.1.6 # via black, pip-tools +click==8.1.7 # via black, pip-tools colorama==0.4.6 # via tox commonmark==0.9.1 # via rich configargparse==1.7 # via gray -coverage[toml]==7.3.0 # via pytest-cov +coverage[toml]==7.3.1 # via pytest-cov distlib==0.3.7 # via virtualenv docutils==0.20.1 # via sphinx -exceptiongroup==1.1.3 # via pytest -filelock==3.12.2 # via tox, virtualenv +filelock==3.12.3 # via tox, virtualenv fixit==0.1.4 # via gray flake8==6.1.0 # via -r dev-requirements.in, fixit, pep8-naming gray==0.13.0 # via -r dev-requirements.in -identify==2.5.26 # via pre-commit +identify==2.5.27 # via pre-commit idna==3.4 # via requests imagesize==1.4.1 # via sphinx importlib-resources==6.0.1 # via fixit @@ -40,7 +39,7 @@ jsonschema-specifications==2023.7.1 # via jsonschema libcst==1.0.1 # via fixit markupsafe==2.1.3 # via jinja2 mccabe==0.7.0 # via flake8 -mypy==1.5.0 # via -r dev-requirements.in +mypy==1.5.1 # via -r dev-requirements.in mypy-extensions==1.0.0 # via black, mypy, typing-inspect nodeenv==1.8.0 # via pre-commit packaging==23.1 # via black, build, pyproject-api, pytest, sphinx, tox @@ -48,40 +47,39 @@ pathspec==0.11.2 # via black pep8-naming==0.13.3 # via -r dev-requirements.in pip-tools==7.3.0 # via -r dev-requirements.in platformdirs==3.10.0 # via black, tox, virtualenv -pluggy==1.2.0 # via pytest, tox -pre-commit==3.3.3 # via -r dev-requirements.in +pluggy==1.3.0 # via pytest, tox +pre-commit==3.4.0 # via -r dev-requirements.in pycodestyle==2.11.0 # via flake8 pyflakes==3.1.0 # via autoflake, flake8 pygments==2.16.1 # via rich, sphinx -pyproject-api==1.5.3 # via tox +pyproject-api==1.6.1 # via tox pyproject-hooks==1.0.0 # via build -pytest==7.4.0 # via -r dev-requirements.in, pytest-cov +pytest==7.4.2 # via -r dev-requirements.in, pytest-cov pytest-cov==4.1.0 # via -r dev-requirements.in pyupgrade==3.10.1 # via gray pyyaml==6.0.1 # via fixit, libcst, pre-commit referencing==0.30.2 # via jsonschema, jsonschema-specifications requests==2.31.0 # via sphinx rich==12.6.0 # via gray -rpds-py==0.9.2 # via jsonschema, referencing +rpds-py==0.10.2 # via jsonschema, referencing snowballstemmer==2.2.0 # via sphinx -sphinx==7.1.2 # via -r dev-requirements.in, sphinxcontrib-applehelp, sphinxcontrib-devhelp, sphinxcontrib-htmlhelp, sphinxcontrib-qthelp, sphinxcontrib-serializinghtml +sphinx==7.2.5 # via -r dev-requirements.in, sphinxcontrib-applehelp, sphinxcontrib-devhelp, sphinxcontrib-htmlhelp, sphinxcontrib-qthelp, sphinxcontrib-serializinghtml sphinxcontrib-applehelp==1.0.7 # via sphinx sphinxcontrib-devhelp==1.0.5 # via sphinx sphinxcontrib-htmlhelp==2.0.4 # via sphinx sphinxcontrib-jsmath==1.0.1 # via sphinx sphinxcontrib-qthelp==1.0.6 # via sphinx -sphinxcontrib-serializinghtml==1.1.8 # via sphinx +sphinxcontrib-serializinghtml==1.1.9 # via sphinx tokenize-rt==5.2.0 # via add-trailing-comma, pyupgrade toml==0.10.2 # via autoflake -tomli==2.0.1 # via black, build, coverage, mypy, pip-tools, pyproject-api, pyproject-hooks, pytest, tox -tox==4.8.0 # via -r dev-requirements.in +tox==4.11.2 # via -r dev-requirements.in typing-extensions==4.7.1 # via libcst, mypy, typing-inspect typing-inspect==0.9.0 # via libcst unify==0.5 # via gray untokenize==0.1.1 # via unify urllib3==2.0.4 # via requests -virtualenv==20.24.3 # via pre-commit, tox -wheel==0.41.1 # via pip-tools +virtualenv==20.24.5 # via pre-commit, tox +wheel==0.41.2 # via pip-tools # The following packages are considered to be unsafe in a requirements file: # pip diff --git a/requirements.in b/requirements.in index 08f0b25..bcbe328 100644 --- a/requirements.in +++ b/requirements.in @@ -27,8 +27,6 @@ wrapt # kiss3 uses attrs kiss3 attrs -# for mobile checking -user-agents dataclasses dacite2 oslo.config diff --git a/requirements.txt b/requirements.txt index 3823144..de23c8a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ # -# This file is autogenerated by pip-compile with Python 3.10 +# This file is autogenerated by pip-compile with Python 3.11 # by the following command: # # pip-compile --annotation-style=line requirements.in @@ -13,7 +13,7 @@ bitarray==2.8.1 # via ax253, kiss3 blinker==1.6.2 # via flask certifi==2023.7.22 # via requests charset-normalizer==3.2.0 # via requests -click==8.1.6 # via -r requirements.in, click-completion, click-params, flask +click==8.1.7 # via -r requirements.in, click-completion, click-params, flask click-completion==0.5.2 # via -r requirements.in click-params==0.4.1 # via -r requirements.in commonmark==0.9.1 # via rich @@ -23,12 +23,12 @@ debtcollector==2.5.0 # via oslo-config decorator==5.1.1 # via validators dnspython==2.4.2 # via eventlet eventlet==0.33.3 # via -r requirements.in -flask==2.3.2 # via -r requirements.in, flask-httpauth, flask-socketio +flask==2.3.3 # via -r requirements.in, flask-httpauth, flask-socketio flask-httpauth==4.8.0 # via -r requirements.in -flask-socketio==5.3.5 # via -r requirements.in +flask-socketio==5.3.6 # via -r requirements.in geographiclib==2.0 # via geopy -geopy==2.3.0 # via -r requirements.in -gevent==23.7.0 # via -r requirements.in +geopy==2.4.0 # via -r requirements.in +gevent==23.9.0.post1 # via -r requirements.in greenlet==2.0.2 # via eventlet, gevent idna==3.4 # via requests imapclient==2.3.1 # via -r requirements.in @@ -38,33 +38,31 @@ jinja2==3.1.2 # via click-completion, flask kiss3==8.0.0 # via -r requirements.in markupsafe==2.1.3 # via jinja2, werkzeug netaddr==0.8.0 # via oslo-config -oslo-config==9.1.1 # via -r requirements.in -oslo-i18n==6.0.0 # via oslo-config +oslo-config==9.2.0 # via -r requirements.in +oslo-i18n==6.1.0 # via oslo-config pbr==5.11.1 # via -r requirements.in, oslo-i18n, stevedore -pluggy==1.2.0 # via -r requirements.in +pluggy==1.3.0 # via -r requirements.in plumbum==1.8.2 # via rpyc pygments==2.16.1 # via rich pyserial==3.5 # via pyserial-asyncio pyserial-asyncio==0.6 # via kiss3 -python-engineio==4.5.1 # via python-socketio -python-socketio==5.8.0 # via -r requirements.in, flask-socketio -pytz==2023.3 # via -r requirements.in +python-engineio==4.7.0 # via python-socketio +python-socketio==5.9.0 # via -r requirements.in, flask-socketio +pytz==2023.3.post1 # via -r requirements.in pyyaml==6.0.1 # via -r requirements.in, oslo-config requests==2.31.0 # via -r requirements.in, oslo-config, update-checker rfc3986==2.0.0 # via oslo-config rich==12.6.0 # via -r requirements.in rpyc==5.3.1 # via -r requirements.in rush==2021.4.0 # via -r requirements.in -shellingham==1.5.0.post1 # via -r requirements.in, click-completion +shellingham==1.5.3 # via -r requirements.in, click-completion six==1.16.0 # via -r requirements.in, click-completion, eventlet, imapclient -soupsieve==2.4.1 # via beautifulsoup4 +soupsieve==2.5 # via beautifulsoup4 stevedore==5.1.0 # via oslo-config tabulate==0.9.0 # via -r requirements.in thesmuggler==1.0.1 # via -r requirements.in -ua-parser==0.18.0 # via user-agents update-checker==0.18.0 # via -r requirements.in urllib3==2.0.4 # via requests -user-agents==2.2.0 # via -r requirements.in validators==0.20.0 # via click-params werkzeug==2.3.7 # via -r requirements.in, flask wrapt==1.15.0 # via -r requirements.in, debtcollector