diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ac14dd..a85cd40 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ # Changelog +## 0.2.1 - 2021-02-26 +### Add +- Add API for listing configurations +- Add Dashboard for showing some infos from configurations ## 0.2.0 - 2021-02-15 ### Add diff --git a/app/Http/Controllers/ConfiguratorController.php b/app/Http/Controllers/ConfiguratorController.php index 79ff4c2..be7fe46 100644 --- a/app/Http/Controllers/ConfiguratorController.php +++ b/app/Http/Controllers/ConfiguratorController.php @@ -2,12 +2,15 @@ namespace App\Http\Controllers; -use Illuminate\Http\Request; - class ConfiguratorController extends Controller { public function index() { - return view('configurator.index'); + $data = []; + $data["title"] = "Ghygen is a GitHub Actions configurator for your Laravel Application."; + $data["description"] = "Setup Database Service, use multiple PHP version, + use multiple Laravel versions, build frontend, cache packages, + execute Browser, Functional, and Unit tests…"; + return view('configurator.index', $data); } } diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.php new file mode 100644 index 0000000..e3d338c --- /dev/null +++ b/app/Http/Controllers/DashboardController.php @@ -0,0 +1,16 @@ +code != "") { $confModel = Configuration::getByCode($this->code); if ($confModel) { - $j = json_decode($confModel->configuration); + //$j = json_decode($confModel->configuration); + $j = $confModel->configuration; Log::debug(__METHOD__ . ' Name : ' . $j->name); $this->name = $j->name; $this->onPush = $j->on_push; @@ -293,7 +294,7 @@ public function submitForm() $json = json_encode($array); //$compressed = gzdeflate($json, 9); $hashCode = md5($json); - Configuration::saveConfiguration($hashCode, json_encode($data)); + Configuration::saveConfiguration($hashCode, $data); $this->code = $hashCode; $seconds = 60 * 60 * 6; // 6 hours $schema = Cache::remember('cache-schema-yaml', $seconds, function () { diff --git a/app/Http/Livewire/Dashboard/Latest.php b/app/Http/Livewire/Dashboard/Latest.php new file mode 100644 index 0000000..b11786b --- /dev/null +++ b/app/Http/Livewire/Dashboard/Latest.php @@ -0,0 +1,21 @@ +latest = Configuration::latest()->take(5)->get(); + } + public function render() + { + + return view('livewire.dashboard.latest'); + } +} diff --git a/app/Http/Livewire/Dashboard/Metrics.php b/app/Http/Livewire/Dashboard/Metrics.php new file mode 100644 index 0000000..677750f --- /dev/null +++ b/app/Http/Livewire/Dashboard/Metrics.php @@ -0,0 +1,42 @@ +count = Configuration::count(); + $this->total = Configuration::sum('counts'); + $this->last4hours = Configuration::where( + 'updated_at', + '>', + Carbon::now()->subHours(3)->toDateTimeString() + )->count(); + $this->last24hours = Configuration::where( + 'updated_at', + '>', + Carbon::now()->subHours(24)->toDateTimeString() + )->count(); + $this->last3days = Configuration::where( + 'updated_at', + '>', + Carbon::now()->subHours(24 * 3)->toDateTimeString() + )->count(); + } + + public function render() + { + return view('livewire.dashboard.metrics'); + } +} diff --git a/app/Http/Livewire/Dashboard/Top.php b/app/Http/Livewire/Dashboard/Top.php new file mode 100644 index 0000000..540f31a --- /dev/null +++ b/app/Http/Livewire/Dashboard/Top.php @@ -0,0 +1,20 @@ +top = Configuration::orderBy("counts", "DESC")->take(5)->get(); + } + public function render() + { + return view('livewire.dashboard.top'); + } +} diff --git a/app/Http/Resources/ConfigurationCollection.php b/app/Http/Resources/ConfigurationCollection.php new file mode 100644 index 0000000..9de4d34 --- /dev/null +++ b/app/Http/Resources/ConfigurationCollection.php @@ -0,0 +1,19 @@ + $this->code, + 'counts' => $this->counts, + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at, + ]; + } +} diff --git a/app/Models/Configuration.php b/app/Models/Configuration.php index b77e523..3a8e998 100644 --- a/app/Models/Configuration.php +++ b/app/Models/Configuration.php @@ -9,6 +9,10 @@ class Configuration extends Model { use HasFactory; + protected $casts = [ + 'configuration' => 'object', + ]; + public static function getByCode($code) { return self::firstWhere('code', $code); diff --git a/exclude-list.txt b/exclude-list.txt index b6c37fe..320dd8d 100644 --- a/exclude-list.txt +++ b/exclude-list.txt @@ -103,3 +103,5 @@ public/files public/chunks public/storage bootstrap/cache/config.php + +.phpunit.result.cache diff --git a/resources/views/components/table/link.blade.php b/resources/views/components/table/link.blade.php new file mode 100644 index 0000000..ab6bd73 --- /dev/null +++ b/resources/views/components/table/link.blade.php @@ -0,0 +1,5 @@ +@props([ +'url' => '#', +] +) +{{ $slot }} diff --git a/resources/views/components/table/td.blade.php b/resources/views/components/table/td.blade.php new file mode 100644 index 0000000..1bc95a2 --- /dev/null +++ b/resources/views/components/table/td.blade.php @@ -0,0 +1,7 @@ +@props([ +'align' => 'center', +] +) + + {{ $slot }} + diff --git a/resources/views/components/table/th.blade.php b/resources/views/components/table/th.blade.php new file mode 100644 index 0000000..c95f3b6 --- /dev/null +++ b/resources/views/components/table/th.blade.php @@ -0,0 +1,7 @@ +@props([ +'title' => '', +] +) + + {{ $slot }} + diff --git a/resources/views/components/table/title.blade.php b/resources/views/components/table/title.blade.php new file mode 100644 index 0000000..b52ccba --- /dev/null +++ b/resources/views/components/table/title.blade.php @@ -0,0 +1,3 @@ +

