Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions ui/src/config/section/infra/hosts.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,19 +111,29 @@ export default {
label: 'label.disable.host',
message: 'message.confirm.disable.host',
dataView: true,
show: (record) => { return record.resourcestate === 'Enabled' },
show: (record) => record.resourcestate === 'Enabled',
popup: true,
component: shallowRef(defineAsyncComponent(() => import('@/views/infra/HostEnableDisable')))
component: shallowRef(defineAsyncComponent(() => import('@/views/infra/HostEnableDisable'))),
events: {
'refresh-data': () => {
store.dispatch('refreshCurrentPage')
}
}
},
{
api: 'updateHost',
icon: 'play-circle-outlined',
label: 'label.enable.host',
message: 'message.confirm.enable.host',
dataView: true,
show: (record) => { return record.resourcestate === 'Disabled' },
show: (record) => record.resourcestate === 'Disabled',
popup: true,
component: shallowRef(defineAsyncComponent(() => import('@/views/infra/HostEnableDisable')))
component: shallowRef(defineAsyncComponent(() => import('@/views/infra/HostEnableDisable'))),
events: {
'refresh-data': () => {
store.dispatch('refreshCurrentPage')
}
}
},
{
api: 'prepareHostForMaintenance',
Expand Down
30 changes: 14 additions & 16 deletions ui/src/views/infra/HostEnableDisable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<template>
<div class="form-layout">
<a-form
:ref="formRef"
ref="formRef"
:model="form"
:rules="rules"
@finish="handleSubmit"
Expand Down Expand Up @@ -54,7 +54,7 @@
</template>

<script>
import { ref, reactive, toRaw } from 'vue'
import { reactive, toRaw } from 'vue'
import { api } from '@/api'

export default {
Expand All @@ -78,11 +78,8 @@ export default {
this.resourcestate = this.resource.resourcestate
this.allocationstate = this.resourcestate === 'Enabled' ? 'Disable' : 'Enable'
},
beforeCreate () {
},
methods: {
initForm () {
this.formRef = ref()
this.form = reactive({})
this.rules = reactive({})
},
Expand All @@ -97,11 +94,9 @@ export default {
})
},
handleSubmit (e) {
e.preventDefault()
this.formRef.value.validate().then(() => {
this.$refs.formRef.validate().then(() => {
const values = toRaw(this.form)

var data = {
const data = {
allocationstate: this.allocationstate,
id: this.resource.id
}
Expand All @@ -110,24 +105,27 @@ export default {
}
api('updateHost', data).then(_ => {
this.$emit('close-action')
this.$emit('refresh-data')
}).catch(err => {
this.$message.error(err.message || 'Failed to update host status')
})
}).catch(() => {
this.$message.error('Validation failed. Please check the inputs.')
})
}
}
}

</script>

<style scoped>
.reason {
padding-top: 20px
padding-top: 20px;
}

.form-layout {
width: 30vw;

@media (min-width: 500px) {
width: 450px;
}
width: 30vw;
@media (min-width: 500px) {
width: 450px;
Comment on lines +126 to +128
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these changes necessary?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just reformat. these are fine aren't they?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, not often will make a difference, will remove it

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me just push the feature in first go , and will do the enhancement later on

}
}
</style>