Skip to content

Commit f3bcf3f

Browse files
Imvedanshrp-
authored andcommitted
Host status auto refresh (apache#10606)
Co-authored-by: Rene Peinthor <[email protected]>
1 parent 89b60a7 commit f3bcf3f

File tree

2 files changed

+28
-20
lines changed

2 files changed

+28
-20
lines changed

ui/src/config/section/infra/hosts.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,19 +122,29 @@ export default {
122122
label: 'label.disable.host',
123123
message: 'message.confirm.disable.host',
124124
dataView: true,
125-
show: (record) => { return record.resourcestate === 'Enabled' },
125+
show: (record) => record.resourcestate === 'Enabled',
126126
popup: true,
127-
component: shallowRef(defineAsyncComponent(() => import('@/views/infra/HostEnableDisable')))
127+
component: shallowRef(defineAsyncComponent(() => import('@/views/infra/HostEnableDisable'))),
128+
events: {
129+
'refresh-data': () => {
130+
store.dispatch('refreshCurrentPage')
131+
}
132+
}
128133
},
129134
{
130135
api: 'updateHost',
131136
icon: 'play-circle-outlined',
132137
label: 'label.enable.host',
133138
message: 'message.confirm.enable.host',
134139
dataView: true,
135-
show: (record) => { return record.resourcestate === 'Disabled' },
140+
show: (record) => record.resourcestate === 'Disabled',
136141
popup: true,
137-
component: shallowRef(defineAsyncComponent(() => import('@/views/infra/HostEnableDisable')))
142+
component: shallowRef(defineAsyncComponent(() => import('@/views/infra/HostEnableDisable'))),
143+
events: {
144+
'refresh-data': () => {
145+
store.dispatch('refreshCurrentPage')
146+
}
147+
}
138148
},
139149
{
140150
api: 'prepareHostForMaintenance',

ui/src/views/infra/HostEnableDisable.vue

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<template>
1919
<div class="form-layout">
2020
<a-form
21-
:ref="formRef"
21+
ref="formRef"
2222
:model="form"
2323
:rules="rules"
2424
@finish="handleSubmit"
@@ -54,7 +54,7 @@
5454
</template>
5555

5656
<script>
57-
import { ref, reactive, toRaw } from 'vue'
57+
import { reactive, toRaw } from 'vue'
5858
import { api } from '@/api'
5959
6060
export default {
@@ -78,11 +78,8 @@ export default {
7878
this.resourcestate = this.resource.resourcestate
7979
this.allocationstate = this.resourcestate === 'Enabled' ? 'Disable' : 'Enable'
8080
},
81-
beforeCreate () {
82-
},
8381
methods: {
8482
initForm () {
85-
this.formRef = ref()
8683
this.form = reactive({})
8784
this.rules = reactive({})
8885
},
@@ -97,11 +94,9 @@ export default {
9794
})
9895
},
9996
handleSubmit (e) {
100-
e.preventDefault()
101-
this.formRef.value.validate().then(() => {
97+
this.$refs.formRef.validate().then(() => {
10298
const values = toRaw(this.form)
103-
104-
var data = {
99+
const data = {
105100
allocationstate: this.allocationstate,
106101
id: this.resource.id
107102
}
@@ -110,24 +105,27 @@ export default {
110105
}
111106
api('updateHost', data).then(_ => {
112107
this.$emit('close-action')
108+
this.$emit('refresh-data')
109+
}).catch(err => {
110+
this.$message.error(err.message || 'Failed to update host status')
113111
})
112+
}).catch(() => {
113+
this.$message.error('Validation failed. Please check the inputs.')
114114
})
115115
}
116116
}
117117
}
118-
119118
</script>
120119
121120
<style scoped>
122121
.reason {
123-
padding-top: 20px
122+
padding-top: 20px;
124123
}
125124
126125
.form-layout {
127-
width: 30vw;
128-
129-
@media (min-width: 500px) {
130-
width: 450px;
131-
}
126+
width: 30vw;
127+
@media (min-width: 500px) {
128+
width: 450px;
132129
}
130+
}
133131
</style>

0 commit comments

Comments
 (0)