mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-12-18 21:38:57 +08:00
feat: Edit the application Compose content to add a comparison. (#10855)
This commit is contained in:
parent
7ea179c2da
commit
0ca96621d4
5 changed files with 31 additions and 13 deletions
|
|
@ -178,6 +178,7 @@ type AppParam struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type AppConfig struct {
|
type AppConfig struct {
|
||||||
Params []AppParam `json:"params"`
|
Params []AppParam `json:"params"`
|
||||||
|
RawCompose string `json:"rawCompose"`
|
||||||
request.AppContainerConfig
|
request.AppContainerConfig
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -796,6 +796,9 @@ func (a *AppInstallService) GetParams(id uint) (*response.AppConfig, error) {
|
||||||
res.RestartPolicy = getRestartPolicy(install.DockerCompose)
|
res.RestartPolicy = getRestartPolicy(install.DockerCompose)
|
||||||
res.WebUI = install.WebUI
|
res.WebUI = install.WebUI
|
||||||
res.Type = install.App.Type
|
res.Type = install.App.Type
|
||||||
|
if rawCompose, err := getUpgradeCompose(install, detail); err == nil {
|
||||||
|
res.RawCompose = rawCompose
|
||||||
|
}
|
||||||
return &res, nil
|
return &res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -270,6 +270,7 @@ export namespace App {
|
||||||
|
|
||||||
export interface AppConfig {
|
export interface AppConfig {
|
||||||
params: InstallParams[];
|
params: InstallParams[];
|
||||||
|
rawCompose?: string;
|
||||||
cpuQuota: number;
|
cpuQuota: number;
|
||||||
memoryLimit: number;
|
memoryLimit: number;
|
||||||
memoryUnit: string;
|
memoryUnit: string;
|
||||||
|
|
|
||||||
|
|
@ -126,22 +126,26 @@
|
||||||
<span class="input-help">{{ $t('app.editComposeHelper') }}</span>
|
<span class="input-help">{{ $t('app.editComposeHelper') }}</span>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<div v-if="paramModel.editCompose">
|
<div v-if="paramModel.editCompose">
|
||||||
|
<el-button @click="openDiff()" type="primary" class="!mb-2">
|
||||||
|
{{ $t('app.showDiff') }}
|
||||||
|
</el-button>
|
||||||
<CodemirrorPro v-model="paramModel.dockerCompose" mode="yaml"></CodemirrorPro>
|
<CodemirrorPro v-model="paramModel.dockerCompose" mode="yaml"></CodemirrorPro>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</el-form>
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
<template #footer v-if="edit">
|
<template #footer v-if="edit">
|
||||||
<span>
|
<el-button @click="handleClose" :disabled="loading">{{ $t('commons.button.cancel') }}</el-button>
|
||||||
<el-button @click="handleClose" :disabled="loading">{{ $t('commons.button.cancel') }}</el-button>
|
<el-button type="primary" :disabled="loading" @click="submit(paramForm)">
|
||||||
<el-button type="primary" :disabled="loading" @click="submit(paramForm)">
|
{{ $t('commons.button.confirm') }}
|
||||||
{{ $t('commons.button.confirm') }}
|
</el-button>
|
||||||
</el-button>
|
|
||||||
</span>
|
|
||||||
</template>
|
</template>
|
||||||
|
<Diff ref="composeDiffRef" @confirm="getNewCompose" />
|
||||||
</DrawerPro>
|
</DrawerPro>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import Diff from '@/views/app-store/installed/upgrade/diff/index.vue';
|
||||||
|
|
||||||
import { App } from '@/api/interface/app';
|
import { App } from '@/api/interface/app';
|
||||||
import { getAppInstallParams, updateAppInstallParams, updateInstallConfig } from '@/api/modules/app';
|
import { getAppInstallParams, updateAppInstallParams, updateInstallConfig } from '@/api/modules/app';
|
||||||
import { reactive, ref } from 'vue';
|
import { reactive, ref } from 'vue';
|
||||||
|
|
@ -200,6 +204,16 @@ const limits = ref<Container.ResourceLimit>({
|
||||||
memory: null as number,
|
memory: null as number,
|
||||||
});
|
});
|
||||||
const oldMemory = ref<number>(0);
|
const oldMemory = ref<number>(0);
|
||||||
|
const composeDiffRef = ref();
|
||||||
|
const rawCompose = ref('');
|
||||||
|
|
||||||
|
const getNewCompose = (compose: string) => {
|
||||||
|
paramModel.dockerCompose = compose;
|
||||||
|
};
|
||||||
|
|
||||||
|
const openDiff = () => {
|
||||||
|
composeDiffRef.value.acceptParams(rawCompose.value, paramModel.dockerCompose);
|
||||||
|
};
|
||||||
|
|
||||||
function checkWebUI() {
|
function checkWebUI() {
|
||||||
if (webUI.domain !== '') {
|
if (webUI.domain !== '') {
|
||||||
|
|
@ -266,6 +280,7 @@ const get = async () => {
|
||||||
try {
|
try {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
const res = await getAppInstallParams(Number(paramData.value.id));
|
const res = await getAppInstallParams(Number(paramData.value.id));
|
||||||
|
rawCompose.value = res.data.rawCompose;
|
||||||
const configParams = res.data.params || [];
|
const configParams = res.data.params || [];
|
||||||
if (configParams && configParams.length > 0) {
|
if (configParams && configParams.length > 0) {
|
||||||
configParams.forEach((d) => {
|
configParams.forEach((d) => {
|
||||||
|
|
|
||||||
|
|
@ -70,12 +70,10 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<span class="dialog-footer">
|
<el-button @click="handleClose" :disabled="loading">{{ $t('commons.button.cancel') }}</el-button>
|
||||||
<el-button @click="handleClose" :disabled="loading">{{ $t('commons.button.cancel') }}</el-button>
|
<el-button type="primary" @click="onOperate" :disabled="versions == null || loading">
|
||||||
<el-button type="primary" @click="onOperate" :disabled="versions == null || loading">
|
{{ $t('commons.button.confirm') }}
|
||||||
{{ $t('commons.button.confirm') }}
|
</el-button>
|
||||||
</el-button>
|
|
||||||
</span>
|
|
||||||
</template>
|
</template>
|
||||||
<Diff ref="composeDiffRef" @confirm="getNewCompose" />
|
<Diff ref="composeDiffRef" @confirm="getNewCompose" />
|
||||||
</DrawerPro>
|
</DrawerPro>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue