diff --git a/app/Http/Controllers/TwoFAccountController.php b/app/Http/Controllers/TwoFAccountController.php index d8e0f67f..33c37277 100644 --- a/app/Http/Controllers/TwoFAccountController.php +++ b/app/Http/Controllers/TwoFAccountController.php @@ -62,6 +62,19 @@ class TwoFAccountController extends Controller } + /** + * 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 * diff --git a/resources/js/packages/fontawesome.js b/resources/js/packages/fontawesome.js index 8bd00527..e57c2178 100644 --- a/resources/js/packages/fontawesome.js +++ b/resources/js/packages/fontawesome.js @@ -14,7 +14,8 @@ import { faLock, faLockOpen, faSearch, - faEllipsisH + faEllipsisH, + faBars } from '@fortawesome/free-solid-svg-icons' library.add( @@ -27,7 +28,8 @@ library.add( faLock, faLockOpen, faSearch, - faEllipsisH + faEllipsisH, + faBars ); Vue.component('font-awesome-icon', FontAwesomeIcon) \ No newline at end of file diff --git a/resources/js/views/Accounts.vue b/resources/js/views/Accounts.vue index 45c516df..607b4fda 100644 --- a/resources/js/views/Accounts.vue +++ b/resources/js/views/Accounts.vue @@ -26,39 +26,46 @@ - -
-
- -
-
- - -
-
-
-
-
- - {{ account.service }} - {{ account.account }} + }" > --> + +
+
+ +
+
+ + +
+
+
+
+
+ + {{ account.service }} + {{ account.account }} +
+ +
+ + {{ $t('commons.edit') }} + +
+
+ +
+ +
+
- -
- - {{ $t('commons.edit') }} - -
-
-
- + +
@@ -132,6 +139,7 @@ import TwofaccountShow from '../components/TwofaccountShow' import Form from './../components/Form' import vuePullRefresh from 'vue-pull-refresh'; + import draggable from 'vuedraggable' export default { data(){ @@ -149,12 +157,17 @@ }, computed: { - filteredAccounts() { - return this.accounts.filter( - item => { - return item.service.toLowerCase().includes(this.search.toLowerCase()) || item.account.toLowerCase().includes(this.search.toLowerCase()); - } - ); + filteredAccounts: { + get: function() { + return this.accounts.filter( + item => { + return item.service.toLowerCase().includes(this.search.toLowerCase()) || item.account.toLowerCase().includes(this.search.toLowerCase()); + } + ); + }, + set: function(reorderedAccounts) { + this.accounts = reorderedAccounts + } }, showAccounts() { @@ -179,7 +192,8 @@ components: { Modal, TwofaccountShow, - 'vue-pull-refresh': vuePullRefresh + 'vue-pull-refresh': vuePullRefresh, + draggable, }, methods: { @@ -241,6 +255,10 @@ } }, + saveOrder() { + this.axios.patch('/api/twofaccounts/reorder', {orderedIds: this.accounts.map(a => a.id)}) + }, + deleteAccount: function (id) { if(confirm(this.$t('twofaccounts.confirm.delete'))) { this.axios.delete('/api/twofaccounts/' + id) diff --git a/resources/sass/app.scss b/resources/sass/app.scss index 32c9f6f5..c3051b9c 100644 --- a/resources/sass/app.scss +++ b/resources/sass/app.scss @@ -52,7 +52,6 @@ a:hover { .tfa { border-radius: 6px; text-align: center; - cursor: pointer; background-color: hsl(0, 0%, 10%); /*black-bis from Bulma*/ padding: 0.75rem 1.5rem; margin: 0.5rem; @@ -89,22 +88,26 @@ a:hover { } .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; align-items: center; padding: 0.5rem 0 0 0; } @media screen and (max-width: 768px) { - .tfa-checkbox, .tfa-dots { + .tfa-checkbox, .tfa-dots, .tfa-edit { display: flex; align-items: center; padding: 0 } + + .tfa-dots { + margin-left: 1.5rem; + } } .tfa-content { @@ -118,7 +121,7 @@ a:hover { } .tfa-dots { - // order: 3; + cursor: grab; } @media screen and (max-width: 768px) { @@ -130,9 +133,13 @@ a:hover { order: 2; } - .tfa-dots { + .tfa-edit { order: 3; } + + .tfa-dots { + order: 4; + } } @media screen and (min-width: 769px) { @@ -146,6 +153,7 @@ a:hover { .tfa-text { display: block; max-width: 300px; + cursor: pointer; } .tfa img { diff --git a/routes/api.php b/routes/api.php index 24076f25..eb96e3a0 100644 --- a/routes/api.php +++ b/routes/api.php @@ -37,6 +37,7 @@ Route::group(['middleware' => 'auth:api'], function() { }); Route::delete('twofaccounts/batch', 'TwoFAccountController@batchDestroy'); + Route::patch('twofaccounts/reorder', 'TwoFAccountController@reorder'); Route::apiResource('twofaccounts', 'TwoFAccountController'); Route::post('twofaccounts/otp', 'TwoFAccountController@generateOTP')->name('twofaccounts.generateOTP'); Route::post('qrcode/decode', 'QrCodeController@decode');