From a51dece5eeebf4e50e74564af06a3982126759d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=8Carodej?= Date: Mon, 14 Mar 2022 18:16:50 +0100 Subject: [PATCH] - readme update - command update --- README.md | 23 +- .../Commands/DemoNotificationDataCommand.php | 222 ------------------ .../Console/Commands/SetupDevEnvironment.php | 111 +++++++++ src/App/Console/Kernel.php | 3 - webpack.mix.js | 4 +- 5 files changed, 125 insertions(+), 238 deletions(-) delete mode 100644 src/App/Console/Commands/DemoNotificationDataCommand.php diff --git a/README.md b/README.md index 604a8553..cf02f65b 100644 --- a/README.md +++ b/README.md @@ -134,7 +134,7 @@ Make sure you have enabled mod_rewrite. There is an example config for running V # Developers ## Running development environment on your localhost -At first, please update your database credentials in .env file +If you would like to express set up, please update your database credentials in .env file ``` DB_CONNECTION=mysql DB_HOST=127.0.0.1 @@ -144,6 +144,17 @@ DB_USERNAME=root DB_PASSWORD= ``` +If you would like to generate demo content, run this command below. Demo account will be created with credentials `howdy@hi5ve.digital` and password `vuefilemanager`. +``` +php artisan setup:dev +``` +If you would like express installation without demo data, run this command below. Demo account will be created with credentials `howdy@hi5ve.digital` and password `vuefilemanager`. +``` +php artisan setup:prod +``` +After that, please make sure your current host/domain where you are running app is included in your .env SANCTUM_STATEFUL_DOMAINS variable. + + To start server on your localhost, run command below. ``` php artisan serve @@ -164,16 +175,6 @@ To compiles for production build, run this command npm run prod ``` -If you would like to generate demo content, run this command below. It wil reinstall application and generate demo data. Demo account will be created with credentials 'howdy@hi5ve.digital' and password 'vuefilemanager'. -``` -php artisan setup:dev -``` -If you would like to install VueFileManager expressively without demo data, run this command below. It wil reinstall application from scratch. New account will be created with credentials 'howdy@hi5ve.digital' and password 'vuefilemanager'. -``` -php artisan setup:prod -``` -After that, please make sure your current host/domain where you are running app is included in your .env SANCTUM_STATEFUL_DOMAINS variable. - ## Support The following support channels are available at your fingertips: diff --git a/src/App/Console/Commands/DemoNotificationDataCommand.php b/src/App/Console/Commands/DemoNotificationDataCommand.php deleted file mode 100644 index 5e4641bd..00000000 --- a/src/App/Console/Commands/DemoNotificationDataCommand.php +++ /dev/null @@ -1,222 +0,0 @@ -info('Setting up notification demo data'); - - $this->generateTeamInvitationNotification(); - $this->generateFileRequestFilledNotification(); - - $this->info('Everything is done, congratulations! 🥳🥳🥳'); - } - - private function generateTeamInvitationNotification() - { - $alice = User::whereEmail('alice@hi5ve.digital') - ->first(); - - $howdy = User::whereEmail('howdy@hi5ve.digital') - ->first(); - - $newV2Wallpaper = Folder::factory() - ->create([ - 'user_id' => $alice->id, - 'team_folder' => true, - 'name' => 'New v2 Wallpaper', - ]); - - $invitation = TeamFolderInvitation::factory() - ->create([ - 'email' => 'howdy@hi5ve.digital', - 'parent_id' => $newV2Wallpaper->id, - 'inviter_id' => $newV2Wallpaper->user_id, - 'status' => 'pending', - 'permission' => 'can-edit', - ]); - - DB::table('notifications') - ->insert([ - 'id' => Str::uuid(), - 'type' => 'Domain\UploadRequest\Notifications\UploadRequestFulfilledNotification', - 'notifiable_type' => 'App\Users\Models\User', - 'notifiable_id' => $howdy->id, - 'data' => json_encode([ - 'type' => 'team-invitation', - 'title' => 'New Team Invitation', - 'description' => 'Jane Doe invite you to join into Team Folder.', - 'action' => [ - 'type' => 'invitation', - 'params' => [ - 'id' => $invitation->id, - ], - ], - ]), - 'read_at' => now(), - 'created_at' => now(), - 'updated_at' => now(), - ]); - } - - private function generateFileRequestFilledNotification() - { - $howdy = User::whereEmail('howdy@hi5ve.digital') - ->first(); - - $sharedFolder = Folder::where('name', 'Shared Folder') - ->first(); - - $fileRequestFolder = Folder::factory() - ->create([ - 'parent_id' => $sharedFolder->id, - 'user_id' => $howdy->id, - 'team_folder' => false, - 'name' => 'Upload Request from 10. Mar. 2022', - ]); - - DB::table('notifications') - ->insert([ - 'id' => Str::uuid(), - 'type' => 'Domain\UploadRequest\Notifications\UploadRequestFulfilledNotification', - 'notifiable_type' => 'App\Users\Models\User', - 'notifiable_id' => $howdy->id, - 'data' => json_encode([ - 'type' => 'file-request', - 'title' => 'File Request Filled', - 'description' => "Your file request for 'Shared Folder' folder was filled successfully.", - 'action' => [ - 'type' => 'route', - 'params' => [ - 'route' => 'Files', - 'button' => 'Show Files', - 'id' => $fileRequestFolder->id, - ], - ], - ]), - 'created_at' => now(), - 'updated_at' => now(), - ]); - - // Get meme gallery - collect([ - 'demo/request/v2-wallpaper.jpg', - ]) - ->each(function ($file) use ($howdy, $fileRequestFolder) { - $thumbnail = $this->generate_thumbnails($file, $howdy); - - // Create file record - File::create([ - 'parent_id' => $fileRequestFolder->id, - 'user_id' => $howdy->id, - 'name' => $thumbnail['name'], - 'basename' => $thumbnail['basename'], - 'type' => 'image', - 'author' => 'user', - 'mimetype' => 'jpg', - 'filesize' => rand(1000000, 4000000), - 'created_at' => now()->subMinutes(rand(1, 5)), - ]); - }); - } - - /** - * @param $avatar - * @return string - * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException - */ - private function generate_avatar($avatar): string - { - $image = \Illuminate\Support\Facades\File::get(storage_path("/demo/avatars/{$avatar}")); - - // Create avatar name - $avatar_name = Str::uuid() . '.png'; - - // Create intervention image - $img = Image::make($image); - - $this->info("Generating thumbnails for $avatar..."); - - // Generate avatar - collect(config('vuefilemanager.avatar_sizes')) - ->each(function ($size) use ($img, $avatar_name) { - // fit thumbnail - $img->fit($size['size'], $size['size'])->stream(); - - // Store thumbnail to disk - Storage::put("avatars/{$size['name']}-{$avatar_name}", $img); - }); - - return $avatar_name; - } - - /** - * @param $file - * @param $user - * @return string - * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException - */ - private function generate_thumbnails($file, $user): array - { - // Create image name - $file_name = Str::uuid() . '.jpg'; - - $this->info("Generating thumbnails for $file..."); - - // Generate avatar sizes - collect([ - config('vuefilemanager.image_sizes.later'), - config('vuefilemanager.image_sizes.immediately'), - ])->collapse() - ->each(function ($size) use ($file_name, $user, $file) { - $image = \Illuminate\Support\Facades\File::get(storage_path($file)); - - // Create intervention image - $intervention = Image::make($image)->orientate(); - - // 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(); - - // Store thumbnail to disk - Storage::put("files/$user->id/{$size['name']}-{$file_name}", $intervention); - } - }); - - // Store original to disk - Storage::putFileAs("files/$user->id", storage_path($file), $file_name, 'private'); - - return [ - 'basename' => $file_name, - 'name' => head(explode('.', last(explode('/', $file)))), - ]; - } -} diff --git a/src/App/Console/Commands/SetupDevEnvironment.php b/src/App/Console/Commands/SetupDevEnvironment.php index 46817582..f4ac9826 100644 --- a/src/App/Console/Commands/SetupDevEnvironment.php +++ b/src/App/Console/Commands/SetupDevEnvironment.php @@ -74,6 +74,9 @@ class SetupDevEnvironment extends Command $this->create_share_records(); $this->generate_traffic(); + $this->generateTeamInvitationNotification(); + $this->generateFileRequestFilledNotification(); + $this->info('Clearing application cache...'); $this->clear_cache(); @@ -87,6 +90,114 @@ class SetupDevEnvironment extends Command $this->info('Everything is done, congratulations! 🥳🥳🥳'); } + private function generateTeamInvitationNotification() + { + $alice = User::whereEmail('alice@hi5ve.digital') + ->first(); + + $howdy = User::whereEmail('howdy@hi5ve.digital') + ->first(); + + $newV2Wallpaper = Folder::factory() + ->create([ + 'user_id' => $alice->id, + 'team_folder' => true, + 'name' => 'New v2 Wallpaper', + ]); + + $invitation = TeamFolderInvitation::factory() + ->create([ + 'email' => 'howdy@hi5ve.digital', + 'parent_id' => $newV2Wallpaper->id, + 'inviter_id' => $newV2Wallpaper->user_id, + 'status' => 'pending', + 'permission' => 'can-edit', + ]); + + DB::table('notifications') + ->insert([ + 'id' => Str::uuid(), + 'type' => 'Domain\UploadRequest\Notifications\UploadRequestFulfilledNotification', + 'notifiable_type' => 'App\Users\Models\User', + 'notifiable_id' => $howdy->id, + 'data' => json_encode([ + 'type' => 'team-invitation', + 'title' => 'New Team Invitation', + 'description' => 'Jane Doe invite you to join into Team Folder.', + 'action' => [ + 'type' => 'invitation', + 'params' => [ + 'id' => $invitation->id, + ], + ], + ]), + 'read_at' => now(), + 'created_at' => now(), + 'updated_at' => now(), + ]); + } + + private function generateFileRequestFilledNotification() + { + $howdy = User::whereEmail('howdy@hi5ve.digital') + ->first(); + + $sharedFolder = Folder::where('name', 'Shared Folder') + ->first(); + + $fileRequestFolder = Folder::factory() + ->create([ + 'parent_id' => $sharedFolder->id, + 'user_id' => $howdy->id, + 'team_folder' => false, + 'name' => 'Upload Request from 10. Mar. 2022', + ]); + + DB::table('notifications') + ->insert([ + 'id' => Str::uuid(), + 'type' => 'Domain\UploadRequest\Notifications\UploadRequestFulfilledNotification', + 'notifiable_type' => 'App\Users\Models\User', + 'notifiable_id' => $howdy->id, + 'data' => json_encode([ + 'type' => 'file-request', + 'title' => 'File Request Filled', + 'description' => "Your file request for 'Shared Folder' folder was filled successfully.", + 'action' => [ + 'type' => 'route', + 'params' => [ + 'route' => 'Files', + 'button' => 'Show Files', + 'id' => $fileRequestFolder->id, + ], + ], + ]), + 'created_at' => now(), + 'updated_at' => now(), + ]); + + // Get meme gallery + collect([ + 'demo/request/v2-wallpaper.jpg', + ]) + ->each(function ($file) use ($howdy, $fileRequestFolder) { + $thumbnail = $this->generate_thumbnails($file, $howdy); + + // Create file record + File::create([ + 'parent_id' => $fileRequestFolder->id, + 'user_id' => $howdy->id, + 'name' => $thumbnail['name'], + 'basename' => $thumbnail['basename'], + 'type' => 'image', + 'author' => 'user', + 'mimetype' => 'jpg', + 'filesize' => rand(1000000, 4000000), + 'created_at' => now()->subMinutes(rand(1, 5)), + ]); + }); + } + /** * Create default admin account */ diff --git a/src/App/Console/Kernel.php b/src/App/Console/Kernel.php index 5becbd72..5663088c 100644 --- a/src/App/Console/Kernel.php +++ b/src/App/Console/Kernel.php @@ -21,9 +21,6 @@ class Kernel extends ConsoleKernel * @var array */ protected $commands = [ - // V2 demo updates - DemoNotificationDataCommand::class, - // Basic demo content generator SetupDevEnvironment::class, SetupProdEnvironment::class, diff --git a/webpack.mix.js b/webpack.mix.js index 5fa9da97..14c468f9 100644 --- a/webpack.mix.js +++ b/webpack.mix.js @@ -25,10 +25,10 @@ mix chunkFilename: '[name].js?id=[chunkhash]', } }) - .options({ + /*.options({ hmrOptions: { host: '192.168.1.112', port: '8080' }, - }) + })*/ .disableNotifications();