- readme update

- command update
This commit is contained in:
Čarodej
2022-03-14 18:16:50 +01:00
parent a7db1a22d2
commit a51dece5ee
5 changed files with 125 additions and 238 deletions

View File

@@ -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:

View File

@@ -1,222 +0,0 @@
<?php
namespace App\Console\Commands;
use App\Users\Models\User;
use Illuminate\Support\Str;
use Domain\Files\Models\File;
use Illuminate\Console\Command;
use Domain\Folders\Models\Folder;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
use Illuminate\Foundation\Testing\WithFaker;
use Domain\Teams\Models\TeamFolderInvitation;
use Intervention\Image\ImageManagerStatic as Image;
class DemoNotificationDataCommand extends Command
{
use WithFaker;
/**
* The name and signature of the console command.
*/
protected $signature = 'demo:notifications';
/**
* The console command description.
*/
protected $description = 'Set up demo notifications data';
/**
* Execute the console command.
*/
public function handle(): void
{
$this->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)))),
];
}
}

View File

@@ -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
*/

View File

@@ -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,

4
webpack.mix.js vendored
View File

@@ -25,10 +25,10 @@ mix
chunkFilename: '[name].js?id=[chunkhash]',
}
})
.options({
/*.options({
hmrOptions: {
host: '192.168.1.112',
port: '8080'
},
})
})*/
.disableNotifications();