-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: #122 rework swarm-related management interfaces
- Loading branch information
1 parent
f493dd3
commit 16bc52c
Showing
18 changed files
with
336 additions
and
365 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,6 @@ class Swarm extends Model | |
use HasOwningTeam; | ||
|
||
protected $fillable = [ | ||
'name', | ||
'data', | ||
'team_id', | ||
]; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
database/migrations/2024_08_20_202958_alter_swarms_remove_name_column.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\DB; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
Schema::table('swarms', function (Blueprint $table) { | ||
$table->dropColumn('name'); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::table('swarms', function (Blueprint $table) { | ||
$table->string('name')->after('id'); | ||
}); | ||
|
||
DB::table('swarms')->update(['name' => DB::raw('CAST(id AS VARCHAR)')]); | ||
|
||
Schema::table('swarms', function (Blueprint $table) { | ||
$table->string('name')->nullable(false)->change(); | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<script setup> | ||
import { defineProps } from "vue"; | ||
import { useForm } from "@inertiajs/vue3"; | ||
import PrimaryButton from "@/Components/PrimaryButton.vue"; | ||
import FormSection from "@/Components/FormSection.vue"; | ||
import InputError from "@/Components/InputError.vue"; | ||
import { FwbCheckbox } from "flowbite-vue"; | ||
import Select from "@/Components/Select.vue"; | ||
import FormField from "@/Components/FormField.vue"; | ||
const props = defineProps({ | ||
node: Object, | ||
}); | ||
const initForm = useForm({ | ||
node_id: props.node.id, | ||
advertise_addr: "", | ||
force_new_cluster: false, | ||
}); | ||
const submit = () => { | ||
initForm.post(route("swarm-tasks.init-cluster"), { | ||
preserveScroll: "errors", | ||
}); | ||
}; | ||
</script> | ||
|
||
<template> | ||
<FormSection @submitted="submit"> | ||
<template #title>Swarm Cluster</template> | ||
|
||
<template #description> | ||
This is your first node in the swarm cluster. Initializing a new | ||
swarm cluster will make this node the manager node, responsible for | ||
orchestrating and managing the cluster. You can add worker nodes to | ||
this cluster later to distribute workloads efficiently. | ||
</template> | ||
|
||
<template #form> | ||
<div v-auto-animate class="col-span-6 sm:col-span-4"> | ||
<div class="grid gap-4"> | ||
<template v-if="$props.node.data.host.networks.length > 0"> | ||
<FormField :error="initForm.errors.advertise_addr"> | ||
<template #label>Advertisement Address</template> | ||
<Select | ||
id="advertise_addr" | ||
v-model="initForm.advertise_addr" | ||
placeholder="Select Advertise Address" | ||
> | ||
<optgroup | ||
v-for="network in $props.node.data.host | ||
.networks" | ||
:label="network.if_name" | ||
> | ||
<option | ||
v-for="ip in network.ips" | ||
:value="ip.ip" | ||
> | ||
{{ ip.ip }} | ||
</option> | ||
</optgroup> | ||
</Select> | ||
</FormField> | ||
|
||
<FormField :error="initForm.errors.force_new_cluster"> | ||
<!-- TODO: add warning that the force new cluster will wipe out your existing cluster (services, data?) --> | ||
<FwbCheckbox | ||
label="Force New Cluster" | ||
v-model="initForm.force_new_cluster" | ||
/> | ||
</FormField> | ||
<InputError | ||
v-if="initForm.force_new_cluster" | ||
message="Be aware that you will lose your data!" | ||
/> | ||
</template> | ||
<template v-else> No IP found </template> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<template #submit> | ||
<PrimaryButton type="submit" | ||
>Initialize Swarm Cluster</PrimaryButton | ||
> | ||
</template> | ||
</FormSection> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<script setup> | ||
import { defineProps } from "vue"; | ||
import { useForm } from "@inertiajs/vue3"; | ||
import PrimaryButton from "@/Components/PrimaryButton.vue"; | ||
import FormSection from "@/Components/FormSection.vue"; | ||
import Select from "@/Components/Select.vue"; | ||
import FormField from "@/Components/FormField.vue"; | ||
const props = defineProps({ | ||
node: Object, | ||
}); | ||
const joinForm = useForm({ | ||
node_id: props.node.id, | ||
role: "manager", | ||
advertise_addr: "", | ||
}); | ||
const submit = () => { | ||
joinForm.post(route("swarm-tasks.join-cluster"), { | ||
preserveScroll: "errors", | ||
}); | ||
}; | ||
</script> | ||
|
||
<template> | ||
<FormSection @submitted="submit"> | ||
<template #title>Swarm Cluster</template> | ||
|
||
<template #description> | ||
Connect this node to an existing Docker Swarm cluster, enabling | ||
seamless integration and distributed computing capabilities. | ||
</template> | ||
|
||
<template #form> | ||
<div class="col-span-6 sm:col-span-4"> | ||
<div class="grid gap-4"> | ||
<FormField :error="joinForm.errors.role"> | ||
<template #label> Role </template> | ||
|
||
<Select v-model="joinForm.role"> | ||
<option value="manager">Manager</option> | ||
<option value="worker">Worker</option> | ||
</Select> | ||
</FormField> | ||
|
||
<FormField :error="joinForm.errors.advertise_addr"> | ||
<template #label>Advertisement Address</template> | ||
<Select | ||
id="advertise_addr" | ||
v-model="joinForm.advertise_addr" | ||
placeholder="Select Advertise Address" | ||
> | ||
<optgroup | ||
v-for="network in $props.node.data.host | ||
.networks" | ||
:label="network.if_name" | ||
> | ||
<option | ||
v-for="ip in network.ips" | ||
:value="ip.ip" | ||
> | ||
{{ ip.ip }} | ||
</option> | ||
</optgroup> | ||
</Select> | ||
</FormField> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<template #submit> | ||
<PrimaryButton type="submit">Join Swarm Cluster</PrimaryButton> | ||
</template> | ||
</FormSection> | ||
</template> |
Oops, something went wrong.