-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6372 from swordqiu/automated-cherry-pick-of-#6368…
…-upstream-release-3.9 Automated cherry pick of #6368: fix: support associate host and backup storage
- Loading branch information
Showing
4 changed files
with
236 additions
and
8 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
100 changes: 100 additions & 0 deletions
100
containers/Storage/views/backup-storage/dialogs/HostAttachBackupStorageDialog.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,100 @@ | ||
<template> | ||
<base-dialog @cancel="cancelDialog"> | ||
<div slot="header">{{this.params.title}}</div> | ||
<div slot="body"> | ||
<dialog-selected-tips :name="$t('dictionary.blockstorage')" :count="params.data.length" :action="this.params.title" /> | ||
<dialog-table :data="params.data" :columns="params.columns.slice(0, 3)" /> | ||
<a-form :form="form.fc" v-bind="formItemLayout"> | ||
<a-form-item :label="$t('storage.text_50')"> | ||
<a-select :loading="hostsLoading" allowClear showSearch :filterOption="filterOption" mode="multiple" v-decorator="decorators.host" :placeholder="$t('storage.text_51')"> | ||
<a-select-option v-for="item in hosts" :key="item.id" :value="item.id">{{item.name}}</a-select-option> | ||
</a-select> | ||
</a-form-item> | ||
</a-form> | ||
</div> | ||
<div slot="footer"> | ||
<a-button type="primary" @click="handleConfirm" :loading="loading">{{ $t("dialog.ok") }}</a-button> | ||
<a-button @click="cancelDialog">{{ $t('dialog.cancel') }}</a-button> | ||
</div> | ||
</base-dialog> | ||
</template> | ||
|
||
<script> | ||
import DialogMixin from '@/mixins/dialog' | ||
import WindowsMixin from '@/mixins/windows' | ||
export default { | ||
name: 'HostAttachBackupStorageDialog', | ||
mixins: [DialogMixin, WindowsMixin], | ||
data () { | ||
return { | ||
loading: false, | ||
hostsLoading: false, | ||
hosts: [], | ||
form: { | ||
fc: this.$form.createForm(this), | ||
}, | ||
formItemLayout: { | ||
labelCol: { span: 4 }, | ||
wrapperCol: { span: 20 }, | ||
}, | ||
} | ||
}, | ||
computed: { | ||
decorators () { | ||
return { | ||
host: [ | ||
'host', | ||
{ | ||
rules: [ | ||
{ required: true, message: this.$t('storage.text_54') }, | ||
], | ||
}, | ||
], | ||
} | ||
}, | ||
}, | ||
created () { | ||
this.queryHostList() | ||
}, | ||
methods: { | ||
filterOption (input, option) { | ||
return ( | ||
option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0 | ||
) | ||
}, | ||
async queryHostList () { | ||
const params = { hypervisor: 'kvm', storage_not_attached: true, backupstorage: this.params.data[0].id } | ||
const manager = new this.$Manager('hosts', 'v2') | ||
this.hostsLoading = true | ||
try { | ||
const { data = {} } = await manager.list({ params }) | ||
this.hosts = data.data || [] | ||
} catch (err) { | ||
throw err | ||
} finally { | ||
this.hostsLoading = false | ||
} | ||
}, | ||
async handleConfirm () { | ||
this.loading = true | ||
try { | ||
const values = await this.form.fc.validateFields() | ||
const manager = new this.$Manager('hosts', 'v2') | ||
await manager.batchPerformAction({ | ||
ids: values.host, | ||
action: '', | ||
data: values, | ||
ctx: [['backupstorages', this.params.data[0].id]], | ||
}) | ||
this.cancelDialog() | ||
this.params.refresh() | ||
this.loading = false | ||
} catch (error) { | ||
this.loading = false | ||
throw error | ||
} | ||
}, | ||
}, | ||
} | ||
</script> |
48 changes: 48 additions & 0 deletions
48
containers/Storage/views/backup-storage/dialogs/HostDetachBackupStorageDialog.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,48 @@ | ||
<!-- 宿主机列表-取消关联宿主机 --> | ||
<template> | ||
<base-dialog @cancel="cancelDialog"> | ||
<div slot="header">{{this.params.title}}</div> | ||
<div slot="body"> | ||
<dialog-selected-tips :count="params.data.length" :action="this.params.title" :name="$t('storage.text_50')" /> | ||
<dialog-table :data="params.data" :columns="params.columns.slice(0, 3)" /> | ||
</div> | ||
<div slot="footer"> | ||
<a-button type="primary" @click="handleConfirm" :loading="loading">{{ $t("dialog.ok") }}</a-button> | ||
<a-button @click="cancelDialog">{{ $t('dialog.cancel') }}</a-button> | ||
</div> | ||
</base-dialog> | ||
</template> | ||
|
||
<script> | ||
import DialogMixin from '@/mixins/dialog' | ||
import WindowsMixin from '@/mixins/windows' | ||
export default { | ||
name: 'HostDetachBackupStorageDialog', | ||
mixins: [DialogMixin, WindowsMixin], | ||
data () { | ||
return { | ||
loading: false, | ||
} | ||
}, | ||
methods: { | ||
async handleConfirm () { | ||
this.loading = true | ||
try { | ||
await this.params.list.onManager('batchDelete', { | ||
id: this.params.data.map(({ id }) => id), | ||
managerArgs: { | ||
ctx: [['backupstorages', this.params.resId]], | ||
}, | ||
}) | ||
// this.$bus.$emit('BlockStorageListSingleUpdate', [this.params.resId]) | ||
this.cancelDialog() | ||
this.loading = false | ||
} catch (error) { | ||
this.loading = false | ||
throw error | ||
} | ||
}, | ||
}, | ||
} | ||
</script> |
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