From 488138013202c6852aed0c1456eca6f39f20479c Mon Sep 17 00:00:00 2001 From: KF7EEL Date: Thu, 22 Apr 2021 18:54:08 -0700 Subject: [PATCH] add external applications page to dashboard --- dev/json_templates.py | 33 ++++++++++++ full_bridge.py | 4 +- scripts/dashboard/dashboard.py | 94 +++++++++++++++++++++++++++++++++- 3 files changed, 127 insertions(+), 4 deletions(-) diff --git a/dev/json_templates.py b/dev/json_templates.py index ffd49af..95bf444 100644 --- a/dev/json_templates.py +++ b/dev/json_templates.py @@ -40,6 +40,39 @@ print('msg_xfer') print(json_object) print('-----------------------------------------') +##msg_xfer_public = { +## 'mode':'msg_xfer', +## 'system_shortcut':'ABC', +## 'server_name':'Test HBlink Network', +## 'response_url':'http://localhost:8093/api/', +## 'auth_type':'public', +## 'auth_token':'1234567899', +## 'data':{ +## 1:{'source_id':1234, +## 'destination_id':3153591, +## 'slot':2, +## 'msg_type':'unit', +## 'msg_format':'motorola', +## 'message':'text of the message' +## }, +## 2:{'source_id':1234, +## 'destination_id':3153591, +## 'slot':2, +## 'msg_type':'unit', +## 'msg_format':'motorola', +## 'message':'text of the 2nd message' +## } +## +## } +## +##} +## +##json_object = json.dumps(msg_xfer_public, indent = 4) +##print('-----------------------------------------') +##print('msg_xfer public') +##print(json_object) +##print('-----------------------------------------') + app_request = { 'mode':'app', 'system_shortcut':'ABC', diff --git a/full_bridge.py b/full_bridge.py index 304c804..1f147c4 100644 --- a/full_bridge.py +++ b/full_bridge.py @@ -273,11 +273,11 @@ def send_app_request(url, message, source_id): def send_msg_xfer(url, user, password, message, source_id, dest_id): - url = url + '/msg_xfer' + url = url + '/api/msg_xfer' msg_xfer = { 'mode':'msg_xfer', 'system_shortcut':CONFIG['GPS_DATA']['MY_API_NAME'], - 'response_url':CONFIG['GPS_DATA']['DASHBOARD_URL'], + 'response_url':CONFIG['GPS_DATA']['DASHBOARD_URL'] + '/api', 'auth_type':'private', 'credentials': { 'user':user, diff --git a/scripts/dashboard/dashboard.py b/scripts/dashboard/dashboard.py index 67487e8..941ed0c 100644 --- a/scripts/dashboard/dashboard.py +++ b/scripts/dashboard/dashboard.py @@ -220,6 +220,71 @@ def help(): def about(): #return get_data() return render_template('about.html', title = dashboard_title, logo = logo, contact_name = contact_name, contact_call = contact_call, contact_email = contact_email, contact_website = contact_website) + +@app.route('/external_apps') +def external_apps(): + access_systems = ast.literal_eval(os.popen('cat ' + access_systems_file).read()) + msg_lst = '' + app_lst = '' + for i_msg in access_systems.items(): + if i_msg[1]['mode'] == 'msg_xfer': + msg_lst = msg_lst + ''' + +  ''' + i_msg[1]['network_name'] + ''' +  ?''' + str(i_msg[0]) + ''' + ''' + i_msg[1]['url'] + ''' + ''' + for i_app in access_systems.items(): + if i_app[1]['mode'] == 'app': + app_lst = app_lst + ''' + +  ''' + i_app[1]['app_name'] + ''' +  ?''' + str(i_app[0]) + ''' + ''' + i_app[1]['website'] + ''' + ''' + content = ''' +

 

+ +

External Networks/Servers

+ + + + + + + + ''' + msg_lst + ''' + +
+

Network/Server

+
+

Shortcut

+
+

URL

+
+

 

+

 External Applications

+ + + + + + + + ''' + app_lst + ''' + +
+

Application

+
+

Shortcut

+
+

Website

+
+

 

+ ''' +## content = 'yo' + return render_template('generic.html', title = dashboard_title, logo = logo, content = Markup(content)) + @app.route('/view_map') def view_map(): reload_time = request.args.get('reload') @@ -769,8 +834,33 @@ def api(api_mode=None): message = jsonify(message='System not authorized') return make_response(message, 401) if api_data['auth_type'] == 'public': - message = jsonify(message='Not implemented') - return make_response(message, 403) +## auth_file = ast.literal_eval(os.popen('cat ' + auth_token_file).read()) +## for token in auth_file: +## print() +## print(token) +## print(api_data['auth_token']) +## print() +## if token == api_data['auth_token']: +## +## auth_file.remove(api_data['auth_token']) +## for i in api_data['data'].items(): +## sms_data = i[1] +## if sms_data['slot'] == 0: +## send_slot = int(unit_sms_ts) - 1 +## if sms_data['slot'] == 1: +## send_slot = 0 +## if sms_data['slot'] == 2: +## send_slot = 1 +## send_sms(False, sms_data['destination_id'], 0000, 0000, 'unit', send_slot, sms_data['message']) +## new_auth_file = auth_file +## with open(auth_token_file, 'w') as auth_token: +## auth_token.write(str(auth_file)) +## auth_token.close() + + return jsonify( + mode=api_data['mode'], + status='GNot implemented yet', + ) else: message = jsonify(message='Not an authentication method') return make_response(message, 400)