mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-04-26 10:29:00 +02:00
Make the accounts sortable and persist new order.
Deactivate Pull-to-refresh feature to prevent side effects
This commit is contained in:
parent
361e6a87f1
commit
eaabe6e9e3
@ -62,6 +62,19 @@ public function show(TwoFAccount $twofaccount)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save new order.
|
||||||
|
*
|
||||||
|
* @param \App\TwoFAccount $twofaccount
|
||||||
|
* @return \Illuminate\Http\Response
|
||||||
|
*/
|
||||||
|
public function reorder(Request $request)
|
||||||
|
{
|
||||||
|
TwoFAccount::setNewOrder($request->orderedIds);
|
||||||
|
return response()->json('order saved', 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a TOTP
|
* Generate a TOTP
|
||||||
*
|
*
|
||||||
|
@ -14,7 +14,8 @@ import {
|
|||||||
faLock,
|
faLock,
|
||||||
faLockOpen,
|
faLockOpen,
|
||||||
faSearch,
|
faSearch,
|
||||||
faEllipsisH
|
faEllipsisH,
|
||||||
|
faBars
|
||||||
} from '@fortawesome/free-solid-svg-icons'
|
} from '@fortawesome/free-solid-svg-icons'
|
||||||
|
|
||||||
library.add(
|
library.add(
|
||||||
@ -27,7 +28,8 @@ library.add(
|
|||||||
faLock,
|
faLock,
|
||||||
faLockOpen,
|
faLockOpen,
|
||||||
faSearch,
|
faSearch,
|
||||||
faEllipsisH
|
faEllipsisH,
|
||||||
|
faBars
|
||||||
);
|
);
|
||||||
|
|
||||||
Vue.component('font-awesome-icon', FontAwesomeIcon)
|
Vue.component('font-awesome-icon', FontAwesomeIcon)
|
@ -26,13 +26,14 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- accounts -->
|
<!-- accounts -->
|
||||||
<vue-pull-refresh :on-refresh="onRefresh" :config="{
|
<!-- <vue-pull-refresh :on-refresh="onRefresh" :config="{
|
||||||
errorLabel: 'error',
|
errorLabel: 'error',
|
||||||
startLabel: '',
|
startLabel: '',
|
||||||
readyLabel: '',
|
readyLabel: '',
|
||||||
loadingLabel: 'refreshing'
|
loadingLabel: 'refreshing'
|
||||||
}" class="accounts columns is-multiline is-centered">
|
}" > -->
|
||||||
<div class="tfa column is-narrow has-text-white" v-for="account in filteredAccounts">
|
<draggable v-model="filteredAccounts" @end="saveOrder" handle=".tfa-dots" class="accounts columns is-multiline is-centered">
|
||||||
|
<div class="tfa column is-narrow has-text-white" v-for="account in filteredAccounts" :key="account.id">
|
||||||
<div class="tfa-container">
|
<div class="tfa-container">
|
||||||
<transition name="slideCheckbox">
|
<transition name="slideCheckbox">
|
||||||
<div class="tfa-checkbox" v-if="editMode">
|
<div class="tfa-checkbox" v-if="editMode">
|
||||||
@ -50,15 +51,21 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<transition name="fadeInOut">
|
<transition name="fadeInOut">
|
||||||
<div class="tfa-dots has-text-grey" v-if="editMode">
|
<div class="tfa-edit has-text-grey" v-if="editMode">
|
||||||
<router-link :to="{ name: 'edit', params: { twofaccountId: account.id }}" class="tag is-dark is-rounded">
|
<router-link :to="{ name: 'edit', params: { twofaccountId: account.id }}" class="tag is-dark is-rounded">
|
||||||
{{ $t('commons.edit') }}
|
{{ $t('commons.edit') }}
|
||||||
</router-link>
|
</router-link>
|
||||||
</div>
|
</div>
|
||||||
</transition>
|
</transition>
|
||||||
|
<transition name="fadeInOut">
|
||||||
|
<div class="tfa-dots has-text-grey" v-if="editMode">
|
||||||
|
<font-awesome-icon :icon="['fas', 'bars']" />
|
||||||
|
</div>
|
||||||
|
</transition>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</vue-pull-refresh>
|
</draggable>
|
||||||
|
<!-- </vue-pull-refresh> -->
|
||||||
</div>
|
</div>
|
||||||
<!-- No account -->
|
<!-- No account -->
|
||||||
<div class="container has-text-centered" v-show="showQuickForm">
|
<div class="container has-text-centered" v-show="showQuickForm">
|
||||||
@ -132,6 +139,7 @@
|
|||||||
import TwofaccountShow from '../components/TwofaccountShow'
|
import TwofaccountShow from '../components/TwofaccountShow'
|
||||||
import Form from './../components/Form'
|
import Form from './../components/Form'
|
||||||
import vuePullRefresh from 'vue-pull-refresh';
|
import vuePullRefresh from 'vue-pull-refresh';
|
||||||
|
import draggable from 'vuedraggable'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data(){
|
data(){
|
||||||
@ -149,13 +157,18 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
filteredAccounts() {
|
filteredAccounts: {
|
||||||
|
get: function() {
|
||||||
return this.accounts.filter(
|
return this.accounts.filter(
|
||||||
item => {
|
item => {
|
||||||
return item.service.toLowerCase().includes(this.search.toLowerCase()) || item.account.toLowerCase().includes(this.search.toLowerCase());
|
return item.service.toLowerCase().includes(this.search.toLowerCase()) || item.account.toLowerCase().includes(this.search.toLowerCase());
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
set: function(reorderedAccounts) {
|
||||||
|
this.accounts = reorderedAccounts
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
showAccounts() {
|
showAccounts() {
|
||||||
return this.accounts.length > 0 && !this.showQuickForm ? true : false
|
return this.accounts.length > 0 && !this.showQuickForm ? true : false
|
||||||
@ -179,7 +192,8 @@
|
|||||||
components: {
|
components: {
|
||||||
Modal,
|
Modal,
|
||||||
TwofaccountShow,
|
TwofaccountShow,
|
||||||
'vue-pull-refresh': vuePullRefresh
|
'vue-pull-refresh': vuePullRefresh,
|
||||||
|
draggable,
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
@ -241,6 +255,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
saveOrder() {
|
||||||
|
this.axios.patch('/api/twofaccounts/reorder', {orderedIds: this.accounts.map(a => a.id)})
|
||||||
|
},
|
||||||
|
|
||||||
deleteAccount: function (id) {
|
deleteAccount: function (id) {
|
||||||
if(confirm(this.$t('twofaccounts.confirm.delete'))) {
|
if(confirm(this.$t('twofaccounts.confirm.delete'))) {
|
||||||
this.axios.delete('/api/twofaccounts/' + id)
|
this.axios.delete('/api/twofaccounts/' + id)
|
||||||
|
@ -52,7 +52,6 @@ a:hover {
|
|||||||
.tfa {
|
.tfa {
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
cursor: pointer;
|
|
||||||
background-color: hsl(0, 0%, 10%); /*black-bis from Bulma*/
|
background-color: hsl(0, 0%, 10%); /*black-bis from Bulma*/
|
||||||
padding: 0.75rem 1.5rem;
|
padding: 0.75rem 1.5rem;
|
||||||
margin: 0.5rem;
|
margin: 0.5rem;
|
||||||
@ -89,22 +88,26 @@ a:hover {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.tfa-container > div:last-of-type {
|
.tfa-container > div:last-of-type {
|
||||||
padding: 0 0.5rem 0 0;
|
padding: 0 1rem 0 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.tfa-checkbox, .tfa-dots {
|
.tfa-checkbox, .tfa-dots, .tfa-edit {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 0.5rem 0 0 0;
|
padding: 0.5rem 0 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media screen and (max-width: 768px) {
|
@media screen and (max-width: 768px) {
|
||||||
.tfa-checkbox, .tfa-dots {
|
.tfa-checkbox, .tfa-dots, .tfa-edit {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 0
|
padding: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tfa-dots {
|
||||||
|
margin-left: 1.5rem;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.tfa-content {
|
.tfa-content {
|
||||||
@ -118,7 +121,7 @@ a:hover {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.tfa-dots {
|
.tfa-dots {
|
||||||
// order: 3;
|
cursor: grab;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media screen and (max-width: 768px) {
|
@media screen and (max-width: 768px) {
|
||||||
@ -130,9 +133,13 @@ a:hover {
|
|||||||
order: 2;
|
order: 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tfa-dots {
|
.tfa-edit {
|
||||||
order: 3;
|
order: 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tfa-dots {
|
||||||
|
order: 4;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@media screen and (min-width: 769px) {
|
@media screen and (min-width: 769px) {
|
||||||
@ -146,6 +153,7 @@ a:hover {
|
|||||||
.tfa-text {
|
.tfa-text {
|
||||||
display: block;
|
display: block;
|
||||||
max-width: 300px;
|
max-width: 300px;
|
||||||
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tfa img {
|
.tfa img {
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
Route::delete('twofaccounts/batch', 'TwoFAccountController@batchDestroy');
|
Route::delete('twofaccounts/batch', 'TwoFAccountController@batchDestroy');
|
||||||
|
Route::patch('twofaccounts/reorder', 'TwoFAccountController@reorder');
|
||||||
Route::apiResource('twofaccounts', 'TwoFAccountController');
|
Route::apiResource('twofaccounts', 'TwoFAccountController');
|
||||||
Route::post('twofaccounts/otp', 'TwoFAccountController@generateOTP')->name('twofaccounts.generateOTP');
|
Route::post('twofaccounts/otp', 'TwoFAccountController@generateOTP')->name('twofaccounts.generateOTP');
|
||||||
Route::post('qrcode/decode', 'QrCodeController@decode');
|
Route::post('qrcode/decode', 'QrCodeController@decode');
|
||||||
|
Loading…
Reference in New Issue
Block a user