🔨 优化主机逻辑.
This commit is contained in:
@@ -85,7 +85,7 @@ public class HostGroupController {
|
|||||||
@OperatorLog(HostGroupOperatorType.RENAME)
|
@OperatorLog(HostGroupOperatorType.RENAME)
|
||||||
@PutMapping("/rename")
|
@PutMapping("/rename")
|
||||||
@Operation(summary = "修改名称")
|
@Operation(summary = "修改名称")
|
||||||
@PreAuthorize("@ss.hasPermission('asset:host-group:update')")
|
@PreAuthorize("@ss.hasAnyPermission('asset:host-group:update', 'asset:host:query')")
|
||||||
public Integer updateHostGroupName(@Validated @RequestBody DataGroupRenameDTO request) {
|
public Integer updateHostGroupName(@Validated @RequestBody DataGroupRenameDTO request) {
|
||||||
return hostGroupService.updateHostGroupName(request);
|
return hostGroupService.updateHostGroupName(request);
|
||||||
}
|
}
|
||||||
@@ -112,7 +112,7 @@ public class HostGroupController {
|
|||||||
@GetMapping("/rel-list")
|
@GetMapping("/rel-list")
|
||||||
@Operation(summary = "查询分组内主机")
|
@Operation(summary = "查询分组内主机")
|
||||||
@Parameter(name = "groupId", description = "groupId", required = true)
|
@Parameter(name = "groupId", description = "groupId", required = true)
|
||||||
@PreAuthorize("@ss.hasPermission('asset:host-group:update')")
|
@PreAuthorize("@ss.hasAnyPermission('asset:host-group:update', 'asset:host:query')")
|
||||||
public Set<Long> queryHostGroupRel(@RequestParam("groupId") Long groupId) {
|
public Set<Long> queryHostGroupRel(@RequestParam("groupId") Long groupId) {
|
||||||
return hostGroupService.queryHostGroupRel(groupId);
|
return hostGroupService.queryHostGroupRel(groupId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,10 +28,7 @@ import lombok.Builder;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
import javax.validation.constraints.Max;
|
import javax.validation.constraints.*;
|
||||||
import javax.validation.constraints.Min;
|
|
||||||
import javax.validation.constraints.NotBlank;
|
|
||||||
import javax.validation.constraints.Size;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -78,6 +75,7 @@ public class HostCreateRequest implements Serializable {
|
|||||||
@Schema(description = "主机端口")
|
@Schema(description = "主机端口")
|
||||||
private Integer port;
|
private Integer port;
|
||||||
|
|
||||||
|
@NotEmpty
|
||||||
@Schema(description = "主机分组")
|
@Schema(description = "主机分组")
|
||||||
private List<Long> groupIdList;
|
private List<Long> groupIdList;
|
||||||
|
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ public class HostUpdateRequest implements Serializable {
|
|||||||
@Schema(description = "主机端口")
|
@Schema(description = "主机端口")
|
||||||
private Integer port;
|
private Integer port;
|
||||||
|
|
||||||
|
@NotEmpty
|
||||||
@Schema(description = "主机分组")
|
@Schema(description = "主机分组")
|
||||||
private List<Long> groupIdList;
|
private List<Long> groupIdList;
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@
|
|||||||
const initOptions = async () => {
|
const initOptions = async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
treeData.value = await cacheStore.loadHostGroups();
|
treeData.value = await cacheStore.loadHostGroupTree();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
|||||||
@@ -310,7 +310,7 @@
|
|||||||
const fetchTreeData = async (force = false) => {
|
const fetchTreeData = async (force = false) => {
|
||||||
try {
|
try {
|
||||||
emits('setLoading', true);
|
emits('setLoading', true);
|
||||||
const groups = await cacheStore.loadHostGroups(force);
|
const groups = await cacheStore.loadHostGroupTree(force);
|
||||||
treeData.value = groups || [];
|
treeData.value = groups || [];
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -93,9 +93,9 @@ export default defineStore('cache', {
|
|||||||
return await this.load('menus', () => getMenuList({}), ['infra:system-menu:query'], force);
|
return await this.load('menus', () => getMenuList({}), ['infra:system-menu:query'], force);
|
||||||
},
|
},
|
||||||
|
|
||||||
// 获取主机分组列表
|
// 获取主机分组树
|
||||||
async loadHostGroups(force = false) {
|
async loadHostGroupTree(force = false) {
|
||||||
return await this.load('hostGroups', getHostGroupTree, ['asset:host-group:update'], force);
|
return await this.load('hostGroups', getHostGroupTree, ['asset:host-group:update', 'asset:host:query'], force);
|
||||||
},
|
},
|
||||||
|
|
||||||
// 获取主机列表
|
// 获取主机列表
|
||||||
|
|||||||
3
orion-visor-ui/src/types/arco.d.ts
vendored
3
orion-visor-ui/src/types/arco.d.ts
vendored
@@ -1,8 +1,7 @@
|
|||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
||||||
import type { TreeNodeData } from '@arco-design/web-vue';
|
import type { TreeNodeData } from '@arco-design/web-vue';
|
||||||
import type { NodeData } from './global';
|
import type { NodeData } from './global';
|
||||||
|
|
||||||
declare module '@arco-design/web-vue' {
|
declare module '@arco-design/web-vue' {
|
||||||
interface TreeNodeData extends NodeData {
|
export interface TreeNodeData extends TreeNodeData, NodeData {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
4
orion-visor-ui/src/types/axios.d.ts
vendored
4
orion-visor-ui/src/types/axios.d.ts
vendored
@@ -1,9 +1,7 @@
|
|||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
||||||
import type { AxiosRequestConfig } from 'axios';
|
import type { AxiosRequestConfig } from 'axios';
|
||||||
|
|
||||||
declare module 'axios' {
|
declare module 'axios' {
|
||||||
// eslint-disable-next-line no-shadow
|
export interface AxiosRequestConfig<D = any> extends AxiosRequestConfig<D> {
|
||||||
export interface AxiosRequestConfig {
|
|
||||||
// 是否添加 Authorization
|
// 是否添加 Authorization
|
||||||
setAuthorization?: boolean;
|
setAuthorization?: boolean;
|
||||||
// 是否使用原始返回
|
// 是否使用原始返回
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import { isEmptyStr } from './index';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取 base64 实际数据
|
* 获取 base64 实际数据
|
||||||
*/
|
*/
|
||||||
@@ -56,7 +54,7 @@ export function getPathAnalysis(path: string, paths: PathAnalysis[] = []): PathA
|
|||||||
return paths;
|
return paths;
|
||||||
}
|
}
|
||||||
const name = path.substring(lastSeparatorIndex, path.length);
|
const name = path.substring(lastSeparatorIndex, path.length);
|
||||||
if (!isEmptyStr(name) && name !== '/') {
|
if (name && name !== '/') {
|
||||||
paths.unshift({
|
paths.unshift({
|
||||||
name: name.substring(1, name.length),
|
name: name.substring(1, name.length),
|
||||||
path: path
|
path: path
|
||||||
|
|||||||
@@ -51,13 +51,6 @@ export function dataColor(str: string, colors: string[], defaultColor = ''): str
|
|||||||
return colors[total % colors.length];
|
return colors[total % colors.length];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断值是否非空
|
|
||||||
*/
|
|
||||||
export function isEmptyStr(val: any) {
|
|
||||||
return typeof (val) === 'undefined' || val == null || val === '';
|
|
||||||
}
|
|
||||||
|
|
||||||
export const YMD_HMS = 'yyyy-MM-dd HH:mm:ss';
|
export const YMD_HMS = 'yyyy-MM-dd HH:mm:ss';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -144,54 +137,6 @@ export function toAnonymousNumber(value: string | undefined): number {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 格式化数字为 ,分割
|
|
||||||
*/
|
|
||||||
export function formatNumber(value: number = 0) {
|
|
||||||
const list = (value + '').split('.');
|
|
||||||
const prefix = list[0].charAt(0) === '-' ? '-' : '';
|
|
||||||
let num = prefix ? list[0].slice(1) : list[0];
|
|
||||||
let result = '';
|
|
||||||
while (num.length > 3) {
|
|
||||||
result = `,${num.slice(-3)}${result}`;
|
|
||||||
num = num.slice(0, num.length - 3);
|
|
||||||
}
|
|
||||||
if (num) {
|
|
||||||
result = num + result;
|
|
||||||
}
|
|
||||||
return `${prefix}${result}${list[1] ? `.${list[1]}` : ''}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断是否为数字
|
|
||||||
*/
|
|
||||||
export function isNumber(value: any, decimal = true, negative = true) {
|
|
||||||
let reg;
|
|
||||||
if (decimal && negative) {
|
|
||||||
reg = /^-?[0-9]*(\.[0-9]*)?$/;
|
|
||||||
} else if (!decimal && negative) {
|
|
||||||
reg = /^-?[0-9]*$/;
|
|
||||||
} else if (decimal && !negative) {
|
|
||||||
reg = /^[0-9]*(\.[0-9]*)?$/;
|
|
||||||
} else if (!decimal && !negative) {
|
|
||||||
reg = /^[0-9]*$/;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return (!isNaN(value) && reg.test(value)) || value === '';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 替换数字
|
|
||||||
*/
|
|
||||||
export function replaceNumber(value: string) {
|
|
||||||
const s = value.charAt(value.length - 1);
|
|
||||||
if (s === '.' || s === '-') {
|
|
||||||
return s.substring(0, value.length - 1);
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 重设对象
|
* 重设对象
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -151,7 +151,7 @@
|
|||||||
// 全选
|
// 全选
|
||||||
const selectAll = async () => {
|
const selectAll = async () => {
|
||||||
// 从缓存中查询全部分组
|
// 从缓存中查询全部分组
|
||||||
const groups = await cacheStore.loadHostGroups();
|
const groups = await cacheStore.loadHostGroupTree();
|
||||||
const groupKeys: number[] = [];
|
const groupKeys: number[] = [];
|
||||||
flatNodeKeys(groups, groupKeys);
|
flatNodeKeys(groups, groupKeys);
|
||||||
checkedGroups.value = groupKeys;
|
checkedGroups.value = groupKeys;
|
||||||
@@ -160,7 +160,7 @@
|
|||||||
// 反选
|
// 反选
|
||||||
const reverseSelect = async () => {
|
const reverseSelect = async () => {
|
||||||
// 从缓存中查询全部分组
|
// 从缓存中查询全部分组
|
||||||
const groups = await cacheStore.loadHostGroups();
|
const groups = await cacheStore.loadHostGroupTree();
|
||||||
const groupKeys: number[] = [];
|
const groupKeys: number[] = [];
|
||||||
flatNodeKeys(groups, groupKeys);
|
flatNodeKeys(groups, groupKeys);
|
||||||
checkedGroups.value = groupKeys.filter(s => !checkedGroups.value.includes(s));
|
checkedGroups.value = groupKeys.filter(s => !checkedGroups.value.includes(s));
|
||||||
|
|||||||
@@ -44,6 +44,11 @@ export const port = [{
|
|||||||
message: '输入的端口不合法'
|
message: '输入的端口不合法'
|
||||||
}] as FieldRule[];
|
}] as FieldRule[];
|
||||||
|
|
||||||
|
export const groupIdList = [{
|
||||||
|
required: true,
|
||||||
|
message: '请选择主机分组'
|
||||||
|
}] as FieldRule[];
|
||||||
|
|
||||||
export const tags = [{
|
export const tags = [{
|
||||||
maxLength: 5,
|
maxLength: 5,
|
||||||
message: '最多选择5个标签'
|
message: '最多选择5个标签'
|
||||||
@@ -61,6 +66,7 @@ export default {
|
|||||||
code,
|
code,
|
||||||
address,
|
address,
|
||||||
port,
|
port,
|
||||||
|
groupIdList,
|
||||||
tags,
|
tags,
|
||||||
description,
|
description,
|
||||||
} as Record<string, FieldRule | FieldRule[]>;
|
} as Record<string, FieldRule | FieldRule[]>;
|
||||||
|
|||||||
Reference in New Issue
Block a user