合并主机额外配置.

This commit is contained in:
lijiahang
2024-04-19 10:18:56 +08:00
parent 33cfb13342
commit 714940bdcf
23 changed files with 173 additions and 221 deletions

View File

@@ -26,13 +26,6 @@ export interface HostExtraUpdateRequest {
extra: string;
}
/**
* 修改主机别名
*/
export function updateHostAlias(request: HostAliasUpdateRequest) {
return axios.put('/asset/host-extra/update-alias', request);
}
/**
* 获取主机拓展信息
*/

View File

@@ -184,13 +184,13 @@
import useFavorite from '@/hooks/favorite';
import { dataColor } from '@/utils';
import { tagColor } from '@/views/asset/host-list/types/const';
import { updateHostAlias } from '@/api/asset/host-extra';
import { openSettingModalKey, PanelSessionType } from '../../types/terminal.const';
import { updateHostExtra } from '@/api/asset/host-extra';
import { openSettingModalKey, PanelSessionType, ExtraSettingItems } from '../../types/terminal.const';
import { useTerminalStore } from '@/store';
const props = defineProps<{
hostList: Array<HostQueryResponse>,
emptyValue: string
hostList: Array<HostQueryResponse>;
emptyValue: string;
}>();
const { openSession } = useTerminalStore();
@@ -218,9 +218,10 @@
}
try {
// 修改别名
await updateHostAlias({
id: item.id,
name: item.alias || ''
await updateHostExtra({
hostId: item.id,
item: ExtraSettingItems.LABEL,
extra: JSON.stringify({ alias: item.alias })
});
item.editable = false;
} catch (e) {

View File

@@ -25,11 +25,11 @@
:host-id="hostId as number"
:item="ExtraSettingItems.SSH" />
</a-tab-pane>
<!-- 标签颜色 -->
<a-tab-pane :key="ExtraSettingItems.COLOR" title="标签颜色">
<color-setting-form ref="colorForm"
<!-- 标签配置 -->
<a-tab-pane :key="ExtraSettingItems.LABEL" title="标签配置">
<label-setting-form ref="labelForm"
:host-id="hostId as number"
:item="ExtraSettingItems.COLOR" />
:item="ExtraSettingItems.LABEL" />
</a-tab-pane>
</a-tabs>
</a-spin>
@@ -51,7 +51,7 @@
import { updateHostExtra } from '@/api/asset/host-extra';
import { Message } from '@arco-design/web-vue';
import SshSettingForm from './ssh-setting-form.vue';
import ColorSettingForm from './color-setting-form.vue';
import LabelSettingForm from './label-setting-form.vue';
const { visible, setVisible } = useVisible();
const { loading, setLoading } = useLoading();
@@ -60,7 +60,7 @@
const title = ref<string>();
const hostId = ref<number>();
const sshForm = ref();
const colorForm = ref();
const labelForm = ref();
// 打开配置
const open = (record: HostQueryResponse) => {
@@ -79,9 +79,9 @@
if (activeItem.value === ExtraSettingItems.SSH) {
// SSH 配置
value = await sshForm.value.getValue();
} else if (activeItem.value === ExtraSettingItems.COLOR) {
// 颜色配置
value = await colorForm.value.getValue();
} else if (activeItem.value === ExtraSettingItems.LABEL) {
// 标签配置
value = await labelForm.value.getValue();
}
if (!value) {
return false;

View File

@@ -30,12 +30,12 @@
<script lang="ts">
export default {
name: 'colorSettingForm'
name: 'labelSettingForm'
};
</script>
<script lang="ts" setup>
import type { ColorExtraSettingModel } from '../../../types/terminal.type';
import type { LabelExtraSettingModel } from '../../../types/terminal.type';
import { onMounted, ref } from 'vue';
import { terminalTabColorKey } from '../../../types/terminal.const';
import { getHostExtraItem } from '@/api/asset/host-extra';
@@ -48,13 +48,13 @@
const { toOptions } = useDictStore();
const formModel = ref<ColorExtraSettingModel>({
const formModel = ref<LabelExtraSettingModel>({
color: ''
});
//
const renderForm = async () => {
const { data } = await getHostExtraItem<ColorExtraSettingModel>({ hostId: props.hostId, item: props.item });
const { data } = await getHostExtraItem<LabelExtraSettingModel>({ hostId: props.hostId, item: props.item });
formModel.value = data;
};

View File

@@ -45,7 +45,7 @@ export const NewConnectionType = {
// 主机额外配置项
export const ExtraSettingItems = {
SSH: 'ssh',
COLOR: 'color'
LABEL: 'label',
};
// 主机额外配置 ssh 认证方式

View File

@@ -59,7 +59,7 @@ export interface ShortcutKeyItem {
type: number;
}
// ssh 额外配置
// SSH 额外配置
export interface SshExtraSettingModel {
authType?: string;
username?: string;
@@ -67,9 +67,10 @@ export interface SshExtraSettingModel {
identityId?: number;
}
// 颜色 额外配置
export interface ColorExtraSettingModel {
color: string;
// 标签额外配置
export interface LabelExtraSettingModel {
alias?: string;
color?: string;
}
// session tab