From 2f39ecbc0b7d9e9147cd254026b6f580b8636f2c Mon Sep 17 00:00:00 2001 From: Alan Neves Date: Mon, 5 Oct 2026 12:31:05 -0300 Subject: [PATCH 1/2] =?UTF-8?q?Atualiza=20index=20para=20mostrar=20hostnam?= =?UTF-8?q?es=20cadastrados=20em=20pr=C3=A9dios?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/IndexController.php | 9 +++++- config/laravel-usp-theme.php | 7 ++++- resources/views/index.blade.php | 37 +++++++++++++++++++++++- resources/views/racks/show.blade.php | 2 ++ 4 files changed, 52 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/IndexController.php b/app/Http/Controllers/IndexController.php index 517e6d0..e7e3ac5 100644 --- a/app/Http/Controllers/IndexController.php +++ b/app/Http/Controllers/IndexController.php @@ -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]); } } diff --git a/config/laravel-usp-theme.php b/config/laravel-usp-theme.php index f11504d..d947b70 100644 --- a/config/laravel-usp-theme.php +++ b/config/laravel-usp-theme.php @@ -3,7 +3,12 @@ $menu = [ [ - 'text' => ' Prédios', + 'text' => ' Home', + 'url' => config('app.url') . '/', + 'can' => 'user', + ], + [ + 'text' => ' Prédios', 'url' => config('app.url') . '/predios', 'can' => 'admin', ], diff --git a/resources/views/index.blade.php b/resources/views/index.blade.php index f1ed288..5b95233 100644 --- a/resources/views/index.blade.php +++ b/resources/views/index.blade.php @@ -2,6 +2,41 @@ @section('content') -Sistema rede +@forelse($predios as $predio) +

Prédio: {{ $predio->nome }}

+ +
+ @forelse($predio->racks as $rack) +
+
+
+ {{ $rack->nome }} +
+
    + @forelse($rack->equipamentos as $equipamento) +
  • + @can('admin') + + {{ $equipamento->hostname }} + + @else + {{ $equipamento->hostname }} + @endcan +
  • + @empty +
  • Sem equipamentos
  • + @endforelse +
+
+
+ @empty +
+
Nenhum rack cadastrado neste prédio.
+
+ @endforelse +
+@empty +
Nenhum prédio cadastrado ainda.
+@endforelse @endsection('content') \ No newline at end of file diff --git a/resources/views/racks/show.blade.php b/resources/views/racks/show.blade.php index 0796f23..35a0cf6 100644 --- a/resources/views/racks/show.blade.php +++ b/resources/views/racks/show.blade.php @@ -54,9 +54,11 @@
+ @can('admin') Ver + @endcan Editar From 8cb89885e76a1b223178e818e0111d542f2dfca0 Mon Sep 17 00:00:00 2001 From: Alan Neves Date: Mon, 5 Oct 2026 12:32:04 -0300 Subject: [PATCH 2/2] atualiza testes dusk para nova view index --- tests/Browser/CriarEquipamentoTest.php | 2 +- tests/Browser/CriarModeloSwitchTest.php | 2 +- tests/Browser/CriarPatchPanelTest.php | 2 +- tests/Browser/CriarPredioTest.php | 2 +- tests/Browser/CriarRackTest.php | 2 +- tests/Browser/CriarSalaTest.php | 2 +- tests/Browser/CriarTipoPortaTest.php | 2 +- tests/Browser/IndexTest.php | 2 +- tests/Browser/LoginTest.php | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/Browser/CriarEquipamentoTest.php b/tests/Browser/CriarEquipamentoTest.php index 8b6324e..e2e4936 100644 --- a/tests/Browser/CriarEquipamentoTest.php +++ b/tests/Browser/CriarEquipamentoTest.php @@ -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') diff --git a/tests/Browser/CriarModeloSwitchTest.php b/tests/Browser/CriarModeloSwitchTest.php index bab1d1f..c0e1bb4 100644 --- a/tests/Browser/CriarModeloSwitchTest.php +++ b/tests/Browser/CriarModeloSwitchTest.php @@ -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') diff --git a/tests/Browser/CriarPatchPanelTest.php b/tests/Browser/CriarPatchPanelTest.php index fe34780..9998b25 100644 --- a/tests/Browser/CriarPatchPanelTest.php +++ b/tests/Browser/CriarPatchPanelTest.php @@ -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') diff --git a/tests/Browser/CriarPredioTest.php b/tests/Browser/CriarPredioTest.php index e0d6ce3..faa775b 100644 --- a/tests/Browser/CriarPredioTest.php +++ b/tests/Browser/CriarPredioTest.php @@ -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'); diff --git a/tests/Browser/CriarRackTest.php b/tests/Browser/CriarRackTest.php index 309d4f0..17c5057 100644 --- a/tests/Browser/CriarRackTest.php +++ b/tests/Browser/CriarRackTest.php @@ -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) diff --git a/tests/Browser/CriarSalaTest.php b/tests/Browser/CriarSalaTest.php index 5c248c1..63311bd 100644 --- a/tests/Browser/CriarSalaTest.php +++ b/tests/Browser/CriarSalaTest.php @@ -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) diff --git a/tests/Browser/CriarTipoPortaTest.php b/tests/Browser/CriarTipoPortaTest.php index d0280bb..d09e4c0 100644 --- a/tests/Browser/CriarTipoPortaTest.php +++ b/tests/Browser/CriarTipoPortaTest.php @@ -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); diff --git a/tests/Browser/IndexTest.php b/tests/Browser/IndexTest.php index 1d159d5..1ac913a 100644 --- a/tests/Browser/IndexTest.php +++ b/tests/Browser/IndexTest.php @@ -15,7 +15,7 @@ public function test_index(): void { $this->browse(function (Browser $browser) { $browser->visit('/') - ->assertSee('Sistema rede'); + ->assertSee('Rede'); }); } } diff --git a/tests/Browser/LoginTest.php b/tests/Browser/LoginTest.php index e3d3efc..3df9a9b 100644 --- a/tests/Browser/LoginTest.php +++ b/tests/Browser/LoginTest.php @@ -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'); }); }