- usage metric fix

- ui fix
- index:usage artisan command
- demo payment settings
This commit is contained in:
Čarodej
2022-01-10 15:43:55 +01:00
parent 5de2b8b0e0
commit 08139c8f96
47 changed files with 88 additions and 50 deletions

View File

@@ -193,7 +193,7 @@ return [
], ],
[ [
'name' => 'allowed_registration_bonus', 'name' => 'allowed_registration_bonus',
'value' => '0', 'value' => 0,
], ],
[ [
'name' => 'registration_bonus_amount', 'name' => 'registration_bonus_amount',

View File

@@ -25,14 +25,14 @@
"/chunks/app-language~chunks/dashboard~chunks/files~chunks/invoices~chunks/my-shared-items~chunks/page~8729b0a3.js": "/chunks/app-language~chunks/dashboard~chunks/files~chunks/invoices~chunks/my-shared-items~chunks/page~8729b0a3.js?id=50f7067283a882b798bd", "/chunks/app-language~chunks/dashboard~chunks/files~chunks/invoices~chunks/my-shared-items~chunks/page~8729b0a3.js": "/chunks/app-language~chunks/dashboard~chunks/files~chunks/invoices~chunks/my-shared-items~chunks/page~8729b0a3.js?id=50f7067283a882b798bd",
"/chunks/app-language~chunks/dashboard~chunks/invoices~chunks/page-edit~chunks/pages~chunks/plan-creat~d6def0d7.js": "/chunks/app-language~chunks/dashboard~chunks/invoices~chunks/page-edit~chunks/pages~chunks/plan-creat~d6def0d7.js?id=a1836cdd057c0e63adc0", "/chunks/app-language~chunks/dashboard~chunks/invoices~chunks/page-edit~chunks/pages~chunks/plan-creat~d6def0d7.js": "/chunks/app-language~chunks/dashboard~chunks/invoices~chunks/page-edit~chunks/pages~chunks/plan-creat~d6def0d7.js?id=a1836cdd057c0e63adc0",
"/chunks/app-others.js": "/chunks/app-others.js?id=dcb25c15345b97c47871", "/chunks/app-others.js": "/chunks/app-others.js?id=dcb25c15345b97c47871",
"/chunks/app-payments.js": "/chunks/app-payments.js?id=7b138db0bc1917cab2c6", "/chunks/app-payments.js": "/chunks/app-payments.js?id=e1b37ac1d8d495edd774",
"/chunks/app-settings.js": "/chunks/app-settings.js?id=5968eed91e41e99efd4c", "/chunks/app-settings.js": "/chunks/app-settings.js?id=5968eed91e41e99efd4c",
"/chunks/app-setup.js": "/chunks/app-setup.js?id=c3a013b11ae7bde6f39d", "/chunks/app-setup.js": "/chunks/app-setup.js?id=c3a013b11ae7bde6f39d",
"/chunks/app-setup~chunks/billings-detail~chunks/create-new-password~chunks/database~chunks/email-veri~2c1222b7.js": "/chunks/app-setup~chunks/billings-detail~chunks/create-new-password~chunks/database~chunks/email-veri~2c1222b7.js?id=5963f5d9fb4e759c600a", "/chunks/app-setup~chunks/billings-detail~chunks/create-new-password~chunks/database~chunks/email-veri~2c1222b7.js": "/chunks/app-setup~chunks/billings-detail~chunks/create-new-password~chunks/database~chunks/email-veri~2c1222b7.js?id=5963f5d9fb4e759c600a",
"/chunks/billing.js": "/chunks/billing.js?id=131b8be8787e1bdbc407", "/chunks/billing.js": "/chunks/billing.js?id=131b8be8787e1bdbc407",
"/chunks/billings-detail.js": "/chunks/billings-detail.js?id=ad632d6f7e088dab55a3", "/chunks/billings-detail.js": "/chunks/billings-detail.js?id=ad632d6f7e088dab55a3",
"/chunks/billing~chunks/dashboard~chunks/invoices~chunks/pages~chunks/plan-subscribers~chunks/plans~ch~5d1c5841.js": "/chunks/billing~chunks/dashboard~chunks/invoices~chunks/pages~chunks/plan-subscribers~chunks/plans~ch~5d1c5841.js?id=9b836534302d97ac5c73", "/chunks/billing~chunks/dashboard~chunks/invoices~chunks/pages~chunks/plan-subscribers~chunks/plans~ch~5d1c5841.js": "/chunks/billing~chunks/dashboard~chunks/invoices~chunks/pages~chunks/plan-subscribers~chunks/plans~ch~5d1c5841.js?id=9b836534302d97ac5c73",
"/chunks/billing~chunks/settings-storage~chunks/user-storage~chunks/user-subscription.js": "/chunks/billing~chunks/settings-storage~chunks/user-storage~chunks/user-subscription.js?id=2760050e539cc5e9b8ab", "/chunks/billing~chunks/settings-storage~chunks/user-storage~chunks/user-subscription.js": "/chunks/billing~chunks/settings-storage~chunks/user-storage~chunks/user-subscription.js?id=3f0a914bca8e3106d9ce",
"/chunks/contact-us.js": "/chunks/contact-us.js?id=b3feaa361fc486e6a0b3", "/chunks/contact-us.js": "/chunks/contact-us.js?id=b3feaa361fc486e6a0b3",
"/chunks/contact-us~chunks/dynamic-page~chunks/homepage.js": "/chunks/contact-us~chunks/dynamic-page~chunks/homepage.js?id=65ee559ca803555be568", "/chunks/contact-us~chunks/dynamic-page~chunks/homepage.js": "/chunks/contact-us~chunks/dynamic-page~chunks/homepage.js?id=65ee559ca803555be568",
"/chunks/create-new-password.js": "/chunks/create-new-password.js?id=8451872075acf5b1b9ab", "/chunks/create-new-password.js": "/chunks/create-new-password.js?id=8451872075acf5b1b9ab",
@@ -396,5 +396,10 @@
"/chunks/billing.461dc4a34199e68429ee.hot-update.js": "/chunks/billing.461dc4a34199e68429ee.hot-update.js", "/chunks/billing.461dc4a34199e68429ee.hot-update.js": "/chunks/billing.461dc4a34199e68429ee.hot-update.js",
"/chunks/billing.eaf0631ae5f10538907d.hot-update.js": "/chunks/billing.eaf0631ae5f10538907d.hot-update.js", "/chunks/billing.eaf0631ae5f10538907d.hot-update.js": "/chunks/billing.eaf0631ae5f10538907d.hot-update.js",
"/chunks/billing.2aeee7e82b62920e2451.hot-update.js": "/chunks/billing.2aeee7e82b62920e2451.hot-update.js", "/chunks/billing.2aeee7e82b62920e2451.hot-update.js": "/chunks/billing.2aeee7e82b62920e2451.hot-update.js",
"/chunks/billing.3153d134251a9670bbe8.hot-update.js": "/chunks/billing.3153d134251a9670bbe8.hot-update.js" "/chunks/billing.3153d134251a9670bbe8.hot-update.js": "/chunks/billing.3153d134251a9670bbe8.hot-update.js",
"/chunks/app-payments.13240e9f411923858d1b.hot-update.js": "/chunks/app-payments.13240e9f411923858d1b.hot-update.js",
"/chunks/billing~chunks/settings-storage~chunks/user-storage~chunks/user-subscription.fc96502ee414d46390b8.hot-update.js": "/chunks/billing~chunks/settings-storage~chunks/user-storage~chunks/user-subscription.fc96502ee414d46390b8.hot-update.js",
"/chunks/billing~chunks/settings-storage~chunks/user-storage~chunks/user-subscription.ab77530f6a2a35df1ddd.hot-update.js": "/chunks/billing~chunks/settings-storage~chunks/user-storage~chunks/user-subscription.ab77530f6a2a35df1ddd.hot-update.js",
"/chunks/billing~chunks/settings-storage~chunks/user-storage~chunks/user-subscription.82770ea7f4382984a333.hot-update.js": "/chunks/billing~chunks/settings-storage~chunks/user-storage~chunks/user-subscription.82770ea7f4382984a333.hot-update.js",
"/chunks/billing~chunks/settings-storage~chunks/user-storage~chunks/user-subscription.bd1a0faf9bc919e624a5.hot-update.js": "/chunks/billing~chunks/settings-storage~chunks/user-storage~chunks/user-subscription.bd1a0faf9bc919e624a5.hot-update.js"
} }

