diff --git a/.codio b/.codio index 5dcec0d..29af06a 100644 --- a/.codio +++ b/.codio @@ -4,6 +4,7 @@ "Run App": "cd /home/codio/workspace/location_app; . venv/bin/activate; flask run" }, "preview": { - "URL": "http://{{domain3000}}/" + "Current File": "http://{{domain}}/{{filepath}}", + "URL": "https://{{domain3000}}/" } } \ No newline at end of file diff --git a/location_app/app/configuration.cfg b/location_app/app/configuration.cfg index 01bc240..665b693 100644 --- a/location_app/app/configuration.cfg +++ b/location_app/app/configuration.cfg @@ -6,4 +6,5 @@ MQTT_TLS_ENABLED=True MQTT_TLS_INSECURE=True MQTT_TLS_CA_CERTS='mqtt.coventry.ac.uk.crt' MQTT_REFRESH_TIME=1.0 -TEMPLATES_AUTO_RELOAD=True \ No newline at end of file +TEMPLATES_AUTO_RELOAD=True +SECRET_KEY='\xd3\x889_\xad\x05$\x0c\xe3\x8fn\xfa\xaeQ\n\xfb\xc1\xc8\x07>\xe9\x97\x07*\r\x12\xcd\x0b\xd8\xa3' \ No newline at end of file diff --git a/location_app/app/functions/data_tools/data_getter.py b/location_app/app/functions/data_tools/data_getter.py index 747348f..312a5d9 100644 --- a/location_app/app/functions/data_tools/data_getter.py +++ b/location_app/app/functions/data_tools/data_getter.py @@ -45,7 +45,6 @@ def get_locations(): res = cur.execute(f"SELECT DISTINCT * From Location ORDER BY tid, timestamp;") for tid, batt, lon, lat, city, road, tst, in res: rtst = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(tst)) - locations.append([tid, batt, lon, lat, city, road, rtst]) - print(locations) + locations.append([tid, batt, lon, lat, city, road, rtst.split(" ")[0], rtst.split(" ")[1]]) return locations \ No newline at end of file diff --git a/location_app/app/routes/__init__.py b/location_app/app/routes/__init__.py index 2011db0..9c77759 100644 --- a/location_app/app/routes/__init__.py +++ b/location_app/app/routes/__init__.py @@ -1,4 +1,7 @@ -from .login import main_bl +from .main import main_bl +from .map import map_bl + def init_app(app): - app.register_blueprint(main_bl) \ No newline at end of file + app.register_blueprint(main_bl) + app.register_blueprint(map_bl, url_prefix="/map") \ No newline at end of file diff --git a/location_app/app/routes/login.py b/location_app/app/routes/login.py deleted file mode 100644 index 860fa6b..0000000 --- a/location_app/app/routes/login.py +++ /dev/null @@ -1,21 +0,0 @@ -from flask import Blueprint, render_template, request, url_for, escape, redirect -from app.functions.auth import password_check -from app.functions.data_tools import data_getter - -main_bl = Blueprint('main', __name__) - -@main_bl.route("/", methods = ["GET", "POST"]) -@main_bl.route("/index", methods = ["GET", "POST"]) -def login(): - if request.method == "POST": - username = request.form["username"] - password = request.form["password"] - status = password_check.username_and_password(username, password) - if status == "L": - return redirect(url_for("testt", username = username)) - elif status == "WP": - return render_template("index.html", error = 1) - elif status == "NO": - return render_template("index.html", error = 2) - else: - return render_template("index.html", error = 0) \ No newline at end of file diff --git a/location_app/app/routes/main.py b/location_app/app/routes/main.py new file mode 100644 index 0000000..4a8e7a9 --- /dev/null +++ b/location_app/app/routes/main.py @@ -0,0 +1,9 @@ +from flask import Blueprint, render_template, request, url_for, escape, redirect, session +from app.functions.auth import password_check +from app.functions.data_tools import data_getter + +main_bl = Blueprint('main', __name__) + +@main_bl.route("/", methods = ["GET", "POST"]) +def index(): + return render_template("main_index.html", locations = data_getter.get_locations(), username = session['username']) \ No newline at end of file diff --git a/location_app/app/routes/map.py b/location_app/app/routes/map.py new file mode 100644 index 0000000..a8e676e --- /dev/null +++ b/location_app/app/routes/map.py @@ -0,0 +1,8 @@ +from flask import Blueprint, render_template, request, session, url_for, escape, redirect +from app.functions.data_tools import data_getter + +map_bl = Blueprint('map', __name__) + +@map_bl.route("/", methods = ["GET", "POST"]) +def index(): + return render_template("map_index.html") \ No newline at end of file diff --git a/location_app/app/static/css/base.css b/location_app/app/static/css/base.css index 438954d..93d4d50 100644 --- a/location_app/app/static/css/base.css +++ b/location_app/app/static/css/base.css @@ -1,3 +1,17 @@ +* { + margin: 0; + padding: 0; +} body { - background-color: red; + background-image: url('../img/earth.jpg'); + background-repeat: no-repeat; + background-attachment: fixed; + background-size: cover; + font-family: Gill Sans, sans-serif; + font-variant: small-caps; + display: grid; + grid-template-columns: 0.5fr 9fr 0.5fr; + grid-template-rows: 1fr; + grid-template-areas: + '. container .'; } \ No newline at end of file diff --git a/location_app/app/static/css/main_index.css b/location_app/app/static/css/main_index.css new file mode 100644 index 0000000..d99ba32 --- /dev/null +++ b/location_app/app/static/css/main_index.css @@ -0,0 +1,69 @@ +.container { + background-color: white; + grid-area: container; + display: grid; + grid-template-columns: 1fr 4fr 4fr 4fr 4fr 1fr; + grid-template-rows: 1.5fr auto 1.5fr 5fr 1.5fr auto 1.5fr; + grid-template-areas: + '. . . . . .' + '. title title title title .' + '. . . . . .' + '. b_prof b_map b_test b_logo .' + '. . . . . .' + '. c_main c_main c_main c_main .' + '. . . . . .'; +} +.title { + grid-area: title; + display: grid; +} +.title_text { + margin: 20px; + justify-self: center; + align-self: center; + text-shadow: 0 1px 0 #ccc, + 0 2px 0 #c9c9c9, + 0 3px 0 #bbb, + 0 4px 0 #b9b9b9, + 0 5px 0 #aaa, + 0 6px 1px rgba(0,0,0,.1), + 0 0 5px rgba(0,0,0,.1), + 0 1px 3px rgba(0,0,0,.3), + 0 3px 5px rgba(0,0,0,.2), + 0 5px 10px rgba(0,0,0,.25), + 0 10px 10px rgba(0,0,0,.2), + 0 20px 20px rgba(0,0,0,.15); + font-size: 7vw; +} +.button_main { + text-align: center; + display: grid; +} +.button_main button { + justify-self: center; + align-self: center; + width: 80%; + font-size: 2vw; + border-radius: 10em; +} +.button_profile { + grid-area: b_prof; +} +.button_map { + grid-area: b_map; +} +.button_3 { + grid-area: b_test; +} +.button_logout { + grid-area: b_logo; +} +.content_main { + grid-area: c_main; +} +tr:nth-child(even) { + background-color: #00f0f0; +} +.table_main { + width: 100%; +} \ No newline at end of file diff --git a/location_app/app/static/css/map_index.css b/location_app/app/static/css/map_index.css new file mode 100644 index 0000000..e69de29 diff --git a/location_app/app/static/img/earth.jpg b/location_app/app/static/img/earth.jpg new file mode 100644 index 0000000..d667982 Binary files /dev/null and b/location_app/app/static/img/earth.jpg differ diff --git a/location_app/app/static/js/test.js b/location_app/app/static/js/test.js new file mode 100644 index 0000000..00a54ee --- /dev/null +++ b/location_app/app/static/js/test.js @@ -0,0 +1,45 @@ +var map; +var mapLat = 52.407633; +var mapLng = -1.496947; +var mapDefaultZoom = 12; + +function initialize_map() { + map = new ol.Map({ + target: "map", + layers: [ + new ol.layer.Tile({ + source: new ol.source.OSM({ + url: "https://a.tile.openstreetmap.org/{z}/{x}/{y}.png" + }) + }) + ], + view: new ol.View({ + center: ol.proj.fromLonLat([mapLng, mapLat]), + zoom: mapDefaultZoom + + }) + }); + } + +function add_map_point() { + for (i=0; i + {% block js %}{% endblock %} {% block title %}{% endblock %} - + {% block css %}{% endblock %} - - {% block body %}{% endblock %} - +{% block body %}{% endblock %} \ No newline at end of file diff --git a/location_app/app/templates/index.html b/location_app/app/templates/index.html deleted file mode 100644 index e272b52..0000000 --- a/location_app/app/templates/index.html +++ /dev/null @@ -1,21 +0,0 @@ -{% extends 'base.html' %} - -{% block title %} Trackmaster {% endblock %} - -{% block body %} - -{% if error == 1 %} -

WRONG PASSWORD!!!

-{% endif %} -{% if error == 2 %} -

WRONG TID!!!

-{% endif %} -
- - - - - -
- -{% endblock %} diff --git a/location_app/app/templates/index2.html b/location_app/app/templates/index2.html deleted file mode 100644 index 9e704e0..0000000 --- a/location_app/app/templates/index2.html +++ /dev/null @@ -1,19 +0,0 @@ -{% extends 'base.html' %} - - -{% block title %} " Insert title here " {% endblock %} - - -{% block body %} - -{% for idd in tids %} -

{{idd}}

-{% endfor %} -
- - -
- -{% endblock %} - - diff --git a/location_app/app/templates/main.html b/location_app/app/templates/main.html deleted file mode 100644 index 3e6bf08..0000000 --- a/location_app/app/templates/main.html +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - Trackmaster - - - - - - - - - - - - - - - - - {% for item in locations %} - - - - - - - - - - - - {% endfor %} -
Locations
IDBatteryLongitudeLatitudeCityRoadTST
{{ item[0] }}{{ item[1] }} %{{ item[2] }}{{ item[3] }}{{ item[4] }}{{ item[5] }}{{ item[6] }}
- - - diff --git a/location_app/app/templates/main_index.html b/location_app/app/templates/main_index.html new file mode 100644 index 0000000..e43ef95 --- /dev/null +++ b/location_app/app/templates/main_index.html @@ -0,0 +1,62 @@ +{% extends 'base.html' %} + +{% block title %} Main {% endblock %} + +{% block css %} + + + +{% endblock %} + +{% block body %} + +
+
+

Trackmaster

+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + + + + + + + + + + + + {% for item in locations %} {% if item[0] == username %} + + + + + + + + + + + {% endif %}{% endfor %} +
Locations
IDBatteryLongitudeLatitudeCityRoadDateTime
{{ item[0] }}{{ item[1] }} %{{ item[2] }}{{ item[3] }}{{ item[4] }}{{ item[5] }}{{ item[6] }}{{ item[7] }}
+
+
+ + + +{% endblock %} + + diff --git a/location_app/app/templates/map_index.html b/location_app/app/templates/map_index.html new file mode 100644 index 0000000..0047de5 --- /dev/null +++ b/location_app/app/templates/map_index.html @@ -0,0 +1,27 @@ +{% extends 'base.html' %} + +{% block title %} Main {% endblock %} + +{% block js %} + + + + +{% endblock %} + +{% block css %} + + + + +{% endblock %} + +{% block body %} + +
+
+ + +{% endblock %} + +