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/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function register()
*/
public function report(Throwable $e)
{
if (app()->bound('sentry') && $this->shouldReport($e)) {
if (config('app.env') != 'local' && app()->bound('sentry') && $this->shouldReport($e)) {
app('sentry')->captureException($e);
}

Expand Down
21 changes: 20 additions & 1 deletion app/Http/Controllers/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace App\Http\Controllers;

use App\Models\Network;
use Auth;
use Illuminate\Http\Request;
use Inertia\Inertia;

Expand All @@ -14,6 +16,23 @@ class DashboardController extends Controller
*/
public function index()
{
return Inertia::render('Dashboard/Index');
return Inertia::render('Dashboard/Index', [
'newHosts' => Network::whereUser(Auth::id())->rightJoin('network_ips', 'networks.id', '=', 'network_ips.network_id')->orderByDesc('created_at')->limit(5)->get([
'networks.name as network_name',
'network_ips.network_id',
'network_ips.name',
'network_ips.address',
'network_ips.created_at',
'network_ips.updated_at',
]),
'updatedHosts' => Network::whereUser(Auth::id())->rightJoin('network_ips', 'networks.id', '=', 'network_ips.network_id')->orderByDesc('updated_at')->limit(5)->get([
'networks.name as network_name',
'network_ips.network_id',
'network_ips.name',
'network_ips.address',
'network_ips.created_at',
'network_ips.updated_at',
]),
]);
}
}
5 changes: 3 additions & 2 deletions app/Http/Controllers/NetworkController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Http\Requests\Network\StoreRequest;
use App\Http\Requests\Network\UpdateRequest;
use App\Models\Network;
use Auth;
use Illuminate\Http\Request;
use Inertia\Inertia;

Expand All @@ -19,7 +20,7 @@ public function index(): \Inertia\Response
{
return Inertia::render('Networks/Index', [
'networks' => function () {
return Network::where('user_id', \Auth::user()->id)->orWhereNull('user_id')->get()->map(function (Network $network) {
return Network::whereUser(Auth::id())->with('ips')->orderBy('name')->get()->map(function (Network $network) {
return [
'id' => $network->id,
'name' => $network->name,
Expand Down Expand Up @@ -55,7 +56,7 @@ public function store(StoreRequest $request)
$data = $request->validated();

$network = new Network();
$network->user_id = \Auth::id();
$network->user_id = Auth::id();
$network->name = $data['name'];
$network->range = $data['range'];

Expand Down
9 changes: 9 additions & 0 deletions app/Models/Network.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ class Network extends Model
'range',
];

/**
* @param $userId
* @return \Illuminate\Database\Eloquent\Builder|static
*/
public static function whereUser($userId)
{
return self::whereNull('user_id')->orWhere('user_id', $userId);
}

/**
* @return string
*/
Expand Down
2 changes: 1 addition & 1 deletion app/Models/NetworkIp.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ class NetworkIp extends Model
*/
public function network(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(Network::class, 'id', 'network_id');
return $this->belongsTo(Network::class, 'network_id', 'id');
}
}
2 changes: 1 addition & 1 deletion resources/js/Pages/About/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<h5 class="card-title m-0">Composer Packages</h5>
</div>
<ul class="list-group">
<li v-for="library in application.libraries.composer" class="list-group-item d-flex justify-content-between align-items-center border-0 border-bottom">
<li v-for="library in application.libraries.composer" class="list-group-item d-flex justify-content-between align-items-center">
<div class="me-auto">
<div class="fw-bold">{{ library.name }}</div>
{{ library.description }}
Expand Down
41 changes: 41 additions & 0 deletions resources/js/Pages/Dashboard/Component/HostsCard.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<template>
<div v-if="hosts.length > 0" class="col-6">
<div class="card">
<div class="card-body pb-0">
<h5 class="card-title m-0">{{ title }}</h5>
</div>
<ul class="list-group">
<li v-for="host in hosts" class="list-group-item d-flex justify-content-between align-items-center border-bottom">
<div class="me-auto">
<div class="fw-bold">{{ host.name }}</div>
{{ host.address }}
</div>
<Link :href="route('networks.show', host.network_id)" class="badge bg-primary rounded-pill fs-6 text-decoration-none">{{ host.network_name }}</Link>
</li>
</ul>
</div>
</div>
</template>

<script>
import {defineComponent} from "vue"
import {Link} from '@inertiajs/inertia-vue3';
import AppLayout from "@/Layouts/AppLayout.vue"

export default defineComponent({
components: {
AppLayout,
Link
},
props: {
title: {
type: String,
required: true
},
hosts: {
type: Array,
required: true
},
}
});
</script>
13 changes: 12 additions & 1 deletion resources/js/Pages/Dashboard/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,27 @@
</h2>
</template>

<div class="row">
<hosts-card title="New Hosts" :hosts="newHosts"/>
<hosts-card title="Updated Hosts" :hosts="updatedHosts"/>
</div>

</app-layout>
</template>

<script>
import {defineComponent} from "vue"
import AppLayout from "@/Layouts/AppLayout.vue"
import HostsCard from "@/Pages/Dashboard/Component/HostsCard";

export default defineComponent({
components: {
AppLayout
HostsCard,
AppLayout,
},
props: {
newHosts: Array,
updatedHosts: Array,
}
});
</script>
11 changes: 11 additions & 0 deletions resources/sass/_custom.scss
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,14 @@
background-color: #bfa100;
}
}

.card > .list-group {
> .list-group-item {
border: none;
border-bottom: 1px solid #dee2e6;

&:last-child {
border: none !important;
}
}
}