View File

@@ -1,6 +1,6 @@
<template> <template>
<div> <div>
<div class="flex items-center mb-4 rounded dark:bg-2x-dark-foreground bg-light-300"> <div class="flex items-center mb-4 rounded dark:bg-2x-dark-foreground bg-light-300 h-2.5">
<div v-for="(chart, i) in data" :key="i" :style="{width: (chart.progress > 1 ? chart.progress : 0) + '%'}" class="chart-wrapper"> <div v-for="(chart, i) in data" :key="i" :style="{width: (chart.progress > 1 ? chart.progress : 0) + '%'}" class="chart-wrapper">
<!--<DotLabel class="label" :class="{'offset-top': chart.progress < 5}" :color="chart.color" :title="chart.value" />--> <!--<DotLabel class="label" :class="{'offset-top': chart.progress < 5}" :color="chart.color" :title="chart.value" />-->
@@ -18,7 +18,7 @@
<!--Multiple line--> <!--Multiple line-->
<span <span
v-if="data.length > 1" v-if="data.length > 1 && chart.progress > 0"
:class="[{ :class="[{
'rounded-tl-lg rounded-bl-lg border-r-2 dark:border-gray-800 border-white': i === 0, 'rounded-tl-lg rounded-bl-lg border-r-2 dark:border-gray-800 border-white': i === 0,
'border-r-2 dark:border-gray-800 border-white': i < (data.length - 1), 'border-r-2 dark:border-gray-800 border-white': i < (data.length - 1),
@@ -29,7 +29,7 @@
</div> </div>
</div> </div>
<footer class="flex items-center"> <footer class="flex items-center w-full overflow-x-auto">
<DotLabel v-for="(chart, i) in data" :key="i" :color="chart.color" :title="chart.title" class="mr-5" /> <DotLabel v-for="(chart, i) in data" :key="i" :color="chart.color" :title="chart.title" class="mr-5" />
</footer> </footer>
</div> </div>

View File

@@ -1,6 +1,6 @@
<?php <?php
use Illuminate\Foundation\Inspiring; use Support\Scheduler\Actions\ReportUsageAction;
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
@@ -13,6 +13,5 @@ use Illuminate\Foundation\Inspiring;
| |
*/ */
Artisan::command('inspire', function () { Artisan::command('report:usage', fn () => resolve(ReportUsageAction::class)())
$this->comment(Inspiring::quote()); ->describe('Store user usage estimates for metered billing');
})->describe('Display an inspiring quote');

View File

@@ -57,11 +57,10 @@ class SetupDevEnvironment extends Command
$this->migrate_and_generate(); $this->migrate_and_generate();
$this->info('Storing default settings and content...'); $this->info('Storing default settings and content...');
$this->store_default_settings();
($this->seedDefaultPages)(); ($this->seedDefaultPages)();
($this->seedDefaultSettings)($this->license); ($this->seedDefaultSettings)($this->license);
($this->seedDefaultLanguage)(); ($this->seedDefaultLanguage)();
$this->store_default_settings();
$this->info('Creating default admin...'); $this->info('Creating default admin...');
$this->create_admin(); $this->create_admin();
@@ -651,13 +650,13 @@ class SetupDevEnvironment extends Command
// Get apartments gallery // Get apartments gallery
collect([ collect([
'demo/images/apartments/Apartment Architecture Ceiling Chairs.jpg', 'demo/images/apartments/Apartment Architecture Ceiling Chairs.jpeg',
'demo/images/apartments/Apartment Chair.jpg', 'demo/images/apartments/Apartment Chair.jpeg',
'demo/images/apartments/Apartment Contemporary Couch Curtains.jpg', 'demo/images/apartments/Apartment Contemporary Couch Curtains.jpeg',
'demo/images/apartments/Brown Wooden Center Table.jpg', 'demo/images/apartments/Brown Wooden Center Table.jpeg',
'demo/images/apartments/Home.jpg', 'demo/images/apartments/Home.jpeg',
'demo/images/apartments/Kitchen Appliances.jpg', 'demo/images/apartments/Kitchen Appliances.jpeg',
'demo/images/apartments/Kitchen Island.jpg', 'demo/images/apartments/Kitchen Island.jpeg',
]) ])
->each(function ($file) use ($user, $apartments) { ->each(function ($file) use ($user, $apartments) {
$thumbnail = $this->generate_thumbnails($file, $user); $thumbnail = $this->generate_thumbnails($file, $user);
@@ -678,17 +677,17 @@ class SetupDevEnvironment extends Command
// Get nature gallery // Get nature gallery
collect([ collect([
'demo/images/nature/Bird Patterncolorful Green.jpg', 'demo/images/nature/Bird Patterncolorful Green.jpeg',
'demo/images/nature/Close Up Of Peacock.jpg', 'demo/images/nature/Close Up Of Peacock.jpeg',
'demo/images/nature/Close Up Photography Of Tiger.jpg', 'demo/images/nature/Close Up Photography Of Tiger.jpeg',
'demo/images/nature/Cold Nature Cute Ice.jpg', 'demo/images/nature/Cold Nature Cute Ice.jpeg',
'demo/images/nature/Landscape Photo of Forest.jpg', 'demo/images/nature/Landscape Photo of Forest.jpeg',
'demo/images/nature/Photo of Hawksbill Sea Turtle.jpg', 'demo/images/nature/Photo of Hawksbill Sea Turtle.jpeg',
'demo/images/nature/Photo Of Reindeer in The Snow.jpg', 'demo/images/nature/Photo Of Reindeer in The Snow.jpeg',
'demo/images/nature/View Of Elephant in Water.jpg', 'demo/images/nature/View Of Elephant in Water.jpeg',
'demo/images/nature/Waterfall Between Trees.jpg', 'demo/images/nature/Waterfall Between Trees.jpeg',
'demo/images/nature/Wildlife Photography of Elephant During Golden Hour.jpg', 'demo/images/nature/Wildlife Photography of Elephant During Golden Hour.jpeg',
'demo/images/nature/Yellow Animal Eyes Fur.jpg', 'demo/images/nature/Yellow Animal Eyes Fur.jpeg',
]) ])
->each(function ($file) use ($user, $nature) { ->each(function ($file) use ($user, $nature) {
$thumbnail = $this->generate_thumbnails($file, $user); $thumbnail = $this->generate_thumbnails($file, $user);
@@ -1005,7 +1004,7 @@ class SetupDevEnvironment extends Command
'value' => 1, 'value' => 1,
], ],
[ [
'name' => 'payments_active', 'name' => 'allowed_payments',
'value' => 1, 'value' => 1,
], ],
[ [
@@ -1064,9 +1063,34 @@ class SetupDevEnvironment extends Command
'name' => 'billing_vat_number', 'name' => 'billing_vat_number',
'value' => '41241241234', 'value' => '41241241234',
], ],
[
'name' => 'allowed_registration_bonus',
'value' => 1,
],
[
'name' => 'registration_bonus_amount',
'value' => 10,
],
[
'name' => 'allowed_paypal',
'value' => 1,
],
[
'name' => 'allowed_paystack',
'value' => 1,
],
[
'name' => 'allowed_stripe',
'value' => 1,
],
[
'name' => 'subscription_type',
'value' => 'metered',
],
])->each(function ($col) { ])->each(function ($col) {
Setting::forceCreate([ Setting::updateOrCreate([
'name' => $col['name'], 'name' => $col['name'],
], [
'value' => $col['value'], 'value' => $col['value'],
]); ]);
}); });

View File

@@ -37,9 +37,9 @@ class SocialiteCallbackController extends Controller
// Create data user data object // Create data user data object
$data = CreateUserData::fromArray([ $data = CreateUserData::fromArray([
'name' => $provider_user->name, 'name' => $provider_user->getName(),
'email' => $provider_user->email, 'email' => $provider_user->getEmail(),
'avatar' => store_socialite_avatar($provider_user->avatar), 'avatar' => store_socialite_avatar($provider_user->getAvatar()),
'oauth_provider' => $provider, 'oauth_provider' => $provider,
]); ]);

View File

@@ -132,8 +132,8 @@ class UserStorageResource extends JsonResource
->where('created_at', '>', $period) ->where('created_at', '>', $period)
->sum('upload'); ->sum('upload');
$upload = $trafficRecords->map(fn ($record) => round(($record->upload / $uploadMax) * 100, 2)); $upload = $trafficRecords->map(fn ($record) => $uploadMax !== 0 ? round(($record->upload / $uploadMax) * 100, 2) : 0);
$download = $trafficRecords->map(fn ($record) => round(($record->download / $downloadMax) * 100, 2)); $download = $trafficRecords->map(fn ($record) => $downloadMax !== 0 ? round(($record->download / $downloadMax) * 100, 2) : 0);
return [$downloadTotal, $uploadTotal, $upload, $download]; return [$downloadTotal, $uploadTotal, $upload, $download];
} }

View File

@@ -13,6 +13,10 @@ class SeedDefaultSettingsAction
): void { ): void {
collect( collect(
config('content.content.' . strtolower($license)) config('content.content.' . strtolower($license))
)->each(fn ($content) => Setting::forceCreate($content)); )->each(fn ($content) => Setting::updateOrCreate([
'name' => $content['name'],
], [
'value' => $content['value'],
]));
} }
} }

