Bozhidar Slaveykov 1 anno fa
parent
commit
93d9009f90

+ 0 - 10
web/app/Filament/Widgets/CustomersCount.php

@@ -20,12 +20,6 @@ class CustomersCount extends BaseWidget
 //        $serverStats = $serverStatistic->getCurrentStats();
 //        $serverStats = $serverStatistic->getCurrentStats();
 
 
 
 
-//
-//        'total' => 0,
-//            'used' => 0,
-//            'free' => 0,
-//            'usedPercentage' => 0,
-//            'mountedOn' => ''
         $customersCount = Customer::count();
         $customersCount = Customer::count();
         $websiteCount = Website::count();
         $websiteCount = Website::count();
 
 
@@ -37,10 +31,6 @@ class CustomersCount extends BaseWidget
 //            Stat::make('Buffer Cache', $serverStats['memory']['buffCache']),
 //            Stat::make('Buffer Cache', $serverStats['memory']['buffCache']),
 //            Stat::make('Available Memory', $serverStats['memory']['available']),
 //            Stat::make('Available Memory', $serverStats['memory']['available']),
 //
 //
-//            Stat::make('Total Disk', $serverStats['disk']['total']),
-//            Stat::make('Used Disk', $serverStats['disk']['used']),
-//            Stat::make('Free Disk', $serverStats['disk']['free']),
-//            Stat::make('Used Disk Percentage', $serverStats['disk']['usedPercentage']),
 
 
 
 
             Stat::make('Websites', $websiteCount)->icon('heroicon-o-globe-alt'),
             Stat::make('Websites', $websiteCount)->icon('heroicon-o-globe-alt'),

+ 3 - 3
web/app/Filament/Widgets/ServerStatistic.php → web/app/Filament/Widgets/ServerDiskUsageStatistic.php

@@ -1,17 +1,17 @@
 <?php
 <?php
 
 
-namespace App\Filament\Widgets;
+namespace app\Filament\Widgets;
 
 
 use Leandrocfe\FilamentApexCharts\Widgets\ApexChartWidget;
 use Leandrocfe\FilamentApexCharts\Widgets\ApexChartWidget;
 
 
-class ServerStatistic extends ApexChartWidget
+class ServerDiskUsageStatistic extends ApexChartWidget
 {
 {
     /**
     /**
      * Chart Id
      * Chart Id
      *
      *
      * @var string
      * @var string
      */
      */
-    protected static ?string $chartId = 'serverStatisticChart';
+    protected static ?string $chartId = 'serverDiskUsageStatisticChart';
 
 
     /**
     /**
      * Widget Title
      * Widget Title

+ 117 - 0
web/app/Filament/Widgets/ServerMemoryStatistic.php

@@ -0,0 +1,117 @@
+<?php
+
+namespace App\Filament\Widgets;
+
+use Leandrocfe\FilamentApexCharts\Widgets\ApexChartWidget;
+
+class ServerMemoryStatistic extends ApexChartWidget
+{
+    /**
+     * Chart Id
+     *
+     * @var string
+     */
+    protected static ?string $chartId = 'serverMemoryStatisticChart';
+
+    /**
+     * Widget Title
+     *
+     * @var string|null
+     */
+    protected static ?string $heading = 'Memory Usage';
+
+    protected static ?int $sort = 2;
+
+
+    /**
+     * Widget content height
+     */
+    protected static ?int $contentHeight = 100;
+
+
+    /**
+     * Widget Footer
+     */
+    protected function getFooter(): \Illuminate\View\View
+    {
+        $serverStatistic = new \App\Statistics\ServerStatistic();
+        $serverStats = $serverStatistic->getCurrentStats();
+
+        return view('charts.order-status.footer', ['data' => $serverStats]);
+    }
+
+
+    /**
+     * Chart options (series, labels, types, size, animations...)
+     * https://apexcharts.com/docs/options
+     */
+    protected function getOptions(): array
+    {
+        $serverStatistic = new \App\Statistics\ServerStatistic();
+        $serverStats = $serverStatistic->getCurrentStats();
+
+        $userPercentage = $serverStats['disk']['usedPercentage'];
+        $userPercentage = str_replace('%', '', $userPercentage);
+        $userPercentage = floatval($userPercentage);
+
+        return [
+            'chart' => [
+                'type' => 'radialBar',
+                'height' => 200,
+                'toolbar' => [
+                    'show' => false,
+                ],
+            ],
+            'series' => [$userPercentage],
+            'plotOptions' => [
+                'radialBar' => [
+                    'startAngle' => 0,
+                    'endAngle' => 360,
+                    'hollow' => [
+                        'size' => '60%',
+                        'background' => 'transparent',
+                    ],
+                    'track' => [
+                        'background' => 'transparent',
+                        'strokeWidth' => '100%',
+                    ],
+                    'dataLabels' => [
+                        'show' => true,
+                        'name' => [
+                            'show' => true,
+                            'offsetY' => -10,
+                            'fontWeight' => 600,
+                            'fontFamily' => 'inherit',
+                        ],
+                        'value' => [
+                            'show' => true,
+                            'fontWeight' => 600,
+                            'fontSize' => '24px',
+                            'fontFamily' => 'inherit',
+                        ],
+                    ],
+
+                ],
+            ],
+            'fill' => [
+                'type' => 'gradient',
+                'gradient' => [
+                    'shade' => 'dark',
+                    'type' => 'horizontal',
+                    'shadeIntensity' => 0.5,
+                    'gradientToColors' => ['#f59e0b'],
+                    'inverseColors' => true,
+                    'opacityFrom' => 1,
+                    'opacityTo' => 0.6,
+                    'stops' => [30, 70, 100],
+                ],
+            ],
+            'stroke' => [
+                'dashArray' => 10,
+            ],
+            'labels' => ['Free Space'],
+            'colors' => ['#16a34a'],
+
+        ];
+    }
+}

+ 28 - 0
web/app/Filament/Widgets/ServerMemoryStatisticCount.php

@@ -0,0 +1,28 @@
+<?php
+
+namespace App\Filament\Widgets;
+
+use App\Models\Customer;
+use App\Models\Website;
+use Filament\Widgets\StatsOverviewWidget as BaseWidget;
+use Filament\Widgets\StatsOverviewWidget\Stat;
+
+class ServerMemoryStatisticCount extends BaseWidget
+{
+    protected static bool $isLazy = false;
+
+    protected static ?int $sort = 4;
+
+    protected static string $view = 'filament.widgets.server-memory-statistic-count';
+
+    protected function getViewData(): array
+    {
+        $serverStatistic = new \App\Statistics\ServerStatistic();
+        $serverStats = $serverStatistic->getCurrentStats();
+
+        return [
+            'serverStats' => $serverStats,
+        ];
+
+    }
+}

+ 6 - 3
web/app/Providers/Filament/AdminPanelProvider.php

@@ -4,7 +4,9 @@ namespace App\Providers\Filament;
 
 
 use App\Filament\Pages\Settings\Settings;
 use App\Filament\Pages\Settings\Settings;
 use App\Filament\Widgets\CustomersCount;
 use App\Filament\Widgets\CustomersCount;
-use App\Filament\Widgets\ServerStatistic;
+use App\Filament\Widgets\ServerDiskUsageStatistic;
+use App\Filament\Widgets\ServerMemoryStatistic;
+use App\Filament\Widgets\ServerMemoryStatisticCount;
 use App\Filament\Widgets\Websites;
 use App\Filament\Widgets\Websites;
 use Filament\Http\Middleware\Authenticate;
 use Filament\Http\Middleware\Authenticate;
 use Filament\Http\Middleware\DisableBladeIconComponents;
 use Filament\Http\Middleware\DisableBladeIconComponents;
@@ -77,9 +79,10 @@ class AdminPanelProvider extends PanelProvider
                     Settings::class,
                     Settings::class,
                 ])
                 ])
             ])
             ])
