|
| 1 | +<script setup> |
| 2 | +import { defineProps } from "vue"; |
| 3 | +import { useForm } from "@inertiajs/vue3"; |
| 4 | +import PrimaryButton from "@/Components/PrimaryButton.vue"; |
| 5 | +import FormSection from "@/Components/FormSection.vue"; |
| 6 | +import InputError from "@/Components/InputError.vue"; |
| 7 | +import { FwbCheckbox } from "flowbite-vue"; |
| 8 | +import Select from "@/Components/Select.vue"; |
| 9 | +import FormField from "@/Components/FormField.vue"; |
| 10 | +
|
| 11 | +const props = defineProps({ |
| 12 | + node: Object, |
| 13 | +}); |
| 14 | +
|
| 15 | +const initForm = useForm({ |
| 16 | + node_id: props.node.id, |
| 17 | + advertise_addr: "", |
| 18 | + force_new_cluster: false, |
| 19 | +}); |
| 20 | +
|
| 21 | +const submit = () => { |
| 22 | + initForm.post(route("swarm-tasks.init-cluster"), { |
| 23 | + preserveScroll: "errors", |
| 24 | + }); |
| 25 | +}; |
| 26 | +</script> |
| 27 | + |
| 28 | +<template> |
| 29 | + <FormSection @submitted="submit"> |
| 30 | + <template #title>Swarm Cluster</template> |
| 31 | + |
| 32 | + <template #description> |
| 33 | + This is your first node in the swarm cluster. Initializing a new |
| 34 | + swarm cluster will make this node the manager node, responsible for |
| 35 | + orchestrating and managing the cluster. You can add worker nodes to |
| 36 | + this cluster later to distribute workloads efficiently. |
| 37 | + </template> |
| 38 | + |
| 39 | + <template #form> |
| 40 | + <div v-auto-animate class="col-span-6 sm:col-span-4"> |
| 41 | + <div class="grid gap-4"> |
| 42 | + <template v-if="$props.node.data.host.networks.length > 0"> |
| 43 | + <FormField :error="initForm.errors.advertise_addr"> |
| 44 | + <template #label>Advertisement Address</template> |
| 45 | + <Select |
| 46 | + id="advertise_addr" |
| 47 | + v-model="initForm.advertise_addr" |
| 48 | + placeholder="Select Advertise Address" |
| 49 | + > |
| 50 | + <optgroup |
| 51 | + v-for="network in $props.node.data.host |
| 52 | + .networks" |
| 53 | + :label="network.if_name" |
| 54 | + > |
| 55 | + <option |
| 56 | + v-for="ip in network.ips" |
| 57 | + :value="ip.ip" |
| 58 | + > |
| 59 | + {{ ip.ip }} |
| 60 | + </option> |
| 61 | + </optgroup> |
| 62 | + </Select> |
| 63 | + </FormField> |
| 64 | + |
| 65 | + <FormField :error="initForm.errors.force_new_cluster"> |
| 66 | + <!-- TODO: add warning that the force new cluster will wipe out your existing cluster (services, data?) --> |
| 67 | + <FwbCheckbox |
| 68 | + label="Force New Cluster" |
| 69 | + v-model="initForm.force_new_cluster" |
| 70 | + /> |
| 71 | + </FormField> |
| 72 | + <InputError |
| 73 | + v-if="initForm.force_new_cluster" |
| 74 | + message="Be aware that you will lose your data!" |
| 75 | + /> |
| 76 | + </template> |
| 77 | + <template v-else> No IP found </template> |
| 78 | + </div> |
| 79 | + </div> |
| 80 | + </template> |
| 81 | + |
| 82 | + <template #submit> |
| 83 | + <PrimaryButton type="submit" |
| 84 | + >Initialize Swarm Cluster</PrimaryButton |
| 85 | + > |
| 86 | + </template> |
| 87 | + </FormSection> |
| 88 | +</template> |
0 commit comments