|
@@ -1,5 +1,6 @@
|
|
|
<template>
|
|
|
<div>
|
|
|
+ <!-- show accounts list -->
|
|
|
<div class="container" v-if="this.showAccounts">
|
|
|
<!-- header -->
|
|
|
<div class="columns is-gapless is-mobile is-centered">
|
|
@@ -32,8 +33,8 @@
|
|
|
readyLabel: '',
|
|
|
loadingLabel: 'refreshing'
|
|
|
}" > -->
|
|
|
- <draggable v-model="filteredAccounts" @start="drag = true" @end="saveOrder" ghost-class="ghost" handle=".tfa-dots" animation="200" class="accounts columns is-multiline is-centered">
|
|
|
- <transition-group type="transition" :name="!drag ? 'flip-list' : null">
|
|
|
+ <draggable v-model="filteredAccounts" @start="drag = true" @end="saveOrder" ghost-class="ghost" handle=".tfa-dots" animation="200" class="accounts">
|
|
|
+ <transition-group class="columns is-multiline is-centered" type="transition" :name="!drag ? 'flip-list' : null">
|
|
|
<div class="tfa column is-narrow has-text-white" v-for="account in filteredAccounts" :key="account.id">
|
|
|
<div class="tfa-container">
|
|
|
<transition name="slideCheckbox">
|
|
@@ -69,42 +70,17 @@
|
|
|
</draggable>
|
|
|
<!-- </vue-pull-refresh> -->
|
|
|
</div>
|
|
|
- <!-- No account -->
|
|
|
- <div class="container has-text-centered" v-show="showQuickForm">
|
|
|
- <div class="columns is-mobile" :class="{ 'is-invisible' : this.accounts.length > 0}">
|
|
|
- <div class="column quickform-header">
|
|
|
- {{ $t('twofaccounts.no_account_here') }}<br>
|
|
|
- {{ $t('twofaccounts.add_first_account') }}
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div class="container">
|
|
|
- <form @submit.prevent="createAccount" @keydown="form.onKeydown($event)">
|
|
|
- <div class="columns is-mobile no-account is-vcentered">
|
|
|
- <div class="column has-text-centered">
|
|
|
- <label :class="{'is-loading' : form.isBusy}" class="button is-link is-medium is-rounded is-focused">
|
|
|
- <input class="file-input" type="file" accept="image/*" v-on:change="uploadQrcode" ref="qrcodeInput">
|
|
|
- {{ $t('twofaccounts.forms.use_qrcode.val') }}
|
|
|
- </label>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <field-error :form="form" field="qrcode" />
|
|
|
- </form>
|
|
|
- </div>
|
|
|
- <div class="columns is-mobile">
|
|
|
- <div class="column quickform-footer">
|
|
|
- <router-link :to="{ name: 'create' }" class="is-link">{{ $t('twofaccounts.use_full_form') }}</router-link>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
+ <!-- Show uploader (because no account) -->
|
|
|
+ <quick-uploader v-if="showUploader" :directStreaming="accounts.length > 0" :showTrailer="accounts.length === 0" ref="QuickUploader"></quick-uploader>
|
|
|
<!-- modal -->
|
|
|
- <modal v-model="ShowTwofaccountInModal">
|
|
|
+ <modal v-model="showTwofaccountInModal">
|
|
|
<twofaccount-show ref="TwofaccountShow" ></twofaccount-show>
|
|
|
</modal>
|
|
|
<!-- footer -->
|
|
|
- <vue-footer :showButtons="this.accounts.length > 0">
|
|
|
+ <vue-footer v-if="showFooter" :showButtons="accounts.length > 0">
|
|
|
<!-- New item buttons -->
|
|
|
- <p class="control" v-if="!showQuickForm && !editMode">
|
|
|
- <a class="button is-link is-rounded is-focus" @click="showQuickForm = true">
|
|
|
+ <p class="control" v-if="!showUploader && !editMode">
|
|
|
+ <a class="button is-link is-rounded is-focus" @click="showUploader = true">
|
|
|
<span>{{ $t('twofaccounts.new') }}</span>
|
|
|
<span class="icon is-small">
|
|
|
<font-awesome-icon :icon="['fas', 'qrcode']" />
|
|
@@ -112,11 +88,11 @@
|
|
|
</a>
|
|
|
</p>
|
|
|
<!-- Manage button -->
|
|
|
- <p class="control" v-if="!showQuickForm && !editMode">
|
|
|
+ <p class="control" v-if="!showUploader && !editMode">
|
|
|
<a class="button is-dark is-rounded" @click="setEditModeTo(true)">{{ $t('twofaccounts.manage') }}</a>
|
|
|
</p>
|
|
|
<!-- Done button -->
|
|
|
- <p class="control" v-if="!showQuickForm && editMode">
|
|
|
+ <p class="control" v-if="!showUploader && editMode">
|
|
|
<a class="button is-success is-rounded" @click="setEditModeTo(false)">
|
|
|
<span>{{ $t('twofaccounts.done') }}</span>
|
|
|
<span class="icon is-small">
|
|
@@ -125,8 +101,8 @@
|
|
|
</a>
|
|
|
</p>
|
|
|
<!-- Cancel QuickFormButton -->
|
|
|
- <p class="control" v-if="showQuickForm">
|
|
|
- <a class="button is-dark is-rounded" @click="cancelQuickForm">
|
|
|
+ <p class="control" v-if="showUploader && showFooter">
|
|
|
+ <a class="button is-dark is-rounded" @click="showUploader = false">
|
|
|
{{ $t('commons.cancel') }}
|
|
|
</a>
|
|
|
</p>
|
|
@@ -139,22 +115,21 @@
|
|
|
|
|
|
import Modal from '../components/Modal'
|
|
|
import TwofaccountShow from '../components/TwofaccountShow'
|
|
|
- import Form from './../components/Form'
|
|
|
- import vuePullRefresh from 'vue-pull-refresh';
|
|
|
+ import QuickUploader from './../components/QuickUploader'
|
|
|
+ // import vuePullRefresh from 'vue-pull-refresh';
|
|
|
import draggable from 'vuedraggable'
|
|
|
|
|
|
+
|
|
|
export default {
|
|
|
data(){
|
|
|
return {
|
|
|
accounts : [],
|
|
|
selectedAccounts: [],
|
|
|
- ShowTwofaccountInModal : false,
|
|
|
+ showTwofaccountInModal : false,
|
|
|
search: '',
|
|
|
editMode: this.InitialEditMode,
|
|
|
- showQuickForm: false,
|
|
|
- form: new Form({
|
|
|
- qrcode: null
|
|
|
- }),
|
|
|
+ showUploader: false,
|
|
|
+ showFooter: true,
|
|
|
drag: false,
|
|
|
}
|
|
|
},
|
|
@@ -174,13 +149,14 @@
|
|
|
},
|
|
|
|
|
|
showAccounts() {
|
|
|
- return this.accounts.length > 0 && !this.showQuickForm ? true : false
|
|
|
+ return this.accounts.length > 0 && !this.showUploader ? true : false
|
|
|
},
|
|
|
+
|
|
|
},
|
|
|
|
|
|
props: ['InitialEditMode'],
|
|
|
|
|
|
- created() {
|
|
|
+ mounted() {
|
|
|
|
|
|
this.fetchAccounts()
|
|
|
|
|
@@ -190,39 +166,30 @@
|
|
|
this.$refs.TwofaccountShow.clearOTP()
|
|
|
});
|
|
|
|
|
|
+ // hide Footer when stream is on
|
|
|
+ this.$on('initStreaming', function() {
|
|
|
+ // this.showFooter = this.accounts.length > 0 ? false : true
|
|
|
+ this.showFooter = false
|
|
|
+ });
|
|
|
+
|
|
|
+ this.$on('stopStreaming', function() {
|
|
|
+
|
|
|
+ this.showUploader = this.accounts.length > 0 ? false : true
|
|
|
+ this.showFooter = true
|
|
|
+ });
|
|
|
+
|
|
|
},
|
|
|
|
|
|
components: {
|
|
|
Modal,
|
|
|
TwofaccountShow,
|
|
|
- 'vue-pull-refresh': vuePullRefresh,
|
|
|
+ // 'vue-pull-refresh': vuePullRefresh,
|
|
|
+ QuickUploader,
|
|
|
draggable,
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
- onRefresh() {
|
|
|
- var that = this
|
|
|
-
|
|
|
- return new Promise(function (resolve, reject) {
|
|
|
- setTimeout(function () {
|
|
|
- that.fetchAccounts()
|
|
|
- resolve();
|
|
|
- }, 1000);
|
|
|
- });
|
|
|
- },
|
|
|
-
|
|
|
- async uploadQrcode(event) {
|
|
|
-
|
|
|
- let imgdata = new FormData();
|
|
|
- imgdata.append('qrcode', this.$refs.qrcodeInput.files[0]);
|
|
|
-
|
|
|
- const { data } = await this.form.upload('/api/qrcode/decode', imgdata)
|
|
|
-
|
|
|
- this.$router.push({ name: 'create', params: { qrAccount: data } });
|
|
|
-
|
|
|
- },
|
|
|
-
|
|
|
fetchAccounts() {
|
|
|
this.accounts = []
|
|
|
this.selectedAccounts = []
|
|
@@ -237,7 +204,7 @@
|
|
|
})
|
|
|
})
|
|
|
|
|
|
- this.showQuickForm = response.data.length === 0 ? true: false
|
|
|
+ this.showUploader = response.data.length === 0 ? true : false
|
|
|
})
|
|
|
},
|
|
|
|
|
@@ -263,7 +230,7 @@
|
|
|
this.axios.patch('/api/twofaccounts/reorder', {orderedIds: this.accounts.map(a => a.id)})
|
|
|
},
|
|
|
|
|
|
- deleteAccount: function (id) {
|
|
|
+ deleteAccount(id) {
|
|
|
if(confirm(this.$t('twofaccounts.confirm.delete'))) {
|
|
|
this.axios.delete('/api/twofaccounts/' + id)
|
|
|
|
|
@@ -299,10 +266,6 @@
|
|
|
this.$parent.showToolbar = state
|
|
|
},
|
|
|
|
|
|
- cancelQuickForm() {
|
|
|
- this.form.clear()
|
|
|
- this.showQuickForm = false
|
|
|
- }
|
|
|
},
|
|
|
|
|
|
beforeRouteEnter (to, from, next) {
|