Skip to content

Commit 44033e0

Browse files
committed
feat: #14 add nodes listing to the nodex page
1 parent dc3f9f2 commit 44033e0

File tree

7 files changed

+47
-12
lines changed

7 files changed

+47
-12
lines changed

app/Http/Controllers/NodeController.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ class NodeController extends Controller
1616
*/
1717
public function index()
1818
{
19-
return Inertia::render('Nodes/Index');
19+
$nodes = Node::all();
20+
21+
return Inertia::render('Nodes/Index', ['nodes' => $nodes]);
2022
}
2123

2224
/**
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<script setup>
2+
defineProps({
3+
'node': Object,
4+
});
5+
</script>
6+
7+
<template>
8+
<div class="mx-2">
9+
<span v-if="$props.node.online"
10+
class="bg-green-300 text-green-950 text-xs font-medium me-2 px-2.5 py-0.5 rounded dark:bg-green-900 dark:text-green-300">Online</span>
11+
<span v-else
12+
class="bg-red-300 text-red-950 text-xs font-medium me-2 px-2.5 py-0.5 rounded dark:bg-red-900 dark:text-red-300">Offline</span>
13+
</div>
14+
</template>

resources/js/Pages/Nodes/Create.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ const createNode = () => {
4747
</template>
4848

4949
<template #description>
50-
How your server will be represented in our system.
50+
<p>How your server will be represented in our system.</p>
51+
<p>You will receive Agent installation instructions on the next step.</p>
5152
</template>
5253

5354
<template #form>

resources/js/Pages/Nodes/Index.vue

+23-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ import { router } from '@inertiajs/vue3'
33
44
import AppLayout from '@/Layouts/AppLayout.vue';
55
import PrimaryButton from "@/Components/PrimaryButton.vue";
6+
import NodeStatus from "@/Components/NodeStatus.vue";
7+
import ValueCard from "@/Components/ValueCard.vue";
8+
9+
defineProps({
10+
'nodes': Array,
11+
})
612
</script>
713

814
<template>
@@ -19,9 +25,23 @@ import PrimaryButton from "@/Components/PrimaryButton.vue";
1925

2026
<div class="py-12">
2127
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
22-
<div class="bg-white dark:bg-gray-800 overflow-hidden shadow-xl sm:rounded-lg">
23-
list nodes here
24-
</div>
28+
<a v-for="node in nodes" :key="node.id" :href="route('nodes.show', {node: node.id})"
29+
class="w-96 bg-white dark:bg-gray-800 overflow-hidden shadow-xl sm:rounded-lg p-4 flex justify-around">
30+
31+
<div class="flex">
32+
<div class="font-bold text-xl">{{ node.name }}</div>
33+
<NodeStatus :node="node" />
34+
</div>
35+
<div class="flex flex-col"
36+
>
37+
<template v-for="network in node.data.host.networks" :key="network.if_name"
38+
>
39+
<ValueCard
40+
v-for="ip in network.ips" :key="ip.ip"
41+
:label="network.if_name" :value="ip.ip" />
42+
</template>
43+
</div>
44+
</a>
2545
</div>
2646
</div>
2747
</AppLayout>

resources/js/Pages/Nodes/Show.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import ShowLayout from "@/Pages/Nodes/ShowLayout.vue";
55
import AgentStatus from "@/Pages/Nodes/Partials/AgentStatus.vue";
66
import SectionBorder from "@/Components/SectionBorder.vue";
77
import InitSwarmProgress from "@/Pages/Nodes/Partials/InitSwarmProgress.vue";
8-
import SwarmDetauls from "@/Pages/Nodes/Partials/SwarmDetauls.vue";
8+
import SwarmDetails from "@/Pages/Nodes/Partials/SwarmDetails.vue";
99
1010
defineProps([
1111
'node',
@@ -26,7 +26,7 @@ defineProps([
2626
<template v-if="$props.node.online">
2727
<NewSwarmCluster v-if="$props.node.swarm_id === null" :node="$props.node"/>
2828
<InitSwarmProgress v-if="$props.initTaskGroup" :taskGroup="$props.initTaskGroup" />
29-
<SwarmDetauls v-if="$props.node.swarm_id !== null" :node="$props.node"/>
29+
<SwarmDetails v-if="$props.node.swarm_id !== null" :node="$props.node"/>
3030
</template>
3131
</ShowLayout>
3232
</template>

resources/js/Pages/Nodes/ShowLayout.vue

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script setup>
22
import AppLayout from "@/Layouts/AppLayout.vue";
33
import LayoutTab from "@/Components/LayoutTab.vue";
4+
import NodeStatus from "@/Components/NodeStatus.vue";
45
56
const props = defineProps({
67
node: Object
@@ -10,14 +11,11 @@ const props = defineProps({
1011
<template>
1112
<AppLayout title="Dashboard">
1213
<template #header>
13-
<h2 class="font-semibold text-xl text-gray-800 dark:text-gray-200 leading-tight">
14+
<h2 class="font-semibold text-xl text-gray-800 dark:text-gray-200 leading-tight flex" >
1415
{{ $props.node.name }}
1516

1617

17-
<span v-if="$props.node.online"
18-
class="bg-green-300 text-green-950 text-xs font-medium me-2 px-2.5 py-0.5 rounded dark:bg-green-900 dark:text-green-300">Online</span>
19-
<span v-else
20-
class="bg-red-300 text-red-950 text-xs font-medium me-2 px-2.5 py-0.5 rounded dark:bg-red-900 dark:text-red-300">Offline</span>
18+
<NodeStatus :node="$props.node" />
2119

2220
</h2>
2321
</template>

0 commit comments

Comments
 (0)