@@ -84,22 +82,18 @@
created() {
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 })
- .then(response => {
- this.companion = response.data
- this.status = response.data.statusInfo
- })
- .catch(this.$root.errorHandler)
+ axios.get('/api/v4/companions/' + this.companion_id, { loader: true })
+ .then(response => {
+ this.companion = response.data
+ this.status = response.data.statusInfo
+ })
+ .catch(this.$root.errorHandler)
- axios.get('/api/v4/companions/' + this.companion_id + '/pairing/', { loader: true })
- .then(response => {
- this.qrcode = response.data.qrcode
- })
- .catch(this.$root.errorHandler)
- } else if (this.companion_id == 'recovery') {
- this.companion = { name: this.$t("companion.recovery-device") }
- }
+ axios.get('/api/v4/companions/' + this.companion_id + '/pairing/', { loader: true })
+ .then(response => {
+ this.qrcode = response.data.qrcode
+ })
+ .catch(this.$root.errorHandler)
},
methods: {
printQRCode() {
diff --git a/src/resources/vue/CompanionApp/List.vue b/src/resources/vue/CompanionApp/List.vue
--- a/src/resources/vue/CompanionApp/List.vue
+++ b/src/resources/vue/CompanionApp/List.vue
@@ -5,9 +5,10 @@
{{ $t('companion.title') }}
{{ $t('dashboard.beta') }}
-
+
+
{{ $t('companion.create') }}
-
+
@@ -22,9 +23,9 @@
{{ $t('companion.description-warning') }}
-
+
{{ $t('companion.create-recovery-device') }}
-
+
@@ -60,6 +61,23 @@
this.companions = response.data.list
})
.catch(this.$root.errorHandler)
+ },
+ methods: {
+ createDevice(name) {
+ // If we already have a device for this purpose, just show that.
+ for (let device of this.companions) {
+ if (device.name == name) {
+ this.$router.push({ name: 'companion' , params: { companion: device.id }})
+ return
+ }
+ }
+
+ axios.post('/api/v4/companions', {'name': name})
+ .then(response => {
+ this.$toast.success(response.data.message)
+ this.$router.push({ name: 'companion' , params: { companion: response.data.id }})
+ })
+ }
}
}