2020-04-24 09:03:00 +02:00
|
|
|
<template>
|
2020-11-23 19:30:58 +01:00
|
|
|
<!-- static landing UI -->
|
|
|
|
<div class="container has-text-centered">
|
|
|
|
<div class="columns quick-uploader">
|
|
|
|
<!-- trailer phrase that invite to add an account -->
|
|
|
|
<div class="column is-full quick-uploader-header" :class="{ 'is-invisible' : accountCount > 0 }">
|
|
|
|
{{ $t('twofaccounts.no_account_here') }}<br>
|
|
|
|
{{ $t('twofaccounts.add_first_account') }}
|
|
|
|
</div>
|
|
|
|
<!-- Livescan button -->
|
|
|
|
<div class="column is-full quick-uploader-button" >
|
|
|
|
<div class="quick-uploader-centerer">
|
|
|
|
<!-- upload a qr code (with basic file field and backend decoding) -->
|
|
|
|
<label v-if="$root.appSettings.useBasicQrcodeReader" class="button is-link is-medium is-rounded is-focused" ref="qrcodeInputLabel">
|
|
|
|
<input class="file-input" type="file" accept="image/*" v-on:change="submitQrCode" ref="qrcodeInput">
|
|
|
|
{{ $t('twofaccounts.forms.upload_qrcode') }}
|
|
|
|
</label>
|
|
|
|
<!-- scan button that launch camera stream -->
|
|
|
|
<label v-else class="button is-link is-medium is-rounded is-focused" @click="capture()">
|
|
|
|
{{ $t('twofaccounts.forms.scan_qrcode') }}
|
|
|
|
</label>
|
2020-04-24 09:03:00 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2020-11-23 19:30:58 +01:00
|
|
|
<!-- alternative methods -->
|
|
|
|
<div class="column is-full">
|
|
|
|
<div class="block has-text-light">{{ $t('twofaccounts.forms.alternative_methods') }}</div>
|
|
|
|
<!-- upload a qr code -->
|
|
|
|
<div class="block has-text-link" v-if="!$root.appSettings.useBasicQrcodeReader">
|
|
|
|
<label class="button is-link is-outlined is-rounded" ref="qrcodeInputLabel">
|
|
|
|
<input class="file-input" type="file" accept="image/*" v-on:change="submitQrCode" ref="qrcodeInput">
|
|
|
|
{{ $t('twofaccounts.forms.upload_qrcode') }}
|
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
<!-- link to advanced form -->
|
|
|
|
<div class="block has-text-link">
|
|
|
|
<router-link class="button is-link is-outlined is-rounded" :to="{ name: 'createAccount' }" >
|
|
|
|
{{ $t('twofaccounts.forms.use_advanced_form') }}
|
2020-11-20 14:11:32 +01:00
|
|
|
</router-link>
|
2020-11-23 19:30:58 +01:00
|
|
|
</div>
|
2020-04-24 09:03:00 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2020-11-23 19:30:58 +01:00
|
|
|
<!-- Footer -->
|
|
|
|
<vue-footer :showButtons="true" v-if="accountCount > 0">
|
|
|
|
<!-- back button -->
|
|
|
|
<p class="control">
|
|
|
|
<router-link class="button is-dark is-rounded" :to="{ name: 'accounts' }" >
|
|
|
|
{{ $t('commons.back') }}
|
|
|
|
</router-link>
|
|
|
|
</p>
|
|
|
|
</vue-footer>
|
2020-04-24 09:03:00 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
2020-11-20 18:47:32 +01:00
|
|
|
/**
|
|
|
|
* Start view
|
|
|
|
*
|
|
|
|
* route: '/start'
|
|
|
|
*
|
|
|
|
* Offer the user all available possibilities for capturing an account :
|
2020-11-23 19:30:58 +01:00
|
|
|
* - By sending the user to the live scanner
|
2020-11-20 18:47:32 +01:00
|
|
|
* - By decoding a QR code submitted with a form 'File' field
|
2020-11-23 19:30:58 +01:00
|
|
|
* - By sending the user to the advanced form
|
2020-11-20 18:47:32 +01:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-04-24 09:03:00 +02:00
|
|
|
|
|
|
|
export default {
|
2020-11-20 14:11:32 +01:00
|
|
|
name: 'Start',
|
2020-04-24 09:03:00 +02:00
|
|
|
|
|
|
|
data(){
|
|
|
|
return {
|
2020-11-21 19:41:36 +01:00
|
|
|
accountCount: null,
|
2020-04-24 09:03:00 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-11-21 19:41:36 +01:00
|
|
|
mounted() {
|
|
|
|
|
|
|
|
this.axios.get('api/twofaccounts/count').then(response => {
|
|
|
|
this.accountCount = response.data.count
|
|
|
|
})
|
|
|
|
},
|
2020-04-24 09:03:00 +02:00
|
|
|
|
|
|
|
created() {
|
2020-11-20 18:59:36 +01:00
|
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
if( this.$root.appSettings.useDirectCapture && this.$root.appSettings.defaultCaptureMode === 'upload' ) {
|
|
|
|
this.$refs.qrcodeInputLabel.click()
|
|
|
|
}
|
|
|
|
})
|
2020-04-24 09:03:00 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
|
2020-11-20 14:11:32 +01:00
|
|
|
/**
|
2020-11-23 19:30:58 +01:00
|
|
|
* Send the submitted QR code to the backend for decoding then push ser to the create form
|
2020-11-20 14:11:32 +01:00
|
|
|
*/
|
|
|
|
async submitQrCode() {
|
2020-04-24 09:03:00 +02:00
|
|
|
|
2020-11-20 14:11:32 +01:00
|
|
|
let imgdata = new FormData();
|
|
|
|
imgdata.append('qrcode', this.$refs.qrcodeInput.files[0]);
|
|
|
|
imgdata.append('inputFormat', 'fileUpload');
|
2020-04-24 09:03:00 +02:00
|
|
|
|
2020-11-20 14:11:32 +01:00
|
|
|
const { data } = await this.form.upload('/api/qrcode/decode', imgdata)
|
2020-04-24 09:03:00 +02:00
|
|
|
|
2020-11-23 19:30:58 +01:00
|
|
|
this.$router.push({ name: 'createAccount', params: { decodedUri: data.uri } });
|
2020-11-20 14:11:32 +01:00
|
|
|
},
|
2020-04-24 09:03:00 +02:00
|
|
|
|
2020-11-20 14:11:32 +01:00
|
|
|
/**
|
2020-11-23 19:30:58 +01:00
|
|
|
* Push user to the dedicated capture view for live scan
|
2020-11-20 14:11:32 +01:00
|
|
|
*/
|
2020-11-23 19:30:58 +01:00
|
|
|
capture() {
|
|
|
|
this.$router.push({ name: 'capture' });
|
2020-04-24 09:03:00 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
</script>
|