Skip to content

Commit

Permalink
feat: show error page when trying to claim on dashboard and using bal…
Browse files Browse the repository at this point in the history
…enacloud

- 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
  • Loading branch information
shawaj committed Jun 26, 2023
1 parent e09f214 commit 294b5fe
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 7 deletions.
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,15 @@ 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
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
3 changes: 2 additions & 1 deletion hw_diag/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)

Expand Down
19 changes: 19 additions & 0 deletions hw_diag/templates/openfleet.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{% extends 'template_hyper.html' %}

{% block title %}Nebra OpenFleet{% endblock %}

{% block body %}
<div class="content">
<br/>
<h3 class="text-center mb-4">Nebra OpenFleet</h3>
<p class="text-center">
Error claiming on <a href="https://nebra.io/dashboard-diag-openfleet" target="_blank">Nebra Dashboard</a>. 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.
</p>
<p class="text-center">
You can find all of the software images on the <a href="https://nebra.io/hub-diag-openfleet" target="_blank">Nebra Hub</a> and you can also find
<a href="https://nebra.io/support-diag-openfleet" target="_blank">detailed installation guides on our support pages</a>.
</p>
</div>
{% endblock %}
7 changes: 6 additions & 1 deletion hw_diag/templates/template_hyper.html
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,16 @@
<i class="fa-duotone fa-chart-line"></i>
<span> View on Dashboard </span>
</a>
{% else %}
{% elif diagnostics.nebra_fleet %}
<a href={{ claim_deeplink }} target="_blank" class="side-nav-link">
<i class="fa-duotone fa-chart-line"></i>
<span> Claim on Dashboard </span>
</a>
{% else %}
<a href="/openfleet" class="side-nav-link">
<i class="fa-duotone fa-chart-line"></i>
<span> Claim on Dashboard </span>
</a>
{% endif %}
</li>
<li class="side-nav-item">
Expand Down
10 changes: 10 additions & 0 deletions hw_diag/views/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
8 changes: 4 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 294b5fe

Please sign in to comment.