mirror of https://github.com/kf7eel/hbnet
bridge status, initial commit
This commit is contained in:
parent
625d8ceb87
commit
1d72354b12
|
|
@ -118,13 +118,14 @@ __email__ = 'kf7eel@qsl.net'
|
||||||
#### return config.build_config(cli_file)
|
#### return config.build_config(cli_file)
|
||||||
|
|
||||||
|
|
||||||
def send_unit_table(CONFIG, _data):
|
def send_unit_table(CONFIG, _data, _bridge_data):
|
||||||
user_man_url = CONFIG['WEB_SERVICE']['URL']
|
user_man_url = CONFIG['WEB_SERVICE']['URL']
|
||||||
shared_secret = str(sha256(CONFIG['WEB_SERVICE']['SHARED_SECRET'].encode()).hexdigest())
|
shared_secret = str(sha256(CONFIG['WEB_SERVICE']['SHARED_SECRET'].encode()).hexdigest())
|
||||||
sms_data = {
|
sms_data = {
|
||||||
'unit_table': CONFIG['WEB_SERVICE']['THIS_SERVER_NAME'],
|
'unit_table': CONFIG['WEB_SERVICE']['THIS_SERVER_NAME'],
|
||||||
'secret':shared_secret,
|
'secret':shared_secret,
|
||||||
'data': str(_data),
|
'data': str(_data),
|
||||||
|
'bridge_data': str(_bridge_data),
|
||||||
|
|
||||||
}
|
}
|
||||||
json_object = json.dumps(sms_data, indent = 4)
|
json_object = json.dumps(sms_data, indent = 4)
|
||||||
|
|
@ -592,7 +593,7 @@ def rule_timer_loop(unit_flood_time):
|
||||||
|
|
||||||
for unit in remove_list:
|
for unit in remove_list:
|
||||||
del UNIT_MAP[unit]
|
del UNIT_MAP[unit]
|
||||||
send_unit_table(CONFIG, UNIT_MAP)
|
send_unit_table(CONFIG, UNIT_MAP, BRIDGES)
|
||||||
|
|
||||||
logger.debug('Removed unit(s) %s from UNIT_MAP', remove_list)
|
logger.debug('Removed unit(s) %s from UNIT_MAP', remove_list)
|
||||||
|
|
||||||
|
|
|
||||||
52
web/app.py
52
web/app.py
|
|
@ -1158,6 +1158,37 @@ By using this service, you agree not to do anything malicious. You agree to use
|
||||||
def gateway_wiz_page(add_server):
|
def gateway_wiz_page(add_server):
|
||||||
return render_template('data_gateway_wizard.html', server = add_server)
|
return render_template('data_gateway_wizard.html', server = add_server)
|
||||||
|
|
||||||
|
@app.route('/bridge_status/<server>/<system>')
|
||||||
|
def bridge_tg_status(server, system):
|
||||||
|
server_bridges = Misc.query.filter_by(field_1='bridge_table_' + server).first()
|
||||||
|
BRIDGES = ast.literal_eval(server_bridges.field_2)
|
||||||
|
table_data = ''
|
||||||
|
for _bridge in BRIDGES:
|
||||||
|
for e in BRIDGES[_bridge]:
|
||||||
|
if system == e['SYSTEM']:
|
||||||
|
## print(e)
|
||||||
|
print(type(e['TIMER']))
|
||||||
|
print(datetime.datetime.fromtimestamp(e['TIMER']))
|
||||||
|
print()
|
||||||
|
if time.time() <= e['TIMER']:
|
||||||
|
exp = '''
|
||||||
|
<div class="alert alert-Success">
|
||||||
|
<strong>On</strong> <br /> ''' + str(datetime.datetime.fromtimestamp(e['TIMER'])).strftime(time_format) + '''
|
||||||
|
</div>
|
||||||
|
'''
|
||||||
|
elif time.time() > e['TIMER']:
|
||||||
|
exp = '''
|
||||||
|
<div class="alert alert-danger">
|
||||||
|
<strong>Off</strong>
|
||||||
|
</div>
|
||||||
|
'''
|
||||||
|
table_data = table_data + '<tr><td>' + _bridge + '</td><td>' + str(int_id(e['TGID'])) + '</td><td>' + exp + '</td></tr>'
|
||||||
|
|
||||||
|
## print(str((timedelta(seconds=e['TIMER']) + datetime.datetime.fromtimestamp(e['TIMER'])).strftime(time_format)))
|
||||||
|
|
||||||
|
|
||||||
|
return render_template('bridge_status.html', table_data = Markup(table_data), server = server, system = system)
|
||||||
|
|
||||||
@app.route('/generate_passphrase/pi-star', methods = ['GET'])
|
@app.route('/generate_passphrase/pi-star', methods = ['GET'])
|
||||||
@login_required
|
@login_required
|
||||||
def gen_pi_star():
|
def gen_pi_star():
|
||||||
|
|
@ -1235,6 +1266,17 @@ By using this service, you agree not to do anything malicious. You agree to use
|
||||||
if i.ip == '':
|
if i.ip == '':
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
tool_menu = '''
|
||||||
|
<div class="dropdown">
|
||||||
|
<button type="button" class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown">
|
||||||
|
Tools
|
||||||
|
</button>
|
||||||
|
<ul class="dropdown-menu">
|
||||||
|
<li><a class="dropdown-item" href="/talkgroups/''' + i.name + '''">Available Talkgroups</a></li>
|
||||||
|
<li><a class="dropdown-item" href="''' + i.dash_url + '''">Dashboard</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
'''
|
||||||
svr_content = svr_content + '''
|
svr_content = svr_content + '''
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header" style="text-align: center;"><h3>''' + i.name + '''</h3></div>
|
<div class="card-header" style="text-align: center;"><h3>''' + i.name + '''</h3></div>
|
||||||
|
|
@ -1243,10 +1285,7 @@ By using this service, you agree not to do anything malicious. You agree to use
|
||||||
''' + svr_status + '''
|
''' + svr_status + '''
|
||||||
<div style="max-width:200px; word-wrap:break-word; text-align: center;">''' + i.public_notes + '''</div>
|
<div style="max-width:200px; word-wrap:break-word; text-align: center;">''' + i.public_notes + '''</div>
|
||||||
<p> </p>
|
<p> </p>
|
||||||
<a href="/talkgroups/''' + i.name + '''"><button type="button" class="btn btn-primary btn-block" >Available Talkgroups</button></a>
|
''' + tool_menu + '''
|
||||||
<hr />
|
|
||||||
<a href="''' + i.dash_url + '''"><button type="button" class="btn btn-success btn-block" >Dashboard</button></a>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -5312,7 +5351,6 @@ Name: <strong>''' + p.name + '''</strong> - Port: <strong>''' + str(
|
||||||
'''
|
'''
|
||||||
for s in all_s:
|
for s in all_s:
|
||||||
tool_menu = '''
|
tool_menu = '''
|
||||||
|
|
||||||
<div class="dropdown">
|
<div class="dropdown">
|
||||||
<button type="button" class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown">
|
<button type="button" class="btn btn-primary dropdown-toggle" data-bs-toggle="dropdown">
|
||||||
Tools
|
Tools
|
||||||
|
|
@ -5322,7 +5360,6 @@ Name: <strong>''' + p.name + '''</strong> - Port: <strong>''' + str(
|
||||||
<li><a class="dropdown-item" href="/manage_servers?server=''' + s.name + '''&server_command=restart">Restart Server</a></li>
|
<li><a class="dropdown-item" href="/manage_servers?server=''' + s.name + '''&server_command=restart">Restart Server</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
'''
|
'''
|
||||||
try:
|
try:
|
||||||
if time.time() - ping_list[s.name] < 30:
|
if time.time() - ping_list[s.name] < 30:
|
||||||
|
|
@ -7660,9 +7697,12 @@ Name: <strong>''' + p.name + '''</strong> - Port: <strong>''' + str(
|
||||||
try:
|
try:
|
||||||
delete_misc_field_1('unit_table_' + hblink_req['unit_table'])
|
delete_misc_field_1('unit_table_' + hblink_req['unit_table'])
|
||||||
misc_add('unit_table_' + hblink_req['unit_table'], str(hblink_req['data']), '', '', 0, 0, 0, 0, False, False)
|
misc_add('unit_table_' + hblink_req['unit_table'], str(hblink_req['data']), '', '', 0, 0, 0, 0, False, False)
|
||||||
|
delete_misc_field_1('bridge_table_' + hblink_req['unit_table'])
|
||||||
|
misc_add('bridge_table_' + hblink_req['unit_table'], str(hblink_req['bridge_data']), '', '', 0, 0, 0, 0, False, False)
|
||||||
except:
|
except:
|
||||||
print('entry error')
|
print('entry error')
|
||||||
misc_add('unit_table_' + hblink_req['unit_table'], str(hblink_req['data']), '', '', 0, 0, 0, 0, False, False)
|
misc_add('unit_table_' + hblink_req['unit_table'], str(hblink_req['data']), '', '', 0, 0, 0, 0, False, False)
|
||||||
|
misc_add('bridge_table_' + hblink_req['unit_table'], str(hblink_req['bridge_data']), '', '', 0, 0, 0, 0, False, False)
|
||||||
## unit_table_add(hblink_req['data'])
|
## unit_table_add(hblink_req['data'])
|
||||||
response = 'rcvd'
|
response = 'rcvd'
|
||||||
elif 'known_services' in hblink_req:
|
elif 'known_services' in hblink_req:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue