From 294b5fe874c97470d9f13527d132f2fa64d331e0 Mon Sep 17 00:00:00 2001 From: Aaron Shaw Date: Mon, 26 Jun 2023 21:55:05 +0100 Subject: [PATCH] feat: show error page when trying to claim on dashboard and using balenacloud - add check for nebra fleets - if not in nebra fleet (i.e. running on balenacloud or own openbalena instance) then when clicking claim on dashboard it goes to a specific error page Closes: #618 --- MANIFEST.in | 2 ++ hw_diag/tasks.py | 3 ++- hw_diag/templates/openfleet.html | 19 +++++++++++++++++++ hw_diag/templates/template_hyper.html | 7 ++++++- hw_diag/views/auth.py | 10 ++++++++++ poetry.lock | 8 ++++---- pyproject.toml | 2 +- 7 files changed, 44 insertions(+), 7 deletions(-) create mode 100644 hw_diag/templates/openfleet.html diff --git a/MANIFEST.in b/MANIFEST.in index a9d3e5c9..42fc2dbf 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -88,6 +88,7 @@ include hw_diag/templates/device_info.html include hw_diag/templates/helium_info.html include hw_diag/templates/login_form.html include hw_diag/templates/myst.html +include hw_diag/templates/openfleet.html include hw_diag/templates/password_change_form.html include hw_diag/templates/password_reset.html include hw_diag/templates/reconfigure_countdown.html @@ -95,6 +96,7 @@ include hw_diag/templates/template_hyper.html include hw_diag/templates/thix_dashboard.html include hw_diag/templates/thix_error.html include hw_diag/templates/thix_onboard.html +include hw_diag/templates/thix_set_region.html include hw_diag/templates/thix_setup.html include hw_diag/templates/ttn_config.html include hw_diag/templates/upgrade.html diff --git a/hw_diag/tasks.py b/hw_diag/tasks.py index a2592488..cff54efb 100644 --- a/hw_diag/tasks.py +++ b/hw_diag/tasks.py @@ -14,7 +14,7 @@ from hw_diag.utilities.gcs_shipper import upload_diagnostics from hw_diag.diagnostics.gateway_diagnostics import GatewayDiagnostics from hm_pyhelper.diagnostics import DiagnosticsReport -from hm_pyhelper.sbc import is_commercial_fleet +from hm_pyhelper.sbc import is_commercial_fleet, is_nebra_fleet log = logging.getLogger() @@ -51,6 +51,7 @@ def perform_hw_diagnostics(ship=False): # noqa: C901 diagnostics['PK'] = public_keys['key'] diagnostics['AN'] = public_keys['name'] diagnostics['commercial_fleet'] = is_commercial_fleet() + diagnostics['nebra_fleet'] = is_nebra_fleet() set_diagnostics_bt_lte(diagnostics) diff --git a/hw_diag/templates/openfleet.html b/hw_diag/templates/openfleet.html new file mode 100644 index 00000000..d0b74db4 --- /dev/null +++ b/hw_diag/templates/openfleet.html @@ -0,0 +1,19 @@ +{% extends 'template_hyper.html' %} + +{% block title %}Nebra OpenFleet{% endblock %} + +{% block body %} +
+
+

Nebra OpenFleet

+

+ Error claiming on Nebra Dashboard. If you are running this software on + balenaCloud or on your own openBalena instance, you will not be able to claim your device on the Nebra Dashboard. In order to use the Nebra + Dashboard for remote management of your device you will need to use the Nebra software images from the Nebra Hub. +

+

+ You can find all of the software images on the Nebra Hub and you can also find + detailed installation guides on our support pages. +

+
+{% endblock %} diff --git a/hw_diag/templates/template_hyper.html b/hw_diag/templates/template_hyper.html index 86e1fdbd..d61bb138 100644 --- a/hw_diag/templates/template_hyper.html +++ b/hw_diag/templates/template_hyper.html @@ -156,11 +156,16 @@ View on Dashboard - {% else %} + {% elif diagnostics.nebra_fleet %} Claim on Dashboard + {% else %} + + + Claim on Dashboard + {% endif %}
  • diff --git a/hw_diag/views/auth.py b/hw_diag/views/auth.py index 74078f8f..e5474642 100644 --- a/hw_diag/views/auth.py +++ b/hw_diag/views/auth.py @@ -212,3 +212,13 @@ def display_upgrade_page(): diagnostics=diagnostics, claim_deeplink=claim_deeplink ) + + +@AUTH.route('/openfleet') +@authenticate +def display_openfleet_page(): + diagnostics = read_diagnostics_file() + return render_template( + 'openfleet.html', + diagnostics=diagnostics + ) diff --git a/poetry.lock b/poetry.lock index b2f1ab74..44e20ffb 100644 --- a/poetry.lock +++ b/poetry.lock @@ -645,13 +645,13 @@ tornado = ["tornado (>=0.2)"] [[package]] name = "hm-pyhelper" -version = "0.14.16" +version = "0.14.17" description = "Helium Python Helper" optional = false python-versions = ">=3.9,<4.0" files = [ - {file = "hm_pyhelper-0.14.16-py3-none-any.whl", hash = "sha256:b4ab0a44da68aff72a8662ad51ebcebe180abae370d9504d4d15f2302c534b1c"}, - {file = "hm_pyhelper-0.14.16.tar.gz", hash = "sha256:3ee1346e0ca5fd9de13c8a422eaff5d7ff55caacbed36f7bcfec9c5323c433e7"}, + {file = "hm_pyhelper-0.14.17-py3-none-any.whl", hash = "sha256:d59df06b0eb169b76cde6abfd1f28b9e3d5b6c1b3dd81214009678d778d6cba3"}, + {file = "hm_pyhelper-0.14.17.tar.gz", hash = "sha256:a435df48cc99bcf194e96f667d687e30a1a6f3137cf4b3075a4991525cda4c5e"}, ] [package.dependencies] @@ -1547,4 +1547,4 @@ watchdog = ["watchdog (>=2.3)"] [metadata] lock-version = "2.0" python-versions = "~3.11" -content-hash = "38e7eb13dfa2b541c9af7a791c6e7d7b022c81dbe0246644cb8e7ca639f2abd0" +content-hash = "257b87879654bead8c68e2b459c226507f3c4e16a1d6d2ed962dd0bf6dd5ba73" diff --git a/pyproject.toml b/pyproject.toml index 8fd17484..778f9427 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,7 +24,7 @@ Flask-APScheduler = "~1.12.4" Flask-Caching = "~2.0.1" grpcio = "~1.53.0" gunicorn = "~20.1.0" -hm-pyhelper = "0.14.16" +hm-pyhelper = "0.14.17" icmplib = "~3.0.3" ipaddress = "~1.0.23" password-strength = "~0.0.3.post2"