Changeset View
Changeset View
Standalone View
Standalone View
src/resources/vue/CompanionApp/Info.vue
<template> | <template> | ||||
<div class="container"> | <div class="container"> | ||||
<div class="card"> | <div class="card"> | ||||
<div class="card-body"> | <div class="card-body"> | ||||
<div class="card-title" v-if="companion_id === 'new'">{{ $t('companion.new') }}</div> | <div class="card-title">{{ $t('form.companion') }} | ||||
<div class="card-title" v-else-if="companion_id === 'recovery'">{{ $t('companion.recovery') }}</div> | |||||
<div class="card-title" v-else>{{ $t('form.companion') }} | |||||
<btn class="btn-outline-danger button-delete float-end" @click="$refs.deleteDialog.show()" icon="trash-can">{{ $t('companion.delete') }}</btn> | <btn class="btn-outline-danger button-delete float-end" @click="$refs.deleteDialog.show()" icon="trash-can">{{ $t('companion.delete') }}</btn> | ||||
</div> | </div> | ||||
<div class="card-text"> | <div class="card-text"> | ||||
<form @submit.prevent="submit" class="card-body"> | <form @submit.prevent="submit" class="card-body"> | ||||
<div class="row mb-3"> | <div class="row mb-3"> | ||||
<label for="name" class="col-sm-4 col-form-label">{{ $t('companion.name') }}</label> | <label for="name" class="col-sm-4 col-form-label">{{ $t('companion.name') }}</label> | ||||
<div class="col-sm-8"> | <div class="col-sm-8"> | ||||
<input type="text" class="form-control" id="name" v-model="companion.name" :disabled="companion.id"> | <input type="text" class="form-control" id="name" v-model="companion.name" :disabled="companion.id"> | ||||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | export default { | ||||
companion: {}, | companion: {}, | ||||
qrcode: "", | qrcode: "", | ||||
status: {} | status: {} | ||||
} | } | ||||
}, | }, | ||||
created() { | created() { | ||||
this.companion_id = this.$route.params.companion | this.companion_id = this.$route.params.companion | ||||
if (this.companion_id !== 'new' && this.companion_id !== 'recovery') { | |||||
axios.get('/api/v4/companions/' + this.companion_id, { loader: true }) | axios.get('/api/v4/companions/' + this.companion_id, { loader: true }) | ||||
.then(response => { | .then(response => { | ||||
this.companion = response.data | this.companion = response.data | ||||
this.status = response.data.statusInfo | this.status = response.data.statusInfo | ||||
}) | }) | ||||
.catch(this.$root.errorHandler) | .catch(this.$root.errorHandler) | ||||
axios.get('/api/v4/companions/' + this.companion_id + '/pairing/', { loader: true }) | axios.get('/api/v4/companions/' + this.companion_id + '/pairing/', { loader: true }) | ||||
.then(response => { | .then(response => { | ||||
this.qrcode = response.data.qrcode | this.qrcode = response.data.qrcode | ||||
}) | }) | ||||
.catch(this.$root.errorHandler) | .catch(this.$root.errorHandler) | ||||
machniak: This request should probably be done only if the previous one was successful. | |||||
Done Inline ActionsNothing improves by doing the second conditionally and this way we're doing them in parallel. mollekopf: Nothing improves by doing the second conditionally and this way we're doing them in parallel. | |||||
} else if (this.companion_id == 'recovery') { | |||||
this.companion = { name: this.$t("companion.recovery-device") } | |||||
} | |||||
}, | }, | ||||
methods: { | methods: { | ||||
printQRCode() { | printQRCode() { | ||||
window.print(); | window.print(); | ||||
}, | }, | ||||
deleteCompanion() { | deleteCompanion() { | ||||
axios.delete('/api/v4/companions/' + this.companion_id) | axios.delete('/api/v4/companions/' + this.companion_id) | ||||
.then(response => { | .then(response => { | ||||
Show All 23 Lines |
This request should probably be done only if the previous one was successful.