Skip to content

Commit d259201

Browse files
committed
frontend: autopilot: disable mavlink endpoint creation if autopilot is not running
1 parent 237d824 commit d259201

File tree

2 files changed

+43
-6
lines changed

2 files changed

+43
-6
lines changed

core/frontend/src/components/autopilot/EndpointManager.vue

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,36 @@
6565
subtitle="Fetching available endpoints..."
6666
/>
6767
</v-container>
68-
<v-card
68+
<v-container
6969
v-else
7070
class="d-flex align-center justify-center pa-6"
7171
>
72-
<p class="text-h6">
73-
No endpoints available.
74-
</p>
75-
</v-card>
72+
<v-card
73+
v-if="!autopilot_board_is_running"
74+
class="d-flex align-center justify-center pa-6"
75+
>
76+
<div class="d-flex flex-column align-center justify-center">
77+
<p class="mb-2">
78+
Autopilot must be running to create endpoints.
79+
</p>
80+
<p class="mb-0">
81+
You can start it in the
82+
<router-link to="autopilot">
83+
Autopilot Firmware
84+
</router-link>
85+
tab.
86+
</p>
87+
</div>
88+
</v-card>
89+
<v-card
90+
v-else
91+
class="d-flex align-center justify-center pa-6"
92+
>
93+
<p class="text-h6">
94+
No endpoints available.
95+
</p>
96+
</v-card>
97+
</v-container>
7698

7799
<v-fab-transition>
78100
<v-btn
@@ -85,6 +107,7 @@
85107
bottom
86108
right
87109
class="v-btn--example"
110+
:disabled="!autopilot_board_is_running"
88111
@click="openCreationDialog"
89112
>
90113
<v-icon>mdi-plus</v-icon>
@@ -109,9 +132,10 @@ import { autopilot_service } from '@/types/frontend_services'
109132
import back_axios from '@/utils/api'
110133
111134
import SpinningLogo from '../common/SpinningLogo.vue'
112-
import { fetchAvailableEndpoints } from './AutopilotManagerUpdater'
135+
import { fetchAvailableEndpoints, fetchCurrentBoard } from './AutopilotManagerUpdater'
113136
import EndpointCard from './EndpointCard.vue'
114137
import CreationDialog from './EndpointCreationDialog.vue'
138+
import autopilot_data from '@/store/autopilot'
115139
116140
const notifier = new Notifier(autopilot_service)
117141
@@ -129,6 +153,7 @@ export default Vue.extend({
129153
available_routers: [] as string[],
130154
updating_router: false,
131155
fetch_available_endpoints_task: new OneMoreTime({ delay: 5000, disposeWith: this }),
156+
fetch_current_board_task: new OneMoreTime({ delay: 5000, disposeWith: this }),
132157
}
133158
},
134159
computed: {
@@ -141,9 +166,13 @@ export default Vue.extend({
141166
are_endpoints_available(): boolean {
142167
return !this.available_endpoints.isEmpty()
143168
},
169+
autopilot_board_is_running(): boolean {
170+
return autopilot.current_board !== null && this.heartbeat_age() < 3000
171+
},
144172
},
145173
mounted() {
146174
this.fetch_available_endpoints_task.setAction(fetchAvailableEndpoints)
175+
this.fetch_current_board_task.setAction(fetchCurrentBoard)
147176
this.fetchAvailableRouters()
148177
this.fetchCurrentRouter()
149178
},
@@ -206,6 +235,9 @@ export default Vue.extend({
206235
notifier.pushBackError('AUTOPILOT_ENDPOINT_CREATE_FAIL', error, true)
207236
})
208237
},
238+
heartbeat_age(): number {
239+
return new Date().valueOf() - autopilot_data.last_heartbeat_date.getTime()
240+
},
209241
},
210242
})
211243
</script>

core/frontend/src/store/autopilot.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,11 @@ class AutopilotStore extends VuexModule {
174174
setVehicleArmed(armed: boolean): void {
175175
this.verhicle_armed = armed
176176
}
177+
178+
@Mutation
179+
setLastHeartbeatDate(date: Date): void {
180+
this.last_heartbeat_date = date
181+
}
177182
}
178183

179184
export { AutopilotStore }

0 commit comments

Comments
 (0)