|
71 | 71 |
|
72 | 72 | <!-- position -->
|
73 | 73 | <div>
|
74 |
| - <div class="flex bg-gray-200 p-2 font-semibold">Position</div> |
| 74 | + <div class="flex bg-gray-200 p-2 font-semibold items-center"> |
| 75 | + <div>Position</div> |
| 76 | + <div class="ml-auto"> |
| 77 | + <RefreshButton @click="requestPosition" :is-refreshing="isRequestingPosition"/> |
| 78 | + </div> |
| 79 | + </div> |
75 | 80 | <ul role="list" class="flex-1 divide-y divide-gray-200">
|
76 | 81 |
|
77 | 82 | <!-- position -->
|
|
87 | 92 | <li class="flex p-3">
|
88 | 93 | <div class="text-sm font-medium text-gray-900">Altitude</div>
|
89 | 94 | <div class="ml-auto text-sm text-gray-700">
|
90 |
| - <span v-if="node.position && node.position.altitude != null">{{ node.position.altitude }}</span> |
| 95 | + <span v-if="node.position && node.position.altitude">{{ node.position.altitude }}</span> |
91 | 96 | <span v-else>???</span>
|
92 | 97 | </div>
|
93 | 98 |
|
@@ -189,6 +194,7 @@ export default {
|
189 | 194 | data() {
|
190 | 195 | return {
|
191 | 196 | isRequestingDeviceMetrics: false,
|
| 197 | + isRequestingPosition: false, |
192 | 198 | };
|
193 | 199 | },
|
194 | 200 | mounted() {
|
@@ -252,6 +258,32 @@ export default {
|
252 | 258 | this.isRequestingDeviceMetrics = false;
|
253 | 259 |
|
254 | 260 | },
|
| 261 | + async requestPosition() { |
| 262 | +
|
| 263 | + // do nothing if already requesting position |
| 264 | + if(this.isRequestingPosition){ |
| 265 | + return; |
| 266 | + } |
| 267 | +
|
| 268 | + // show loading |
| 269 | + this.isRequestingPosition = true; |
| 270 | +
|
| 271 | + try { |
| 272 | +
|
| 273 | + // fetch position from node |
| 274 | + const position = await NodeAPI.requestPosition(this.node.num); |
| 275 | +
|
| 276 | + // update this nodes position |
| 277 | + this.node.position = position; |
| 278 | +
|
| 279 | + } catch(e) { |
| 280 | + DialogUtils.showErrorAlert(e); |
| 281 | + } |
| 282 | +
|
| 283 | + // no longer requesting position |
| 284 | + this.isRequestingPosition = false; |
| 285 | +
|
| 286 | + }, |
255 | 287 | },
|
256 | 288 | computed: {
|
257 | 289 | node() {
|
|
0 commit comments