⚡ 合并主机额外配置.
This commit is contained in:
@@ -14,4 +14,4 @@
|
||||
7. 任何单位或个人不得在未经本人书面授权的情况下对本项目本身申请相关的知识产权。
|
||||
8. 如果本声明的任何部分被认为无效或不可执行,则该部分将被解释为反映本人的初衷,其余部分仍具有完全效力。不可执行的部分声明,并不构成我们放弃执行该声明的权利。
|
||||
9. 本人有权随时对本声明条款及附件内容进行单方面的变更,并以消息推送、网页公告等方式予以公布,公布后立即自动生效,无需另行单独通知;若您在本声明内容公告变更后继续使用的,表示您已充分阅读、理解并接受修改后的声明内容。
|
||||
10. 本人对本声明拥有最终解释权。
|
||||
10. 本人保留对本声明的最终解释权。
|
||||
|
||||
@@ -14,4 +14,4 @@
|
||||
7. 任何单位或个人不得在未经本人书面授权的情况下对本项目本身申请相关的知识产权。
|
||||
8. 如果本声明的任何部分被认为无效或不可执行,则该部分将被解释为反映本人的初衷,其余部分仍具有完全效力。不可执行的部分声明,并不构成我们放弃执行该声明的权利。
|
||||
9. 本人有权随时对本声明条款及附件内容进行单方面的变更,并以消息推送、网页公告等方式予以公布,公布后立即自动生效,无需另行单独通知;若您在本声明内容公告变更后继续使用的,表示您已充分阅读、理解并接受修改后的声明内容。
|
||||
10. 本人对本声明拥有最终解释权。
|
||||
10. 本人保留对本声明的最终解释权。
|
||||
|
||||
@@ -4,20 +4,26 @@
|
||||
|
||||
## v1.0.5
|
||||
|
||||
`2024-04-` `release`
|
||||
`2024-04-22` `release`
|
||||
|
||||
* 🐞 修复 用户列表用户名显示错误
|
||||
* 🐞 修复 主机分组页面无法编辑的问题
|
||||
* 🐞 修复 资产授权时提示数据发生变更的问题
|
||||
* 🐞 修复 删除资产时授权记录未删除的问题
|
||||
* 🐞 修复 命令执行权限控制失效的问题
|
||||
* 🌈 新增 定时删除未引用的 `tag`
|
||||
* 🌈 新增 执行命令时可使用脚本文件执行
|
||||
* 🌈 新增 主机身份添加类型字段
|
||||
* 🔨 优化 文件传输列表进度显示
|
||||
* 🔨 优化 命令执行日志持续时间
|
||||
* 🔨 优化 命令执行添加内置参数
|
||||
* 🔨 优化 tracker 监听文件可配置 `app.tracker`
|
||||
* 🔨 优化 sftp 上传文件重复处理可配置 `app.sftp`
|
||||
* 🔨 优化 用户状态调整交互逻辑
|
||||
* 🔨 优化 角色状态调整交互逻辑
|
||||
* 🔨 优化 命令执行添加内置参数
|
||||
* 🔨 删除 用户锁定状态
|
||||
* 🔨 优化 优化资产授权交互逻辑
|
||||
* 🔨 优化 SFTP 交互逻辑
|
||||
* 🧹 删除 用户锁定状态
|
||||
|
||||
[如何升级](/update/v1.0.5.md)
|
||||
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
## 功能排期 ⏳
|
||||
## 功能排期
|
||||
|
||||
* 管理员也需要自行授权资产
|
||||
* 快捷命令导入
|
||||
* 文件夹书签
|
||||
* 默认主机
|
||||
* 批量上传
|
||||
* 文件夹书签
|
||||
* 站内消息
|
||||
* 终端背景图片
|
||||
* 资产授权 UI 改版
|
||||
* RDP 远程桌面
|
||||
* 接入 config 后端动态配置
|
||||
* 文档中巡检模板
|
||||
* 批量执行 模板 定时任务 配置是否使用文件执行
|
||||
* 导入快捷命令
|
||||
* 导入命令模板
|
||||
* 使用 vite press 开发文档
|
||||
|
||||
## 已知问题 🐞
|
||||
## 已知问题
|
||||
|
||||
* 顶部菜单折叠宽度计算有问题 (arco 框架内问题)
|
||||
|
||||
@@ -32,4 +32,16 @@ UPDATE `system_user` SET status = 0 WHERE status = 2;
|
||||
DELETE FROM `dict_value` WHERE id = 19;
|
||||
-- 设置主机配置中的 osType
|
||||
UPDATE host_config SET config = JSON_SET(config, '$.osType', 'LINUX') WHERE type = 'ssh' AND deleted = 0;
|
||||
-- 重新设置额外数据
|
||||
UPDATE data_extra alias
|
||||
LEFT JOIN data_extra color
|
||||
ON alias.user_id = color.user_id
|
||||
AND alias.rel_id = color.rel_id
|
||||
AND alias.type= color.type
|
||||
AND color.item = 'color'
|
||||
SET alias.item = 'label',
|
||||
alias.value = JSON_OBJECT('alias', JSON_EXTRACT(alias.value, '$.value'), 'color', JSON_EXTRACT(color.value, '$.color'))
|
||||
WHERE alias.item = 'alias';
|
||||
-- 删除 color 数据
|
||||
DELETE FROM data_extra WHERE type = 'HOST' AND item = 'color';
|
||||
```
|
||||
|
||||
@@ -1,13 +1,3 @@
|
||||
### 修改主机别名
|
||||
PUT {{baseUrl}}/asset/host-extra/update-alias
|
||||
Content-Type: application/json
|
||||
Authorization: {{token}}
|
||||
|
||||
{
|
||||
"id": 1,
|
||||
"name": "alias"
|
||||
}
|
||||
|
||||
### 获取主机拓展信息
|
||||
GET {{baseUrl}}/asset/host-extra/get?hostId=1&item=ssh
|
||||
Authorization: {{token}}
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.orion.ops.module.asset.controller;
|
||||
import com.orion.ops.framework.log.core.annotation.IgnoreLog;
|
||||
import com.orion.ops.framework.log.core.enums.IgnoreLogMode;
|
||||
import com.orion.ops.framework.web.core.annotation.RestWrapper;
|
||||
import com.orion.ops.module.asset.entity.request.host.HostAliasUpdateRequest;
|
||||
import com.orion.ops.module.asset.entity.request.host.HostExtraQueryRequest;
|
||||
import com.orion.ops.module.asset.entity.request.host.HostExtraUpdateRequest;
|
||||
import com.orion.ops.module.asset.service.HostExtraService;
|
||||
@@ -36,12 +35,6 @@ public class HostExtraController {
|
||||
@Resource
|
||||
private HostExtraService hostExtraService;
|
||||
|
||||
@PutMapping("/update-alias")
|
||||
@Operation(summary = "修改主机别名")
|
||||
public Integer updateHostAlias(@Validated @RequestBody HostAliasUpdateRequest request) {
|
||||
return hostExtraService.updateHostAlias(request);
|
||||
}
|
||||
|
||||
@IgnoreLog(IgnoreLogMode.RET)
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获取主机拓展信息")
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
package com.orion.ops.module.asset.entity.request.host;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 主机别名 更新请求对象
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023-9-13 14:31
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(name = "HostAliasUpdateRequest", description = "主机别名 更新请求对象")
|
||||
public class HostAliasUpdateRequest implements Serializable {
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "id")
|
||||
private Long id;
|
||||
|
||||
@NotNull
|
||||
@Size(max = 32)
|
||||
@Schema(description = "别名")
|
||||
private String name;
|
||||
|
||||
}
|
||||
@@ -3,9 +3,9 @@ package com.orion.ops.module.asset.enums;
|
||||
import com.orion.ops.framework.common.handler.data.GenericsDataDefinition;
|
||||
import com.orion.ops.framework.common.handler.data.model.GenericsDataModel;
|
||||
import com.orion.ops.framework.common.handler.data.strategy.MapDataStrategy;
|
||||
import com.orion.ops.module.asset.handler.host.extra.model.HostColorExtraModel;
|
||||
import com.orion.ops.module.asset.handler.host.extra.model.HostLabelExtraModel;
|
||||
import com.orion.ops.module.asset.handler.host.extra.model.HostSshExtraModel;
|
||||
import com.orion.ops.module.asset.handler.host.extra.strategy.HostColorExtraStrategy;
|
||||
import com.orion.ops.module.asset.handler.host.extra.strategy.HostLabelExtraStrategy;
|
||||
import com.orion.ops.module.asset.handler.host.extra.strategy.HostSshExtraStrategy;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
@@ -27,9 +27,9 @@ public enum HostExtraItemEnum implements GenericsDataDefinition {
|
||||
SSH("ssh", HostSshExtraModel.class, HostSshExtraStrategy.class),
|
||||
|
||||
/**
|
||||
* 颜色额外配置
|
||||
* 标签额外配置
|
||||
*/
|
||||
COLOR("color", HostColorExtraModel.class, HostColorExtraStrategy.class),
|
||||
LABEL("label", HostLabelExtraModel.class, HostLabelExtraStrategy.class),
|
||||
|
||||
;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 主机拓展信息 - color 模型
|
||||
* 主机拓展信息 - 标签模型
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
@@ -18,10 +18,13 @@ import lombok.NoArgsConstructor;
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(name = "HostColorExtraModel", description = "主机拓展信息 - color 模型")
|
||||
public class HostColorExtraModel implements GenericsDataModel {
|
||||
@Schema(name = "HostLabelExtraModel", description = "主机拓展信息 - 标签模型")
|
||||
public class HostLabelExtraModel implements GenericsDataModel {
|
||||
|
||||
@Schema(description = "标签 tab 颜色")
|
||||
@Schema(description = "别名")
|
||||
private String alias;
|
||||
|
||||
@Schema(description = "颜色")
|
||||
private String color;
|
||||
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package com.orion.ops.module.asset.handler.host.extra.strategy;
|
||||
|
||||
import com.orion.ops.framework.common.handler.data.strategy.MapDataStrategy;
|
||||
import com.orion.ops.module.asset.handler.host.extra.model.HostColorExtraModel;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 主机拓展信息 - 颜色 模型处理策略
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2024/2/29 23:16
|
||||
*/
|
||||
@Component
|
||||
public class HostColorExtraStrategy implements MapDataStrategy<HostColorExtraModel> {
|
||||
|
||||
@Override
|
||||
public HostColorExtraModel getDefault() {
|
||||
return HostColorExtraModel.builder()
|
||||
// 默认透明
|
||||
.color("")
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateFill(HostColorExtraModel beforeModel, HostColorExtraModel afterModel) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preValid(HostColorExtraModel model) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void valid(HostColorExtraModel model) {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.orion.ops.module.asset.handler.host.extra.strategy;
|
||||
|
||||
import com.orion.ops.framework.common.constant.Const;
|
||||
import com.orion.ops.framework.common.handler.data.strategy.MapDataStrategy;
|
||||
import com.orion.ops.module.asset.handler.host.extra.model.HostLabelExtraModel;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 主机拓展信息 - 标签模型处理策略
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2024/2/29 23:16
|
||||
*/
|
||||
@Component
|
||||
public class HostLabelExtraStrategy implements MapDataStrategy<HostLabelExtraModel> {
|
||||
|
||||
@Override
|
||||
public HostLabelExtraModel getDefault() {
|
||||
return HostLabelExtraModel.builder()
|
||||
// 透明
|
||||
.color(Const.EMPTY)
|
||||
// 无别名
|
||||
.alias(Const.EMPTY)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateFill(HostLabelExtraModel beforeModel, HostLabelExtraModel afterModel) {
|
||||
// 为空则覆盖
|
||||
if (afterModel.getAlias() == null) {
|
||||
afterModel.setAlias(beforeModel.getAlias());
|
||||
}
|
||||
if (afterModel.getColor() == null) {
|
||||
afterModel.setColor(beforeModel.getColor());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preValid(HostLabelExtraModel model) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void valid(HostLabelExtraModel model) {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.orion.ops.module.asset.service;
|
||||
|
||||
import com.orion.ops.framework.common.handler.data.model.GenericsDataModel;
|
||||
import com.orion.ops.module.asset.entity.request.host.HostAliasUpdateRequest;
|
||||
import com.orion.ops.module.asset.entity.request.host.HostExtraQueryRequest;
|
||||
import com.orion.ops.module.asset.entity.request.host.HostExtraUpdateRequest;
|
||||
import com.orion.ops.module.asset.enums.HostExtraItemEnum;
|
||||
@@ -17,14 +16,6 @@ import java.util.Map;
|
||||
*/
|
||||
public interface HostExtraService {
|
||||
|
||||
/**
|
||||
* 修改主机别名
|
||||
*
|
||||
* @param request request
|
||||
* @return effect
|
||||
*/
|
||||
Integer updateHostAlias(HostAliasUpdateRequest request);
|
||||
|
||||
/**
|
||||
* 获取主机额外配置
|
||||
*
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package com.orion.ops.module.asset.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.orion.lang.function.Functions;
|
||||
import com.orion.lang.utils.Refs;
|
||||
import com.orion.lang.utils.collect.Lists;
|
||||
import com.orion.lang.utils.collect.Maps;
|
||||
import com.orion.lang.utils.collect.Sets;
|
||||
@@ -14,10 +12,10 @@ import com.orion.ops.module.asset.entity.request.asset.AssetAuthorizedDataQueryR
|
||||
import com.orion.ops.module.asset.entity.vo.*;
|
||||
import com.orion.ops.module.asset.enums.HostConfigTypeEnum;
|
||||
import com.orion.ops.module.asset.enums.HostConnectTypeEnum;
|
||||
import com.orion.ops.module.asset.handler.host.extra.model.HostColorExtraModel;
|
||||
import com.orion.ops.module.asset.enums.HostExtraItemEnum;
|
||||
import com.orion.ops.module.asset.handler.host.extra.model.HostLabelExtraModel;
|
||||
import com.orion.ops.module.asset.service.*;
|
||||
import com.orion.ops.module.infra.api.*;
|
||||
import com.orion.ops.module.infra.constant.DataExtraItems;
|
||||
import com.orion.ops.module.infra.entity.dto.data.DataGroupDTO;
|
||||
import com.orion.ops.module.infra.entity.dto.tag.TagDTO;
|
||||
import com.orion.ops.module.infra.enums.*;
|
||||
@@ -138,9 +136,9 @@ public class AssetAuthorizedDataServiceImpl implements AssetAuthorizedDataServic
|
||||
// 查询最近连接的主机
|
||||
Future<List<Long>> latestConnectHostIdList = hostConnectLogService.getLatestConnectHostIdAsync(HostConnectTypeEnum.of(type), userId);
|
||||
// 查询主机拓展信息
|
||||
Future<List<Map<Long, String>>> hostExtraResult = dataExtraApi.getExtraItemsValuesByCacheAsync(userId,
|
||||
Future<Map<Long, String>> labelExtraResult = dataExtraApi.getExtraItemValuesByCacheAsync(userId,
|
||||
DataExtraTypeEnum.HOST,
|
||||
Lists.of(DataExtraItems.ALIAS, DataExtraItems.COLOR));
|
||||
HostExtraItemEnum.LABEL.getItem());
|
||||
// 查询分组
|
||||
List<DataGroupDTO> dataGroup = dataGroupApi.getDataGroupList(DataGroupTypeEnum.HOST);
|
||||
// 查询分组引用
|
||||
@@ -156,7 +154,7 @@ public class AssetAuthorizedDataServiceImpl implements AssetAuthorizedDataServic
|
||||
// 设置主机拓展信息
|
||||
this.getAuthorizedHostExtra(wrapper.getHostList(),
|
||||
favoriteResult.get(),
|
||||
hostExtraResult.get());
|
||||
labelExtraResult.get());
|
||||
// 设置最近连接的主机
|
||||
wrapper.setLatestHosts(new LinkedHashSet<>(latestConnectHostIdList.get()));
|
||||
return wrapper;
|
||||
@@ -262,13 +260,13 @@ public class AssetAuthorizedDataServiceImpl implements AssetAuthorizedDataServic
|
||||
/**
|
||||
* 设置授权主机的额外参数
|
||||
*
|
||||
* @param hosts hosts
|
||||
* @param favorite favorite
|
||||
* @param extraList extraList
|
||||
* @param hosts hosts
|
||||
* @param favorite favorite
|
||||
* @param labelExtra labelExtra
|
||||
*/
|
||||
private void getAuthorizedHostExtra(List<HostVO> hosts,
|
||||
List<Long> favorite,
|
||||
List<Map<Long, String>> extraList) {
|
||||
Map<Long, String> labelExtra) {
|
||||
if (Lists.isEmpty(hosts)) {
|
||||
return;
|
||||
}
|
||||
@@ -284,25 +282,18 @@ public class AssetAuthorizedDataServiceImpl implements AssetAuthorizedDataServic
|
||||
for (int i = 0; i < hosts.size(); i++) {
|
||||
hosts.get(i).setTags(tags.get(i));
|
||||
}
|
||||
// 设置主机别名
|
||||
Map<Long, String> aliasMap = extraList.get(0);
|
||||
if (!Maps.isEmpty(aliasMap)) {
|
||||
hosts.forEach(s -> {
|
||||
String alias = aliasMap.get(s.getId());
|
||||
if (alias != null) {
|
||||
s.setAlias(Refs.unrefToString(alias));
|
||||
}
|
||||
});
|
||||
}
|
||||
// 设置主机颜色
|
||||
Map<Long, String> colorMap = extraList.get(1);
|
||||
if (!Maps.isEmpty(colorMap)) {
|
||||
hosts.forEach(s -> {
|
||||
HostColorExtraModel color = JSON.parseObject(colorMap.get(s.getId()), HostColorExtraModel.class);
|
||||
if (color != null) {
|
||||
s.setColor(color.getColor());
|
||||
}
|
||||
});
|
||||
// 这种主机标签信息
|
||||
for (HostVO host : hosts) {
|
||||
String extra = labelExtra.get(host.getId());
|
||||
if (extra == null) {
|
||||
continue;
|
||||
}
|
||||
HostLabelExtraModel label = HostExtraItemEnum.LABEL.parse(extra);
|
||||
if (label == null) {
|
||||
continue;
|
||||
}
|
||||
host.setAlias(label.getAlias());
|
||||
host.setColor(label.getColor());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,20 +1,16 @@
|
||||
package com.orion.ops.module.asset.service.impl;
|
||||
|
||||
import com.orion.lang.function.Functions;
|
||||
import com.orion.lang.utils.Refs;
|
||||
import com.orion.lang.utils.collect.Maps;
|
||||
import com.orion.ops.framework.common.constant.ErrorMessage;
|
||||
import com.orion.ops.framework.common.handler.data.model.GenericsDataModel;
|
||||
import com.orion.ops.framework.common.handler.data.strategy.MapDataStrategy;
|
||||
import com.orion.ops.framework.common.utils.Valid;
|
||||
import com.orion.ops.framework.security.core.utils.SecurityUtils;
|
||||
import com.orion.ops.module.asset.entity.request.host.HostAliasUpdateRequest;
|
||||
import com.orion.ops.module.asset.entity.request.host.HostExtraQueryRequest;
|
||||
import com.orion.ops.module.asset.entity.request.host.HostExtraUpdateRequest;
|
||||
import com.orion.ops.module.asset.enums.HostExtraItemEnum;
|
||||
import com.orion.ops.module.asset.service.HostExtraService;
|
||||
import com.orion.ops.module.infra.api.DataExtraApi;
|
||||
import com.orion.ops.module.infra.constant.DataExtraItems;
|
||||
import com.orion.ops.module.infra.entity.dto.data.DataExtraDTO;
|
||||
import com.orion.ops.module.infra.entity.dto.data.DataExtraQueryDTO;
|
||||
import com.orion.ops.module.infra.entity.dto.data.DataExtraSetDTO;
|
||||
@@ -39,17 +35,6 @@ public class HostExtraServiceImpl implements HostExtraService {
|
||||
@Resource
|
||||
private DataExtraApi dataExtraApi;
|
||||
|
||||
@Override
|
||||
public Integer updateHostAlias(HostAliasUpdateRequest request) {
|
||||
DataExtraSetDTO update = DataExtraSetDTO.builder()
|
||||
.userId(SecurityUtils.getLoginUserId())
|
||||
.item(DataExtraItems.ALIAS)
|
||||
.relId(request.getId())
|
||||
.value(Refs.json(request.getName()))
|
||||
.build();
|
||||
return dataExtraApi.setExtraItem(update, DataExtraTypeEnum.HOST);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getHostExtra(Long hostId, String item) {
|
||||
HostExtraItemEnum extraItem = Valid.valid(HostExtraItemEnum::of, item);
|
||||
@@ -110,21 +95,24 @@ public class HostExtraServiceImpl implements HostExtraService {
|
||||
|
||||
@Override
|
||||
public Integer updateHostExtra(HostExtraUpdateRequest request) {
|
||||
String item = request.getItem();
|
||||
Long hostId = request.getHostId();
|
||||
Long userId = SecurityUtils.getLoginUserId();
|
||||
HostExtraItemEnum extraItem = Valid.valid(HostExtraItemEnum::of, item);
|
||||
MapDataStrategy<GenericsDataModel> strategy = extraItem.getStrategyBean();
|
||||
HostExtraItemEnum item = Valid.valid(HostExtraItemEnum::of, request.getItem());
|
||||
MapDataStrategy<GenericsDataModel> strategy = item.getStrategyBean();
|
||||
// 查询原始配置
|
||||
DataExtraQueryDTO query = DataExtraQueryDTO.builder()
|
||||
.userId(userId)
|
||||
.relId(hostId)
|
||||
.item(item)
|
||||
.item(item.getItem())
|
||||
.build();
|
||||
DataExtraDTO beforeExtraItem = dataExtraApi.getExtraItem(query, DataExtraTypeEnum.HOST);
|
||||
Valid.notNull(beforeExtraItem, ErrorMessage.CONFIG_ABSENT);
|
||||
GenericsDataModel newExtra = extraItem.parse(request.getExtra());
|
||||
GenericsDataModel beforeExtra = extraItem.parse(beforeExtraItem.getValue());
|
||||
if (beforeExtraItem == null) {
|
||||
// 初始化并查询
|
||||
this.checkInitItem(item, userId, hostId);
|
||||
beforeExtraItem = dataExtraApi.getExtraItem(query, DataExtraTypeEnum.HOST);
|
||||
}
|
||||
GenericsDataModel newExtra = item.parse(request.getExtra());
|
||||
GenericsDataModel beforeExtra = item.parse(beforeExtraItem.getValue());
|
||||
// 更新验证
|
||||
strategy.doValidChain(beforeExtra, newExtra);
|
||||
// 更新配置
|
||||
@@ -134,28 +122,42 @@ public class HostExtraServiceImpl implements HostExtraService {
|
||||
/**
|
||||
* 检查配置项并且转为视图 (不存在则初始化默认值)
|
||||
*
|
||||
* @param extraItem extraItem
|
||||
* @param item item
|
||||
* @param extraValue extraValue
|
||||
* @param userId userId
|
||||
* @param hostId hostId
|
||||
* @return viewMap
|
||||
*/
|
||||
private Map<String, Object> checkItemAndToView(HostExtraItemEnum extraItem, String extraValue, Long userId, Long hostId) {
|
||||
String item = extraItem.getItem();
|
||||
MapDataStrategy<GenericsDataModel> strategy = extraItem.getStrategyBean();
|
||||
private Map<String, Object> checkItemAndToView(HostExtraItemEnum item, String extraValue, Long userId, Long hostId) {
|
||||
MapDataStrategy<GenericsDataModel> strategy = item.getStrategyBean();
|
||||
if (extraValue == null) {
|
||||
// 初始化默认数据
|
||||
extraValue = strategy.getDefault().serial();
|
||||
// 插入默认值
|
||||
DataExtraSetDTO set = DataExtraSetDTO.builder()
|
||||
.userId(userId)
|
||||
.relId(hostId)
|
||||
.item(item)
|
||||
.value(extraValue)
|
||||
.build();
|
||||
dataExtraApi.addExtraItem(set, DataExtraTypeEnum.HOST);
|
||||
extraValue = this.checkInitItem(item, userId, hostId);
|
||||
}
|
||||
return strategy.toView(extraValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查配置项 不存在则初始化默认值
|
||||
*
|
||||
* @param item item
|
||||
* @param userId userId
|
||||
* @param hostId hostId
|
||||
* @return defaultValue
|
||||
*/
|
||||
private String checkInitItem(HostExtraItemEnum item, Long userId, Long hostId) {
|
||||
MapDataStrategy<GenericsDataModel> strategy = item.getStrategyBean();
|
||||
// 初始化默认数据
|
||||
String extraValue = strategy.getDefault().serial();
|
||||
// 插入默认值
|
||||
DataExtraSetDTO set = DataExtraSetDTO.builder()
|
||||
.userId(userId)
|
||||
.relId(hostId)
|
||||
.item(item.getItem())
|
||||
.value(extraValue)
|
||||
.build();
|
||||
dataExtraApi.addExtraItem(set, DataExtraTypeEnum.HOST);
|
||||
return extraValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,8 +9,4 @@ package com.orion.ops.module.infra.constant;
|
||||
*/
|
||||
public interface DataExtraItems {
|
||||
|
||||
String ALIAS = "alias";
|
||||
|
||||
String COLOR = "color";
|
||||
|
||||
}
|
||||
|
||||
@@ -136,8 +136,7 @@ public class DataExtraServiceImpl implements DataExtraService {
|
||||
.stream()
|
||||
.collect(Collectors.toMap(DataExtraDO::getRelId,
|
||||
DataExtraDO::getValue,
|
||||
Functions.right())
|
||||
);
|
||||
Functions.right()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -26,13 +26,6 @@ export interface HostExtraUpdateRequest {
|
||||
extra: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改主机别名
|
||||
*/
|
||||
export function updateHostAlias(request: HostAliasUpdateRequest) {
|
||||
return axios.put('/asset/host-extra/update-alias', request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主机拓展信息
|
||||
*/
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -45,7 +45,7 @@ export const NewConnectionType = {
|
||||
// 主机额外配置项
|
||||
export const ExtraSettingItems = {
|
||||
SSH: 'ssh',
|
||||
COLOR: 'color'
|
||||
LABEL: 'label',
|
||||
};
|
||||
|
||||
// 主机额外配置 ssh 认证方式
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user