Skip to content

Commit

Permalink
fix(ui): Hide forbidden zones editor menu item on gen 1 (#382)
Browse files Browse the repository at this point in the history
  • Loading branch information
ne0phyte authored and Hypfer committed Jun 8, 2020
1 parent ffc06d6 commit 32e9416
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
20 changes: 11 additions & 9 deletions client/zones.html
Expand Up @@ -10,14 +10,16 @@
<ons-list id="spot-list">
<ons-list-item>No spots are configured yet.</ons-list-item>
</ons-list>

<ons-list-title style="margin-top:20px;">Forbidden markers</ons-list-title>
<ons-list id="spot-list">
<ons-list-item tappable class="locations-list-item" onclick="switchToForbiddenMarkersEdit()">
<label><ons-icon icon="edit"></ons-icon></label>
<label>Configure forbidden zones</label>
</ons-list-item>
</ons-list>

<div id="forbidden-zones-item" hidden>
<ons-list-title style="margin-top:20px;">Forbidden markers</ons-list-title>
<ons-list id="forbidden-zones-list">
<ons-list-item tappable class="locations-list-item" onclick="switchToForbiddenMarkersEdit()">
<label><ons-icon icon="edit"></ons-icon></label>
<label>Configure forbidden zones</label>
</ons-list-item>
</ons-list>
</div>

<script>
{
Expand All @@ -43,4 +45,4 @@
background-color: #f45942; /* Random nice red color :) */
}
</style>
</ons-page>
</ons-page>
12 changes: 12 additions & 0 deletions client/zones.js
Expand Up @@ -5,6 +5,7 @@ import {ApiService} from "./services/api.service.js";
let loadingBarZones = document.getElementById("loading-bar-zones");
let zonesList = document.getElementById("zones-list");
let spotList = document.getElementById("spot-list");
let forbiddenZonesItem = document.getElementById("forbidden-zones-item");

/** @type {Array<{id:number, name:string, user: boolean, areas: Array}>} */
let zonesConfig = [];
Expand Down Expand Up @@ -212,6 +213,17 @@ async function ZonesInit() {
{buttonLabel: "Dismiss", timeout: window.fn.toastErrorTimeout});
}

/* forbidden zones are not supported by gen 1 vacuums */
try {
let modelConfig = await ApiService.getModel();
if (modelConfig.identifier !== "rockrobo.vacuum.v1") {
forbiddenZonesItem.hidden = false;
}
} catch (err) {
ons.notification.toast(err.message,
{buttonLabel: "Dismiss", timeout: window.fn.toastErrorTimeout});
}

loadingBarZones.removeAttribute("indeterminate");
}

Expand Down

0 comments on commit 32e9416

Please sign in to comment.