Skip to content

Commit

Permalink
feat: 1.配置示例新增p2p开关;2.节点管理临时目录不符合规则不显示复制按钮及内容--story=118517185
Browse files Browse the repository at this point in the history
  • Loading branch information
q15971095971 committed Jul 19, 2024
1 parent 72e1b53 commit 0dcb316
Show file tree
Hide file tree
Showing 13 changed files with 610 additions and 39 deletions.
10 changes: 10 additions & 0 deletions bcs-services/bcs-bscp/ui/src/api/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,13 @@ export const getClientCommonlyUsedNameCheck = (bizId: string, appId: number, nam
*/
export const retryClients = (bizId: string, appId: number, ids: number[]) =>
http.post(`/config/biz/${bizId}/apps/${appId}/clients/retry`, { client_ids: ids, all: false });

/**
* 获取集群列表
* @param bizId 业务ID
* @param appId 应用ID
* @param appId 应用ID
* @returns
*/

export const getClusterList = (bizId: string, appId: number) => http.get(`/config/biz/${bizId}/apps/${appId}/xxx/xxx`);
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ spec:
value: {{ .Bk_Bscp_Variable_Leabels }}
# 配置文件临时目录,文件将下发到 {temp_dir}/files 目录下
- name: temp_dir
value: {{ .Bk_Bscp_VariableTempDir }}
value: {{ .Bk_Bscp_Variable_TempDir }}
{{ .Bk_Bscp_Variable_p2p_part1 }}
# 需要同时挂载文件临时目录到 Init 容器,sidecar 容器,业务容器
volumeMounts:
- mountPath: {{ .Bk_Bscp_VariableTempDir }}
- mountPath: {{ .Bk_Bscp_Variable_TempDir }}
name: bscp-temp-dir
containers:
# 以 nginx 容器为例的业务容器,正式使用时需将其替换为实际业务程序容器
Expand All @@ -49,7 +50,7 @@ spec:
- containerPort: 80
# 需要同时挂载文件临时目录到 Init 容器,sidecar 容器,业务容器
volumeMounts:
- mountPath: {{ .Bk_Bscp_VariableTempDir }}
- mountPath: {{ .Bk_Bscp_Variable_TempDir }}
name: bscp-temp-dir
# BSCP Sidecar 容器负责监控配置文件版本变动,并将更新的配置文件下载到指定临时目录,业务可以通过后置脚本或其他流程实现新配置文件的生效
- name: bscp-sidecar
Expand All @@ -67,9 +68,10 @@ spec:
- name: labels
value: {{ .Bk_Bscp_Variable_Leabels }}
- name: temp_dir
value: {{ .Bk_Bscp_VariableTempDir }}
value: {{ .Bk_Bscp_Variable_TempDir }}
{{ .Bk_Bscp_Variable_p2p_part2 }}
volumeMounts:
- mountPath: {{ .Bk_Bscp_VariableTempDir }}
- mountPath: {{ .Bk_Bscp_Variable_TempDir }}
name: bscp-temp-dir
volumes:
- name: bscp-temp-dir
Expand Down
10 changes: 10 additions & 0 deletions bcs-services/bcs-bscp/ui/src/i18n/en-us.ts
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,16 @@ export default {
'仅支持字母,数字,\'-\',\'_\',\'.\' 及 \'/\' 且需以字母数字开头和结尾': 'Only supports letters, numbers, \'-\', \'_\', \'.\' and \'/\' characters, and must start and end with a letter or number',
'需以字母、数字开头和结尾,可包含 \'-\',\'_\',\'.\' 和字母数字及负数': 'Must start and end with a letter or number, can include \'-\', \'_\', \'.\', and alphanumeric characters, as well as negative numbers',
服务标签: 'service label',
'启用 P2P 网络加速': 'Enable P2P network acceleration',
查看说明: 'View instructions',
'启用 P2P 网络加速主要适用于业务但配置文件较大及大量节点拉取配置的场景,以实现更优的文件传输速度。': 'Enabling P2P network acceleration is primarily suitable for scenarios where business configuration files are large and many nodes are pulling configurations, to achieve better file transfer speeds',
'以下是启用 P2P 网络加速的基本条件,已确保实现有效的网络加速:': 'Below are the basic conditions for enabling P2P network acceleration, ensuring effective network acceleration:',
'⒈ 单个配置文件的大小应超过 50MB': '⒈ The size of a single configuration file should exceed 50MB',
'⒉ 客户端实例数量应超过 50 个': '⒉ The number of client instances should exceed 50',
'P2P 网络加速依赖于 BCS 集群的元数据,请指定客户端即将部署的 BCS 集群 ID。\n更多 P2P 前置依赖信息,请查阅白皮书 P2P 网络加速': 'P2P network acceleration depends on the metadata of the BCS cluster. Please specify the BCS cluster ID where the client will be deployed.\nFor more P2P pre-requisite information, please refer to the P2P network acceleration white paper',
'BCS 集群 ID': 'BCS cluster ID',
搜索视图: 'Search view',
'请先选择BCS 集群 ID,替换下方示例代码后,再尝试复制示例': 'Please select the BCS cluster ID first, replace the example code below, and then try to copy the example',

// 公共组件
页面不存在: 'Page does not exist',
Expand Down
10 changes: 10 additions & 0 deletions bcs-services/bcs-bscp/ui/src/i18n/zh-cn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,16 @@ export default {
'仅支持字母,数字,\'-\',\'_\',\'.\' 及 \'/\' 且需以字母数字开头和结尾': '仅支持字母,数字,\'-\',\'_\',\'.\' 及 \'/\' 且需以字母数字开头和结尾',
'需以字母、数字开头和结尾,可包含 \'-\',\'_\',\'.\' 和字母数字及负数': '需以字母、数字开头和结尾,可包含 \'-\',\'_\',\'.\' 和字母数字及负数',
服务标签: '服务标签',
'启用 P2P 网络加速': '启用 P2P 网络加速',
查看说明: '查看说明',
'启用 P2P 网络加速主要适用于业务但配置文件较大及大量节点拉取配置的场景,以实现更优的文件传输速度。': '启用 P2P 网络加速主要适用于业务但配置文件较大及大量节点拉取配置的场景,以实现更优的文件传输速度。',
'以下是启用 P2P 网络加速的基本条件,已确保实现有效的网络加速:': '以下是启用 P2P 网络加速的基本条件,已确保实现有效的网络加速:',
'⒈ 单个配置文件的大小应超过 50MB': '⒈ 单个配置文件的大小应超过 50MB',
'⒉ 客户端实例数量应超过 50 个': '⒉ 客户端实例数量应超过 50 个',
'P2P 网络加速依赖于 BCS 集群的元数据,请指定客户端即将部署的 BCS 集群 ID。\n更多 P2P 前置依赖信息,请查阅白皮书 P2P 网络加速': 'P2P 网络加速依赖于 BCS 集群的元数据,请指定客户端即将部署的 BCS 集群 ID。\n更多 P2P 前置依赖信息,请查阅白皮书 P2P 网络加速',
'BCS 集群 ID': 'BCS 集群 ID',
搜索视图: '搜索视图',
'请先选择BCS 集群 ID,替换下方示例代码后,再尝试复制示例': '请先选择BCS 集群 ID,替换下方示例代码后,再尝试复制示例',

// 公共组件
页面不存在: '页面不存在',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
defineProps<{ labelName: string }>();
const emits = defineEmits(['send-label', 'send-validate']);
const emits = defineEmits(['send-label']);
const labelArr = ref<{ key: string; value: string }[]>([]);
const showErrorKeyValidation = ref<boolean[]>([]); // key的错误状态
Expand Down Expand Up @@ -100,14 +100,15 @@
// 数据传递
const sendVal = () => {
// 处理数据格式用于展示
// const newArr: string[] = [];
// labelArr.value.forEach((item) => {
// if (item.key || item.value) {
// newArr.push(`"${item.key}":"${item.value}"`);
// }
// });
// const filterArr = newArr.filter((item) => item !== undefined);
const newArr = labelArr.value.map((item) => {
// let { key, value } = item;
// key与value的输入不符合时直接为空(同步临时目录输入)
// if (!keyValidateReg.test(labelArr.value[index].key)) {
// key = '';
// }
// if (!valueValidateReg.test(labelArr.value[index].value)) {
// value = '';
// }
return `"${item.key}":"${item.value}"`;
});
emits('send-label', newArr);
Expand All @@ -122,6 +123,7 @@
display: flex;
justify-content: flex-start;
align-items: center;
height: 20px;
}
.label-span {
font-size: 12px;
Expand All @@ -140,6 +142,7 @@
justify-content: flex-start;
align-items: center;
font-size: 12px;
line-height: 20px;
color: #3a84ff;
cursor: pointer;
border-left: 1px solid #dcdee5;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
<template>
<bk-select
v-model="currentValue"
v-bkloading="loading"
ref="selectorRef"
:class="['p2p-selector', { 'select-error': isError }]"
:popover-options="{ theme: 'light bk-select-popover' }"
:filterable="true"
:input-search="false"
:clearable="false"
:search-placeholder="$t('搜索视图')"
:no-data-text="$t('暂无数据')"
:no-match-text="$t('搜索结果为空')"
@change="handleSelectChange">
<template #trigger>
<div class="selector-trigger">
<bk-overflow-title v-if="currentValue" class="app-name" type="tips">
{{ currentValue }}
</bk-overflow-title>
<span v-else class="no-app">{{ $t('请选择') }}</span>
<AngleUpFill class="arrow-icon arrow-fill" />
<span v-show="isError" class="error-msg">
{{ $t('请先选择BCS 集群 ID,替换下方示例代码后,再尝试复制示例') }}
</span>
</div>
</template>
<bk-option-group
v-for="groupItem in projectGroup"
:key="groupItem.groupName"
:label="groupItem.groupName"
collapsible>
<bk-option
v-if="groupItem.children.length"
v-for="item in groupItem.children"
:key="item.name"
:id="`${item.name}${item.desc}`"
:label="item.name + item.desc">
<div class="cluster-option-item">
<div class="item-name">{{ item.name }}</div>
<div class="item-desc">{{ item.desc }}</div>
</div>
</bk-option>
<div v-else class="bk-select-option no-data">{{ $t('暂无数据') }}</div>
</bk-option-group>
</bk-select>
</template>

<script lang="ts" setup>
import { ref, onMounted } from 'vue';
// import { useRoute } from 'vue-router';
// import { ICredentialItem } from '../../../../../../types/client';
// import { getClusterList } from '../../../../../api/client';
import { AngleUpFill } from 'bkui-vue/lib/icon';
interface IgroupItem {
groupName: string;
children: IchildrenInfo[];
}
interface IchildrenInfo {
name: string;
desc: string;
}
const emits = defineEmits(['current-cluster']);
// const route = useRoute();
// const router = useRouter();
// const bizId = ref(String(route.params.spaceId));
const isError = ref(false);
const loading = ref(true);
const currentValue = ref('');
const projectGroup = ref<IgroupItem[]>([]);
// const projectGroup = ref<IgroupItem[]>([
// {
// groupName: '项目A',
// children: [
// { name: 'bcs测试集群', desc: 'BCS-K8S-00000' },
// { name: '测试00000', desc: 'BCS-K8S-88888' },
// ],
// },
// {
// groupName: '项目B',
// children: [{ name: '蓝鲸 2.0 集群', desc: 'BCS-K8S-15336' }],
// },
// ]);
onMounted(() => {
// loadClusterList();
});
// 表单校验失败检查集群ID是否为空
const validateCluster = () => {
isError.value = !currentValue.value;
};
// 获取集群ID
// const loadClusterList = async () => {
// loading.value = true;
// try {
// // const query = {
// // start: 0,
// // all: true,
// // };
// const res = await getClusterList(bizId.value, 1);
// console.log(res);
// // credentialList.value = res.details;
// } catch (e) {
// console.error(e);
// } finally {
// loading.value = false;
// }
// };
// 下拉列表操作
const handleSelectChange = (val: string) => {
validateCluster();
const parts = val.split('');
emits('current-cluster', { name: parts[0], value: parts[1] });
};
defineExpose({
validateCluster,
});
</script>

<style scoped lang="scss">
.p2p-selector {
&.select-error .selector-trigger {
border-color: #ea3636;
}
&.popover-show .selector-trigger {
border-color: #3a84ff;
box-shadow: 0 0 3px #a3c5fd;
.arrow-icon {
transform: rotate(-180deg);
}
}
&.is-focus {
.selector-trigger {
outline: 0;
}
}
.selector-trigger {
position: relative;
padding: 0 10px 0;
height: 32px;
cursor: pointer;
display: flex;
align-items: center;
justify-content: space-between;
border-radius: 2px;
transition: all 0.3s;
background: #ffffff;
font-size: 14px;
border: 1px solid #c4c6cc;
.app-name {
max-width: 220px;
color: #313238;
}
.no-app {
font-size: 12px;
color: #c4c6cc;
}
.arrow-icon {
margin-left: 13.5px;
color: #979ba5;
transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.error-msg {
position: absolute;
left: 0;
bottom: -17px;
font-size: 12px;
line-height: 1;
white-space: nowrap;
color: #ea3636;
animation: form-error-appear-animation 0.15s;
}
}
}
.cluster-option-item {
padding: 5px 0;
.item-name {
color: #63656e;
}
.item-desc {
color: #979ba5;
}
}
.bk-popover.bk-pop2-content.bk-select-popover .bk-select-content-wrapper .bk-select-option {
height: auto;
line-height: 20px;
}
@keyframes form-error-appear-animation {
0% {
opacity: 0;
transform: translateY(-30%);
}
100% {
opacity: 1;
transform: translateY(0);
}
}
</style>
Loading

0 comments on commit 0dcb316

Please sign in to comment.