Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/Actions/AddDominioAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class AddDominioAction
{
public function execute(array $validated): array
{
$validated['dominio'] = $validated['name'] . 'fflch.usp.br';
$validated['dominio'] = $validated['name'] . '.fflch.usp.br';
$validated['user_id'] = Auth::id();

return $validated;
Expand Down
15 changes: 13 additions & 2 deletions app/Http/Controllers/DockerImageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public function create()

public function store(DockerImageRequest $request)
{
$dockerImage = DockerImage::create($request->validated());
return redirect()->route('dockerimages.show', $dockerImage);
DockerImage::create($request->validated());
return redirect()->route('dockerimages.index');
}

public function edit(DockerImage $dockerimage)
Expand Down Expand Up @@ -62,4 +62,15 @@ public function destroy(DockerImage $dockerimage)
}
}

public function variables(DockerImage $dockerimage)
{
return view(
'dockerimages.editvariables',
[
'variables' => $dockerimage->imageVariables,
'image' => $dockerimage
]
);
}

}
7 changes: 3 additions & 4 deletions app/Http/Controllers/ImageVariableController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
namespace App\Http\Controllers;

use App\Http\Requests\StoreImageVariableRequest;
use App\Models\DockerImage;
use App\Models\ImageVariable;

class ImageVariableController extends Controller
{

public function store(StoreImageVariableRequest $request)
{
ImageVariable::create($request->validated());
Expand All @@ -16,10 +16,9 @@ public function store(StoreImageVariableRequest $request)

public function destroy(ImageVariable $imageVariable)
{
$imageId = $imageVariable->image_id;
$image = $imageVariable->image;
$imageVariable->delete();

return redirect()->route('dockerimages.show', $imageId);
return redirect()->route('dockerimages.variables', $image);
}

}
2 changes: 2 additions & 0 deletions app/Http/Requests/AppUpdateRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public function rules(): array
{
return [
'name' => 'required',
'justificativa' => 'required',
'image_id' => 'required',
'version' => 'required'
];
Expand All @@ -32,6 +33,7 @@ public function rules(): array
public function messages(){
return [
'name.required' => 'O domínio é obrigatório.',
'justificativa' => 'A justificativa é obrigatória.',
'image_id' => 'A imagem do app é obrigatória.',
'version.required' => 'A versão da imagme é obrigatória.'
];
Expand Down
8 changes: 4 additions & 4 deletions resources/views/dockerimages/create.blade.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
@extends('main')
@section('content')
<div class="card">
<div class="col m-2">
<p><b>Adicionar nova imagem:</b></p>
<div class="card-header col">
<h1>Adicionar nova imagem:</h1>
</div>
<div>
<form action="/dockerimages" method="post" class="card w-50 pt-2 pb-2 m-2">
<div class="card-body">
<form action="/dockerimages" method="post" class="w-50">
@method('post')
@csrf
<div class="col">
Expand Down
14 changes: 7 additions & 7 deletions resources/views/dockerimages/edit.blade.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
@extends('main')
@section('content')
<div class="card">
<div>
<p>Atualize a imagem: {{ $docker_image->name }}</p>
<div class="card-header">
<h1>{{ $docker_image->name }}</h1>
</div>
<div>
<form action="/dockerimages/{{ $docker_image->id }}" method="post">
<div class="card-body">
<form class="d-flex align-items-end" action="/dockerimages/{{ $docker_image->id }}" method="post">
@method('patch')
@csrf
<div class="input-group mb-3">
<span class="input-group-text" id="basic-addon1">Imagem docker:</span>
<div class="w-25">
<span class="mb-2">Imagem docker:</span>
<input type="text" class="form-control" value="{{ old('path', $docker_image->path) }}" name="path"
placeholder="ghcr.io/caminho/nome_da_imagem">
</div>
<button type="submit" class="btn btn-primary">salvar</button>
<button type="submit" class="btn btn-success ml-2">salvar</button>
</form>
</div>
</div>
Expand Down
50 changes: 50 additions & 0 deletions resources/views/dockerimages/editvariables.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
@extends('main')
@section('content')
<div class="card">
<div class="card-header">
<h1>Configurar variáveis</h1>
</div>
<div class="card-body">
<form class="d-flex align-items-end" method="post" action="{{ route('imageVariable.store') }}">
@csrf
@method('post')
<input type="hidden" name="image_id" value="{{ $image->id }}">
<div class="w-25">
<label for="name">Adicione uma variável</label>
<input class="form-control" type="text" name="name" placeholder="">
</div>
<button class="btn btn-success ml-2" type="submit">Adicionar</button>
</form>
</div>
@if ($variables)
<div class="card-body">
<table class="table table-striped table-hover">
<thead>
<tr>
<th scope="col">Nome</th>
<th scope="col">Ações</th>
</tr>
</thead>
<tbody>
@foreach ($variables as $variable)
<tr>
<td>{{ $variable->name }}</td>
<td>
<form action="{{ route("imageVariable.destroy", $variable) }}" method="post">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger">remover</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endif
</div>

@endsection

@section('javascripts_bottom')
@endsection('javascripts_bottom')
44 changes: 32 additions & 12 deletions resources/views/dockerimages/index.blade.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,36 @@
@extends('main')
@section('content')
<div class="card">
<div>
<p>Imagens docker:</p>
</div>
<div>
<ul>
@foreach ($docker_images as $image)
<li><a href="/dockerimages/{{ $image->id }}">{{ $image->name }}</a></li>
@endforeach
</ul>
</div>
</div>
<div class="card">
<div class="card-header">
<h3>Imagens</h3>
</div>
<div class="card-body">
<div class="row">
<table class="table table-striped table-hover">
<thead>
<tr>
<th scope="col">Nome</th>
<th scope="col">Imagem</th>
<th scope="col">Ações</th>
</tr>
</thead>
<tbody>
@foreach ($docker_images as $image)
<tr>
<td>{{ $image->name }}</td>
<td>{{ $image->path }}</td>
<td>
<a class="btn btn-warning" href="{{ route('dockerimages.edit', $image) }}">Editar</a>
<a class="btn btn-danger" href="{{ route('dockerimages.destroy', $image) }}">Deletar</a>
<a class="btn btn-success"
href="{{ route('dockerimages.variables', $image) }}">Variáveis</a>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>

</div>
</div>
@endsection
10 changes: 3 additions & 7 deletions resources/views/dockerimages/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@
@foreach ($docker_image->imageVariables as $variable)
<tr>
<td>
<form
class="d-flex justify-content-between"
action="{{ route('imageVariable.destroy', $variable->id) }}"
<form class="d-flex justify-content-between"
action="{{ route('imageVariable.destroy', $variable->id) }}"
method="post">
@csrf
@method('delete')
Expand All @@ -48,10 +47,7 @@ class="d-flex justify-content-between"
</tbody>
</table>
</div>
<form
class="ml-4 w-50"
action="{{ route('imageVariable.store') }}"
method="post">
<form class="ml-4 w-50" action="{{ route('imageVariable.store') }}" method="post">
@csrf
@method('post')
<input type="hidden" name="image_id" value="{{ $docker_image->id }}">
Expand Down
13 changes: 10 additions & 3 deletions resources/views/webapps/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
</div>
</div>

<div class="row">
<div class="col">
<label><b>Justificativa</b></label>
<textarea class="form-control" name="justificativa">{{ old('justificativa', $webapp->justificativa) }}</textarea>
</div>
</div>

<div class="row mb-3 mt-3">
<div class="col">
<label><b>Imagem</b></label>
Expand All @@ -26,9 +33,9 @@
Seleciona a imagem docker para a aplicação
</option>
@foreach ($docker_images as $image)
<option value="{{ $image->id }}" @selected(old('image_id', $webapp->image_id ?? null) == $image->id)>
{{ $image->name }}
</option>
<option value="{{ $image->id }}" @selected(old('image_id', $webapp->image_id ?? null) == $image->id)>
{{ $image->name }}
</option>
@endforeach
</select>
</div>
Expand Down
28 changes: 23 additions & 5 deletions resources/views/webapps/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,29 @@
<div class="card-header"><h3>Apps</h3></div>
<div class="card-body">
<div class="row">
<ul>
@foreach ($webapps as $webapp)
<li><a href="/webapps/{{ $webapp->id }}">{{ $webapp->dominio }}</a></li>
@endforeach
</ul>
<table class="table table-stripped table-hover">
<thead>
<tr>
<th scope="col">Nome</th>
<th scope="col">Imagem</th>
<th scope="col">Versão</th>
<th scope="col">Ações</th>
</tr>
</thead>
<tbody>
@foreach ($webapps as $webapp)
<tr>
<td>{{ $webapp->dominio }}</td>
<td>{{ $webapp->dockerImage->path }}</td>
<td>{{ $webapp->version }}</td>
<td>
<a class="btn btn-success" href="{{ route("webapps.show", $webapp) }}">Ver</a>
<a class="btn btn-warning" href="{{ route("webapps.edit", $webapp) }}">Editar</a>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>

</div>
Expand Down
Loading
Loading