diff --git a/web/app.py b/web/app.py index 0c3f328..eaf8dac 100644 --- a/web/app.py +++ b/web/app.py @@ -292,6 +292,7 @@ def create_app(): report_clients =db.Column(db.String(100), nullable=False, server_default='127.0.0.1') unit_time = db.Column(db.Integer(), primary_key=False, server_default='10080') notes = db.Column(db.String(100), nullable=False, server_default='') + dash_url = db.Column(db.String(100), nullable=True, server_default='https://hbnet.xyz') class MasterList(db.Model): __tablename__ = 'master_list' @@ -375,7 +376,7 @@ def create_app(): off = db.Column(db.String(100), nullable=False, server_default='') reset = db.Column(db.String(100), nullable=False, server_default='') server = db.Column(db.String(100), nullable=False, server_default='') - public_list = db.Column(db.Boolean(), nullable=False, server_default='0') +## public_list = db.Column(db.Boolean(), nullable=False, server_default='0') proxy = db.Column(db.Boolean(), nullable=False, server_default='0') class BridgeList(db.Model): @@ -640,6 +641,27 @@ def create_app(): @login_required def gen(): #print(str(gen_passphrase(3153591))) #(int(i[0]))) + sl = ServerList.query.all() + svr_content = '' + for i in sl: + svr_content = svr_content + ''' +

 

+ + + + + + + + + + + + +
+

Server: ''' + i.name + '''

+
Available Talkgroups
Dashboard
+''' try: #content = Markup('The HTML String') #user_id = request.args.get('user_id') @@ -651,6 +673,7 @@ def create_app(): ## print(request.args.get('mode')) ## if request.args.get('mode') == 'generated': #print(id_dict) + content = '\n' for i in id_dict.items(): if isinstance(i[1], int) == True and i[1] != 0: @@ -732,15 +755,9 @@ def create_app(): #return str(content) - return render_template('view_passphrase.html', markup_content = Markup(content)) + return render_template('view_passphrase.html', passphrase_content = Markup(content), server_content = Markup(svr_content)) -## # The Members page is only accessible to authenticated users via the @login_required decorator -## @app.route('/members') -## @login_required # User must be authenticated -## def member_page(): -## content = 'Mem only' -## return render_template('flask_user_layout.html', markup_content = content) - + @app.route('/update_ids', methods=['POST', 'GET']) @login_required # User must be authenticated def update_info(): @@ -1605,6 +1622,140 @@ def create_app(): ## content = 'hji' return render_template('flask_user_layout.html', markup_content = Markup(content)) + + @app.route('/tg/') #, methods=['POST', 'GET']) +## @login_required + def tg_details(name): + tg_d = BridgeList.query.filter_by(bridge_name=name).first() + content = ''' + + + + + + + + + + + +
+

''' + tg_d.bridge_name + '''

+
TG #: ''' + str(tg_d.tg) + '''
 ''' + tg_d.description + '''
+

 

''' + return render_template('flask_user_layout.html', markup_content = Markup(content)) + + @app.route('/talkgroups') +## @login_required + def tg_list(): + cbl = BridgeList.query.filter_by(public_list=True).all() + print(cbl) + content = ''' +

 

+

Note: Talkgroups listed here may not be available on all servers. See Passphrases for complete list of talkgroup availability per server.

+ + + + + + + ''' + for i in cbl: + content = content + ''' + + + + +''' + content = content + ''' + +
 Name TG Description
 ''' + i.bridge_name + ''' ''' + str(i.tg) + ''' ''' + i.description + '''
+''' + return render_template('flask_user_layout.html', markup_content = Markup(content)) + + @app.route('/talkgroups/') #, methods=['POST', 'GET']) + @login_required + def tg_list_server(server): + svr = ServerList.query.filter_by(name=server).first() + content = ''' +

 

+ + + + + ''' + m_list = MasterList.query.filter_by(server=server).filter_by(public_list=True).all() + p_list = ProxyList.query.filter_by(server=server).filter_by(public_list=True).all() + tg_list = '' + for m in m_list: + br = BridgeRules.query.filter_by(server=server).filter_by(system_name=m.name).all() + print(br) +## for t in br: +## print(t.tg) + for b in br: + print(b.bridge_name) + bl = BridgeList.query.filter_by(bridge_name=b.bridge_name).first() +## print(bl) + if m.name == b.system_name and m.server == b.server and bl.public_list == True: +## print(b.bridge_name) + tg_list = tg_list + ''' + + + + ''' + content = content + ''' +''' + tg_list = '' + + for p in p_list: + br = BridgeRules.query.filter_by(server=server).filter_by(system_name=p.name).all() + for b in br: + bl = BridgeList.query.filter_by(bridge_name=b.bridge_name).first() +## print(bl.bridge_name) + if p.name == b.system_name and p.server == b.server and bl.public_list == True: +## print(b.bridge_name) + tg_list = tg_list + ''' + + + + ''' + content = content + ''' +''' + tg_list = '' + content = content + ''' + +
 

Server: ''' + svr.name + '''  -  IP/Host: ''' + str(svr.ip) + '''

 ''' + b.bridge_name + ''' ''' + str(b.tg) + ''' ''' + bl.description + '''
''' + ''' + + + + +
Name: ''' + m.name + '''  -  Port: ''' + str(m.port) + '''
+ + + + + + +''' + tg_list + ''' + +
 Name TG Description
''' + '''
 ''' + b.bridge_name + ''' ''' + str(b.tg) + ''' ''' + bl.description + '''
''' + ''' + + + + +
Name: ''' + p.name + '''  -  Port: ''' + str(p.external_port) + '''
+ + + + + + +''' + tg_list + ''' + +
 Name TG Description
''' + '''
+

 

''' + + return render_template('flask_user_layout.html', markup_content = Markup(content)) @app.route('/test') @@ -2011,7 +2162,7 @@ def create_app(): timeout = int(s.timeout) if s.proxy == True: p = ProxyList.query.filter_by(server=_name).filter_by(name=s.system_name).first() - print(p.external_port) +## print(p.external_port) n_systems = p.internal_stop_port - p.internal_start_port n_count = 0 while n_count < n_systems: @@ -2162,7 +2313,7 @@ def create_app(): # print(master_config_list) return master_config_list - def add_system_rule(_bridge_name, _system_name, _ts, _tg, _active, _timeout, _to_type, _on, _off, _reset, _server, _public_list): + def add_system_rule(_bridge_name, _system_name, _ts, _tg, _active, _timeout, _to_type, _on, _off, _reset, _server): proxy = ProxyList.query.filter_by(server=_server).filter_by(name=_system_name).first() is_proxy = False try: @@ -2182,13 +2333,12 @@ def create_app(): off = _off, reset = _reset, server = _server, - public_list = _public_list, proxy = is_proxy ) db.session.add(add_system) db.session.commit() - def edit_system_rule(_bridge_name, _system_name, _ts, _tg, _active, _timeout, _to_type, _on, _off, _reset, _server, _public_list): + def edit_system_rule(_bridge_name, _system_name, _ts, _tg, _active, _timeout, _to_type, _on, _off, _reset, _server): proxy = ProxyList.query.filter_by(server=_server).filter_by(name=_system_name).first() is_proxy = False try: @@ -2197,10 +2347,10 @@ def create_app(): except: pass r = BridgeRules.query.filter_by(system_name=_system_name).filter_by(bridge_name=_bridge_name).first() - print('---') - print(_system_name) - print(_bridge_name) - print(r) +## print('---') +## print(_system_name) +## print(_bridge_name) +## print(r) ## for i in r: ## print(i.name) ## add_system = BridgeRules( @@ -2215,7 +2365,7 @@ def create_app(): r.off = _off r.reset = _reset r.server = _server - r.public_list = _public_list + #r.public_list = _public_list r.proxy = is_proxy ## db.session.add(add_system) db.session.commit() @@ -2232,7 +2382,7 @@ def create_app(): db.session.commit() - def server_edit(_name, _secret, _ip, _port, _global_path, _global_ping_time, _global_max_missed, _global_use_acl, _global_reg_acl, _global_sub_acl, _global_tg1_acl, _global_tg2_acl, _ai_subscriber_file, _ai_try_download, _ai_path, _ai_peer_file, _ai_tgid_file, _ai_peer_url, _ai_subs_url, _ai_stale, _um_shorten_passphrase, _um_burn_file, _report_enable, _report_interval, _report_port, _report_clients, _unit_time, _notes): + def server_edit(_name, _secret, _ip, _port, _global_path, _global_ping_time, _global_max_missed, _global_use_acl, _global_reg_acl, _global_sub_acl, _global_tg1_acl, _global_tg2_acl, _ai_subscriber_file, _ai_try_download, _ai_path, _ai_peer_file, _ai_tgid_file, _ai_peer_url, _ai_subs_url, _ai_stale, _um_shorten_passphrase, _um_burn_file, _report_enable, _report_interval, _report_port, _report_clients, _unit_time, _notes, _dash_url): s = ServerList.query.filter_by(name=_name).first() # print(_name) if _secret == '': @@ -2269,6 +2419,7 @@ def create_app(): s.report_clients = _report_clients s.unit_time = int(_unit_time) s.notes = _notes + s.dash_url = _dash_url db.session.commit() def master_delete(_mode, _server, _name): @@ -2452,7 +2603,7 @@ def create_app(): db.session.commit() - def server_add(_name, _secret, _ip, _port, _global_path, _global_ping_time, _global_max_missed, _global_use_acl, _global_reg_acl, _global_sub_acl, _global_tg1_acl, _global_tg2_acl, _ai_subscriber_file, _ai_try_download, _ai_path, _ai_peer_file, _ai_tgid_file, _ai_peer_url, _ai_subs_url, _ai_stale, _um_shorten_passphrase, _um_burn_file, _report_enable, _report_interval, _report_port, _report_clients, _unit_time, _notes): + def server_add(_name, _secret, _ip, _port, _global_path, _global_ping_time, _global_max_missed, _global_use_acl, _global_reg_acl, _global_sub_acl, _global_tg1_acl, _global_tg2_acl, _ai_subscriber_file, _ai_try_download, _ai_path, _ai_peer_file, _ai_tgid_file, _ai_peer_url, _ai_subs_url, _ai_stale, _um_shorten_passphrase, _um_burn_file, _report_enable, _report_interval, _report_port, _report_clients, _unit_time, _notes, _dash_url): add_server = ServerList( name = _name, secret = hashlib.sha256(_secret.encode()).hexdigest(), @@ -2486,7 +2637,8 @@ def create_app(): report_port = _report_port, report_clients = _report_clients, unit_time = int(_unit_time), - notes = _notes + notes = _notes, + dash_url = _dash_url ) db.session.add(add_server) db.session.commit() @@ -2679,13 +2831,13 @@ def create_app():

Redirecting in 3 seconds.

''' else: - server_add(request.form.get('server_name'), request.form.get('server_secret'), request.form.get('server_ip'), _port, request.form.get('global_path'), _global_ping_time, _global_max_missed, _global_use_acl, request.form.get('reg_acl'), request.form.get('sub_acl'), request.form.get('global_ts1_acl'), request.form.get('global_ts2_acl'), request.form.get('sub_file'), _ai_try_download, request.form.get('aliases_path'), request.form.get('peer_file'), request.form.get('tgid_file'), request.form.get('peer_url'), request.form.get('sub_url'), _ai_stale, _um_shorten_passphrase, request.form.get('um_burn_file'), _report_enabled, _report_interval, _report_port, request.form.get('report_clients'), request.form.get('unit_time'), request.form.get('notes')) + server_add(request.form.get('server_name'), request.form.get('server_secret'), request.form.get('server_ip'), _port, request.form.get('global_path'), _global_ping_time, _global_max_missed, _global_use_acl, request.form.get('reg_acl'), request.form.get('sub_acl'), request.form.get('global_ts1_acl'), request.form.get('global_ts2_acl'), request.form.get('sub_file'), _ai_try_download, request.form.get('aliases_path'), request.form.get('peer_file'), request.form.get('tgid_file'), request.form.get('peer_url'), request.form.get('sub_url'), _ai_stale, _um_shorten_passphrase, request.form.get('um_burn_file'), _report_enabled, _report_interval, _report_port, request.form.get('report_clients'), request.form.get('unit_time'), request.form.get('notes'), request.form.get('dash_url')) content = '''

Server saved.

Redirecting in 3 seconds.

''' if request.args.get('save_mode') == 'edit': ## print(request.args.get('server')) - server_edit(request.args.get('server'), request.form.get('server_secret'), request.form.get('server_ip'), _port, request.form.get('global_path'), _global_ping_time, _global_max_missed, _global_use_acl, request.form.get('reg_acl'), request.form.get('sub_acl'), request.form.get('global_ts1_acl'), request.form.get('global_ts2_acl'), request.form.get('sub_file'), _ai_try_download, request.form.get('aliases_path'), request.form.get('peer_file'), request.form.get('tgid_file'), request.form.get('peer_url'), request.form.get('sub_url'), _ai_stale, _um_shorten_passphrase, request.form.get('um_burn_file'), _report_enabled, _report_interval, _report_port, request.form.get('report_clients'), request.form.get('unit_time'), request.form.get('notes')) + server_edit(request.args.get('server'), request.form.get('server_secret'), request.form.get('server_ip'), _port, request.form.get('global_path'), _global_ping_time, _global_max_missed, _global_use_acl, request.form.get('reg_acl'), request.form.get('sub_acl'), request.form.get('global_ts1_acl'), request.form.get('global_ts2_acl'), request.form.get('sub_file'), _ai_try_download, request.form.get('aliases_path'), request.form.get('peer_file'), request.form.get('tgid_file'), request.form.get('peer_url'), request.form.get('sub_url'), _ai_stale, _um_shorten_passphrase, request.form.get('um_burn_file'), _report_enabled, _report_interval, _report_port, request.form.get('report_clients'), request.form.get('unit_time'), request.form.get('notes'), request.form.get('dash_url')) content = '''

