|
1 | 1 | <script setup>
|
2 |
| -
|
3 | 2 | import InputError from "@/Components/InputError.vue";
|
4 | 3 | import InputLabel from "@/Components/InputLabel.vue";
|
5 | 4 | import PrimaryButton from "@/Components/PrimaryButton.vue";
|
6 | 5 | import AppLayout from "@/Layouts/AppLayout.vue";
|
7 | 6 | import TextInput from "@/Components/TextInput.vue";
|
8 | 7 | import ActionSection from "@/Components/ActionSection.vue";
|
9 |
| -import {useForm} from "@inertiajs/vue3"; |
| 8 | +import { useForm } from "@inertiajs/vue3"; |
10 | 9 | import FormField from "@/Components/FormField.vue";
|
11 | 10 | import Select from "@/Components/Select.vue";
|
12 | 11 | import SecondaryButton from "@/Components/SecondaryButton.vue";
|
13 | 12 | import TextArea from "@/Components/TextArea.vue";
|
14 |
| -import {computed, effect, reactive} from "vue"; |
| 13 | +import { computed, effect, reactive } from "vue"; |
15 | 14 | import ServiceDetailsForm from "@/Pages/Services/Partials/ServiceDetailsForm.vue";
|
16 | 15 | import DeploymentData from "@/Pages/Services/Partials/DeploymentData.vue";
|
| 16 | +import TemplatePicker from "@/Pages/Services/Partials/TemplatePicker.vue"; |
17 | 17 |
|
18 | 18 | const props = defineProps({
|
19 |
| - 'swarms': Array, |
20 |
| - 'networks': Array, |
21 |
| - 'nodes': Array, |
22 |
| - 'deploymentData': Object, |
23 |
| - 'dockerRegistries': Array, |
24 |
| - 's3Storages': Array, |
25 |
| -}) |
| 19 | + swarms: Array, |
| 20 | + networks: Array, |
| 21 | + nodes: Array, |
| 22 | + deploymentData: Object, |
| 23 | + dockerRegistries: Array, |
| 24 | + s3Storages: Array, |
| 25 | +}); |
26 | 26 |
|
27 | 27 | const form = useForm({
|
28 |
| - name: '', |
29 |
| - swarm_id: props.swarms[0]?.id, |
30 |
| - deploymentData: props.deploymentData |
| 28 | + name: "", |
| 29 | + swarm_id: props.swarms[0]?.id, |
| 30 | + deploymentData: props.deploymentData, |
31 | 31 | });
|
32 | 32 |
|
33 | 33 | const createService = () => {
|
34 |
| - form.post(route('services.store')) |
35 |
| -} |
| 34 | + form.post(route("services.store")); |
| 35 | +}; |
| 36 | +
|
| 37 | +const showTemplatePicker = reactive({ |
| 38 | + show: false, |
| 39 | +}); |
| 40 | +
|
| 41 | +const openTemplatePicker = () => { |
| 42 | + showTemplatePicker.show = true; |
| 43 | +}; |
| 44 | +
|
| 45 | +const hideTemplatePicker = () => { |
| 46 | + showTemplatePicker.show = false; |
| 47 | +}; |
| 48 | +
|
| 49 | +const applyTemplate = (template) => { |
| 50 | + form.name = template.name; |
| 51 | + console.log(JSON.stringify(template.deploymentData.processes)); |
| 52 | + form.deploymentData.processes = template.deploymentData.processes; |
| 53 | +
|
| 54 | + hideTemplatePicker(); |
| 55 | +}; |
36 | 56 | </script>
|
37 | 57 |
|
38 | 58 | <template>
|
39 |
| - <AppLayout title="Dashboard"> |
40 |
| - <template #header> |
41 |
| - <h2 class="font-semibold text-xl text-gray-800 dark:text-gray-200 leading-tight"> |
42 |
| - Create Service |
43 |
| - </h2> |
44 |
| - </template> |
45 |
| - |
46 |
| - <div class="py-12"> |
47 |
| - <form class="max-w-7xl mx-auto sm:px-6 lg:px-8" @submit.prevent="createService"> |
48 |
| - <ActionSection> |
49 |
| - <template #title> |
50 |
| - Service Details |
51 |
| - </template> |
52 |
| - |
53 |
| - <template #description> |
54 |
| - <p>Select a swarm where the service will be deployed to.</p> |
55 |
| - <p>The name of the service can be changed at any time. Be aware, that the service name in the Swarm cluster |
56 |
| - will not be changed.</p> |
57 |
| - |
58 |
| - <p>You can isolate containers from each other by using different networks.</p> |
59 |
| - <p>Service will be accessible by the internal domain name to other containers on the same network.</p> |
60 |
| - <p>You can make certain ports of the containers accessible from the host network. Please set up the firewall |
61 |
| - rule on your host to prevent unwanted access.</p> |
62 |
| - <p>If you don't select the Placement Node, the containers will be able to run on any node of the Swarm |
63 |
| - Cluster.</p> |
64 |
| - </template> |
65 |
| - |
66 |
| - <template #content> |
67 |
| - <ServiceDetailsForm v-model="form" :team="$page.props.auth.user.current_team" :swarms="swarms" /> |
68 |
| - </template> |
69 |
| - </ActionSection> |
70 |
| - |
71 |
| - <DeploymentData v-model="form.deploymentData" |
72 |
| - :networks="networks" |
73 |
| - :nodes="nodes" |
74 |
| - :errors="form.errors" |
75 |
| - :service-name="form.name" |
76 |
| - :docker-registries="props.dockerRegistries" |
77 |
| - :s3-storages="props.s3Storages" |
| 59 | + <AppLayout title="Dashboard"> |
| 60 | + <TemplatePicker |
| 61 | + :show="showTemplatePicker.show" |
| 62 | + @apply="applyTemplate" |
| 63 | + @close="hideTemplatePicker" |
78 | 64 | />
|
79 | 65 |
|
80 |
| - <div class="flex justify-end"> |
81 |
| - <PrimaryButton :class="{ 'opacity-25': form.processing }" :disabled="form.processing"> |
82 |
| - Create Service |
83 |
| - </PrimaryButton> |
| 66 | + <template #header> |
| 67 | + <h2 |
| 68 | + class="font-semibold text-xl text-gray-800 dark:text-gray-200 leading-tight" |
| 69 | + > |
| 70 | + Create Service |
| 71 | + </h2> |
| 72 | + </template> |
| 73 | + |
| 74 | + <template #actions> |
| 75 | + <SecondaryButton @click="openTemplatePicker" |
| 76 | + >Use a Template</SecondaryButton |
| 77 | + > |
| 78 | + </template> |
| 79 | + |
| 80 | + <div class="py-12"> |
| 81 | + <form |
| 82 | + class="max-w-7xl mx-auto sm:px-6 lg:px-8" |
| 83 | + @submit.prevent="createService" |
| 84 | + > |
| 85 | + <ActionSection> |
| 86 | + <template #title> Service Details </template> |
| 87 | + |
| 88 | + <template #description> |
| 89 | + <p> |
| 90 | + Select a swarm where the service will be deployed |
| 91 | + to. |
| 92 | + </p> |
| 93 | + <p> |
| 94 | + The name of the service can be changed at any time. |
| 95 | + Be aware, that the service name in the Swarm cluster |
| 96 | + will not be changed. |
| 97 | + </p> |
| 98 | + |
| 99 | + <p> |
| 100 | + You can isolate containers from each other by using |
| 101 | + different networks. |
| 102 | + </p> |
| 103 | + <p> |
| 104 | + Service will be accessible by the internal domain |
| 105 | + name to other containers on the same network. |
| 106 | + </p> |
| 107 | + <p> |
| 108 | + You can make certain ports of the containers |
| 109 | + accessible from the host network. Please set up the |
| 110 | + firewall rule on your host to prevent unwanted |
| 111 | + access. |
| 112 | + </p> |
| 113 | + <p> |
| 114 | + If you don't select the Placement Node, the |
| 115 | + containers will be able to run on any node of the |
| 116 | + Swarm Cluster. |
| 117 | + </p> |
| 118 | + </template> |
| 119 | + |
| 120 | + <template #content> |
| 121 | + <ServiceDetailsForm |
| 122 | + v-model="form" |
| 123 | + :team="$page.props.auth.user.current_team" |
| 124 | + :swarms="swarms" |
| 125 | + /> |
| 126 | + </template> |
| 127 | + </ActionSection> |
| 128 | + |
| 129 | + <DeploymentData |
| 130 | + v-model="form.deploymentData" |
| 131 | + :networks="networks" |
| 132 | + :nodes="nodes" |
| 133 | + :errors="form.errors" |
| 134 | + :service-name="form.name" |
| 135 | + :docker-registries="props.dockerRegistries" |
| 136 | + :s3-storages="props.s3Storages" |
| 137 | + /> |
| 138 | + |
| 139 | + <div class="flex justify-end"> |
| 140 | + <PrimaryButton |
| 141 | + :class="{ 'opacity-25': form.processing }" |
| 142 | + :disabled="form.processing" |
| 143 | + > |
| 144 | + Create Service |
| 145 | + </PrimaryButton> |
| 146 | + </div> |
| 147 | + </form> |
84 | 148 | </div>
|
85 |
| - </form> |
86 |
| - </div> |
87 |
| - </AppLayout> |
| 149 | + </AppLayout> |
88 | 150 | </template>
|
0 commit comments