From b802817a07a7086bd65ca309d7b30e98f409a08e Mon Sep 17 00:00:00 2001 From: utchoang Date: Fri, 20 Mar 2020 13:08:04 +0700 Subject: [PATCH] add storage backups --- src/components/view/InfoCard.vue | 7 ++++- src/components/view/ListView.vue | 6 ++++ src/config/section/storage.js | 48 ++++++++++++++++++++++++++++++++ src/views/AutogenView.vue | 16 ++++++++++- 4 files changed, 75 insertions(+), 2 deletions(-) diff --git a/src/components/view/InfoCard.vue b/src/components/view/InfoCard.vue index 13c87fda7..0118be07b 100644 --- a/src/components/view/InfoCard.vue +++ b/src/components/view/InfoCard.vue @@ -29,7 +29,7 @@

- {{ resource.displayname || resource.displaytext || resource.name || resource.hostname || resource.username || resource.ipaddress }} + {{ resource.displayname || resource.displaytext || resource.name || resource.hostname || resource.username || resource.ipaddress || resource.virtualmachinename }}

@@ -646,6 +646,11 @@ export default { return } + if (typeof this.resource.volumes === 'string') { + const volumes = JSON.parse(this.resource.volumes) + this.$set(this.resource, 'volumes', volumes) + } + this.resourceType = this.$route.meta.resourceType this.annotationType = '' this.showKeys = false diff --git a/src/components/view/ListView.vue b/src/components/view/ListView.vue index f60ccd000..dbfaa7738 100644 --- a/src/components/view/ListView.vue +++ b/src/components/view/ListView.vue @@ -71,6 +71,9 @@ {{ text }} + + {{ text }} + {{ text }} @@ -96,6 +99,9 @@ + diff --git a/src/config/section/storage.js b/src/config/section/storage.js index 26cbeabba..dbca332f6 100644 --- a/src/config/section/storage.js +++ b/src/config/section/storage.js @@ -251,6 +251,54 @@ export default { } } ] + }, + { + name: 'backups', + title: 'Backups', + icon: 'rollback', + permission: ['listBackups'], + resourceType: 'backup', + columns: ['virtualmachinename', 'status', 'type', 'created', 'account', 'zone'], + details: ['virtualmachinename', 'id', 'volumename', 'intervaltype', 'account', 'domain', 'created'], + filters: ['name', 'domainid', 'account', 'tags'], + actions: [ + { + api: 'deleteBackup', + icon: 'delete', + label: 'label.backup.delete', + dataView: true + }, + { + api: 'restoreBackup', + icon: 'undo', + label: 'label.backup.restore', + dataView: true + }, + { + api: 'restoreVolumeFromBackupAndAttachToVM', + icon: 'paper-clip', + label: 'label.backup.restore.and.attach.vm', + dataView: true, + args: ['volumeid', 'virtualmachineid'], + mapping: { + backupid: { + value: (record) => { return record.id } + } + } + }, + { + api: 'removeVirtualMachineFromBackupOffering', + icon: 'stop', + label: 'label.backup.delete.chain', + dataView: true, + args: ['forced'], + mapping: { + virtualmachineid: { + value: (record) => { return record.virtualmachineid } + } + } + } + ] } ] } diff --git a/src/views/AutogenView.vue b/src/views/AutogenView.vue index 40b9107be..1bce2a495 100644 --- a/src/views/AutogenView.vue +++ b/src/views/AutogenView.vue @@ -150,7 +150,8 @@ }" > - {{ opt.name || opt.description || opt.traffictype || opt.publicip }} + + @@ -549,6 +550,19 @@ export default { if (param.type === 'list' && param.name === 'hosttags') { param.type = 'string' } + if (param.name === 'volumeid' && param.type === 'string') { + if (this.resource && this.resource.volumes && this.resource.volumes.length > 0) { + param.type = 'uuid' + param.listLocal = true + param.opts = this.resource.volumes + this.$forceUpdate() + } + } + + if (param.listLocal) { + continue + } + if (param.type === 'uuid' || param.type === 'list' || param.name === 'account' || (this.currentAction.mapping && param.name in this.currentAction.mapping)) { this.listUuidOpts(param) }