- Add ProjectTypes Enum
- Add Smtp Enum - Add Requests - Fix HTTPS on project.edit
This commit is contained in:
parent
149de0e783
commit
733e23bbc2
12 changed files with 223 additions and 24 deletions
36
app/Enums/ProjectTypes.php
Normal file
36
app/Enums/ProjectTypes.php
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use Kwaadpepper\Enum\BaseEnumRoutable;
|
||||
|
||||
/**
|
||||
* Projects Different Types
|
||||
*
|
||||
* @method static self other() Autre
|
||||
* @method static self wp() WP
|
||||
* @method static self laravel() Laravel
|
||||
* @method static self symfony() Symfony
|
||||
*/
|
||||
final class ProjectTypes extends BaseEnumRoutable
|
||||
{
|
||||
protected static function values(): array
|
||||
{
|
||||
return [
|
||||
'other' => 1,
|
||||
'wp' => 2,
|
||||
'laravel' => 3,
|
||||
'symfony' => 4,
|
||||
];
|
||||
}
|
||||
|
||||
protected static function labels(): array
|
||||
{
|
||||
return [
|
||||
'other' => 'Autre',
|
||||
'wp' => 'WP',
|
||||
'laravel' => 'Laravel',
|
||||
'symfony' => 'Symfony',
|
||||
];
|
||||
}
|
||||
}
|
||||
33
app/Enums/Smtp.php
Normal file
33
app/Enums/Smtp.php
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use Kwaadpepper\Enum\BaseEnumRoutable;
|
||||
|
||||
/**
|
||||
* SMTP Types
|
||||
*
|
||||
* @method static self ldc() LDC Relay
|
||||
* @method static self mailjet() Mailjet Relay
|
||||
* @method static self sendinblue() Sendinblue Relay
|
||||
*/
|
||||
final class Smtp extends BaseEnumRoutable
|
||||
{
|
||||
protected static function values(): array
|
||||
{
|
||||
return [
|
||||
'ldc' => 1,
|
||||
'mailjet' => 2,
|
||||
'sendinblue' => 3,
|
||||
];
|
||||
}
|
||||
|
||||
protected static function labels(): array
|
||||
{
|
||||
return [
|
||||
'ldc' => 'LDC Relay',
|
||||
'mailjet' => 'Mailjet',
|
||||
'sendinblue' => 'Sendinblue',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\Projects\StoreProjects;
|
||||
use App\Http\Requests\Projects\UpdateProjects;
|
||||
use App\Models\Projects;
|
||||
use App\Models\Servers;
|
||||
use Carbon\Carbon;
|
||||
|
|
@ -75,7 +77,7 @@ class ProjectsController extends Controller
|
|||
return view('projects.edit', ['project' => $project, 'dev_db_server' => $dev_db_server, 'dev_web_server' => $dev_web_server, 'prod_db_server' => $prod_db_server, 'prod_web_server' => $prod_web_server]);
|
||||
}
|
||||
|
||||
public function update(Request $request)
|
||||
public function update(UpdateProjects $request)
|
||||
{
|
||||
$uuid = $request->uuid;
|
||||
$project = Projects::where('uuid', '=', $uuid)->first();
|
||||
|
|
@ -85,7 +87,7 @@ class ProjectsController extends Controller
|
|||
return redirect()->route('projects.edit', ['uuid' => $project->uuid])->with('status', 'Sauvegardé !');
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
public function store(StoreProjects $request)
|
||||
{
|
||||
$project = new Projects();
|
||||
$project->uuid = Uuid::uuid4();
|
||||
|
|
@ -161,6 +163,8 @@ class ProjectsController extends Controller
|
|||
$prod_ga_id = $request->prod_ga_id;
|
||||
$prod_laravel_app_key = $request->prod_laravel_app_key;
|
||||
$dev_laravel_app_key = $request->dev_laravel_app_key;
|
||||
$prod_smtp_config = $request->prod_smtp_config;
|
||||
$prod_smtp_key = $request->prod_smtp_key;
|
||||
|
||||
if (Auth::user()->role === 1) {
|
||||
$prod_login = $request->prod_login;
|
||||
|
|
@ -207,6 +211,8 @@ class ProjectsController extends Controller
|
|||
$project->prod_ga_id = $prod_ga_id;
|
||||
$project->prod_laravel_app_key = $prod_laravel_app_key;
|
||||
$project->dev_laravel_app_key = $dev_laravel_app_key;
|
||||
$project->prod_smtp_config = $prod_smtp_config;
|
||||
$project->prod_smtp_key = $prod_smtp_key;
|
||||
|
||||
if (Auth::user()->role === 1) {
|
||||
$project->prod_login = $prod_login;
|
||||
|
|
|
|||
33
app/Http/Requests/Projects/StoreProjects.php
Normal file
33
app/Http/Requests/Projects/StoreProjects.php
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Projects;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class StoreProjects extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return Auth::checK();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
// TODO : compléter les rules
|
||||
'prod_smtp_config' => 'integer|required',
|
||||
'prod_smtp_key' => 'required_if:prod_smtp_config,3'
|
||||
];
|
||||
}
|
||||
}
|
||||
35
app/Http/Requests/Projects/UpdateProjects.php
Normal file
35
app/Http/Requests/Projects/UpdateProjects.php
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Projects;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class UpdateProjects extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return Auth::checK();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
// TODO : compléter les rules
|
||||
'prod_laravel_app_key' => 'required_if:type,3',
|
||||
'dev_laravel_app_key' => 'required_if:type,3',
|
||||
'prod_smtp_config' => 'integer|required',
|
||||
'prod_smtp_key' => 'required_if:prod_smtp_config,3'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -226,6 +226,8 @@ return [
|
|||
'URL' => Illuminate\Support\Facades\URL::class,
|
||||
'Validator' => Illuminate\Support\Facades\Validator::class,
|
||||
'View' => Illuminate\Support\Facades\View::class,
|
||||
'SmtpEnum' => App\Enums\Smtp::class,
|
||||
'ProjectTypesEnum' => App\Enums\ProjectTypes::class,
|
||||
|
||||
],
|
||||
|
||||
|
|
|
|||
2
public/js/app.js
vendored
2
public/js/app.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -3,12 +3,12 @@
|
|||
<div class="row" style="margin: 10px;">
|
||||
<div v-if="datas.length > 0" class="col-md-12">
|
||||
<div class="row" v-for="(item, index) in datas">
|
||||
<div :class="type === 'WP' ? 'col-md-4' : 'col-md-5'">
|
||||
<div :class="type === 2 ? 'col-md-4' : 'col-md-5'">
|
||||
<div class="form-group">
|
||||
<input v-model="item.login" type="text" placeholder="Login" class="form-control" required>
|
||||
</div>
|
||||
</div>
|
||||
<div :class="type === 'WP' ? 'col-md-4' : 'col-md-5'">
|
||||
<div :class="type === 2 ? 'col-md-4' : 'col-md-5'">
|
||||
<div class="form-group">
|
||||
<input v-model="item.pwd" type="text" placeholder="Password" class="form-control" required>
|
||||
</div>
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
<div class="col-md-2">
|
||||
<a @click="removeItem(index)" href="#" class="btn btn-danger"><i class="fas fa-user-times"></i></a>
|
||||
</div>
|
||||
<div v-if="type === 'WP'" class="col-md-2">
|
||||
<div v-if="type === 2" class="col-md-2">
|
||||
<a :href="'/projects/wp-auto-login?url=' + url + 'wp-login.php&login=' + item.login + '&pwd=' + item.pwd" target="_blank" class="btn btn-success"><i class="fas fa-sign-in-alt"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -16,6 +16,15 @@
|
|||
{{ session('status') }}
|
||||
</div>
|
||||
@endif
|
||||
@if ($errors->any())
|
||||
<div class="alert alert-danger">
|
||||
<ul>
|
||||
@foreach ($errors->all() as $error)
|
||||
<li>{{ $error }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
@endif
|
||||
<form action="/projects/store" method="POST">
|
||||
@csrf
|
||||
<div class="row">
|
||||
|
|
@ -51,10 +60,9 @@
|
|||
<div class="form-group">
|
||||
<label><b>Type :</b></label>
|
||||
<select name="type" class="form-control" required>
|
||||
<option value="WP">WP</option>
|
||||
<option value="Laravel">Laravel</option>
|
||||
<option value="Symfony">Symfony</option>
|
||||
<option value="other">Autres</option>
|
||||
@foreach (ProjectTypesEnum::toArray() as $p_type)
|
||||
<option value="{{ $p_type->value }}">{{ $p_type->label }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -352,6 +360,25 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label><b>Config SMTP * :</b></label>
|
||||
<select name="prod_smtp_config" class="form-control" required>
|
||||
<option value=""></option>
|
||||
@foreach (SmtpEnum::toArray() as $smtp)
|
||||
<option value="{{ $smtp->value }}">{{ $smtp->label }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label><b>Clé SMTP :</b></label>
|
||||
<input type="text" name="prod_smtp_key" class="form-control" placeholder="Clé SMTP">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
|
|
|
|||
|
|
@ -22,6 +22,15 @@
|
|||
{{ session('error') }}
|
||||
</div>
|
||||
@endif
|
||||
@if ($errors->any())
|
||||
<div class="alert alert-danger">
|
||||
<ul>
|
||||
@foreach ($errors->all() as $error)
|
||||
<li>{{ $error }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
@endif
|
||||
<form action="/projects/{{$project->uuid}}/update" method="POST">
|
||||
@csrf
|
||||
<div class="row">
|
||||
|
|
@ -57,10 +66,9 @@
|
|||
<div class="form-group">
|
||||
<label><b>Type :</b></label>
|
||||
<select name="type" class="form-control" required>
|
||||
<option @if ($project->type === 'WP') selected @endif value="WP">WP</option>
|
||||
<option @if ($project->type === 'Laravel') selected @endif value="Laravel">Laravel</option>
|
||||
<option @if ($project->type === 'Symfony') selected @endif value="Symfony">Symfony</option>
|
||||
<option @if ($project->type === 'other') selected @endif value="other">Autres</option>
|
||||
@foreach (ProjectTypesEnum::toArray() as $p_type)
|
||||
<option @if ($project->type === $p_type->value) selected @endif value="{{ $p_type->value }}">{{ $p_type->label }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -68,8 +76,8 @@
|
|||
<div class="form-group">
|
||||
<label><b>HTTPS :</b></label>
|
||||
<select name="https" class="form-control">
|
||||
<option @if ($project->type === '1') selected @endif value="1">Oui</option>
|
||||
<option @if ($project->type === '0') selected @endif value="0">Non</option>
|
||||
<option @if ($project->https === 1) selected @endif value="1">Oui</option>
|
||||
<option @if ($project->https === 0) selected @endif value="0">Non</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -97,10 +105,10 @@
|
|||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<login-id name="dev_login" dbdatas="{{$project->dev_login}}" url="{{$project->dev_url}}" type="{{$project->type}}"/>
|
||||
<login-id name="dev_login" dbdatas="{{$project->dev_login}}" url="{{$project->dev_url}}" :type="{{$project->type}}"/>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<login-id name="prod_login" dbdatas="{{$project->prod_login}}" url="{{$project->prod_url}}" type="{{$project->type}}"/>
|
||||
<login-id name="prod_login" dbdatas="{{$project->prod_login}}" url="{{$project->prod_url}}" :type="{{$project->type}}"/>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
|
@ -238,7 +246,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@if ($project->type === 'Laravel')
|
||||
@if ($project->type === ProjectTypesEnum::laravel()->value)
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="form-group">
|
||||
|
|
@ -392,7 +400,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@if ($project->type === 'Laravel')
|
||||
@if ($project->type === ProjectTypesEnum::laravel()->value)
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="form-group">
|
||||
|
|
@ -402,6 +410,25 @@
|
|||
</div>
|
||||
</div>
|
||||
@endif
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label><b>Config SMTP * :</b></label>
|
||||
<select name="prod_smtp_config" class="form-control" required>
|
||||
<option value=""></option>
|
||||
@foreach (SmtpEnum::toArray() as $smtp)
|
||||
<option value="{{ $smtp->value }}" @if ($project->prod_smtp_config === $smtp->value) selected @endif>{{ $smtp->label }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label><b>Clé SMTP :</b></label>
|
||||
<input type="text" name="prod_smtp_key" class="form-control" placeholder="Clé SMTP" value="{{$project->prod_smtp_key}}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
<td class="text-left"><a href="/projects/{{$project->uuid}}/edit">{{$project->name}}</a></td>
|
||||
<td class="text-left">{{$project->display_name}}</td>
|
||||
<td><b>{{$project->php}}</b></td>
|
||||
<td>{{$project->type}}</td>
|
||||
<td>{{ ProjectTypesEnum::make($project->type)->label }}</td>
|
||||
<td>
|
||||
@if($project->https === 0)
|
||||
<i class="fas fa-unlock red"></i>
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
</td>
|
||||
<th scope="row" class="text-left"><a href="/projects/{{$project->uuid}}/edit">{{$project->display_name}}</a></th>
|
||||
<td><b>{{$project->php}}</b></td>
|
||||
<td>{{$project->type}}</td>
|
||||
<td>{{ ProjectTypesEnum::make($project->type)->label }}</td>
|
||||
<td>
|
||||
@if ($project->code === 'missing')
|
||||
<i class="fas fa-ghost"></i>
|
||||
|
|
@ -47,13 +47,13 @@
|
|||
@php
|
||||
$code = json_decode($project->code);
|
||||
@endphp
|
||||
@if ($project->type === 'WP')
|
||||
@if ($project->type === ProjectTypesEnum::wp()->value)
|
||||
@if ($code->version === $wp_latest)
|
||||
{{$code->version}}
|
||||
@else
|
||||
<b class="red">{{$code->version}} ({{$wp_latest}})</b>
|
||||
@endif
|
||||
@elseif ($project->type === 'Laravel')
|
||||
@elseif ($project->type === ProjectTypesEnum::laravel()->value)
|
||||
@if ($code->version === $laravel_latest)
|
||||
{{$code->version}}
|
||||
@else
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue