Skip to content

Commit

Permalink
feat: #14 add nodes listing to the nodex page
Browse files Browse the repository at this point in the history
  • Loading branch information
bohdan-shulha committed Jun 21, 2024
1 parent dc3f9f2 commit 44033e0
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 12 deletions.
4 changes: 3 additions & 1 deletion app/Http/Controllers/NodeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ class NodeController extends Controller
*/
public function index()
{
return Inertia::render('Nodes/Index');
$nodes = Node::all();

return Inertia::render('Nodes/Index', ['nodes' => $nodes]);
}

/**
Expand Down
14 changes: 14 additions & 0 deletions resources/js/Components/NodeStatus.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<script setup>
defineProps({
'node': Object,
});
</script>

<template>
<div class="mx-2">
<span v-if="$props.node.online"
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>
<span v-else
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>
</div>
</template>
3 changes: 2 additions & 1 deletion resources/js/Pages/Nodes/Create.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ const createNode = () => {
</template>

<template #description>
How your server will be represented in our system.
<p>How your server will be represented in our system.</p>
<p>You will receive Agent installation instructions on the next step.</p>
</template>

<template #form>
Expand Down
26 changes: 23 additions & 3 deletions resources/js/Pages/Nodes/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ import { router } from '@inertiajs/vue3'
import AppLayout from '@/Layouts/AppLayout.vue';
import PrimaryButton from "@/Components/PrimaryButton.vue";
import NodeStatus from "@/Components/NodeStatus.vue";
import ValueCard from "@/Components/ValueCard.vue";
defineProps({
'nodes': Array,
})
</script>

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

<div class="py-12">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
<div class="bg-white dark:bg-gray-800 overflow-hidden shadow-xl sm:rounded-lg">
list nodes here
</div>
<a v-for="node in nodes" :key="node.id" :href="route('nodes.show', {node: node.id})"
class="w-96 bg-white dark:bg-gray-800 overflow-hidden shadow-xl sm:rounded-lg p-4 flex justify-around">

<div class="flex">
<div class="font-bold text-xl">{{ node.name }}</div>
<NodeStatus :node="node" />
</div>
<div class="flex flex-col"
>
<template v-for="network in node.data.host.networks" :key="network.if_name"
>
<ValueCard
v-for="ip in network.ips" :key="ip.ip"
:label="network.if_name" :value="ip.ip" />
</template>
</div>
</a>
</div>
</div>
</AppLayout>
Expand Down
4 changes: 2 additions & 2 deletions resources/js/Pages/Nodes/Show.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import ShowLayout from "@/Pages/Nodes/ShowLayout.vue";
import AgentStatus from "@/Pages/Nodes/Partials/AgentStatus.vue";
import SectionBorder from "@/Components/SectionBorder.vue";
import InitSwarmProgress from "@/Pages/Nodes/Partials/InitSwarmProgress.vue";
import SwarmDetauls from "@/Pages/Nodes/Partials/SwarmDetauls.vue";
import SwarmDetails from "@/Pages/Nodes/Partials/SwarmDetails.vue";
defineProps([
'node',
Expand All @@ -26,7 +26,7 @@ defineProps([
<template v-if="$props.node.online">
<NewSwarmCluster v-if="$props.node.swarm_id === null" :node="$props.node"/>
<InitSwarmProgress v-if="$props.initTaskGroup" :taskGroup="$props.initTaskGroup" />
<SwarmDetauls v-if="$props.node.swarm_id !== null" :node="$props.node"/>
<SwarmDetails v-if="$props.node.swarm_id !== null" :node="$props.node"/>
</template>
</ShowLayout>
</template>
8 changes: 3 additions & 5 deletions resources/js/Pages/Nodes/ShowLayout.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script setup>
import AppLayout from "@/Layouts/AppLayout.vue";
import LayoutTab from "@/Components/LayoutTab.vue";
import NodeStatus from "@/Components/NodeStatus.vue";
const props = defineProps({
node: Object
Expand All @@ -10,14 +11,11 @@ const props = defineProps({
<template>
<AppLayout title="Dashboard">
<template #header>
<h2 class="font-semibold text-xl text-gray-800 dark:text-gray-200 leading-tight">
<h2 class="font-semibold text-xl text-gray-800 dark:text-gray-200 leading-tight flex" >
{{ $props.node.name }}


<span v-if="$props.node.online"
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>
<span v-else
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>
<NodeStatus :node="$props.node" />

</h2>
</template>
Expand Down

0 comments on commit 44033e0

Please sign in to comment.