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
9 changes: 8 additions & 1 deletion app/Http/Controllers/IndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@

namespace App\Http\Controllers;

use App\Models\Predio;

class IndexController extends Controller
{
public function index(){

return view('index');
$predios = Predio::with([
'racks' => fn ($q) => $q->orderBy('nome'),
'racks.equipamentos' => fn ($q) => $q->orderBy('ordem'),
])->orderBy('nome')->get();

return view('index',['predios' => $predios]);

}
}
7 changes: 6 additions & 1 deletion config/laravel-usp-theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@

$menu = [
[
'text' => '<i class="fas fa-home"></i> Prédios',
'text' => '<i class="fas fa-home"></i> Home',
'url' => config('app.url') . '/',
'can' => 'user',
],
[
'text' => '<i class="fas fa-building"></i> Prédios',
'url' => config('app.url') . '/predios',
'can' => 'admin',
],
Expand Down
37 changes: 36 additions & 1 deletion resources/views/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,41 @@

@section('content')

Sistema rede
@forelse($predios as $predio)
<h4 class="mt-4 text-uppercase">Prédio: {{ $predio->nome }}</h4>

<div class="row">
@forelse($predio->racks as $rack)
<div class="col-md-3 mb-3">
<div class="card h-100">
<div class="card-header bg-usp py-2">
<strong class="text-dark">{{ $rack->nome }}</strong>
</div>
<ul class="list-group list-group-flush">
@forelse($rack->equipamentos as $equipamento)
<li class="list-group-item py-1">
@can('admin')
<a href="{{ route('equipamentos.show', ['equipamento' => $equipamento]) }}">
{{ $equipamento->hostname }}
</a>
@else
{{ $equipamento->hostname }}
@endcan
</li>
@empty
<li class="list-group-item py-1 text-muted">Sem equipamentos</li>
@endforelse
</ul>
</div>
</div>
@empty
<div class="col-12">
<div class="alert alert-info">Nenhum rack cadastrado neste prédio.</div>
</div>
@endforelse
</div>
@empty
<div class="alert alert-info">Nenhum prédio cadastrado ainda.</div>
@endforelse

@endsection('content')
2 changes: 2 additions & 0 deletions resources/views/racks/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,11 @@
</td>
<td>
<div class="d-flex gap-2">
@can('admin')
<a href="{{ route('equipamentos.show', ['equipamento' => $equipamento]) }}" class="btn btn-info btn-sm">
Ver
</a>
@endcan
<a href="{{ route('equipamentos.edit', ['equipamento' => $equipamento]) }}" class="btn btn-warning btn-sm">
Editar
</a>
Expand Down
2 changes: 1 addition & 1 deletion tests/Browser/CriarEquipamentoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function test_criar_equipamento(): void
->type('#callback', 'http://rede/callback')
->type('#loginUsuario', '1111')
->press('Login')
->waitForText('Sistema rede', 5);
->waitForText('Rede', 5);

// Vai para lista de prédios
$browser->clickLink('Prédios')
Expand Down
2 changes: 1 addition & 1 deletion tests/Browser/CriarModeloSwitchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function test_criar_modelo_siwtch(): void
->type('#callback', 'http://rede/callback')
->type('#loginUsuario', '1111')
->press('Login')
->waitForText('Sistema rede', 5);
->waitForText('Rede', 5);

// Vai para lista de modelos de switch
$browser->clickLink('Modelos de Switch')
Expand Down
2 changes: 1 addition & 1 deletion tests/Browser/CriarPatchPanelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function test_criar_patch_panel(): void
->type('#callback', 'http://rede/callback')
->type('#loginUsuario', '1111')
->press('Login')
->waitForText('Sistema rede', 5);
->waitForText('Rede', 5);

// Navega até o rack
$browser->clickLink('Prédios')
Expand Down
2 changes: 1 addition & 1 deletion tests/Browser/CriarPredioTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function test_criar_predio(): void
->type('#callback', 'http://rede/callback')
->type('#loginUsuario', '1111')
->press('Login')
->waitForText('Sistema rede', 5);
->waitForText('Rede', 5);
// Vai diretamente para a lista de prédios
$browser->clickLink('Prédios')
->assertPathIs('/predios');
Expand Down
2 changes: 1 addition & 1 deletion tests/Browser/CriarRackTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function test__criar_rack(): void
->type('#callback', 'http://rede/callback')
->type('#loginUsuario', '1111')
->press('Login')
->waitForText('Sistema rede', 5);
->waitForText('Rede', 5);
// Vai diretamente para a lista de prédios
$browser->clickLink('Prédios')
->waitForLocation('/predios', 5)
Expand Down
2 changes: 1 addition & 1 deletion tests/Browser/CriarSalaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function test_criar_sala(): void
->type('#callback', 'http://rede/callback')
->type('#loginUsuario', '1111')
->press('Login')
->waitForText('Sistema rede', 5);
->waitForText('Rede', 5);
// Vai diretamente para a lista de prédios
$browser->clickLink('Prédios')
->waitForLocation('/predios', 5)
Expand Down
2 changes: 1 addition & 1 deletion tests/Browser/CriarTipoPortaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function test_criar_tipo_porta(): void
->type('#callback', 'http://rede/callback')
->type('#loginUsuario', '1111')
->press('Login')
->waitForText('Sistema rede', 5);
->waitForText('Rede', 5);
// Vai diretamente para a lista de tipo de portas
$browser->clickLink('Tipos de Porta')
->waitForLocation('/tipo-portas', 5);
Expand Down
2 changes: 1 addition & 1 deletion tests/Browser/IndexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function test_index(): void
{
$this->browse(function (Browser $browser) {
$browser->visit('/')
->assertSee('Sistema rede');
->assertSee('Rede');
});
}
}
2 changes: 1 addition & 1 deletion tests/Browser/LoginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function test_login(): void
->type('#callback', 'http://rede/callback')
->type('#loginUsuario', '1111')
->press('Login')
->waitForText('Sistema rede')
->waitForText('Rede')
->assertSee('Sair');
});
}
Expand Down
Loading