Skip to content

Commit

Permalink
Merge pull request #42 from Hi-Folks/develop
Browse files Browse the repository at this point in the history
v0.2.1
  • Loading branch information
roberto-butti authored Feb 26, 2021
2 parents 87da459 + 0af062f commit 150e3b9
Show file tree
Hide file tree
Showing 21 changed files with 413 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 6 additions & 3 deletions app/Http/Controllers/ConfiguratorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
16 changes: 16 additions & 0 deletions app/Http/Controllers/DashboardController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace App\Http\Controllers;

class DashboardController extends Controller
{
public function 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('dashboard.index', $data);
}
}
5 changes: 3 additions & 2 deletions app/Http/Livewire/ConfiguratorForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ public function mount()
if ($this->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;
Expand Down Expand Up @@ -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 () {
Expand Down
21 changes: 21 additions & 0 deletions app/Http/Livewire/Dashboard/Latest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace App\Http\Livewire\Dashboard;

use App\Models\Configuration;
use Livewire\Component;

class Latest extends Component
{
public $latest;

public function mount()
{
$this->latest = Configuration::latest()->take(5)->get();
}
public function render()
{

return view('livewire.dashboard.latest');
}
}
42 changes: 42 additions & 0 deletions app/Http/Livewire/Dashboard/Metrics.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace App\Http\Livewire\Dashboard;

use App\Models\Configuration;
use Illuminate\Support\Carbon;
use Livewire\Component;

class Metrics extends Component
{
public $count;
public $total;
public $last4hours;
public $last24hours;
public $last3days;

public function mount()
{
$this->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');
}
}
20 changes: 20 additions & 0 deletions app/Http/Livewire/Dashboard/Top.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace App\Http\Livewire\Dashboard;

use App\Models\Configuration;
use Livewire\Component;

class Top extends Component
{
public $top;

public function mount()
{
$this->top = Configuration::orderBy("counts", "DESC")->take(5)->get();
}
public function render()
{
return view('livewire.dashboard.top');
}
}
19 changes: 19 additions & 0 deletions app/Http/Resources/ConfigurationCollection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\ResourceCollection;

class ConfigurationCollection extends ResourceCollection
{
/**
* Transform the resource collection into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return parent::toArray($request);
}
}
24 changes: 24 additions & 0 deletions app/Http/Resources/ConfigurationResource.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class ConfigurationResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
return [
'code' => $this->code,
'counts' => $this->counts,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
];
}
}
4 changes: 4 additions & 0 deletions app/Models/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ class Configuration extends Model
{
use HasFactory;

protected $casts = [
'configuration' => 'object',
];

public static function getByCode($code)
{
return self::firstWhere('code', $code);
Expand Down
2 changes: 2 additions & 0 deletions exclude-list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,5 @@ public/files
public/chunks
public/storage
bootstrap/cache/config.php

.phpunit.result.cache
5 changes: 5 additions & 0 deletions resources/views/components/table/link.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@props([
'url' => '#',
]
)
<a class="text-indigo-600 hover:text-indigo-900" href="{{ $url }}">{{ $slot }}</a>
7 changes: 7 additions & 0 deletions resources/views/components/table/td.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@props([
'align' => 'center',
]
)
<td class="px-6 py-4 text-{{ $align }} whitespace-nowrap">
{{ $slot }}
</td>
7 changes: 7 additions & 0 deletions resources/views/components/table/th.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@props([
'title' => '',
]
)
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
{{ $slot }}
</th>
3 changes: 3 additions & 0 deletions resources/views/components/table/title.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<p class="pb-3 mt-2 text-3xl leading-8 font-extrabold tracking-tight text-gray-900 sm:text-4xl">
{{ $slot }}
</p>
16 changes: 10 additions & 6 deletions resources/views/configurator/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ config("app.name") }} - GitHub Actions Yaml Generator</title>
<title>{{ config("app.name") }} - {{ $title }}</title>
<livewire:styles/>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>

<meta name="description" content="{{ $title }} {{ $description }}" />
<link href="{{ mix('css/app.css') }}" rel="stylesheet">

<script src="{{ mix('js/app.js') }}" defer></script>
<meta property="og:url" content="{{ config('app.url') }}"/>
<meta property="og:type" content="website"/>
<meta property="og:title" content="{{ config("app.name") }} - GitHub Actions Yaml Generator"/>
<meta property="og:description" content="Create your GitHub Actions workflow for Laravel applications."/>
<meta property="og:title" content="{{ config("app.name") }} - {{ $title }}"/>
<meta property="og:description" content="{{ $description }}"/>
<meta property="og:image"
content="{{ asset('ghygen-title.png') }}"/>

Expand All @@ -24,9 +24,13 @@
<header class="bg-white shadow">
<div class="max-w-7xl mx-auto py-6 px-4 sm:px-6 lg:px-8 ">
<img class="w-48 " src="{{ asset('ghygen-title.png') }}">
<h1 class="pl-20 text-gray-500">
Github Actions Yaml Generator for Laravel
<h1 class="pl-20 text-gray-800">
{{ $title }}
</h1>
<p class="pl-20 text-gray-500 text-sm">
{{ $description }}
</p>

</div>
</header>
<main>
Expand Down
53 changes: 53 additions & 0 deletions resources/views/dashboard/index.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ config("app.name") }} - {{ $title }}</title>
<livewire:styles/>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta name="description" content="{{ $title }} {{ $description }}" />
<link href="{{ mix('css/app.css') }}" rel="stylesheet">

<script src="{{ mix('js/app.js') }}" defer></script>
<meta property="og:url" content="{{ config('app.url') }}"/>
<meta property="og:type" content="website"/>
<meta property="og:title" content="{{ config("app.name") }} - {{ $title }}"/>
<meta property="og:description" content="{{ $description }}"/>
<meta property="og:image"
content="{{ asset('ghygen-title.png') }}"/>

</head>
<body class="antialiased">
<div>
<header class="bg-white shadow">
<div class="max-w-7xl mx-auto py-6 px-4 sm:px-6 lg:px-8 ">
<img class="w-48 " src="{{ asset('ghygen-title.png') }}">
<h1 class="pl-20 text-gray-800">
{{ $title }}
</h1>
<p class="pl-20 text-gray-500 text-sm">
{{ $description }}
</p>

</div>
</header>
<main>
<div class="max-w-7xl mx-auto py-1 sm:px-6 lg:px-8">
<livewire:dashboard.metrics></livewire:dashboard.metrics>
</div>
<div class="max-w-7xl mx-auto py-1 sm:px-6 lg:px-8">
<livewire:dashboard.latest></livewire:dashboard.latest>
</div>
<div class="max-w-7xl mx-auto py-1 sm:px-6 lg:px-8">
<livewire:dashboard.top></livewire:dashboard.top>
</div>
</main>
<x-footer></x-footer>
</div>
<livewire:scripts/>


</body>
</html>
51 changes: 51 additions & 0 deletions resources/views/livewire/dashboard/latest.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<div class="flex flex-col">
<div class="-my-2 overflow-x-auto sm:-mx-6 lg:-mx-8">
<div class="py-2 align-middle inline-block min-w-full sm:px-6 lg:px-8">
<div class="shadow overflow-hidden border-b border-gray-200 sm:rounded-lg">
<x-table.title>
Latest configurations
</x-table.title>

<table class="w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<x-table.th >Code</x-table.th>
<x-table.th >Title</x-table.th>
<x-table.th >MySql</x-table.th>
<x-table.th >Updated At</x-table.th>
<x-table.th >Counts</x-table.th>

</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">

@foreach( $latest as $l)
<tr class="">
<x-table.td>
<x-table.link url='{{ route("index", ["code" => $l->code ]) }}'>{{ $l->code }}</x-table.link>
</x-table.td>
<x-table.td align="left">
{{ $l->configuration->name }}
</x-table.td>

<x-table.td align="left">
@if ($l->configuration->mysqlService)
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800">
{{ $l->configuration->mysqlVersion }}
</span>
@endif
</x-table.td>
<x-table.td align="left">
{{ $l->updated_at }}
</x-table.td>
<x-table.td align="right">
{{ $l->counts }}
</x-table.td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
Loading

0 comments on commit 150e3b9

Please sign in to comment.