Skip to content

Commit

Permalink
feat: proxy批量选择版本
Browse files Browse the repository at this point in the history
# Reviewed, transaction id: 23025
  • Loading branch information
hyunfa committed Nov 6, 2024
1 parent 9d6c548 commit 20aa6d7
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 8 deletions.
3 changes: 2 additions & 1 deletion frontend/src/components/setup-table/install-table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
appendSlot: config.appendSlot,
parentProp: config.parentProp,
parentTip: config.parentTip,
focusRow: focusRow
focusRow: focusRow,
extraInfo: config.extraInfo || {}
}"
@chooseVersion="handleChooseVersion"
@confirm="handleBatchConfirm(arguments, config)">
Expand Down
11 changes: 10 additions & 1 deletion frontend/src/components/setup-table/table-header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@
</span>
<ChoosePkgDialog
v-model="versionsDialog.show"
:project="versionsDialog.project"
:type="versionsDialog.type"
:title="versionsDialog.title"
:versions="versionsDialog.versions"
:operate="versionsDialog.operate"
@confirm="versionConfirm" />
@confirm="versionConfirm"
@cancel="handleBatchCancel"/>
</template>
<bk-popover
class="batch-btn"
Expand Down Expand Up @@ -149,6 +151,7 @@ export default class TableHeader extends Vue {
@Prop({ type: String, default: '' }) private readonly appendSlot!: string;
@Prop({ type: Object, default: () => ({}) }) private readonly focusRow!: ISetupRow;
@Prop({ type: String, default: 'light setup-tips' }) private readonly tipTheme!: string;
@Prop({ type: Object, default: () => ({}) }) private readonly extraInfo!: any;
@Ref('batch') private readonly batchRef!: any;
@Ref('tipSpan') private readonly tipSpan!: any;
Expand All @@ -163,6 +166,7 @@ export default class TableHeader extends Vue {
private tipsTrigger: 'mouseenter' | 'manual' = 'mouseenter';
private chooseVersion = '';
private versionsDialog = {
project: 'gse_agent',
show: false,
type: 'unified',
operate: 'reinstall_batch',
Expand Down Expand Up @@ -218,6 +222,11 @@ export default class TableHeader extends Vue {
if (this.isActive) {
this.versionsDialog.show = false;
} else {
if (this.extraInfo.pkgType === 'gse_proxy') {
this.versionsDialog.project = 'gse_proxy';
this.versionsDialog.title = this.$t('选择Proxy版本');
this.versionsDialog.operate = 'Install Proxy';
}
this.versionsDialog.show = true;
this.versionsDialog.versions = this.chooseVersion ? [this.chooseVersion] : [];
this.isActive = true;
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/i18n/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ export default {
内网网卡IP: 'LAN IP',
外网网卡IP: 'WAN IP',
登录IP: 'Login IP',
Agent包版本: 'Agent package version',
Proxy包版本: 'Proxy package version',
选择Proxy版本: 'Select Proxy version',
'选择 Agent 版本': 'Select Agent version',
数据IP: 'Data IP',
数据IP提示: 'IP address for Agent data collection, which is bound to the LAN IP by default, it can be developed separately if any special needs ',
确定: 'OK',
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/i18n/zh.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ export default {
外网网卡IP: '外网网卡IP',
登录IP: '登录IP',
Agent包版本: 'Agent 包版本',
Proxy包版本: 'Proxy 包版本',
'选择 Agent 版本': '选择 Agent 版本',
选择Proxy版本: '选择Proxy版本',
数据IP: '数据IP',
数据IP提示: 'Agent采集数据的IP地址, 默认绑定到内网网卡所在的IP, 如有特殊需求可单独制定',
确定: '确定',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ export interface ISetupHead {
getDefaultValue?: Function
handleValueChange?: Function
handleBlur?: Function
extraInfo?: any
}

// 文件导入配置
Expand Down
10 changes: 8 additions & 2 deletions frontend/src/views/agent/agent-setup/agent-import.vue
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ export default class AgentImport extends Mixins(mixin) {
private loading = false;
// 默认版本
private defaultVersion = '';
// 版本列表
private agentVersionList = [] as string[];
// 编辑head
private editTableHead: { editConfig: ISetupHead[], editManualConfig: ISetupHead[] } = {
editConfig: [],
Expand Down Expand Up @@ -423,7 +425,10 @@ export default class AgentImport extends Mixins(mixin) {
if (!this.isApV2(item.ap_id)) {
item.version = 'stable';
} else {
item.version === '' && (item.version = this.defaultVersion);
// 无agent版本信息或者agent版本是被禁用的,则设置为默认版本(稳定版本)
if (!item.version || !this.agentVersionList.includes(item.version)) {
item.version = this.defaultVersion;
}
}
return item;
});
Expand All @@ -444,12 +449,13 @@ export default class AgentImport extends Mixins(mixin) {
* @returns {Promise<ISetupRow[]>} - 包含默认版本的数据
*/
private async getDefaultVersion() {
const { default_version } = await AgentStore.apiGetPkgVersion({
const { default_version, pkg_info } = await AgentStore.apiGetPkgVersion({
project: 'gse_agent',
os: '',
cpu_arch: ''
});
this.defaultVersion = default_version;
this.agentVersionList = pkg_info.map(item => item.version);
};
// agent包管理开关是否打开
private get AgentPkgShow(): Boolean {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/agent/package/package-cols.vue
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export default class PackageCols extends Mixins(HeaderRenderMixin) {
}
private getDisable(row: IPkgRow) {
return row.formatTags.some((item: any) => item.name === '稳定版本')
return row.formatTags.some((item: any) => item.name === '稳定版本' || item.name === 'stable version')
}
filter = reactive<{ [key: string]: ITabelFliter }>({
pkg_name: {
Expand Down
10 changes: 7 additions & 3 deletions frontend/src/views/cloud/config/netTableConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { authentication, DHCP_FILTER_KEYS, getDefaultConfig } from '@/config/con
import { ISetupHead, ISetupRow } from '@/types';
import { osDirReplace, reguFnMinInteger, reguFnSysPath, reguIp, reguIPMixins, reguIPv6 } from '@/common/form-check';
import { splitCodeArr } from '@/common/regexp';
import { MainStore } from '@/store';

export const parentHead = [
{ label: '主机IPTip', prop: 'host_ip', type: 'text', colspan: 0, required: true, tips: 'proxySetupHostIp' },
Expand Down Expand Up @@ -215,17 +216,20 @@ const config: ISetupHead[] = [
parentProp: 'trans_info',
},
{
label: 'Agent包版本',
label: 'Proxy包版本',
prop: 'version',
type: 'choose',
required: true,
noRequiredMark: false,
placeholder: window.i18n.t('请选择'),
batch: false,
batch: true,
default: '',
width: 100,
width: MainStore.language === 'en' ? 170 : 120,
manualProp: true,
parentProp: 'install_info',
extraInfo: {
pkgType: 'gse_proxy',
}
},
{
label: '',
Expand Down

0 comments on commit 20aa6d7

Please sign in to comment.