Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: frontend: add autopilot restart button to power menu #2062

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
39 changes: 39 additions & 0 deletions core/frontend/src/components/app/PowerMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,21 @@
</v-icon>
Power off
</v-btn>
<v-btn
v-tooltip="'Restarts the autopilot'"
class="ma-2"
:loading="restarting_autopilot"
:disabled="restarting_autopilot"
@click="restartAutopilot"
>
<v-icon
left
color="orange"
>
mdi-restart
</v-icon>
Restart Autopilot
</v-btn>
<v-btn
v-tooltip="'Fully restarts the onboard computer'"
class="ma-2"
Expand Down Expand Up @@ -87,13 +102,19 @@
<script lang="ts">
import Vue from 'vue'

import Notifier from '@/libs/notifier'
import settings from '@/libs/settings'
import autopilot_data from '@/store/autopilot'
import autopilot from '@/store/autopilot_manager'
import commander from '@/store/commander'
import { ShutdownType } from '@/types/commander'
import { autopilot_service } from '@/types/frontend_services'
import back_axios from '@/utils/api'

import SpinningLogo from '../common/SpinningLogo.vue'

const notifier = new Notifier(autopilot_service)

/// Used for internal status control
enum Status {
None,
Expand All @@ -115,6 +136,9 @@ export default Vue.extend({
}
},
computed: {
restarting_autopilot(): boolean {
return autopilot.restarting
},
non_default_status(): boolean {
return this.service_status !== Status.None
},
Expand All @@ -135,6 +159,21 @@ export default Vue.extend({
},
},
methods: {
async restartAutopilot(): Promise<void> {
autopilot_data.reset()
autopilot.setRestarting(true)
await back_axios({
method: 'post',
url: `${autopilot.API_URL}/restart`,
timeout: 10000,
})
.catch((error) => {
notifier.pushBackError('AUTOPILOT_RESTART_FAIL', error)
})
.finally(() => {
autopilot.setRestarting(false)
})
},
async reboot(): Promise<void> {
this.service_status = Status.Rebooting
commander.shutdown(ShutdownType.Reboot)
Expand Down