Server changed.

Redirecting in 3 seconds.

''' @@ -2716,6 +2868,10 @@ def create_app():   + Dashboard URL: + +  Host (IP/DNS, for listing on passphrase page):   @@ -2912,6 +3068,10 @@ def create_app():   + Dashboard URL: + +  Host (IP/DNS):   @@ -4583,12 +4743,12 @@ def create_app(): #Rules elif request.args.get('save_rule'): - public_list = False +## public_list = False active = False if request.form.get('active_dropdown') == 'True': active = True if request.args.get('save_rule') == 'new': - add_system_rule(request.form.get('bridge_dropdown'), request.form.get('system_text'), request.form.get('ts_dropdown'), request.form.get('tgid'), active, request.form.get('timer_time'), request.form.get('type_dropdown'), request.form.get('on'), request.form.get('off'), request.form.get('reset'), request.args.get('server'), public_list) + add_system_rule(request.form.get('bridge_dropdown'), request.form.get('system_text'), request.form.get('ts_dropdown'), request.form.get('tgid'), active, request.form.get('timer_time'), request.form.get('type_dropdown'), request.form.get('on'), request.form.get('off'), request.form.get('reset'), request.args.get('server')) content = '''

Bridge (talkgroup) rule saved.

Redirecting in 3 seconds.

