diff --git a/src/api/one-class-page/virtualMachine.js b/src/api/one-class-page/virtualMachine.js index 24bc86e..14dea51 100644 --- a/src/api/one-class-page/virtualMachine.js +++ b/src/api/one-class-page/virtualMachine.js @@ -283,7 +283,7 @@ export function getImages() { export function createImages(data) { return request({ - url: '/virtual/v1/harvesterhci.io.virtualmachineimages', + url: '/virtual/v1/harvester/harvesterhci.io.virtualmachineimages', method: 'post', data: data }) @@ -301,9 +301,9 @@ export function editImage(name, data) { data: data }) } -export function getImagesYaml(name, isYaml = false) { +export function getImagesYaml(name, isYaml = false, namespace = 'default') { return request({ - url: '/virtual/apis/harvesterhci.io/v1beta1/namespaces/default/virtualmachineimages/' + name, + url: `/virtual/apis/harvesterhci.io/v1beta1/namespaces/${namespace}/virtualmachineimages/${name}`, method: 'get', headers: { 'Accept': isYaml ? 'application/yaml' : 'application/json' @@ -311,9 +311,9 @@ export function getImagesYaml(name, isYaml = false) { }) } -export function putImagesYaml(name, yaml) { +export function putImagesYaml(name, yaml, namespace = 'default') { return request({ - url: '/virtual/apis/harvesterhci.io/v1beta1/namespaces/default/virtualmachineimages/' + name, + url: `/virtual/apis/harvesterhci.io/v1beta1/namespaces/${namespace}/virtualmachineimages/${name}`, method: 'put', data: yaml }) diff --git a/src/utils/get-Kube-List.js b/src/utils/get-Kube-List.js index d6b71ad..e7b55ef 100644 --- a/src/utils/get-Kube-List.js +++ b/src/utils/get-Kube-List.js @@ -418,15 +418,14 @@ const getImagesList = () => { obj.index = item obj.displayName = res.data[item].spec.displayName obj.name = res.data[item].metadata.name - obj.state = res.data[item].metadata.state.name + obj.message = res.data[item].status.conditions?.map(e => e.status === 'False' ? e.message : '').filter(e => e)[0] || '' + obj.state = obj.message ? 'Failed' : res.data[item].status.progress === 6 ? 'Downloading' : res.data[item].metadata.state.name obj.namespace = res.data[item].metadata.namespace obj.progress = res.data[item].status?.progress === 100 ? '已完成' : '未完成' obj.creationTime = res.data[item].metadata.creationTimestamp obj.aliveTime = res.data[item].metadata.fields[3] obj.size = Number((res.data[item].status?.size / 1024 / 1024).toString().match(/^\d+(?:\.\d{0,2})?/)) + 'MB' - obj.aliveTime = obj.aliveTime.replace('d', '天') - obj.aliveTime = obj.aliveTime.replace('h', '小时') - obj.aliveTime = obj.aliveTime.replace('m', '分钟') + obj.aliveTime = obj.aliveTime.replace('d', '天').replace('h', '小时').replace('m', '分钟') listResult[item] = obj } resolve({ total: res.data.length, rows: listResult }) diff --git a/src/views/virtualMachine/image/detail.vue b/src/views/virtualMachine/image/detail.vue index d540d38..4f3f4ee 100644 --- a/src/views/virtualMachine/image/detail.vue +++ b/src/views/virtualMachine/image/detail.vue @@ -1,6 +1,6 @@ @@ -55,7 +56,8 @@ export default { resourceType: '镜像地址', size: '大小', description: '描述' - } + }, + loading: false } }, computed: { @@ -73,6 +75,7 @@ export default { this.$router.push({ path: '/virtual/images' }) }, getFormData() { + this.loading = true getImages().then(res => { for (let i = 0; i < res.data.length; i++) { if (this.$route.query.name.toString() === res.data[i].metadata.name) { @@ -87,28 +90,31 @@ export default { name: data.metadata.name, state: data.metadata.state.name, labels: data.metadata.labels, + namespace: data.metadata.namespace, aliveTime: data.metadata.fields[3].replace('d', '天').replace('h', '小时').replace('m', '分钟'), description: data.metadata.annotations ? data.metadata.annotations['field.cattle.io/description'] : '-', size: Number((data.status.size / 1024 / 1024).toString().match(/^\d+(?:\.\d{0,2})?/)) + 'MB', resourceType: data.spec.url } + this.loading = false }) }, handleDropdown(command) { switch (command) { case '1': - this.$refs.detail.disableConfig = false + this.$router.push({ path: `edit`, query: { name: this.$route.query.name, namespace: this.formData.namespace }}) break case '2': + this.$router.push({ path: `edit`, query: { name: this.$route.query.name, namespace: this.formData.namespace, clone: true }}) break case '6': - this.viewYamlFunc(this.$route.query.name) + this.viewYamlFunc(this.$route.query.name, this.formData.namespace) break case '3': - this.editYamlFunc(this.$route.query.name) + this.editYamlFunc(this.$route.query.name, this.formData.namespace) break case '4': - this.downloadYamlFunc(this.$route.query.name, getImagesYaml) + this.downloadYamlFunc(this.$route.query.name, getImagesYaml, this.formData.namespace) break case 5: break diff --git a/src/views/virtualMachine/image/edit.vue b/src/views/virtualMachine/image/edit.vue index 64850e9..50783d1 100644 --- a/src/views/virtualMachine/image/edit.vue +++ b/src/views/virtualMachine/image/edit.vue @@ -8,7 +8,7 @@ - + @@ -37,6 +38,7 @@
基本信息
@@ -65,13 +67,14 @@ - diff --git a/vue.config.js b/vue.config.js index bf05a6e..4e71edb 100644 --- a/vue.config.js +++ b/vue.config.js @@ -100,8 +100,12 @@ module.exports = { '^/virtual': { ws: false, target: 'https://jointcloud.net/', + // target: 'https://10.105.20.1/', changeOrigin: true, secure: false + // pathRewrite: { + // '^/virtual': '' + // } }, '^/jcc-faas-manager': { ws: false,