Skip to content

Commit 990a68a

Browse files
committed
enh(api): Add getServices and wire service dropdowns
Add deploymentsApi.getServices() for fetching deployment services. Export apiClient for reuse. Remove hardcoded container_name from compose templates. Replace free-text service input in CronJobsView with a dropdown populated from the deployment's real services. Signed-off-by: nfebe <fenn25.fn@gmail.com>
1 parent ef57429 commit 990a68a

3 files changed

Lines changed: 38 additions & 15 deletions

File tree

src/components/NewDeploymentModal.vue

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1951,7 +1951,6 @@ const getDatabaseServiceYaml = () => {
19511951
return `
19521952
db:
19531953
image: mysql:8
1954-
container_name: ${form.name}-db
19551954
environment:
19561955
MYSQL_ROOT_PASSWORD: ${rootPassword}
19571956
MYSQL_DATABASE: ${dbName}
@@ -1966,7 +1965,6 @@ const getDatabaseServiceYaml = () => {
19661965
return `
19671966
db:
19681967
image: mariadb:10
1969-
container_name: ${form.name}-db
19701968
environment:
19711969
MYSQL_ROOT_PASSWORD: ${rootPassword}
19721970
MYSQL_DATABASE: ${dbName}
@@ -1981,7 +1979,6 @@ const getDatabaseServiceYaml = () => {
19811979
return `
19821980
db:
19831981
image: postgres:15
1984-
container_name: ${form.name}-db
19851982
environment:
19861983
POSTGRES_DB: ${dbName}
19871984
POSTGRES_USER: ${db.dbUser || "app"}
@@ -1995,7 +1992,6 @@ const getDatabaseServiceYaml = () => {
19951992
return `
19961993
db:
19971994
image: mongo:6
1998-
container_name: ${form.name}-db
19991995
environment:
20001996
MONGO_INITDB_ROOT_USERNAME: ${db.dbUser || "app"}
20011997
MONGO_INITDB_ROOT_PASSWORD: ${db.dbPassword}
@@ -2032,7 +2028,6 @@ const buildComposeTemplate = (name: string, ports: { containerPort: number; host
20322028
services:
20332029
app:
20342030
image: nginx:alpine
2035-
container_name: ${name}
20362031
${portConfig}
20372032
networks:
20382033
- ${networkName}
@@ -2071,8 +2066,6 @@ const buildComposeFromImage = () => {
20712066
return `name: ${name}
20722067
services:
20732068
app:
2074-
image: ${image}
2075-
container_name: ${name}
20762069
${portConfig}
20772070
networks:
20782071
- ${networkName}

src/services/api.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import axios from "axios";
22
import type {
33
Deployment,
4+
Service,
45
Network,
56
Certificate,
67
ProxyStatus,
@@ -83,6 +84,7 @@ export const deploymentsApi = {
8384
const queryString = params.toString();
8485
return apiClient.delete(`/deployments/${name}${queryString ? `?${queryString}` : ""}`);
8586
},
87+
getServices: (name: string) => apiClient.get<{ services: Service[] }>(`/deployments/${name}/services`),
8688
start: (name: string) => apiClient.post(`/deployments/${name}/start`),
8789
stop: (name: string) => apiClient.post(`/deployments/${name}/stop`),
8890
restart: (name: string) => apiClient.post(`/deployments/${name}/restart`),

src/views/CronJobsView.vue

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -229,15 +229,18 @@
229229
</div>
230230

231231
<div class="form-group">
232-
<label for="service">Service (optional)</label>
233-
<input
232+
<label for="service">Service</label>
233+
<select
234234
id="service"
235235
v-model="form.service"
236-
type="text"
237-
placeholder="web, app, worker..."
238-
:disabled="saving"
239-
/>
240-
<span class="hint">Leave empty to use deployment name as container</span>
236+
:disabled="saving || loadingServices || !form.deployment_name"
237+
>
238+
<option value="">Default ({{ form.deployment_name || "select deployment" }})</option>
239+
<option v-for="svc in deploymentServices" :key="svc.name" :value="svc.name">
240+
{{ svc.name }}
241+
</option>
242+
</select>
243+
<span class="hint">Target service container for the command</span>
241244
</div>
242245

243246
<div class="form-group">
@@ -374,7 +377,7 @@
374377
import { ref, computed, onMounted, watch } from "vue";
375378
import { schedulerApi, deploymentsApi } from "@/services/api";
376379
import type { ScheduledTask, TaskExecution } from "@/services/api";
377-
import type { Deployment } from "@/types";
380+
import type { Deployment, Service } from "@/types";
378381
import { useNotificationsStore } from "@/stores/notifications";
379382
import { useAuthStore } from "@/stores/auth";
380383
import ConfirmModal from "@/components/ConfirmModal.vue";
@@ -512,6 +515,31 @@ const defaultForm = (): CronJobForm => ({
512515
});
513516
514517
const form = ref<CronJobForm>(defaultForm());
518+
const deploymentServices = ref<Service[]>([]);
519+
const loadingServices = ref(false);
520+
521+
const fetchDeploymentServices = async (deploymentName: string) => {
522+
if (!deploymentName) {
523+
deploymentServices.value = [];
524+
return;
525+
}
526+
loadingServices.value = true;
527+
try {
528+
const response = await deploymentsApi.getServices(deploymentName);
529+
deploymentServices.value = response.data.services || [];
530+
} catch {
531+
deploymentServices.value = [];
532+
} finally {
533+
loadingServices.value = false;
534+
}
535+
};
536+
537+
watch(
538+
() => form.value.deployment_name,
539+
(name) => {
540+
fetchDeploymentServices(name);
541+
},
542+
);
515543
516544
const isFormValid = computed(() => {
517545
return Boolean(

0 commit comments

Comments
 (0)