+ {{ $slot }} +

diff --git a/resources/views/configurator/index.blade.php b/resources/views/configurator/index.blade.php index 6f25f31..adb9f9a 100644 --- a/resources/views/configurator/index.blade.php +++ b/resources/views/configurator/index.blade.php @@ -3,18 +3,18 @@ - {{ config("app.name") }} - GitHub Actions Yaml Generator + {{ config("app.name") }} - {{ $title }} - + - - + + @@ -24,9 +24,13 @@
-

- Github Actions Yaml Generator for Laravel +

+ {{ $title }}

+

+ {{ $description }} +

+
diff --git a/resources/views/dashboard/index.blade.php b/resources/views/dashboard/index.blade.php new file mode 100644 index 0000000..c1ab9d9 --- /dev/null +++ b/resources/views/dashboard/index.blade.php @@ -0,0 +1,53 @@ + + + + + + {{ config("app.name") }} - {{ $title }} + + + + + + + + + + + + + + + +
+
+
+ +

+ {{ $title }} +

+

+ {{ $description }} +

+ +
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+ + + + + diff --git a/resources/views/livewire/dashboard/latest.blade.php b/resources/views/livewire/dashboard/latest.blade.php new file mode 100644 index 0000000..5c9efec --- /dev/null +++ b/resources/views/livewire/dashboard/latest.blade.php @@ -0,0 +1,51 @@ +
+
+
+
+ + Latest configurations + + + + + + Code + Title + MySql + Updated At + Counts + + + + + + @foreach( $latest as $l) + + + {{ $l->code }} + + + {{ $l->configuration->name }} + + + + @if ($l->configuration->mysqlService) + + {{ $l->configuration->mysqlVersion }} + + @endif + + + {{ $l->updated_at }} + + + {{ $l->counts }} + + + @endforeach + +
+
+
+
+
diff --git a/resources/views/livewire/dashboard/metrics.blade.php b/resources/views/livewire/dashboard/metrics.blade.php new file mode 100644 index 0000000..a575f7f --- /dev/null +++ b/resources/views/livewire/dashboard/metrics.blade.php @@ -0,0 +1,53 @@ +
+
+
+
+
+
Unique Configurations
+
{{ $count }}
+
+
+
+
+
+
+
+
+
Total Configurations
+
{{ $total }}
+
+
+
+
+
+
+
+
+
Last 4 Hours
+
{{ $last4hours }}
+
+
+
+
+
+
+
+
+
Last 24 Hours
+
{{ $last24hours }}
+
+
+
+
+
+
+
+
+
Last 3 Days
+
{{ $last3days }}
+
+
+
+
+ +
diff --git a/resources/views/livewire/dashboard/top.blade.php b/resources/views/livewire/dashboard/top.blade.php new file mode 100644 index 0000000..f4dd7ac --- /dev/null +++ b/resources/views/livewire/dashboard/top.blade.php @@ -0,0 +1,54 @@ +
+ +
+ +
+ +
+ + Most used configurations + + + + + + Code + Title + MySql + Updated At + Counts + + + + + + @foreach( $top as $l) + + + {{ $l->code }} + + + {{ $l->configuration->name }} + + + + @if ($l->configuration->mysqlService) + + {{ $l->configuration->mysqlVersion }} + + @endif + + + {{ $l->updated_at }} + + + {{ $l->counts }} + + + @endforeach + +
+
+
+
+
diff --git a/routes/web.php b/routes/web.php index 58608e3..8243a48 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,6 +1,9 @@ name("index"); +Route::get('/dashboard', [ DashboardController::class, 'index'])->name("dashboard"); Route::post('/action', function () { //$type = "application/x-yaml"; @@ -30,3 +34,7 @@ ->view('action_yaml', $data, 200) ->header('Content-Type', $type); }); + +Route::get('/configurations', function () { + return ConfigurationResource::collection(Configuration::all()); +});