forked from TencentBlueKing/bk-repo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 增加制品预加载功能管理页面 TencentBlueKing#2683
* feat: 增加制品预加载功能管理页面 TencentBlueKing#2683 * feat: 修改文件名称 TencentBlueKing#2683 * feat: 修改文件名称 TencentBlueKing#2683
- Loading branch information
1 parent
4401758
commit 5f365c4
Showing
10 changed files
with
806 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import request from '@/utils/request' | ||
|
||
const PREFIX_SERVICES = '/repository/api/preload' | ||
|
||
export function queryStrategies(projectId, repoName) { | ||
return request({ | ||
url: `${PREFIX_SERVICES}/strategy/${projectId}/${repoName}`, | ||
method: 'get' | ||
}) | ||
} | ||
|
||
export function deleteStrategy(projectId, repoName, id) { | ||
return request({ | ||
url: `${PREFIX_SERVICES}/strategy/${projectId}/${repoName}/${id}`, | ||
method: 'delete' | ||
}) | ||
} | ||
|
||
export function createStrategy(data) { | ||
return request({ | ||
url: `${PREFIX_SERVICES}/strategy/`, | ||
method: 'post', | ||
data: data | ||
}) | ||
} | ||
|
||
export function updateStrategy(data) { | ||
return request({ | ||
url: `${PREFIX_SERVICES}/strategy/`, | ||
method: 'put', | ||
data: data | ||
}) | ||
} | ||
|
||
export function createPlan(data) { | ||
return request({ | ||
url: `${PREFIX_SERVICES}/plan/`, | ||
method: 'post', | ||
data: data | ||
}) | ||
} | ||
|
||
export function queryPlans(body) { | ||
return request({ | ||
url: `${PREFIX_SERVICES}/plan/${body.projectId}/${body.repoName}`, | ||
method: 'get', | ||
params: { | ||
pageNumber: body.pageNumber, | ||
pageSize: body.pageSize | ||
} | ||
}) | ||
} | ||
|
||
export function deletePlan(projectId, repoName, id) { | ||
return request({ | ||
url: `${PREFIX_SERVICES}/plan/${projectId}/${repoName}/${id}`, | ||
method: 'delete' | ||
}) | ||
} | ||
|
||
export function deletePlans(projectId, repoName) { | ||
return request({ | ||
url: `${PREFIX_SERVICES}/plan/${projectId}/${repoName}`, | ||
method: 'delete' | ||
}) | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
165 changes: 165 additions & 0 deletions
165
src/frontend/devops-op/src/views/preload/components/EditPlanConfigDialog.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
<template> | ||
<el-dialog title="创建预加载计划配置" :visible.sync="showDialog" :before-close="close"> | ||
<el-form ref="form" :rules="rules" :model="plan" status-icon> | ||
<el-form-item ref="project-form-item" label="项目ID" prop="projectId" :rules="[{ required: true, message: '项目ID不能为空'}]"> | ||
<el-autocomplete | ||
v-model="plan.projectId" | ||
class="inline-input" | ||
:fetch-suggestions="queryProjects" | ||
placeholder="请输入项目ID" | ||
size="mini" | ||
@select="selectProject" | ||
> | ||
<template slot-scope="{ item }"> | ||
<div>{{ item.name }}</div> | ||
</template> | ||
</el-autocomplete> | ||
</el-form-item> | ||
<el-form-item | ||
ref="repo-form-item" | ||
label="仓库名称" | ||
prop="repoName" | ||
:rules="[{ required: true, message: '仓库名不能为空'}]" | ||
> | ||
<el-autocomplete | ||
v-model="plan.repoName" | ||
class="inline-input" | ||
:fetch-suggestions="queryRepositories" | ||
:disabled="!plan.projectId" | ||
placeholder="请输入仓库名" | ||
size="mini" | ||
@select="selectRepo" | ||
> | ||
<template slot-scope="{ item }"> | ||
<div>{{ item.name }}</div> | ||
</template> | ||
</el-autocomplete> | ||
</el-form-item> | ||
<el-form-item label="文件路径" prop="fullPath" :rules="[{ required: true, message: '文件路径不能为空'}]"> | ||
<el-input v-model="plan.fullPath" style="height: 40px ; width: 500px;" /> | ||
</el-form-item> | ||
<el-form-item label="预加载计划执行毫秒时间戳" prop="executeTime"> | ||
<el-date-picker | ||
v-model="plan.executeTime" | ||
type="datetime" | ||
placeholder="选择日期时间" | ||
default-time="12:00:00" | ||
/> | ||
</el-form-item> | ||
</el-form> | ||
<div slot="footer"> | ||
<el-button @click="close">取 消</el-button> | ||
<el-button type="primary" @click="handleUpdate()">确 定</el-button> | ||
</div> | ||
</el-dialog> | ||
</template> | ||
<script> | ||
import { createPlan } from '@/api/preload' | ||
import { searchProjects } from '@/api/project' | ||
import { listRepositories } from '@/api/repository' | ||
export default { | ||
name: 'EditPlanConfigDialog', | ||
props: { | ||
visible: Boolean, | ||
createMode: Boolean, | ||
/** | ||
* 仅在更新模式时有值 | ||
*/ | ||
updatingPlanConfig: { | ||
type: Object, | ||
default: undefined | ||
} | ||
}, | ||
data() { | ||
return { | ||
repoCache: {}, | ||
projects: undefined, | ||
showDialog: this.visible, | ||
plan: this.newPlan(), | ||
rules: {} | ||
} | ||
}, | ||
watch: { | ||
visible: function(newVal) { | ||
if (newVal) { | ||
this.resetPlan() | ||
this.showDialog = true | ||
} else { | ||
this.close() | ||
} | ||
} | ||
}, | ||
methods: { | ||
queryProjects(queryStr, cb) { | ||
searchProjects(queryStr).then(res => { | ||
this.projects = res.data.records | ||
cb(this.projects) | ||
}) | ||
}, | ||
selectProject(project) { | ||
this.$refs['project-form-item'].resetField() | ||
this.plan.projectId = project.name | ||
}, | ||
queryRepositories(queryStr, cb) { | ||
let repositories = this.repoCache[this.plan.projectId] | ||
if (!repositories) { | ||
listRepositories(this.plan.projectId).then(res => { | ||
repositories = res.data | ||
this.repoCache[this.plan.projectId] = repositories | ||
cb(this.doFilter(repositories, queryStr)) | ||
}) | ||
} else { | ||
cb(this.doFilter(repositories, queryStr)) | ||
} | ||
}, | ||
selectRepo(repo) { | ||
this.$refs['repo-form-item'].resetField() | ||
this.plan.repoName = repo.name | ||
}, | ||
doFilter(arr, queryStr) { | ||
return queryStr ? arr.filter(obj => { | ||
return obj.name.toLowerCase().indexOf(queryStr.toLowerCase()) !== -1 | ||
}) : arr | ||
}, | ||
resetPlan() { | ||
this.plan = this.newPlan() | ||
this.$nextTick(() => { | ||
this.$refs['form'].clearValidate() | ||
}) | ||
}, | ||
newPlan() { | ||
const plan = { | ||
projectId: '', | ||
repoName: '', | ||
executeTime: '', | ||
fullPath: '' | ||
} | ||
return plan | ||
}, | ||
close(changed) { | ||
this.showDialog = false | ||
this.$refs['form'].resetFields() | ||
if (changed === true) { | ||
this.$emit('updated') | ||
} | ||
this.$emit('update:visible', false) | ||
}, | ||
handleUpdate() { | ||
this.$refs['form'].validate((valid) => { | ||
if (valid) { | ||
this.plan.executeTime = this.plan.executeTime.getTime() | ||
createPlan(this.plan).then(() => { | ||
this.$message.success('新建配置成功') | ||
this.close(true) | ||
}) | ||
} | ||
}) | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
</style> |
Oops, something went wrong.