Skip to content

Commit

Permalink
Merge pull request #11256 from vhwweng/issue_9820_fix
Browse files Browse the repository at this point in the history
fix: 构建机的最大并发数设置需要支持设置docker构建的最大并发数 #9820
  • Loading branch information
bkci-bot authored Nov 29, 2024
2 parents 5e73e74 + ee80fa4 commit 4ffd12e
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,33 @@
<div :class="{ 'is-disabled': !nodeDetails.canEdit }" v-else><span @click="editHandle('parallelTaskCount', true)">{{ $t('edit') }}</span></div>
</div>
</div>
<div class="item-content">
<div class="item-label">{{ $t('setting.nodeInfo.dockerMaxConcurrency') }}</div>
<div class="item-value">
<div class="display-item" v-if="isEditDockerCount">
<input type="number" class="bk-form-input parallelTaskCount-input"
ref="dockerParallelTaskCount"
name="dockerParallelTaskCount"
:placeholder="$t('setting.nodeInfo.parallelTaskCountTips')"
v-validate.initial="`required|between:0,100|decimal:0`"
v-model="dockerParallelTaskCount"
:class="{ 'is-danger': errors.has('dockerParallelTaskCount') }">
</div>
<div class="editing-item" v-else>{{ nodeDetails.dockerParallelTaskCount || '--' }}</div>
</div>
<div class="handle-btn">
<div v-if="isEditDockerCount">
<span @click="saveHandle('dockerParallelTaskCount')">{{ $t('setting.save') }}</span>
<span @click="editHandle('dockerParallelTaskCount', false)">{{ $t('setting.cancel') }}</span>
</div>
<div
v-else
:class="{ 'is-disabled': !nodeDetails.canEdit }"
>
<span @click="editHandle('dockerParallelTaskCount', true)">{{ $t('setting.edit') }}</span>
</div>
</div>
</div>
<div class="item-content">
<div class="item-label">{{ $t('status') }}</div>
<div class="item-value" :class="nodeDetails.status === 'NORMAL' ? 'normal' : 'abnormal'">
Expand Down Expand Up @@ -79,7 +106,9 @@
return {
nodeDetails: {},
isEditCount: false,
parallelTaskCount: 0
parallelTaskCount: 0,
isEditDockerCount: false,
dockerParallelTaskCount: 0
}
},
computed: {
Expand Down Expand Up @@ -110,27 +139,55 @@
})
}
break
case 'dockerParallelTaskCount':
this.isEditDockerCount = isOpen
if (isOpen) {
this.dockerParallelTaskCount = this.nodeDetails.dockerParallelTaskCount
this.$nextTick(() => {
this.$refs.dockerParallelTaskCount.focus()
})
}
break
default:
break
}
},
async saveHandle () {
async saveHandle (type) {
const valid = await this.$validator.validate()
if (valid) {
this.saveParallelTaskCount(this.parallelTaskCount)
if (!valid) return
switch (type) {
case 'parallelTaskCount':
this.saveParallelTaskCount(this.parallelTaskCount, 'parallelTaskCount')
break
case 'dockerParallelTaskCount':
this.saveParallelTaskCount(this.dockerParallelTaskCount, 'dockerParallelTaskCount')
break
default:
break
}
},
async saveParallelTaskCount (parallelTaskCount) {
async saveParallelTaskCount (count, type) {
let message, theme
const fn = type === 'dockerParallelTaskCount'
? setting.saveDockerParallelTaskCount
: setting.saveParallelTaskCount
const params = {
projectId: this.projectId,
nodeHashId: this.nodeHashId,
count: count
}
try {
await setting.saveParallelTaskCount(this.projectId, this.nodeHashId, parallelTaskCount)
await fn(params)
message = this.$t('setting.successfullySaved')
theme = 'success'
this.requestNodeDetail()
} catch (err) {
message = err.message ? err.message : err
theme = 'error'
} finally {
this.isEditCount = false
this.isEditDockerCount = false
this.$bkMessage({
message,
theme
Expand All @@ -140,7 +197,6 @@
async requestNodeDetail () {
try {
this.nodeDetails = await setting.requestNodeDetail(this.projectId, this.nodeHashId)
this.isEditCount = false
} catch (err) {
const message = err.message ? err.message : err
const theme = 'error'
Expand Down Expand Up @@ -179,7 +235,7 @@
align-items: center;
border-bottom: 1px solid #DDE4EB;
.item-label {
width: 180px;
width: 188px;
padding: 12px 20px;
border-right: 1px solid #DDE4EB;
}
Expand Down
10 changes: 8 additions & 2 deletions src/frontend/devops-stream/src/http/setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,14 @@ export default {
/**
* 设置agent构建并发数
*/
saveParallelTaskCount (projectId, nodeHashId, parallelTaskCount) {
return api.post(`${ENVIRNMENT_PERFIX}/user/environment/thirdPartyAgent/projects/${projectId}/nodes/${nodeHashId}/parallelTaskCount?parallelTaskCount=${parallelTaskCount}`).then(response => {
saveParallelTaskCount ({ projectId, nodeHashId, count }) {
return api.post(`${ENVIRNMENT_PERFIX}/user/environment/thirdPartyAgent/projects/${projectId}/nodes/${nodeHashId}/parallelTaskCount?parallelTaskCount=${count }`).then(response => {
return response
})
},

saveDockerParallelTaskCount ({ projectId, nodeHashId, count }) {
return api.post(`${ENVIRNMENT_PERFIX}/user/environment/thirdPartyAgent/projects/${projectId}/nodes/${nodeHashId}/dockerParallelTaskCount?count=${count}`).then(response => {
return response
})
},
Expand Down
3 changes: 2 additions & 1 deletion src/frontend/locale/stream/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,8 @@
"set": "Set",
"remaining": "Remaining",
"canApplyCount": "Can apply count",
"selectNewNode": "Select new Agent"
"selectNewNode": "Select new Agent",
"dockerMaxConcurrency": "Maximum Docker Build Concurrency"
}
},
"清空筛选条件": "Clear Search Conditions",
Expand Down
3 changes: 2 additions & 1 deletion src/frontend/locale/stream/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,8 @@
"set": "",
"remaining": "还剩",
"canApplyCount": "台可申请",
"selectNewNode": "请选择你的新节点"
"selectNewNode": "请选择你的新节点",
"dockerMaxConcurrency": "docker构建最大并发数"
}
},
"清空筛选条件": "清空筛选条件",
Expand Down

0 comments on commit 4ffd12e

Please sign in to comment.