add: notification in viewer when error appears && api requests exception && new map-style (preparing for new update) && buttons color change

This commit is contained in:
te5154c
2024-02-28 00:51:08 +03:00
parent ce41b31331
commit bc8ca01729
7 changed files with 38 additions and 7 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ Project based on [Virtual Air Traffic Simulation Network (VATSIM) API](https://v
Written in Python 3.8.18 + JS (JQuery framework) + Boostrap
## Startup
For run application on your own machine, you must install docker. Then just one command in the "src" folder with the project source code:
To run application on your own machine, you must install docker. Then just one command in the "src" folder with the project source code:
```bash
docker compose up
+2 -2
View File
@@ -22,9 +22,9 @@ def request_handler():
try:
return requests.get(f"{VATSIM_API_URL}{request_string}").json()
except requests.exceptions.JSONDecodeError:
return jsonify({"result": "not found"})
return jsonify({"result": "error", "message": "Something went wrong. Report that error please"})
return jsonify({"result": "not found"})
return jsonify({"result": "not found", "message": "Not found"})
@app.route("/<int:cid>/")
+4
View File
@@ -6,3 +6,7 @@
.fox_active, .fox_atc_active {
background-color: #dee2e6 !important;
}
#notification_wrapper {
display: none;
}
+11 -3
View File
@@ -2,8 +2,10 @@
let userSession = {};
fetch(ATC_API_URL, {}).then(response => response.json()).then(result => {
if (result && result["result"] == "not found")
return
if (result && (result["result"] == "not found" || result["result"] == "error")) {
showAlert("Error while getting ATC information", result["message"]);
return;
}
for (let session of result["items"]) {
// Separate each session by it's connection ID
@@ -143,7 +145,7 @@ function showFlight(flight) {
// Function to show ATC session
function showSession(session) {
if (!session) return;
console.log(session);
$(".atc_callsign").text(session["connection_id"]["callsign"]);
$(".atc_start_time").text(session["connection_id"]["start"].replace("T", " "));
$(".atc_end_time").text(session["connection_id"]["end"].replace("T", " "));
@@ -153,3 +155,9 @@ function showSession(session) {
$(".atc_transfers").text(session["handoffsinitiated"]);
$(".atc_received").text(session["handoffsreceived"]);
}
function showAlert(title, message) {
$("#notification_wrapper").css("display", "block");
$("#notification_title").text(title);
$("#notification_message").text(message);
}
+12
View File
@@ -18,7 +18,19 @@
{% block header_css %}{% endblock %}
</head>
<style>
.btn-outline-primary:hover, .btn-outline-primary:active {
color: white !important;
background-color: var(--main-rgb) !important;
border-color: var(--main-rgb) !important;
}
.btn-outline-primary {
border-color: var(--main-rgb);
color: var(--main-rgb);
}
:root {
--main-rgb: #FA8232;
--bs-primary-rgb: 250, 130, 50
}
</style>
+1 -1
View File
@@ -7,7 +7,7 @@
<p class="col-md-8 fs-4">See your detailed profile statistic</p>
<div class="d-flex" role="search">
<input class="fox_input form-control me-2" type="number" placeholder="100000" aria-label="CID">
<button class="fox_submit btn btn-outline-success" type="submit">Search</button>
<button class="fox_submit btn btn-outline-primary" type="submit">Search</button>
</div>
<p class="fox_message text-primary col-md-8 fs-4"></p>
</div>
+7
View File
@@ -6,6 +6,13 @@
{% endblock %}
{% block content %}
<div class="mb-5">
<div id="notification_wrapper">
<div class="mb-4 alert alert-warning" role="alert">
<h4 id="notification_title"></h4>
<span id="notification_message"></span>
</div>
</div>
<h2 class="text-center text-primary mb-4">{{user["id"]}}</h2>
<p class="fs-4 text-secondary">Date of registration: <span class="date_registration"></span></p>
</div>