-            ->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets')
+         //   ->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets')
             ->widgets([
             ->widgets([
-                ServerStatistic::class,
+                ServerDiskUsageStatistic::class,
+                ServerMemoryStatisticCount::class,
                 CustomersCount::class,
                 CustomersCount::class,
                 Websites::class,
                 Websites::class,
                // Widgets\AccountWidget::class,
                // Widgets\AccountWidget::class,

+ 57 - 0
web/resources/views/filament/widgets/server-memory-statistic-count.blade.php

@@ -0,0 +1,57 @@
+<div class="flex flex-col gap-y-6">
+
+    <x-filament::card class="bg-primary-500 text-white">
+
+        <div class="flex items-center justify-between">
+                <div class="ml-4 text-lg font-semibold leading-7">
+                    <div class="text-white">
+                        {{ $serverStats['memory']['total'] }}
+                    </div>
+                    <div class="text-sm text-gray-200">
+                        Total Memory
+                    </div>
+                </div>
+                <div class="ml-4 text-lg font-semibold leading-7">
+                    <div class="text-white">
+                        {{ $serverStats['memory']['used'] }}
+                    </div>
+                    <div class="text-sm text-gray-200">
+                        Used Memory
+                    </div>
+                </div>
+                <div class="ml-4 text-lg font-semibold leading-7">
+                    <div class="text-white">
+                        {{ $serverStats['memory']['free'] }}
+                    </div>
+                    <div class="text-sm text-gray-200">
+                        Free Memory
+                    </div>
+                </div>
+        </div>
+
+    </x-filament::card>
+
+    <x-filament::card class="bg-primary-500 text-white">
+
+        <div class="flex items-center gap-4">
+            <div class="ml-4 text-lg font-semibold leading-7">
+                <div class="text-white">
+                    {{ $serverStats['memory']['shared'] }}
+                </div>
+                <div class="text-sm text-gray-200">
+                    Shared Memory
+                </div>
+            </div>
+            <div class="ml-4 text-lg font-semibold leading-7">
+                <div class="text-white">
+                    {{ $serverStats['memory']['buffCache'] }}
+                </div>
+                <div class="text-sm text-gray-200">
+                    Buff Cache Memory
+                </div>
+            </div>
+        </div>
+
+    </x-filament::card>
+
+</div>