From 5da3eb25e43974891b417ce9f7846e8977e1f619 Mon Sep 17 00:00:00 2001 From: rhrt04 Date: Fri, 2 Oct 2020 12:34:04 +0200 Subject: [PATCH 01/35] Added Setting controller and model, Added Initial view for application settings --- .../Controllers/api/v1/SettingController.php | 64 ++++++ app/Setting.php | 15 ++ resources/js/lang/de/settings.js | 57 ++++++ resources/js/lang/en/settings.js | 57 ++++++ resources/js/router.js | 12 ++ resources/js/views/settings/Application.vue | 193 ++++++++++++++++++ resources/js/views/settings/Settings.vue | 9 + 7 files changed, 407 insertions(+) create mode 100644 app/Http/Controllers/api/v1/SettingController.php create mode 100644 app/Setting.php create mode 100644 resources/js/views/settings/Application.vue diff --git a/app/Http/Controllers/api/v1/SettingController.php b/app/Http/Controllers/api/v1/SettingController.php new file mode 100644 index 000000000..793ff4a4c --- /dev/null +++ b/app/Http/Controllers/api/v1/SettingController.php @@ -0,0 +1,64 @@ + Promise.resolve( + PermissionService.can('manage', 'SettingPolicy') + ) + } } ] }, diff --git a/resources/js/views/settings/Application.vue b/resources/js/views/settings/Application.vue new file mode 100644 index 000000000..f44575560 --- /dev/null +++ b/resources/js/views/settings/Application.vue @@ -0,0 +1,193 @@ + + + + + diff --git a/resources/js/views/settings/Settings.vue b/resources/js/views/settings/Settings.vue index 5e77694a9..922f1f601 100644 --- a/resources/js/views/settings/Settings.vue +++ b/resources/js/views/settings/Settings.vue @@ -22,6 +22,15 @@ + + + + + + {{ $t('settings.application.title') }} + + + From 75e79db58dc0d49c4652bc631776a5ce461c30d8 Mon Sep 17 00:00:00 2001 From: rhrt04 Date: Mon, 5 Oct 2020 15:50:23 +0200 Subject: [PATCH 02/35] Added Update Settings functionality, removed controller & model, removed settings that not yet necessary. --- .../api/v1/ApplicationController.php | 46 ++- .../Controllers/api/v1/SettingController.php | 64 ---- app/Http/Requests/UpdateSetting.php | 23 ++ app/Setting.php | 15 - resources/js/lang/de/settings.js | 65 ++-- resources/js/lang/en/settings.js | 65 ++-- resources/js/views/settings/Application.vue | 337 ++++++++++-------- routes/api.php | 2 + 8 files changed, 294 insertions(+), 323 deletions(-) delete mode 100644 app/Http/Controllers/api/v1/SettingController.php create mode 100644 app/Http/Requests/UpdateSetting.php delete mode 100644 app/Setting.php diff --git a/app/Http/Controllers/api/v1/ApplicationController.php b/app/Http/Controllers/api/v1/ApplicationController.php index 28a7fed10..ee6aeaacb 100644 --- a/app/Http/Controllers/api/v1/ApplicationController.php +++ b/app/Http/Controllers/api/v1/ApplicationController.php @@ -3,31 +3,55 @@ namespace App\Http\Controllers\api\v1; use App\Http\Controllers\Controller; +use App\Http\Requests\UpdateSetting; use App\Http\Resources\User as UserResource; +use Illuminate\Http\JsonResponse; use Illuminate\Support\Facades\Auth; class ApplicationController extends Controller { /** * Load basic application data, like settings - * @return \Illuminate\Http\JsonResponse + * @return JsonResponse */ public function settings() { return response()->json(['data' => [ - 'logo' => setting('logo'), - 'room_limit' => setting('room_limit'), - 'pagination_page_size' => setting('pagination_page_size'), - 'bbb' => [ - 'file_mimes' => config('bigbluebutton.allowed_file_mimes'), - 'max_filesize' => config('bigbluebutton.max_filesize'), - 'room_name_limit' => config('bigbluebutton.room_name_limit'), - 'welcome_message_limit' => config('bigbluebutton.welcome_message_limit') - ] - ] + 'logo' => setting('logo'), + 'room_limit' => setting('room_limit'), + 'pagination_page_size' => setting('pagination_page_size'), + 'own_rooms_pagination_page_size' => setting('own_rooms_pagination_page_size'), + 'bbb' => [ + 'file_mimes' => config('bigbluebutton.allowed_file_mimes'), + 'max_filesize' => config('bigbluebutton.max_filesize'), + 'room_name_limit' => config('bigbluebutton.room_name_limit'), + 'welcome_message_limit' => config('bigbluebutton.welcome_message_limit') + ] + ] ]); } + /** + * Update application settings data + * @param UpdateSetting $request + * @return JsonResponse + */ + public function updateSettings(UpdateSetting $request) + { + $data = $request->all(); + + foreach ($data as $key => $value) { + setting([$key => $value])->save(); + } + + return response()->json(['data' => [ + 'logo' => setting('logo'), + 'room_limit' => setting('room_limit'), + 'pagination_page_size' => setting('pagination_page_size'), + 'own_rooms_pagination_page_size' => setting('own_rooms_pagination_page_size') + ]], 201); + } + /** * Load current user * @return UserResource diff --git a/app/Http/Controllers/api/v1/SettingController.php b/app/Http/Controllers/api/v1/SettingController.php deleted file mode 100644 index 793ff4a4c..000000000 --- a/app/Http/Controllers/api/v1/SettingController.php +++ /dev/null @@ -1,64 +0,0 @@ - 'sometimes|required|numeric|max:255', + 'logo' => 'sometimes|required|url|max:255', + 'own_rooms_pagination_page_size' => 'sometimes|required|numeric|max:255', + 'pagination_page_size' => 'sometimes|required|numeric|max:255' + ]; + } +} diff --git a/app/Setting.php b/app/Setting.php deleted file mode 100644 index 5bc221e1d..000000000 --- a/app/Setting.php +++ /dev/null @@ -1,15 +0,0 @@ -
-

- {{ $t('settings.application.title') }} -

+ + +

+ {{ $t('settings.application.title') }} +

+
+ + + {{$t('settings.application.save')}} + + +

- + - - - - - {{ $t('settings.application.save') }} - - - - - - - - - + + {{ $t('settings.application.logo.title') }} + + + + + - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - + + + + + - + - - {{ $t('settings.application.registrationMethod.open') }} - {{ $t('settings.application.registrationMethod.invitation') }} - - - - - - {{ $t('settings.application.roomAuthentication.enabled') }} - {{ $t('settings.application.roomAuthentication.disabled') }} - - + - - - - {{ $t('settings.application.roomShare.enabled') }} - {{ $t('settings.application.roomShare.disabled') }} - + - + - + + {{ $t('settings.application.paginationPageSize.title') }} + + + - {{ $t('settings.application.recordingVisibility.public') }} - {{ $t('settings.application.recordingVisibility.unlisted') }} - + - + - - {{$t('settings.application.roomsPerUser.option.one')}} - {{$t('settings.application.roomsPerUser.option.five')}} - {{$t('settings.application.roomsPerUser.option.ten')}} - {{$t('settings.application.roomsPerUser.option.unlimited')}} - + + + + +
@@ -186,6 +125,98 @@ \ No newline at end of file diff --git a/resources/js/app.js b/resources/js/app.js index 7e2dcbb63..5bee20cec 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -51,6 +51,8 @@ Vue.config.errorHandler = function (error, vm, info) { } else if (responseStatus === env.HTTP_GUESTS_ONLY) { // 420 => only for guests, redirect to home route vm.flashMessage.info(vm.$t('app.flash.guestsOnly')); vm.$router.replace({ name: 'home' }); + } else if (responseStatus === env.HTTP_PAYLOAD_TOO_LARGE) { // 413 => payload to large + vm.flashMessage.error(vm.$t('app.flash.tooLarge')); } else if (responseStatus !== undefined) { // Another error on server vm.flashMessage.error({ message: errorMessage ? vm.$t('app.flash.serverError.message', { message: errorMessage }) : vm.$t('app.flash.serverError.emptyMessage'), diff --git a/resources/js/lang/de/app.js b/resources/js/lang/de/app.js index 6574240b4..6ea70146e 100644 --- a/resources/js/lang/de/app.js +++ b/resources/js/lang/de/app.js @@ -13,6 +13,11 @@ export default { title: 'Fehler' }, + tooLarge: { + message: 'Die übertragenen Daten waren zu groß!', + title: 'Fehler' + }, + guestsOnly: { message: 'Die Anfrage ist nur für nicht angemeldete Nutzer gestattet!', title: 'Nür für Gäste' diff --git a/resources/js/lang/en/app.js b/resources/js/lang/en/app.js index d71d4aec1..523e823d4 100644 --- a/resources/js/lang/en/app.js +++ b/resources/js/lang/en/app.js @@ -13,6 +13,11 @@ export default { title: 'Error' }, + tooLarge: { + message: 'The transmitted data was too large!', + title: 'Error' + }, + guestsOnly: { message: 'The request can only be done by guests!', title: 'Only for guests' diff --git a/resources/js/lang/en/settings.js b/resources/js/lang/en/settings.js index a91349da1..97fdd2123 100644 --- a/resources/js/lang/en/settings.js +++ b/resources/js/lang/en/settings.js @@ -52,11 +52,25 @@ export default { title: 'Logo', uploadTitle: 'Upload a logo (max. 500 KB)', urlTitle: 'URL to logo file', - description: 'Change the application logo. Enter the image URL', + description: 'Changes the application logo. Enter the image URL', hint: 'Image URL', selectFile: 'Select logo file' }, + favicon: { + title: 'Favicon', + uploadTitle: 'Upload a favicon (max. 500 KB, Format: .ico)', + urlTitle: 'URL to favicon file', + description: 'Changes the application favicon. Enter the favicon URL', + hint: 'https://domain.tld/path/favicon.ico', + selectFile: 'Select favicon file' + }, + + name: { + title: 'Name of the application', + description: 'Changes the site title' + }, + roomLimit: { title: 'Number of rooms per user', description: 'Limits the number of rooms that a user can have. This setting does not apply to administrators. Enter the value -1 for unlimited number of rooms' diff --git a/resources/js/views/settings/Application.vue b/resources/js/views/settings/Application.vue index bfef25a7e..d26f882dc 100644 --- a/resources/js/views/settings/Application.vue +++ b/resources/js/views/settings/Application.vue @@ -358,10 +358,6 @@ export default { }) .catch((error) => { if (error.response) { - if (error.response.status === env.HTTP_PAYLOAD_TOO_LARGE) { - this.errors = { logo_file: [this.$t('app.validation.tooLarge')] }; - return; - } if (error.response.status === env.HTTP_UNPROCESSABLE_ENTITY) { this.errors = error.response.data.errors; return; diff --git a/tests/Frontend/views/settings/Application.spec.js b/tests/Frontend/views/settings/Application.spec.js index 0bdb4eb92..045d7e378 100644 --- a/tests/Frontend/views/settings/Application.spec.js +++ b/tests/Frontend/views/settings/Application.spec.js @@ -334,10 +334,7 @@ describe('Application', function () { } }).then(() => { view.vm.$nextTick(); - - // Errors data 'logo_file' array is populated for this error code - expect(view.vm.$data.errors.logo_file.length).toBeGreaterThan(0); - + sinon.assert.calledOnce(Base.error); Base.error.restore(); done(); }); From 932878589dbecfe7ecee4ab439f42b440ac15d0f Mon Sep 17 00:00:00 2001 From: Samuel Weirich Date: Wed, 25 Nov 2020 14:11:00 +0100 Subject: [PATCH 24/35] Update resources/js/views/settings/Application.vue Co-authored-by: Dennis Stumm <6422711+dennis95stumm@users.noreply.github.com> --- resources/js/views/settings/Application.vue | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/resources/js/views/settings/Application.vue b/resources/js/views/settings/Application.vue index d26f882dc..bd03745c4 100644 --- a/resources/js/views/settings/Application.vue +++ b/resources/js/views/settings/Application.vue @@ -357,7 +357,11 @@ export default { this.roomLimitMode = (this.settings.roomLimit === -1 ? 'unlimited' : 'custom'); }) .catch((error) => { - if (error.response) { + if (error.response && error.response.status === env.HTTP_UNPROCESSABLE_ENTITY) { + this.errors = error.response.data.errors; + } else { + Base.error(error, this.$root); + } if (error.response.status === env.HTTP_UNPROCESSABLE_ENTITY) { this.errors = error.response.data.errors; return; From f8cf5cfa4caa06c669c660227ec763a8244837c2 Mon Sep 17 00:00:00 2001 From: Samuel Weirich Date: Mon, 30 Nov 2020 15:19:51 +0100 Subject: [PATCH 25/35] Github comments --- app/Http/Requests/UpdateSetting.php | 6 +- resources/js/lang/de/settings.js | 6 +- resources/js/lang/en/settings.js | 8 +- resources/js/views/settings/Application.vue | 169 +++++++++----------- 4 files changed, 84 insertions(+), 105 deletions(-) diff --git a/app/Http/Requests/UpdateSetting.php b/app/Http/Requests/UpdateSetting.php index e31fec9da..7f06cd8e9 100644 --- a/app/Http/Requests/UpdateSetting.php +++ b/app/Http/Requests/UpdateSetting.php @@ -15,13 +15,13 @@ public function rules() { return [ 'name' => 'required|string|max:255', - 'room_limit' => 'required|numeric|min:-1,max:100', + 'room_limit' => 'required|numeric|min:-1|max:100', 'logo' => 'required_without:logo_file|string|max:255', 'logo_file' => 'required_without:logo|image|max:500', // 500 KB, larger files are bad for loading times 'favicon' => 'required_without:favicon_file|string|max:255', 'favicon_file' => 'required_without:favicon|mimes:ico|max:500', // 500 KB, larger files are bad for loading times - 'own_rooms_pagination_page_size' => 'required|numeric|min:1,max:25', - 'pagination_page_size' => 'required|numeric|min:1,max:100' + 'own_rooms_pagination_page_size' => 'required|numeric|min:1|max:25', + 'pagination_page_size' => 'required|numeric|min:1|max:100' ]; } } diff --git a/resources/js/lang/de/settings.js b/resources/js/lang/de/settings.js index ff8a3283f..bf310f4c6 100644 --- a/resources/js/lang/de/settings.js +++ b/resources/js/lang/de/settings.js @@ -55,7 +55,8 @@ export default { urlTitle: 'URL zu Logo-Datei', description: 'URL zum Logo', hint: 'https://domain.tld/path/logo.svg', - selectFile: 'Logo-Datei auswählen' + selectFile: 'Logo-Datei auswählen', + alt: 'Favicon Vorschau' }, favicon: { @@ -64,7 +65,8 @@ export default { urlTitle: 'URL zu Favicon-Datei', description: 'URL zum Favicon', hint: 'https://domain.tld/path/favicon.ico', - selectFile: 'Favicon-Datei auswählen' + selectFile: 'Favicon-Datei auswählen', + alt: 'Favicon Vorschau' }, name: { diff --git a/resources/js/lang/en/settings.js b/resources/js/lang/en/settings.js index 97fdd2123..fe844db5c 100644 --- a/resources/js/lang/en/settings.js +++ b/resources/js/lang/en/settings.js @@ -53,8 +53,9 @@ export default { uploadTitle: 'Upload a logo (max. 500 KB)', urlTitle: 'URL to logo file', description: 'Changes the application logo. Enter the image URL', - hint: 'Image URL', - selectFile: 'Select logo file' + hint: 'https://domain.tld/path/logo.svg', + selectFile: 'Select logo file', + alt: 'Logo preview' }, favicon: { @@ -63,7 +64,8 @@ export default { urlTitle: 'URL to favicon file', description: 'Changes the application favicon. Enter the favicon URL', hint: 'https://domain.tld/path/favicon.ico', - selectFile: 'Select favicon file' + selectFile: 'Select favicon file', + alt: 'Favicon preview' }, name: { diff --git a/resources/js/views/settings/Application.vue b/resources/js/views/settings/Application.vue index bd03745c4..9affce048 100644 --- a/resources/js/views/settings/Application.vue +++ b/resources/js/views/settings/Application.vue @@ -2,29 +2,19 @@

{{ $t('settings.application.title') }} - - {{ $t('app.save') }} -


- + - - - - - - {{ $t('settings.application.favicon.urlTitle') }} - - - - + + {{ $t('settings.application.favicon.uploadTitle') }} - - - {{ $t('settings.application.logo.urlTitle') }} - - - - + + {{ $t('settings.application.logo.uploadTitle') }} - - - @@ -207,17 +187,15 @@ - - - - - - +
+ + {{ $t('app.save') }} + +
@@ -277,9 +263,9 @@ export default { name: null, logo: null, favicon: null, - roomLimit: null, - paginationPageSize: null, - ownRoomsPaginationPageSize: null + room_limit: null, + pagination_page_size: null, + own_rooms_pagination_page_size: null }, errors: {} }; @@ -292,13 +278,8 @@ export default { this.isBusy = true; Base.call('settings') .then(response => { - this.settings.name = response.data.data.name; - this.settings.logo = response.data.data.logo; - this.settings.favicon = response.data.data.favicon; - this.settings.roomLimit = response.data.data.room_limit; - this.settings.ownRoomsPaginationPageSize = response.data.data.own_rooms_pagination_page_size; - this.settings.paginationPageSize = response.data.data.pagination_page_size; - this.roomLimitMode = (this.settings.roomLimit === -1 ? 'unlimited' : 'custom'); + this.settings = response.data.data; + this.roomLimitMode = (this.settings.room_limit === -1 ? 'unlimited' : 'custom'); }) .catch((error) => { Base.error(error, this.$root, error.message); @@ -348,13 +329,8 @@ export default { this.uploadLogoFile = null; // update form input - this.settings.logo = response.data.data.logo; - this.settings.favicon = response.data.data.favicon; - this.settings.name = response.data.data.name; - this.settings.roomLimit = response.data.data.room_limit; - this.settings.ownRoomsPaginationPageSize = response.data.data.own_rooms_pagination_page_size; - this.settings.paginationPageSize = response.data.data.pagination_page_size; - this.roomLimitMode = (this.settings.roomLimit === -1 ? 'unlimited' : 'custom'); + this.settings = response.data.data; + this.roomLimitMode = (this.settings.room_limit === -1 ? 'unlimited' : 'custom'); }) .catch((error) => { if (error.response && error.response.status === env.HTTP_UNPROCESSABLE_ENTITY) { @@ -362,12 +338,6 @@ export default { } else { Base.error(error, this.$root); } - if (error.response.status === env.HTTP_UNPROCESSABLE_ENTITY) { - this.errors = error.response.data.errors; - return; - } - } - Base.error(error, this.$root); }) .finally(() => { this.isBusy = false; @@ -381,10 +351,10 @@ export default { roomLimitModeChanged (value) { switch (value) { case 'unlimited': - this.settings.roomLimit = -1; + this.settings.room_limit = -1; break; case 'custom': - this.settings.roomLimit = 0; + this.settings.room_limit = 0; break; } }, @@ -426,6 +396,11 @@ export default { } }, watch: { + + room_limit (newValue, oldValue) { + + }, + /** * watch for logo file select changes, encode to base64 and display image * @param newValue From b1df3d5ad00c3172e5a236fc0610497a2c95c1ef Mon Sep 17 00:00:00 2001 From: Samuel Weirich Date: Mon, 30 Nov 2020 15:26:43 +0100 Subject: [PATCH 26/35] fix tests --- .../views/settings/Application.spec.js | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/Frontend/views/settings/Application.spec.js b/tests/Frontend/views/settings/Application.spec.js index 045d7e378..652aaf45b 100644 --- a/tests/Frontend/views/settings/Application.spec.js +++ b/tests/Frontend/views/settings/Application.spec.js @@ -69,9 +69,9 @@ describe('Application', function () { }).then(() => { view.vm.$nextTick(); expect(view.vm.$data.settings.logo).toBe('test.svg'); - expect(view.vm.$data.settings.roomLimit).toBe(-1); - expect(view.vm.$data.settings.paginationPageSize).toBe(10); - expect(view.vm.$data.settings.ownRoomsPaginationPageSize).toBe(5); + expect(view.vm.$data.settings.room_limit).toBe(-1); + expect(view.vm.$data.settings.pagination_page_size).toBe(10); + expect(view.vm.$data.settings.own_rooms_pagination_page_size).toBe(5); expect(view.vm.$data.roomLimitMode).toBe('unlimited'); done(); }); @@ -102,9 +102,9 @@ describe('Application', function () { }).then(() => { view.vm.$nextTick(); expect(view.vm.$data.settings.logo).toBe('test.svg'); - expect(view.vm.$data.settings.roomLimit).toBe(32); - expect(view.vm.$data.settings.paginationPageSize).toBe(10); - expect(view.vm.$data.settings.ownRoomsPaginationPageSize).toBe(5); + expect(view.vm.$data.settings.room_limit).toBe(32); + expect(view.vm.$data.settings.pagination_page_size).toBe(10); + expect(view.vm.$data.settings.own_rooms_pagination_page_size).toBe(5); expect(view.vm.$data.roomLimitMode).toBe('custom'); done(); }); @@ -154,9 +154,9 @@ describe('Application', function () { }).then(() => { view.vm.$nextTick(); expect(view.vm.$data.settings.logo).toBe('test.svg'); - expect(view.vm.$data.settings.roomLimit).toBe(32); - expect(view.vm.$data.settings.paginationPageSize).toBe(10); - expect(view.vm.$data.settings.ownRoomsPaginationPageSize).toBe(5); + expect(view.vm.$data.settings.room_limit).toBe(32); + expect(view.vm.$data.settings.pagination_page_size).toBe(10); + expect(view.vm.$data.settings.own_rooms_pagination_page_size).toBe(5); expect(view.vm.$data.roomLimitMode).toBe('custom'); expect(view.vm.$data.isBusy).toBeFalsy(); done(); @@ -207,9 +207,9 @@ describe('Application', function () { }).then(() => { view.vm.$nextTick(); expect(view.vm.$data.settings.logo).toBe('test.svg'); - expect(view.vm.$data.settings.roomLimit).toBe(-1); - expect(view.vm.$data.settings.paginationPageSize).toBe(10); - expect(view.vm.$data.settings.ownRoomsPaginationPageSize).toBe(5); + expect(view.vm.$data.settings.room_limit).toBe(-1); + expect(view.vm.$data.settings.pagination_page_size).toBe(10); + expect(view.vm.$data.settings.own_rooms_pagination_page_size).toBe(5); expect(view.vm.$data.roomLimitMode).toBe('unlimited'); expect(view.vm.$data.isBusy).toBeFalsy(); done(); @@ -234,12 +234,12 @@ describe('Application', function () { // Simulate radio group check to 'unlimited' option, set room limit value to '-1' and hide roomLimitInput await view.vm.roomLimitModeChanged('unlimited'); - expect(view.vm.$data.settings.roomLimit).toBe(-1); + expect(view.vm.$data.settings.room_limit).toBe(-1); // Simulate radio group check back to 'custom' option await view.vm.roomLimitModeChanged('custom'); - expect(view.vm.$data.settings.roomLimit).toBe(0); + expect(view.vm.$data.settings.room_limit).toBe(0); }); it('getSettings error handler', function (done) { From 49ee710f08b8a2070adfd06309f5c1638cbdf4b6 Mon Sep 17 00:00:00 2001 From: Samuel Weirich Date: Tue, 1 Dec 2020 09:38:28 +0100 Subject: [PATCH 27/35] add minMax-Test --- tests/Feature/api/v1/SettingsTest.php | 50 +++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/tests/Feature/api/v1/SettingsTest.php b/tests/Feature/api/v1/SettingsTest.php index 9bc931944..642481ff4 100644 --- a/tests/Feature/api/v1/SettingsTest.php +++ b/tests/Feature/api/v1/SettingsTest.php @@ -185,4 +185,54 @@ public function testUpdateApplicationSettingsWithInvalidInputs() 'room_limit' ]); } + + /** + * Tests that updates application settings with invalid inputs for numeric input + * + * @return void + */ + public function testUpdateApplicationSettingsMinMax() + { + // Add necessary role and permission to user to update application settings + $role = factory(Role::class)->create(); + $permission = factory(Permission::class)->create(['name' => 'settings.update']); + $role->permissions()->attach($permission); + $this->user->roles()->attach($role); + + // inputs lower than allowed minimum + $this->actingAs($this->user)->putJson(route('api.v1.application.update'), + [ + 'name' => 'test', + 'favicon' => '/storage/image/favicon.ico', + 'logo' => '/storage/image/testfile.svg', + 'pagination_page_size' => '0', + 'own_rooms_pagination_page_size' => '0', + 'room_limit' => '-2', + ] + ) + ->assertStatus(422) + ->assertJsonValidationErrors([ + 'pagination_page_size', + 'own_rooms_pagination_page_size', + 'room_limit' + ]); + + // inputs higher than allowed minimum + $this->putJson(route('api.v1.application.update'), + [ + 'name' => 'test', + 'favicon' => '/storage/image/favicon.ico', + 'logo' => '/storage/image/testfile.svg', + 'pagination_page_size' => '101', + 'own_rooms_pagination_page_size' => '26', + 'room_limit' => '101', + ] + ) + ->assertStatus(422) + ->assertJsonValidationErrors([ + 'pagination_page_size', + 'own_rooms_pagination_page_size', + 'room_limit' + ]); + } } From 8efb04ac7654f01b74943060d4a7d0a0b496e86d Mon Sep 17 00:00:00 2001 From: Samuel Weirich Date: Tue, 1 Dec 2020 09:58:16 +0100 Subject: [PATCH 28/35] Add b-form and form validation --- resources/js/views/settings/Application.vue | 41 ++++++++++++++++----- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/resources/js/views/settings/Application.vue b/resources/js/views/settings/Application.vue index 9affce048..3b19fde1e 100644 --- a/resources/js/views/settings/Application.vue +++ b/resources/js/views/settings/Application.vue @@ -6,6 +6,8 @@
+ + @@ -55,6 +58,7 @@ @@ -198,6 +206,9 @@ v-model="settings.pagination_page_size" type="number" :disabled="isBusy || viewOnly" + min="1" + max="100" + required :state='fieldState("pagination_page_size")' > @@ -219,6 +230,9 @@ @@ -233,12 +247,14 @@ {{ $t('app.save') }} + + @@ -289,12 +305,19 @@ export default { }); }, + /** + * Handle form submit event, prevent default form submission, instead call updateSettings to send data to server + */ + onSubmit (evt) { + evt.preventDefault(); + this.updateSettings(); + }, + /** * Handle update settings data * - * @param settings Settings object to fill the payload */ - updateSettings (settings) { + updateSettings () { this.isBusy = true; // Build form data @@ -302,17 +325,17 @@ export default { if (this.uploadLogoFile) { formData.append('logo_file', this.uploadLogoFile); } else { - formData.append('logo', settings.logo); + formData.append('logo', this.settings.logo); } if (this.uploadFaviconFile) { formData.append('favicon_file', this.uploadFaviconFile); } else { - formData.append('favicon', settings.favicon); + formData.append('favicon', this.settings.favicon); } - formData.append('name', settings.name); - formData.append('room_limit', settings.roomLimit); - formData.append('pagination_page_size', settings.paginationPageSize); - formData.append('own_rooms_pagination_page_size', settings.ownRoomsPaginationPageSize); + formData.append('name', this.settings.name); + formData.append('room_limit', this.settings.room_limit); + formData.append('pagination_page_size', this.settings.pagination_page_size); + formData.append('own_rooms_pagination_page_size', this.settings.own_rooms_pagination_page_size); formData.append('_method', 'PUT'); Base.call('settings', From 3ac6710f995b89a1100a70612c650009acb37ce0 Mon Sep 17 00:00:00 2001 From: Samuel Weirich Date: Tue, 1 Dec 2020 10:13:09 +0100 Subject: [PATCH 29/35] Add overlay and fix git comments --- resources/js/views/settings/Application.vue | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/resources/js/views/settings/Application.vue b/resources/js/views/settings/Application.vue index 3b19fde1e..7d66570fe 100644 --- a/resources/js/views/settings/Application.vue +++ b/resources/js/views/settings/Application.vue @@ -5,7 +5,7 @@
- + @@ -254,7 +254,7 @@ - + @@ -269,20 +269,14 @@ export default { data () { return { + loaded: false, roomLimitMode: 'custom', uploadLogoFile: null, uploadLogoFileSrc: null, uploadFaviconFile: null, uploadFaviconFileSrc: null, isBusy: false, - settings: { - name: null, - logo: null, - favicon: null, - room_limit: null, - pagination_page_size: null, - own_rooms_pagination_page_size: null - }, + settings: {}, errors: {} }; }, @@ -296,6 +290,7 @@ export default { .then(response => { this.settings = response.data.data; this.roomLimitMode = (this.settings.room_limit === -1 ? 'unlimited' : 'custom'); + this.loaded = true; }) .catch((error) => { Base.error(error, this.$root, error.message); From 2a7ee10ae9b4744c295fc2847abfdc0150762dc8 Mon Sep 17 00:00:00 2001 From: Samuel Weirich Date: Tue, 1 Dec 2020 12:12:49 +0100 Subject: [PATCH 30/35] Improve overlay --- resources/js/views/settings/Application.vue | 494 ++++++++++---------- 1 file changed, 254 insertions(+), 240 deletions(-) diff --git a/resources/js/views/settings/Application.vue b/resources/js/views/settings/Application.vue index 7d66570fe..0501fce9d 100644 --- a/resources/js/views/settings/Application.vue +++ b/resources/js/views/settings/Application.vue @@ -6,256 +6,270 @@
- - - - - - - - - - - - - - - +
+ + - - - - {{ $t('settings.application.favicon.urlTitle') }} - {{ $t('app.reload') }} + +
+ + + + + + + - {{ $t('settings.application.favicon.uploadTitle') }} - - - - - -
-
- - -
- - - - - - - - - - {{ $t('settings.application.logo.urlTitle') }} - - - {{ $t('settings.application.logo.uploadTitle') }} - - +
+ +
+ + + + + + + + + + {{ $t('settings.application.favicon.urlTitle') }} + - - - - - - - - - - - - + {{ $t('settings.application.favicon.uploadTitle') }} + + + + + + + + + + + + + + + + + + + + {{ $t('settings.application.logo.urlTitle') }} + + + {{ $t('settings.application.logo.uploadTitle') }} + + + + + + + + + + + + + + :label="$t('settings.application.roomLimit.title')" + > + - - - - - - - - - + + + + + + + - - - - - - - - + + + + + + + - - - - - -
- - {{ $t('app.save') }} - - -
+ + + + + + +
+
+ + {{ $t('app.save') }} + +
+
- +