Commit 56204ae1 authored by 智勇's avatar 智勇

创建服务增加镜像默认值

parent dbb774e5
......@@ -4,7 +4,8 @@ export function getNotify(data) {
return request({
url: '/notify/getNotify',
method: 'post',
data })
data
})
}
export function saveNotify(data) {
......
import request from '@/utils/request'
export function getMaster(data) {
export function getBranch(query) {
return request({
url: '/pipeline/master',
method: 'post',
data
url: '/pipeline/getGitBranch',
method: 'get',
params: query
})
}
export function saveApplication(data) {
......
......@@ -328,7 +328,7 @@
v-for="(item,index) in tagOptions"
:key="index"
:label="item.tagName"
:value="item.repo_name + ':' +item.tagName"/>
:value="item.tagName"/>
</el-select>
</el-col>
</el-row>
......@@ -367,7 +367,7 @@
:closable="false"
title="温馨提醒"
type="warning"
description="警告:该操作将会更新这个服务为指定版本,在这个pod上做的所有操作将会丢失。"
description="警告:该操作将会更新这个服务为指定版本,在这个pod上做的所有操作将会丢失。"
/>
<p class="title-sub">选择服务</p>
<el-row :gutter="20">
......@@ -387,7 +387,7 @@
v-for="(item,index) in tagOptions"
:key="index"
:label="item.tagName"
:value="item.repo_name + ':' +item.tagName"/>
:value="item.tagName"/>
</el-select>
</el-col>
</el-row>
......@@ -587,6 +587,7 @@ export default {
}).then(res => {
if (res.data.tagCount) {
this.tagOptions = res.data.tagInfo
this.tagName = `latest`
}
})
},
......@@ -602,7 +603,7 @@ export default {
CreateCluService({
serviceName: serviceName,
namespace: this.namespace,
image: this.tagName,
image: `${this.reponame}:${this.tagName}`,
label: this.label,
type: this.type,
domain: this.domain.split('.')[0],
......@@ -695,7 +696,6 @@ export default {
},
updateService(value) {
this.tagName = ''
this.updateDialog = true
this.serviceName = value.serviceName
this.type = value.labels.type
......@@ -703,6 +703,8 @@ export default {
fetchTaglist({ reponame: 'qa-' + value.labels.type + '/' + this.serviceName }).then(res => {
if (res.data.tagCount) {
this.tagOptions = res.data.tagInfo
this.reponame = res.data.reponame
this.tagName = 'latest'
this.server = res.data.server
}
})
......@@ -726,7 +728,7 @@ export default {
updateClusterService() {
const self = this
modifyCluService({ serviceName: this.serviceName, image: this.tagName, namespace: this.namespace, type: this.type }).then(res => {
modifyCluService({ serviceName: this.serviceName, image: `${this.reponame}:${this.tagName}`, namespace: this.namespace, type: this.type }).then(res => {
this.$message({
message: `更新${this.serviceName}成功`,
type: 'success',
......
......@@ -43,7 +43,7 @@
</template>
</el-table-column>
<el-table-column prop="namespace" label="命名空间" align="center"/>
<el-table-column prop="create_time" label="创建时间" align="center"/>
<el-table-column :formatter="formatDate" label="时间" align="center"/>
<el-table-column :label="$t('table.actions')" align="center" width="180" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button type="primary" size="mini" @click="handleUpdate(scope.row)">{{ $t('table.edit') }}</el-button>
......@@ -123,7 +123,7 @@
</template>
<script>
import { getApplications, saveApplication, updateApplication, deleteApplication, getMaster } from '@/api/pipelineNode'
import { getApplications, saveApplication, updateApplication, deleteApplication, getBranch } from '@/api/pipelineNode'
import { getProjects } from '@/api/proconfig'
import waves from '@/directive/waves' // Waves directive
import Pagination from '@/components/Pagination' // Secondary package based on el-pagination
......@@ -132,18 +132,14 @@ import { getCluster } from '@/api/cluster'
import { fetchKubernetesList } from '@/api/docker'
export default {
name: 'ComplexTable',
components: { Pagination },
directives: { waves },
filters: {
replaceeRef(ref) {
return ref ? ref.replace('refs/heads/', '') : ''
},
formatDeploy(ref) {
return ref ? '' : ''
},
formatDate(date, pattern = 'YYYY-MM-DD HH:mm:ss') {
return moment(date).format(pattern)
formatDeploy(data) {
return data ? '' : ''
}
},
data() {
......@@ -151,17 +147,13 @@ export default {
value1: true,
repository: '',
total: 0,
cacheData: {},
listQuery: {
},
temp: {
},
listQuery: {},
temp: {},
dialogFormVisible: false,
dialogDeleteVisible: false,
dialogStatus: '',
rules: {
application_name: [{ required: true, message: '请输入', trigger: 'change' }],
// timestamp: [{ type: 'date', required: true, message: 'timestamp is required', trigger: 'change' }],
namespace: [{ required: true, message: '请输入', trigger: 'blur' }],
cluster: [{ required: true, message: '请输入', trigger: 'blur' }]
},
......@@ -239,6 +231,11 @@ export default {
this.getApplications()
},
formatDate(row, val) {
const pattern = 'YYYY-MM-DD HH:mm:ss'
return moment(row.updatedAt || row.createdAt).format(pattern)
},
resetTemp() {
this.temp = {
id: 0,
......@@ -248,24 +245,28 @@ export default {
isDeploy: false,
repos: [{ repository: '', ref: { id: '请选择' }}],
application_name: '',
create_time: moment().format('YYYY-MM-DD HH:mm:ss'),
new_user: '',
update_user: '',
cluster: this.$store.getters.cluster
}
},
handleCreate() {
this.resetTemp()
this.dialogStatus = '新建'
getProjects() {
getProjects({ is_active: true, deploy_to_testenv: true }).then(res => {
this.repos = res.data
this.repos.sort((s1, s2) => {
return s1.project_name.localeCompare(s2.project_name)
})
})
},
handleCreate() {
this.resetTemp()
this.dialogStatus = '新建'
this.getProjects()
this.dialogFormVisible = true
},
getRefs(repo, flag) {
if (flag) {
this.temp.repos.forEach(item => {
......@@ -274,9 +275,7 @@ export default {
}
})
}
// 拿出gitlab地址信息
const gitlabAddress = this.screen(repo, this.repos)
getMaster({ name: repo, gitlabAddress }).then(res => {
getBranch({ name: repo }).then(res => {
if (res.data.code === '0001') {
this.$notify({
title: 'error',
......@@ -296,14 +295,7 @@ export default {
}
})
},
screen(name, list) {
const data = list.filter(item => {
if (name === item.project_name) {
return item
}
})
return data[0].git_lab
},
createData() {
this.$refs['dataForm'].validate((valid) => {
if (valid) {
......@@ -374,16 +366,12 @@ export default {
this.temp = Object.assign({}, row) // copy obj
this.dialogStatus = '编辑'
this.dialogFormVisible = true
getProjects({ is_active: true }).then(res => {
this.repos = res.data
this.repos.sort((s1, s2) => {
return s1.project_name.localeCompare(s2.project_name)
})
row.repos.forEach(item => {
this.getRefs(item.repository)
})
this.getProjects()
row.repos.forEach(item => {
this.getRefs(item.repository)
})
},
handleDelete(row) {
this.temp = row
this.dialogDeleteVisible = true
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment