diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/resources/templates/orion-vue-views-components-form-drawer.vue.vm b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/resources/templates/orion-vue-views-components-form-drawer.vue.vm index 255afef4..49bdbecf 100644 --- a/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/resources/templates/orion-vue-views-components-form-drawer.vue.vm +++ b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/resources/templates/orion-vue-views-components-form-drawer.vue.vm @@ -8,7 +8,7 @@ :cancel-button-props="{ disabled: loading }" :on-before-ok="handlerOk" @cancel="handleClose"> - + - + Long keyId = model.getKeyId(); Long identityId = model.getIdentityId(); // 必填验证 - if (HostExtraSshAuthTypeEnum.KEY.equals(authType)) { + if (HostExtraSshAuthTypeEnum.CUSTOM_KEY.equals(authType)) { Valid.notNull(keyId); - } else if (HostExtraSshAuthTypeEnum.IDENTITY.equals(authType)) { + } else if (HostExtraSshAuthTypeEnum.CUSTOM_IDENTITY.equals(authType)) { Valid.notNull(identityId); } // 验证主机秘钥是否存在 diff --git a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/service/impl/AssetAuthorizedDataServiceImpl.java b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/service/impl/AssetAuthorizedDataServiceImpl.java index 80e46093..b6425b56 100644 --- a/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/service/impl/AssetAuthorizedDataServiceImpl.java +++ b/orion-ops-module-asset/orion-ops-module-asset-service/src/main/java/com/orion/ops/module/asset/service/impl/AssetAuthorizedDataServiceImpl.java @@ -243,7 +243,6 @@ public class AssetAuthorizedDataServiceImpl implements AssetAuthorizedDataServic List authorizedGroupIdList) { // 查询主机列表 List hosts = hostService.getHostListByCache(); - // 全部数据直接返回 if (allData) { return hosts; @@ -258,6 +257,7 @@ public class AssetAuthorizedDataServiceImpl implements AssetAuthorizedDataServic .map(dataGroupRel::get) .filter(Lists::isNoneEmpty) .flatMap(Collection::stream) + .distinct() .map(hostMap::get) .filter(Objects::nonNull) .collect(Collectors.toList()); diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/impl/DataPermissionServiceImpl.java b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/impl/DataPermissionServiceImpl.java index d2e49a59..c52a5cc8 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/impl/DataPermissionServiceImpl.java +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/java/com/orion/ops/module/infra/service/impl/DataPermissionServiceImpl.java @@ -149,14 +149,17 @@ public class DataPermissionServiceImpl implements DataPermissionService { List list = RedisLists.range(cacheKey, Long::valueOf); if (list.isEmpty()) { LambdaQueryWrapper wrapper = dataPermissionDAO.lambda() - .eq(DataPermissionDO::getType, type) - .eq(DataPermissionDO::getUserId, userId); - // 查询用户角色 + .eq(DataPermissionDO::getType, type); if (dataType.isToRole()) { + // 查询用户角色 List roleIdList = systemUserRoleDAO.selectRoleIdByUserId(userId); - if (!roleIdList.isEmpty()) { - wrapper.or().in(DataPermissionDO::getRoleId, roleIdList); - } + wrapper.and(s -> s.eq(DataPermissionDO::getUserId, userId) + .or() + .in(!roleIdList.isEmpty(), DataPermissionDO::getRoleId, roleIdList) + ); + } else { + // 单用户 + wrapper.eq(DataPermissionDO::getUserId, userId); } // 查询数据库 list = dataPermissionDAO.of() diff --git a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/resources/mapper/DataExtraMapper.xml b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/resources/mapper/DataExtraMapper.xml index e8fc026f..d516900c 100644 --- a/orion-ops-module-infra/orion-ops-module-infra-service/src/main/resources/mapper/DataExtraMapper.xml +++ b/orion-ops-module-infra/orion-ops-module-infra-service/src/main/resources/mapper/DataExtraMapper.xml @@ -26,7 +26,11 @@ UPDATE data_extra SET value = JSON_REPLACE(value, "$.keyId", NULL, - "$.authType", IF(JSON_EXTRACT(value, "$.authType") = 'KEY', 'DEFAULT', JSON_EXTRACT(value, "$.authType"))) + "$.authType", IF( + JSON_EXTRACT(value, "$.authType") = 'CUSTOM_KEY', + 'DEFAULT', + JSON_EXTRACT(value, "$.authType") + )) WHERE deleted = 0 AND type = 'HOST' AND item = 'ssh' @@ -37,7 +41,11 @@ UPDATE data_extra SET value = JSON_REPLACE(value, "$.identityId", NULL, - "$.authType", IF(JSON_EXTRACT(value, "$.authType") = 'IDENTITY', 'DEFAULT', JSON_EXTRACT(value, "$.authType"))) + "$.authType", IF( + JSON_EXTRACT(value, "$.authType") = 'CUSTOM_IDENTITY', + 'DEFAULT', + JSON_EXTRACT(value, "$.authType") + )) WHERE deleted = 0 AND type = 'HOST' AND item = 'ssh' diff --git a/orion-ops-ui/src/api/asset/asset-authorized-data.ts b/orion-ops-ui/src/api/asset/asset-authorized-data.ts index 6b96bdc5..0bd905a9 100644 --- a/orion-ops-ui/src/api/asset/asset-authorized-data.ts +++ b/orion-ops-ui/src/api/asset/asset-authorized-data.ts @@ -24,12 +24,12 @@ export function getCurrentAuthorizedHost() { * 查询当前用户已授权的主机秘钥 */ export function getCurrentAuthorizedHostKey() { - return axios.get('/asset/authorized-data/current-host-key'); + return axios.get>('/asset/authorized-data/current-host-key'); } /** * 查询当前用户已授权的主机身份 */ export function getCurrentAuthorizedHostIdentity() { - return axios.get('/asset/authorized-data/current-host-identity'); + return axios.get>('/asset/authorized-data/current-host-identity'); } diff --git a/orion-ops-ui/src/api/asset/host-extra.ts b/orion-ops-ui/src/api/asset/host-extra.ts index 11d75df4..c5decf88 100644 --- a/orion-ops-ui/src/api/asset/host-extra.ts +++ b/orion-ops-ui/src/api/asset/host-extra.ts @@ -8,9 +8,48 @@ export interface HostAliasUpdateRequest { name?: string; } +/** + * 主机拓展信息查询请求 + */ +export interface HostExtraQueryRequest { + hostId?: number; + item: string; + items?: Array; +} + +/** + * 主机拓展信息更新请求 + */ +export interface HostExtraUpdateRequest { + hostId?: number; + item: string; + extra: string; +} + /** * 修改主机别名 */ export function updateHostAlias(request: HostAliasUpdateRequest) { return axios.put('/asset/host-extra/update-alias', request); } + +/** + * 获取主机拓展信息 + */ +export function getHostExtraItem(params: HostExtraQueryRequest) { + return axios.get('/asset/host-extra/get', { params }); +} + +/** + * 获取多个主机拓展信息 + */ +export function getHostExtraItemList(request: HostExtraQueryRequest) { + return axios.post>>('/asset/host-extra/list', request); +} + +/** + * 修改主机拓展信息 + */ +export function updateHostExtra(request: HostExtraUpdateRequest) { + return axios.put('/asset/host-extra/update', request); +} diff --git a/orion-ops-ui/src/assets/style/global.less b/orion-ops-ui/src/assets/style/global.less index b47c67c3..8d058609 100644 --- a/orion-ops-ui/src/assets/style/global.less +++ b/orion-ops-ui/src/assets/style/global.less @@ -94,6 +94,11 @@ body { border-color: rgb(var(--gray-2)); } +.full { + width: 100%; + height: 100%; +} + .disabled { pointer-events: none; } diff --git a/orion-ops-ui/src/components/app/navbar/index.vue b/orion-ops-ui/src/components/app/navbar/index.vue index 7c1d93be..a31ec8f0 100644 --- a/orion-ops-ui/src/components/app/navbar/index.vue +++ b/orion-ops-ui/src/components/app/navbar/index.vue @@ -256,10 +256,10 @@ const localeRef = ref(); // 打开应用设置 - const openAppSetting = inject(openAppSettingKey) as () => void; + const openAppSetting = inject<() => void>(openAppSettingKey); // 注入收缩菜单 - const toggleDrawerMenu = inject(toggleDrawerMenuKey) as () => void; + const toggleDrawerMenu = inject<() => void>(toggleDrawerMenuKey); // 切换主题 const handleToggleTheme = () => { diff --git a/orion-ops-ui/src/components/asset/host-identity/host-identity-selector.vue b/orion-ops-ui/src/components/asset/host-identity/host-identity-selector.vue index cdce3f89..7199e8f2 100644 --- a/orion-ops-ui/src/components/asset/host-identity/host-identity-selector.vue +++ b/orion-ops-ui/src/components/asset/host-identity/host-identity-selector.vue @@ -20,6 +20,7 @@ const props = defineProps({ modelValue: Number, + authorized: Boolean }); const emits = defineEmits(['update:modelValue']); @@ -45,7 +46,9 @@ onBeforeMount(async () => { setLoading(true); try { - const hostIdentities = await cacheStore.loadHostIdentities(); + const hostIdentities = props.authorized + ? await cacheStore.loadAuthorizedHostIdentities() + : await cacheStore.loadHostIdentities(); optionData.value = hostIdentities.map(s => { return { label: `${s.name} (${s.username})`, diff --git a/orion-ops-ui/src/components/asset/host-key/host-key-selector.vue b/orion-ops-ui/src/components/asset/host-key/host-key-selector.vue index b6e3d86d..71f6a9f1 100644 --- a/orion-ops-ui/src/components/asset/host-key/host-key-selector.vue +++ b/orion-ops-ui/src/components/asset/host-key/host-key-selector.vue @@ -20,6 +20,7 @@ const props = defineProps({ modelValue: Number, + authorized: Boolean }); const emits = defineEmits(['update:modelValue']); @@ -45,7 +46,9 @@ onBeforeMount(async () => { setLoading(true); try { - const hostKeys = await cacheStore.loadHostKeys(); + const hostKeys = props.authorized + ? await cacheStore.loadAuthorizedHostKeys() + : await cacheStore.loadHostKeys(); optionData.value = hostKeys.map(s => { return { label: s.name, diff --git a/orion-ops-ui/src/components/user/user/update-password-modal.vue b/orion-ops-ui/src/components/user/user/update-password-modal.vue index e482d84f..a4235ea5 100644 --- a/orion-ops-ui/src/components/user/user/update-password-modal.vue +++ b/orion-ops-ui/src/components/user/user/update-password-modal.vue @@ -12,7 +12,7 @@ :cancel-button-props="{ disabled: loading }" :on-before-ok="handlerOk" @close="handleClose"> - + ({}), @@ -98,5 +101,15 @@ export default defineStore('cache', { return await this.load(`${type}_Tags`, () => getTagList(type), force); }, + // 获取已授权的主机秘钥列表 + async loadAuthorizedHostKeys(force = false) { + return await this.load('authorizedHostKeys', getCurrentAuthorizedHostKey, force); + }, + + // 获取已授权的主机身份列表 + async loadAuthorizedHostIdentities(force = false) { + return await this.load('authorizedHostIdentities', getCurrentAuthorizedHostIdentity, force); + }, + } }); diff --git a/orion-ops-ui/src/store/modules/cache/types.ts b/orion-ops-ui/src/store/modules/cache/types.ts index 3c4d8c22..41fda8f5 100644 --- a/orion-ops-ui/src/store/modules/cache/types.ts +++ b/orion-ops-ui/src/store/modules/cache/types.ts @@ -16,6 +16,8 @@ export interface CacheState { hostKeys?: HostKeyQueryResponse[]; hostIdentities?: HostIdentityQueryResponse[]; dictKeys?: DictKeyQueryResponse[]; + authorizedHostKeys?: HostKeyQueryResponse[]; + authorizedHostIdentities?: HostIdentityQueryResponse[]; [key: string]: unknown; } diff --git a/orion-ops-ui/src/views/asset/host-identity/components/host-identity-form-modal.vue b/orion-ops-ui/src/views/asset/host-identity/components/host-identity-form-modal.vue index 7914b556..f1659165 100644 --- a/orion-ops-ui/src/views/asset/host-identity/components/host-identity-form-modal.vue +++ b/orion-ops-ui/src/views/asset/host-identity/components/host-identity-form-modal.vue @@ -12,7 +12,7 @@ :cancel-button-props="{ disabled: loading }" :on-before-ok="handlerOk" @close="handleClose"> - + + :help="SshAuthType.IDENTITY === formModel.authType ? '将使用主机身份的用户名' : undefined"> @@ -48,10 +48,10 @@ + :options="toOptions(sshAuthTypeKey)" /> - - - - + import type { HostQueryResponse } from '@/api/asset/host'; + import { ref, nextTick, inject } from 'vue'; import useFavorite from '@/hooks/favorite'; import { dataColor } from '@/utils'; import { tagColor } from '@/views/asset/host-list/types/const'; - import { ref, nextTick } from 'vue'; import { updateHostAlias } from '@/api/asset/host-extra'; + import { sshModalKey } from '../../types/terminal.const'; const props = defineProps<{ hostList: Array, @@ -183,7 +184,7 @@ const clickEditAlias = (item: HostQueryResponse) => { item.editable = true; if (!item.alias) { - item.alias = `${item.name} (${item.code})`; + item.alias = ''; } nextTick(() => { aliasNameInput.value?.focus(); @@ -217,9 +218,7 @@ }; // 打开配置 - const openSetting = (item: HostQueryResponse) => { - console.log('set', item); - }; + const openSetting = inject<(record: HostQueryResponse) => void>(sshModalKey); // 设置收藏 const setFavorite = async (item: HostQueryResponse) => { diff --git a/orion-ops-ui/src/views/host-ops/terminal/components/new-connection/hosts-view.vue b/orion-ops-ui/src/views/host-ops/terminal/components/new-connection/hosts-view.vue index 96ac2c3e..cbecd489 100644 --- a/orion-ops-ui/src/views/host-ops/terminal/components/new-connection/hosts-view.vue +++ b/orion-ops-ui/src/views/host-ops/terminal/components/new-connection/hosts-view.vue @@ -21,6 +21,8 @@ class="list-view-container" :hostList="hostList" empty-value="暂无连接记录, 快去体验吧!" /> + + @@ -31,12 +33,13 @@ + + + + diff --git a/orion-ops-ui/src/views/host-ops/terminal/index.vue b/orion-ops-ui/src/views/host-ops/terminal/index.vue index 2bcb88b5..13a3e7ed 100644 --- a/orion-ops-ui/src/views/host-ops/terminal/index.vue +++ b/orion-ops-ui/src/views/host-ops/terminal/index.vue @@ -34,9 +34,9 @@