From e362fa73205ca717f59e870af8e6112c9a852b41 Mon Sep 17 00:00:00 2001 From: KF7EEL Date: Wed, 30 Dec 2020 09:26:41 -0800 Subject: [PATCH] update web dashboard, add template --- scripts/dashboard/dashboard.py | 145 ++++++++++-------- .../dashboard/dashboard_settings-SAMPLE.py | 27 ++++ scripts/dashboard/templates/index.html | 27 ++++ 3 files changed, 136 insertions(+), 63 deletions(-) create mode 100644 scripts/dashboard/dashboard_settings-SAMPLE.py create mode 100644 scripts/dashboard/templates/index.html diff --git a/scripts/dashboard/dashboard.py b/scripts/dashboard/dashboard.py index b90b133..2eb173a 100644 --- a/scripts/dashboard/dashboard.py +++ b/scripts/dashboard/dashboard.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python -# ############################################################################### # HBLink - Copyright (C) 2020 Cortney T. Buffington, N0MJS # GPS/Data - Copyright (C) 2020 Eric Craw, KF7EEL @@ -23,75 +21,96 @@ This is a web dashboard for the GPS/Data application. ''' -from flask import Flask +from flask import Flask, render_template import ast, os +from dashboard_settings import * app = Flask(__name__) -dash_entries = ast.literal_eval(os.popen('cat /tmp/gps_data_user_loc.txt').read()) -#dash_bb = ast.literal_eval(os.popen('cat /tmp/gps_data_user_bb.txt').read()) -def get_data(): - dash_loc = ast.literal_eval(os.popen('cat /tmp/gps_data_user_loc.txt').read()) - dash_bb = ast.literal_eval(os.popen('cat /tmp/gps_data_user_bb.txt').read()) - tmp_bb = '' - tmp_loc = '' - tbl_hdr = ''' + +tbl_hdr = ''' ''' - tbl_ftr = ''' +tbl_ftr = '''
''' - bb_hdr = ''' - - -

 Callsign 

- - -

 DMR ID 

- - -

 Bulletin 

- - -

 Local Time 

- - -''' - loc_hdr = ''' - - -

 Callsign 

- - -

 Latitude 

- - -

 Longitude 

- - -

 Local Time 

- - -''' - - for e in dash_bb: - tmp_bb = tmp_bb + ''' - ''' + e['call'] + '''  -''' + str(e['dmr_id']) + ''' - ''' + e['bulliten'] + '''  - ''' + e['time'] + '''  -''' - for e in dash_loc: - tmp_loc = tmp_loc + ''' - ''' + e['call'] + '''  - ''' + str(e['lat']) + '''  - ''' + str(e['lon']) + '''  - ''' + e['time'] + '''  -''' - return str('

Bulletin Board

' + tbl_hdr + bb_hdr + tmp_bb + tbl_ftr + str('

Positions Received

') + tbl_hdr + loc_hdr + tmp_loc + tbl_ftr) + +def get_loc_data(): + try: + dash_loc = ast.literal_eval(os.popen('cat /tmp/gps_data_user_loc.txt').read()) + tmp_loc = '' + loc_hdr = ''' + + +

 Callsign 

+ + +

 Latitude 

+ + +

 Longitude 

+ + +

 Local Time 

+ + + ''' + for e in dash_loc: + tmp_loc = tmp_loc + ''' + ''' + e['call'] + ''' +  ''' + str(e['lat']) + '''  +  ''' + str(e['lon']) + '''  +  ''' + e['time'] + '''  + ''' + return str(str('

Positions Received

') + tbl_hdr + loc_hdr + tmp_loc + tbl_ftr) + except: + return str('

No data

') + + +def get_bb_data(): + try: + dash_bb = ast.literal_eval(os.popen('cat /tmp/gps_data_user_bb.txt').read()) + tmp_bb = '' + + bb_hdr = ''' + + +

 Callsign 

+ + +

 DMR ID 

+ + +

 Bulletin 

+ + +

 Local Time 

+ + + ''' + + for e in dash_bb: + tmp_bb = tmp_bb + ''' +  ''' + e['call'] + '''  + ''' + str(e['dmr_id']) + ''' +  ''' + e['bulliten'] + '''  +  ''' + e['time'] + '''  + ''' + + return str('

Bulletin Board

' + tbl_hdr + bb_hdr + tmp_bb + tbl_ftr) + except: + return str('

No data

') @app.route('/') -def dash(): - #return 'Hello, World!' - return get_data() +def index(): + #return get_data() + return render_template('index.html', title = dashboard_title, logo = logo) +@app.route('/bulletin_board') +def dash_bb(): + return get_bb_data() + #return render_template('index.html', data = str(get_data())) +@app.route('/positions') +def dash_loc(): + return get_loc_data() + #return render_template('index.html', data = str(get_data())) diff --git a/scripts/dashboard/dashboard_settings-SAMPLE.py b/scripts/dashboard/dashboard_settings-SAMPLE.py new file mode 100644 index 0000000..c90b23d --- /dev/null +++ b/scripts/dashboard/dashboard_settings-SAMPLE.py @@ -0,0 +1,27 @@ +############################################################################### +# HBLink - Copyright (C) 2020 Cortney T. Buffington, N0MJS +# GPS/Data - Copyright (C) 2020 Eric Craw, KF7EEL +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +############################################################################### + +''' +Settings for web dashboard. +''' + +# Title of the Dashboard +dashboard_title = 'HBLink3 D-APRS Dashboard' +# Logo used on dashboard page +logo = 'https://raw.githubusercontent.com/kf7eel/hblink3/gps/HBlink.png' diff --git a/scripts/dashboard/templates/index.html b/scripts/dashboard/templates/index.html new file mode 100644 index 0000000..c4d6ab6 --- /dev/null +++ b/scripts/dashboard/templates/index.html @@ -0,0 +1,27 @@ + + + + + + {{title}} + + + +

Logo

+

{{title}}

+
+

+

+ +
+
Dashboard created by KF7EEL - https://github.com/kf7eel/hblink3
+

HBLink created by N0MJS.
HBLink GitHub page

+