''' @@ -4736,11 +4896,11 @@ def create_app(): content = br_view elif request.args.get('edit_rule') == 'save' and request.args.get('bridge_edit'): - public_list = False +## public_list = False active = False if request.form.get('active_dropdown') == 'True': active = True - edit_system_rule(request.args.get('bridge_edit'), request.args.get('system'), request.form.get('ts_dropdown'), request.form.get('tgid'), active, request.form.get('timer_time'), request.form.get('type_dropdown'), request.form.get('on'), request.form.get('off'), request.form.get('reset'), request.args.get('server'), public_list) + edit_system_rule(request.args.get('bridge_edit'), request.args.get('system'), request.form.get('ts_dropdown'), request.form.get('tgid'), active, request.form.get('timer_time'), request.form.get('type_dropdown'), request.form.get('on'), request.form.get('off'), request.form.get('reset'), request.args.get('server')) content = '''

System rule changed.

Redirecting in 3 seconds.

''' diff --git a/web/templates/flask_user_layout.html b/web/templates/flask_user_layout.html index 21893ba..92b1598 100644 --- a/web/templates/flask_user_layout.html +++ b/web/templates/flask_user_layout.html @@ -34,11 +34,12 @@

Logo

{{title}}


- +
+ {% if not call_or_get(current_user.is_authenticated) %} @@ -52,7 +53,7 @@ {% endif %} - + @@ -63,7 +64,7 @@ {% if call_or_get(current_user.is_authenticated) %} {% if call_or_get(current_user.has_roles('Admin')) %} -
HomeTalkgroupsRegister Sign inHelpView Passphrase(s)Passphrase(s) Edit {{ current_user.username or current_user.email }} Sign out
+
diff --git a/web/templates/view_passphrase.html b/web/templates/view_passphrase.html index aaf231e..52ef2bc 100644 --- a/web/templates/view_passphrase.html +++ b/web/templates/view_passphrase.html @@ -6,25 +6,10 @@ -
Manage Servers
- - - - - - - - - - - - - - - -
Name:My Server
Host/IP:127.0.0.1
Port:62030
+{{server_content}}
{{markup_content}} +{{passphrase_content}}