View File

@@ -39,7 +39,7 @@ class ReportUsageAction
->sum('filesize'); ->sum('filesize');
// We count storage size in GB, e.g. 0.15 is 150mb // We count storage size in GB, e.g. 0.15 is 150mb
$amount = $filesize / 1000000000; $amount = $filesize / 1000000;
// Record storage capacity usage // Record storage capacity usage
$subscription->recordUsage('storage', $amount); $subscription->recordUsage('storage', $amount);
@@ -51,10 +51,10 @@ class ReportUsageAction
$record = $subscription $record = $subscription
->user ->user
->traffics() ->traffics()
->where('created_at', today()->subDay()) ->whereDate('created_at', today()->subDay())
->first(); ->first();
$amount = ($record->download ?? 0) / 1000000000; $amount = (($record->download ?? 0) + ($record->upload ?? 0)) / 1000000;
// Record storage capacity usage // Record storage capacity usage
$subscription->recordUsage('bandwidth', $amount); $subscription->recordUsage('bandwidth', $amount);

View File

@@ -475,7 +475,7 @@ if (! function_exists('get_storage_percentage')) {
// Count progress // Count progress
if ($total == 0) { if ($total == 0) {
$progress = 100; $progress = 0;
} else { } else {
$progress = ($used * 100) / $total; $progress = ($used * 100) / $total;
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 424 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 311 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 267 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 526 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 563 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 551 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 420 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 434 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 352 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 314 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 774 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 764 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 713 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 635 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 376 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 784 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 678 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 524 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 902 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 756 KiB

View File

@@ -1,6 +1,8 @@
<?php <?php
namespace Tests\App\Socialite; namespace Tests\App\Socialite;
use Mockery;
use Storage; use Storage;
use Tests\TestCase; use Tests\TestCase;
use App\Users\Models\User; use App\Users\Models\User;
@@ -35,12 +37,16 @@ class SocialiteTest extends TestCase
]); ]);
// Create fake user // Create fake user
$socialiteUser = $this->createMock(\Laravel\Socialite\Two\User::class); $socialiteUser = Mockery::mock(\Laravel\Socialite\Two\User::class);
$socialiteUser->token = 'fake_token'; $socialiteUser
$socialiteUser->id = 'fake_id'; ->shouldReceive('getId')
$socialiteUser->name = 'Jane Doe'; ->andReturn('fake_id')
$socialiteUser->email = 'howdy@hi5ve.digital'; ->shouldReceive('getEmail')
$socialiteUser->avatar = 'https://vuefilemanager.com/avatar.jpg'; ->andReturn('howdy@hi5ve.digital')
->shouldReceive('getName')
->andReturn('Jane Doe')
->shouldReceive('getAvatar')
->andReturn('https://vuefilemanager.com/avatar.jpg');
// Mock user with FB provider // Mock user with FB provider
$provider = $this->createMock(FacebookProvider::class); $provider = $this->createMock(FacebookProvider::class);
@@ -75,7 +81,7 @@ class SocialiteTest extends TestCase
collect(config('vuefilemanager.avatar_sizes')) collect(config('vuefilemanager.avatar_sizes'))
->each( ->each(
fn ($size) => Storage::disk('local') fn($size) => Storage::disk('local')
->assertExists("avatars/{$size['name']}-{$user->settings->getRawOriginal('avatar')}") ->assertExists("avatars/{$size['name']}-{$user->settings->getRawOriginal('avatar')}")
); );
} }