diff --git a/public/mix-manifest.json b/public/mix-manifest.json index a1d9035a..4b299404 100644 --- a/public/mix-manifest.json +++ b/public/mix-manifest.json @@ -24,7 +24,7 @@ "/chunks/app-language.js": "/chunks/app-language.js?id=21a381da055e57280eed", "/chunks/app-language~chunks/dashboard~chunks/files~chunks/invoices~chunks/my-shared-items~chunks/page~7dbb6a42.js": "/chunks/app-language~chunks/dashboard~chunks/files~chunks/invoices~chunks/my-shared-items~chunks/page~7dbb6a42.js?id=3cbb19b80e635b3524e5", "/chunks/app-language~chunks/dashboard~chunks/invoices~chunks/page-edit~chunks/pages~chunks/plan-creat~1a92dd55.js": "/chunks/app-language~chunks/dashboard~chunks/invoices~chunks/page-edit~chunks/pages~chunks/plan-creat~1a92dd55.js?id=75317652be9e911b6013", - "/chunks/app-others.js": "/chunks/app-others.js?id=d763956aafc730e5bdcb", + "/chunks/app-others.js": "/chunks/app-others.js?id=2789aac07c894eeb29ea", "/chunks/app-payments.js": "/chunks/app-payments.js?id=8ca6c120a8ba6f3659f6", "/chunks/app-settings.js": "/chunks/app-settings.js?id=2a96295eef59bd6c8921", "/chunks/app-setup.js": "/chunks/app-setup.js?id=1b7698981735d7173309", @@ -250,5 +250,6 @@ "/chunks/user-storage.0e8d7663b9f8cd40de17.hot-update.js": "/chunks/user-storage.0e8d7663b9f8cd40de17.hot-update.js", "/chunks/user-storage.4eff070ff2a92236c8b2.hot-update.js": "/chunks/user-storage.4eff070ff2a92236c8b2.hot-update.js", "/chunks/settings-storage.4ecc7c38e789439da637.hot-update.js": "/chunks/settings-storage.4ecc7c38e789439da637.hot-update.js", - "/chunks/user-storage.4ecc7c38e789439da637.hot-update.js": "/chunks/user-storage.4ecc7c38e789439da637.hot-update.js" + "/chunks/user-storage.4ecc7c38e789439da637.hot-update.js": "/chunks/user-storage.4ecc7c38e789439da637.hot-update.js", + "/chunks/app-others.753478462556c2b747a9.hot-update.js": "/chunks/app-others.753478462556c2b747a9.hot-update.js" } diff --git a/resources/js/views/Admin/AppSettings/AppSettingsTabs/Others.vue b/resources/js/views/Admin/AppSettings/AppSettingsTabs/Others.vue index 8e8757c2..a43b66be 100644 --- a/resources/js/views/Admin/AppSettings/AppSettingsTabs/Others.vue +++ b/resources/js/views/Admin/AppSettings/AppSettingsTabs/Others.vue @@ -15,7 +15,7 @@ - { @@ -149,7 +149,7 @@ this.app = { contactMail: response.data.contact_email, googleAnalytics: response.data.google_analytics, - defaultStorage: response.data.default_storage_amount, + defaultStorage: response.data.default_max_storage_amount, userRegistration: parseInt(response.data.registration), storageLimitation: parseInt(response.data.storage_limitation), mimetypesBlacklist: response.data.mimetypes_blacklist, diff --git a/resources/views/index.blade.php b/resources/views/index.blade.php index c4100ab8..3a770cf7 100644 --- a/resources/views/index.blade.php +++ b/resources/views/index.blade.php @@ -60,8 +60,8 @@ userRegistration: {{ $settings->registration ?? 1 }}, userVerification: {{ $settings->user_verification ?? 0 }}, storageLimit: {{ $settings->storage_limitation ?? 1 }}, - storageDefaultSpace: {{ $settings->default_storage_amount ?? 5 }}, - storageDefaultSpaceFormatted: '{{ isset($settings->default_storage_amount) ? format_gigabytes($settings->default_storage_amount) : format_gigabytes(5) }}', + storageDefaultSpace: {{ $settings->default_max_storage_amount ?? 5 }}, + storageDefaultSpaceFormatted: '{{ isset($settings->default_max_storage_amount) ? format_gigabytes($settings->default_max_storage_amount) : format_gigabytes(5) }}', mimetypesBlacklist: '{{ isset($settings->mimetypes_blacklist) ? $settings->mimetypes_blacklist: null}}', uploadLimit: {{ isset($settings->upload_limit) ? format_bytes($settings->upload_limit) : 'undefined' }}, uploadLimitFormatted: '{{ isset($settings->upload_limit) ? format_megabytes($settings->upload_limit) : null }}', diff --git a/src/App/Console/Commands/SetupDevEnvironment.php b/src/App/Console/Commands/SetupDevEnvironment.php index e6d0ff68..0f12effa 100644 --- a/src/App/Console/Commands/SetupDevEnvironment.php +++ b/src/App/Console/Commands/SetupDevEnvironment.php @@ -1,4 +1,5 @@ setUpFaker(); } @@ -71,10 +73,10 @@ class SetupDevEnvironment extends Command $this->info('Creating default demo content...'); $this->create_admin_default_content(); - $this->generate_traffic(); $this->create_team_folders_content(); $this->create_share_with_me_team_folders_content(); $this->create_share_records(); + $this->generate_traffic(); $this->info('Clearing application cache...'); $this->clear_cache(); @@ -104,38 +106,21 @@ class SetupDevEnvironment extends Command $user ->settings() ->create([ - 'avatar' => $avatar_name, - 'name' => 'Jane Doe', - 'address' => $this->faker->address, - 'state' => $this->faker->state, - 'city' => $this->faker->city, - 'postal_code' => $this->faker->postcode, - 'country' => $this->faker->randomElement(['SK', 'CZ', 'DE', 'FR']), - 'phone_number' => $this->faker->phoneNumber, - 'timezone' => $this->faker->randomElement(['+1.0', '+2.0', '+3.0']), + 'avatar' => $avatar_name, + 'name' => 'Jane Doe', + 'address' => $this->faker->address, + 'state' => $this->faker->state, + 'city' => $this->faker->city, + 'postal_code' => $this->faker->postcode, + 'country' => $this->faker->randomElement(['SK', 'CZ', 'DE', 'FR']), + 'phone_number' => $this->faker->phoneNumber, + 'timezone' => $this->faker->randomElement(['+1.0', '+2.0', '+3.0']), ]); // Show user credentials $this->info('Default admin account created. Email: howdy@hi5ve.digital and Password: vuefilemanager'); } - private function generate_traffic(): void - { - $user = User::whereEmail('howdy@hi5ve.digital') - ->first(); - - foreach (range(0, 45) as $day) { - DB::table('traffic')->insert([ - 'id' => Str::uuid(), - 'user_id' => $user->id, - 'upload' => random_int(1111111, 9999999), - 'download' => random_int(11111111, 99999999), - 'created_at' => now()->subDays($day), - 'updated_at' => now()->subDays($day), - ]); - } - } - /** * Create default admin account */ @@ -179,15 +164,15 @@ class SetupDevEnvironment extends Command $newbie ->settings() ->create([ - 'avatar' => $avatar_name, - 'name' => $this->faker->name, - 'address' => $this->faker->address, - 'state' => $this->faker->state, - 'city' => $this->faker->city, - 'postal_code' => $this->faker->postcode, - 'country' => $this->faker->randomElement(['SK', 'CZ', 'DE', 'FR']), - 'phone_number' => $this->faker->phoneNumber, - 'timezone' => $this->faker->randomElement(['+1.0', '+2.0', '+3.0']), + 'avatar' => $avatar_name, + 'name' => $this->faker->name, + 'address' => $this->faker->address, + 'state' => $this->faker->state, + 'city' => $this->faker->city, + 'postal_code' => $this->faker->postcode, + 'country' => $this->faker->randomElement(['SK', 'CZ', 'DE', 'FR']), + 'phone_number' => $this->faker->phoneNumber, + 'timezone' => $this->faker->randomElement(['+1.0', '+2.0', '+3.0']), ]); $this->info("Generated user with email: $newbie->email and Password: vuefilemanager"); @@ -776,7 +761,7 @@ class SetupDevEnvironment extends Command collect([$members[0]->id, $members[1]->id]) ->each( - fn ($id) => DB::table('team_folder_members') + fn($id) => DB::table('team_folder_members') ->insert([ 'parent_id' => $companyProjectFolder->id, 'user_id' => $id, @@ -786,7 +771,7 @@ class SetupDevEnvironment extends Command collect([$members[2]->id, $members[3]->id]) ->each( - fn ($id) => DB::table('team_folder_members') + fn($id) => DB::table('team_folder_members') ->insert([ 'parent_id' => $financeDocumentsFolder->id, 'user_id' => $id, @@ -797,7 +782,7 @@ class SetupDevEnvironment extends Command // Create invitations collect([$members[4], $members[5]]) ->each( - fn ($user) => TeamFolderInvitation::factory() + fn($user) => TeamFolderInvitation::factory() ->create([ 'email' => $user->email, 'parent_id' => $companyProjectFolder->id, @@ -1030,9 +1015,13 @@ class SetupDevEnvironment extends Command 'value' => 1, ], [ - 'name' => 'default_storage_amount', + 'name' => 'default_max_storage_amount', 'value' => 5, ], + [ + 'name' => 'default_max_team_member', + 'value' => 10, + ], [ 'name' => 'setup_wizard_success', 'value' => 1, @@ -1091,6 +1080,30 @@ class SetupDevEnvironment extends Command }); } + + /** + * Generate demo traffic data + */ + private function generate_traffic(): void + { + $user = User::all(); + + foreach (range(0, 45) as $day) { + + $user + ->each(fn($user) => DB::table('traffic') + ->insert([ + 'id' => Str::uuid(), + 'user_id' => $user->id, + 'upload' => random_int(1111111, 9999999), + 'download' => random_int(11111111, 99999999), + 'created_at' => now()->subDays($day), + 'updated_at' => now()->subDays($day), + ]) + ); + } + } + /** * Migrate database and generate application keys */ @@ -1171,7 +1184,7 @@ class SetupDevEnvironment extends Command // Create thumbnail only if image is larger than predefined image sizes if ($intervention->getWidth() > $size['size']) { // Generate thumbnail - $intervention->resize($size['size'], null, fn ($constraint) => $constraint->aspectRatio())->stream(); + $intervention->resize($size['size'], null, fn($constraint) => $constraint->aspectRatio())->stream(); // Store thumbnail to disk Storage::put("files/$user->id/{$size['name']}-{$file_name}", $intervention); diff --git a/src/App/Console/Commands/SetupProdEnvironment.php b/src/App/Console/Commands/SetupProdEnvironment.php index 8d4bd98e..fe377c17 100644 --- a/src/App/Console/Commands/SetupProdEnvironment.php +++ b/src/App/Console/Commands/SetupProdEnvironment.php @@ -125,9 +125,13 @@ class SetupProdEnvironment extends Command 'value' => 1, ], [ - 'name' => 'default_storage_amount', + 'name' => 'default_max_storage_amount', 'value' => 5, ], + [ + 'name' => 'default_max_team_member', + 'value' => 10, + ], [ 'name' => 'setup_wizard_success', 'value' => 1, diff --git a/src/App/Users/Actions/CreateNewUserAction.php b/src/App/Users/Actions/CreateNewUserAction.php index 009b87bd..4fdd8fb9 100644 --- a/src/App/Users/Actions/CreateNewUserAction.php +++ b/src/App/Users/Actions/CreateNewUserAction.php @@ -24,7 +24,7 @@ class CreateNewUserAction extends Controller RegisterUserRequest $request ): Application | ResponseFactory | Response { $settings = get_settings([ - 'default_storage_amount', 'registration', 'user_verification', + 'default_max_storage_amount', 'registration', 'user_verification', ]); // Check if account registration is enabled diff --git a/src/App/Users/Models/User.php b/src/App/Users/Models/User.php index 1458e85f..75a202a7 100644 --- a/src/App/Users/Models/User.php +++ b/src/App/Users/Models/User.php @@ -209,8 +209,8 @@ class User extends Authenticatable implements MustVerifyEmail // Create default limitations $user->limitations()->create([ - 'max_storage_amount' => get_settings('default_storage_amount') ?? 1, - 'max_team_members' => 5, + 'max_storage_amount' => get_settings('default_max_storage_amount') ?? 1, + 'max_team_members' => get_settings('default_max_team_member') ?? 10, ]); // Create user directory for his files diff --git a/src/Domain/SetupWizard/Controllers/StoreAppSettingsController.php b/src/Domain/SetupWizard/Controllers/StoreAppSettingsController.php index 59878820..f270c1c3 100644 --- a/src/Domain/SetupWizard/Controllers/StoreAppSettingsController.php +++ b/src/Domain/SetupWizard/Controllers/StoreAppSettingsController.php @@ -61,9 +61,13 @@ class StoreAppSettingsController extends Controller 'value' => $request->input('storageLimitation'), ], [ - 'name' => 'default_storage_amount', + 'name' => 'default_max_storage_amount', 'value' => $request->input('defaultStorage') ?? 5, ], + [ + 'name' => 'default_max_team_member', + 'value' => $request->input('defaultMaxTeamMember') ?? 10, + ], ])->each(function ($col) { Setting::forceCreate([ 'name' => $col['name'], diff --git a/src/Support/Listeners/SubscriptionEventSubscriber.php b/src/Support/Listeners/SubscriptionEventSubscriber.php index c32a3923..e859dacf 100644 --- a/src/Support/Listeners/SubscriptionEventSubscriber.php +++ b/src/Support/Listeners/SubscriptionEventSubscriber.php @@ -27,7 +27,7 @@ class SubscriptionEventSubscriber public function handleSubscriptionWasExpired($event) { $event->subscription->user->limitations()->update([ - 'max_storage_amount' => get_settings('default_storage_amount') ?? 1, + 'max_storage_amount' => get_settings('default_max_storage_amount') ?? 5, 'max_team_members' => 5, ]); } diff --git a/tests/App/Users/SignFlowTest.php b/tests/App/Users/SignFlowTest.php index 40fbd51a..f0567b57 100644 --- a/tests/App/Users/SignFlowTest.php +++ b/tests/App/Users/SignFlowTest.php @@ -19,7 +19,7 @@ class SignFlowTest extends TestCase { collect([ [ - 'name' => 'default_storage_amount', + 'name' => 'default_max_storage_amount', 'value' => 12, ], [ diff --git a/tests/App/Users/UserSubscriptionTest.php b/tests/App/Users/UserSubscriptionTest.php index 93d8ba89..4e2f165c 100644 --- a/tests/App/Users/UserSubscriptionTest.php +++ b/tests/App/Users/UserSubscriptionTest.php @@ -95,7 +95,7 @@ class UserSubscriptionTest extends TestCase SubscriptionWasExpired::dispatch($user->subscription); $this->assertDatabaseHas('user_limitations', [ - 'max_storage_amount' => 1, + 'max_storage_amount' => 5, 'max_team_members' => 5, ]); } diff --git a/tests/Domain/SetupWizard/SetupWizardTest.php b/tests/Domain/SetupWizard/SetupWizardTest.php index fb3dfee4..de75082d 100644 --- a/tests/Domain/SetupWizard/SetupWizardTest.php +++ b/tests/Domain/SetupWizard/SetupWizardTest.php @@ -188,7 +188,7 @@ class SetupWizardTest extends TestCase ]); $this->assertDatabaseHas('settings', [ - 'name' => 'default_storage_amount', + 'name' => 'default_max_storage_amount', 'value' => '10', ]); diff --git a/tests/Domain/Teams/TeamLimitsTest.php b/tests/Domain/Teams/TeamLimitsTest.php index 5e636039..785448eb 100644 --- a/tests/Domain/Teams/TeamLimitsTest.php +++ b/tests/Domain/Teams/TeamLimitsTest.php @@ -46,6 +46,26 @@ class TeamLimitsTest extends TestCase 'email' => 'test@doe.com', 'permission' => 'can-edit', ], + [ + 'email' => 'test2@doe.com', + 'permission' => 'can-edit', + ], + [ + 'email' => 'test3@doe.com', + 'permission' => 'can-edit', + ], + [ + 'email' => 'test4@doe.com', + 'permission' => 'can-edit', + ], + [ + 'email' => 'test5@doe.com', + 'permission' => 'can-edit', + ], + [ + 'email' => 'test6@doe.com', + 'permission' => 'can-edit', + ], ], ]) ->assertStatus(423);