mirror of
https://github.com/MCSManager/MCSManager.git
synced 2025-03-25 16:50:22 +08:00
feat: edit docker env
This commit is contained in:
parent
e61f5b3a6e
commit
96ecc0ce77
@ -13,6 +13,7 @@ import { INSTANCE_TYPE_TRANSLATION } from "@/hooks/useInstance";
|
||||
import { Dayjs } from "dayjs";
|
||||
import _ from "lodash";
|
||||
import { dayjsToTimestamp, timestampToDayjs } from "../../../tools/time";
|
||||
import { useDockerEnvEditDialog } from "@/components/fc";
|
||||
|
||||
interface FormDetail extends InstanceDetail {
|
||||
dayjsEndTime?: Dayjs;
|
||||
@ -96,6 +97,21 @@ const encodeFormData = () => {
|
||||
throw new Error("Ref Options is null");
|
||||
};
|
||||
|
||||
const handleEditDockerEnv = async () => {
|
||||
if (!options.value?.config) return;
|
||||
|
||||
const envs = options.value.config.docker.env?.map((v) => {
|
||||
const tmp = v.split("=");
|
||||
return {
|
||||
label: tmp[0] || "",
|
||||
value: tmp[1] || ""
|
||||
};
|
||||
});
|
||||
const result = await useDockerEnvEditDialog(envs);
|
||||
const envsArray = result.map((v) => `${v.label}=${v.value}`);
|
||||
options.value.config.docker.env = envsArray;
|
||||
};
|
||||
|
||||
defineExpose({
|
||||
openDialog
|
||||
});
|
||||
@ -217,7 +233,7 @@ defineExpose({
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
|
||||
<a-col :xs="24" :offset="0">
|
||||
<a-col :xs="24" :lg="18" :offset="0">
|
||||
<a-form-item>
|
||||
<a-typography-title :level="5">{{ t("TXT_CODE_bb0b9711") }}</a-typography-title>
|
||||
<a-typography-paragraph>
|
||||
@ -236,6 +252,22 @@ defineExpose({
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
|
||||
<a-col :xs="24" :lg="6" :offset="0">
|
||||
<a-form-item>
|
||||
<a-typography-title :level="5">{{ t("TXT_CODE_b916a8dc") }}</a-typography-title>
|
||||
<a-typography-paragraph>
|
||||
<a-typography-text type="secondary" :class="!isPhone && 'two-line-height'">
|
||||
{{ t("TXT_CODE_33ce1c5c") }}
|
||||
</a-typography-text>
|
||||
</a-typography-paragraph>
|
||||
<a-input-group compact>
|
||||
<a-button type="default" @click="handleEditDockerEnv">
|
||||
{{ t("TXT_CODE_ad207008") }}
|
||||
</a-button>
|
||||
</a-input-group>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form>
|
||||
</div>
|
||||
|
@ -424,6 +424,8 @@ router.put(
|
||||
const stopCommand = config.stopCommand ? toText(config.stopCommand) : null;
|
||||
const startCommand = toText(config.startCommand);
|
||||
const updateCommand = toText(config.updateCommand);
|
||||
const dockerEnv =
|
||||
!isEmpty(config.docker.env) && Array.isArray(config.docker.env) ? config.docker.env : [];
|
||||
|
||||
const remoteService = RemoteServiceSubsystem.getInstance(daemonId || "");
|
||||
|
||||
@ -434,6 +436,14 @@ router.put(
|
||||
const isCmdChanged = (cmd: string | null, instanceCmd: string) => cmd !== instanceCmd;
|
||||
const hasPermission = isTopPermissionByUuid(getUserUuid(ctx));
|
||||
|
||||
if (
|
||||
dockerEnv.length &&
|
||||
instance.config.processType !== "docker" &&
|
||||
!systemConfig?.allowChangeCmd &&
|
||||
!hasPermission
|
||||
)
|
||||
return verificationFailed(ctx);
|
||||
|
||||
if (
|
||||
(startCommand || updateCommand) &&
|
||||
isCmdChanged(startCommand, instance.config.startCommand) &&
|
||||
@ -468,7 +478,10 @@ router.put(
|
||||
tag: instanceTags,
|
||||
fileCode,
|
||||
startCommand: startCommand ?? instance.startCommand,
|
||||
updateCommand: updateCommand ?? instance.updateCommand
|
||||
updateCommand: updateCommand ?? instance.updateCommand,
|
||||
docker: {
|
||||
env: dockerEnv
|
||||
}
|
||||
}
|
||||
});
|
||||
ctx.body = result;
|
||||
|
Loading…
x
Reference in New Issue
Block a user