infocard: support for tags and config across UI

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
Rohit Yadav 2019-10-11 12:27:47 +05:30
parent 246e035716
commit 6049cd64d8
9 changed files with 52 additions and 24 deletions

View File

@ -36,6 +36,7 @@ export function generateRouterMap (section) {
keepAlive: true, keepAlive: true,
icon: child.icon, icon: child.icon,
permission: child.permission, permission: child.permission,
resourceType: child.resourceType,
params: child.params ? child.params : {}, params: child.params ? child.params : {},
columns: child.columns, columns: child.columns,
actions: child.actions actions: child.actions
@ -50,6 +51,7 @@ export function generateRouterMap (section) {
keepAlive: true, keepAlive: true,
icon: child.icon, icon: child.icon,
permission: child.permission, permission: child.permission,
resourceType: child.resourceType,
params: child.params ? child.params : {}, params: child.params ? child.params : {},
actions: child.actions ? child.actions : [], actions: child.actions ? child.actions : [],
viewComponent: child.viewComponent viewComponent: child.viewComponent
@ -90,6 +92,7 @@ export function generateRouterMap (section) {
keepAlive: true, keepAlive: true,
icon: section.icon, icon: section.icon,
permission: section.permission, permission: section.permission,
resourceType: section.resourceType,
params: section.params ? section.params : {}, params: section.params ? section.params : {},
actions: section.actions ? section.actions : [], actions: section.actions ? section.actions : [],
viewComponent: section.viewComponent viewComponent: section.viewComponent

View File

@ -8,6 +8,7 @@ export default {
title: 'Instances', title: 'Instances',
icon: 'desktop', icon: 'desktop',
permission: [ 'listVirtualMachinesMetrics', 'listVirtualMachines' ], permission: [ 'listVirtualMachinesMetrics', 'listVirtualMachines' ],
resourceType: 'UserVm',
viewComponent: () => import('@/views/compute/InstanceView.vue'), viewComponent: () => import('@/views/compute/InstanceView.vue'),
columns: [ columns: [
{ 'name': (record) => { return record.displayname } }, 'state', 'instancename', { 'name': (record) => { return record.displayname } }, 'state', 'instancename',

View File

@ -23,6 +23,7 @@ export default {
title: 'Domains', title: 'Domains',
icon: 'block', icon: 'block',
permission: [ 'listDomains' ], permission: [ 'listDomains' ],
resourceType: 'Domain',
columns: ['name', 'state', 'path', 'parentdomainname', 'level'] columns: ['name', 'state', 'path', 'parentdomainname', 'level']
}, },
{ {

View File

@ -8,6 +8,7 @@ export default {
title: 'Templates', title: 'Templates',
icon: 'save', icon: 'save',
permission: [ 'listTemplates' ], permission: [ 'listTemplates' ],
resourceType: 'Template',
params: { 'templatefilter': 'executable' }, params: { 'templatefilter': 'executable' },
columns: ['name', 'ostypename', 'status', 'hypervisor', 'account', 'domain'], columns: ['name', 'ostypename', 'status', 'hypervisor', 'account', 'domain'],
actions: [ actions: [
@ -25,6 +26,7 @@ export default {
title: 'ISOs', title: 'ISOs',
icon: 'usb', icon: 'usb',
permission: [ 'listIsos' ], permission: [ 'listIsos' ],
resourceType: 'ISO',
columns: ['name', 'ostypename', 'account', 'domain'] columns: ['name', 'ostypename', 'account', 'domain']
} }
] ]

View File

@ -40,6 +40,7 @@ export default {
title: 'Hosts', title: 'Hosts',
icon: 'desktop', icon: 'desktop',
permission: [ 'listHosts', 'listHostsMetrics' ], permission: [ 'listHosts', 'listHostsMetrics' ],
resourceType: 'Host',
params: { 'type': 'routing' }, params: { 'type': 'routing' },
columns: [ 'name', 'state', 'resourcestate', 'ipaddress', 'hypervisor', 'hypervisorversion', 'clustername', 'zonename' ] columns: [ 'name', 'state', 'resourcestate', 'ipaddress', 'hypervisor', 'hypervisorversion', 'clustername', 'zonename' ]
}, },

View File

@ -8,6 +8,7 @@ export default {
title: 'Guest Networks', title: 'Guest Networks',
icon: 'gateway', icon: 'gateway',
permission: [ 'listNetworks' ], permission: [ 'listNetworks' ],
resourceType: 'Network',
columns: ['name', 'state', 'type', 'cidr', 'ip6cidr', 'broadcasturi', 'account', 'zonename'], columns: ['name', 'state', 'type', 'cidr', 'ip6cidr', 'broadcasturi', 'account', 'zonename'],
actions: [ actions: [
{ {
@ -25,6 +26,7 @@ export default {
title: 'VPC', title: 'VPC',
icon: 'deployment-unit', icon: 'deployment-unit',
permission: [ 'listVPCs' ], permission: [ 'listVPCs' ],
resourceType: 'Vpc',
columns: ['name', 'state', 'displaytext', 'cidr', 'account', 'zonename'] columns: ['name', 'state', 'displaytext', 'cidr', 'account', 'zonename']
}, },
{ {
@ -32,6 +34,7 @@ export default {
title: 'Security Groups', title: 'Security Groups',
icon: 'fire', icon: 'fire',
permission: [ 'listSecurityGroups' ], permission: [ 'listSecurityGroups' ],
resourceType: 'SecurityGroup',
columns: ['name', 'description', 'account', 'domain'] columns: ['name', 'description', 'account', 'domain']
}, },
{ {
@ -39,6 +42,7 @@ export default {
title: 'Public IP Addresses', title: 'Public IP Addresses',
icon: 'environment', icon: 'environment',
permission: [ 'listPublicIpAddresses' ], permission: [ 'listPublicIpAddresses' ],
resourceType: 'PublicIpAddress',
columns: ['ipaddress', 'state', 'associatednetworkname', 'virtualmachinename', 'allocated', 'account', 'zonename'] columns: ['ipaddress', 'state', 'associatednetworkname', 'virtualmachinename', 'allocated', 'account', 'zonename']
}, },
{ {
@ -46,6 +50,7 @@ export default {
title: 'VPN Gateway', title: 'VPN Gateway',
icon: 'lock', icon: 'lock',
permission: [ 'listVpnCustomerGateways' ], permission: [ 'listVpnCustomerGateways' ],
resourceType: 'VpnGateway',
columns: ['name', 'ipaddress', 'gateway', 'cidrlist', 'ipsecpsk', 'account', 'domain'] columns: ['name', 'ipaddress', 'gateway', 'cidrlist', 'ipsecpsk', 'account', 'domain']
} }
] ]

View File

@ -3,5 +3,6 @@ export default {
title: 'Projects', title: 'Projects',
icon: 'project', icon: 'project',
permission: [ 'listProjects' ], permission: [ 'listProjects' ],
resourceType: 'Project',
columns: ['name', 'state', 'displaytext', 'account', 'domain'] columns: ['name', 'state', 'displaytext', 'account', 'domain']
} }

View File

@ -8,6 +8,7 @@ export default {
title: 'Volumes', title: 'Volumes',
icon: 'hdd', icon: 'hdd',
permission: [ 'listVolumesMetrics', 'listVolumes' ], permission: [ 'listVolumesMetrics', 'listVolumes' ],
resourceType: 'Volume',
columns: ['name', 'state', 'type', 'vmname', 'size', 'physicalsize', 'utilization', 'diskkbsread', 'diskkbswrite', 'diskiopstotal', 'storage', 'account', 'zonename'], columns: ['name', 'state', 'type', 'vmname', 'size', 'physicalsize', 'utilization', 'diskkbsread', 'diskkbswrite', 'diskiopstotal', 'storage', 'account', 'zonename'],
hidden: ['storage', 'utilization'], hidden: ['storage', 'utilization'],
actions: [ actions: [
@ -90,6 +91,7 @@ export default {
title: 'Snapshots', title: 'Snapshots',
icon: 'build', icon: 'build',
permission: [ 'listSnapshots' ], permission: [ 'listSnapshots' ],
resourceType: 'Snapshot',
columns: ['name', 'state', 'volumename', 'intervaltype', 'created', 'account'] columns: ['name', 'state', 'volumename', 'intervaltype', 'created', 'account']
}, },
{ {
@ -97,6 +99,7 @@ export default {
title: 'VM Snapshots', title: 'VM Snapshots',
icon: 'camera', icon: 'camera',
permission: [ 'listVMSnapshot' ], permission: [ 'listVMSnapshot' ],
resourceType: 'VMSnapshot',
columns: ['name', 'state', 'type', 'current', 'parent', 'created', 'account'] columns: ['name', 'state', 'type', 'current', 'parent', 'created', 'account']
} }
] ]

View File

@ -9,12 +9,8 @@
<div class="name"> <div class="name">
<slot name="name"> <slot name="name">
<h4> <h4>
<status :text="resource.state" v-if="resource.state"/>
{{ resource.name }} {{ resource.name }}
</h4> </h4>
<a-tag v-if="resource.state || resource.status">
{{ resource.state || resource.status }}
</a-tag>
<a-tag v-if="resource.type"> <a-tag v-if="resource.type">
{{ resource.type }} {{ resource.type }}
</a-tag> </a-tag>
@ -88,7 +84,7 @@
</div> </div>
</div> </div>
<div class="account-center-tags"> <div class="account-center-tags" v-if="resourceType && 'listTags' in $store.getters.apis">
<a-divider/> <a-divider/>
<div class="tagsTitle">Tags</div> <div class="tagsTitle">Tags</div>
<div> <div>
@ -122,12 +118,11 @@
</div> </div>
</div> </div>
<div class="account-center-team" v-if="showNotes"> <div class="account-center-team" v-if="annotationType && 'listAnnotations' in $store.getters.apis">
<a-divider :dashed="true"/> <a-divider :dashed="true"/>
<div class="teamTitle"> <div class="teamTitle">
Comments ({{ notes.length }}) Comments ({{ notes.length }})
</div> </div>
<a-list <a-list
v-if="notes.length" v-if="notes.length"
:dataSource="notes" :dataSource="notes"
@ -139,14 +134,20 @@
:content="item.annotation" :content="item.annotation"
:datetime="item.created" :datetime="item.created"
> >
<a-button slot="avatar" shape="circle" size="small" @click="deleteNote(item)"> <a-button
<a-icon type="close"/> v-if="'removeAnnotation' in $store.getters.apis"
slot="avatar"
type="danger"
shape="circle"
size="small"
@click="deleteNote(item)">
<a-icon type="delete"/>
</a-button> </a-button>
</a-comment> </a-comment>
</a-list-item> </a-list-item>
</a-list> </a-list>
<a-comment> <a-comment v-if="'addAnnotation' in $store.getters.apis">
<a-avatar <a-avatar
slot="avatar" slot="avatar"
icon="edit" icon="edit"
@ -184,18 +185,12 @@ export default {
resource: { resource: {
type: Object, type: Object,
required: true required: true
},
resourceType: {
type: String,
required: true
},
showNotes: {
type: Boolean,
default: false
} }
}, },
data () { data () {
return { return {
resourceType: '',
annotationType: '',
inputVisible: false, inputVisible: false,
inputKey: '', inputKey: '',
inputValue: '', inputValue: '',
@ -208,6 +203,24 @@ export default {
watch: { watch: {
resource: function (newItem, oldItem) { resource: function (newItem, oldItem) {
this.resource = newItem this.resource = newItem
this.resourceType = this.$route.meta.resourceType
switch (this.resourceType) {
case 'UserVm':
this.annotationType = 'VM'
break
case 'Domain':
this.annotationType = 'DOMAIN'
// Domain resource type is not supported for tags
this.resourceType = ''
break
case 'Host':
this.annotationType = 'HOST'
// Host resource type is not supported for tags
this.resourceType = ''
break
}
this.getTags() this.getTags()
this.getNotes() this.getNotes()
if ('tags' in this.resource) { if ('tags' in this.resource) {
@ -225,9 +238,8 @@ export default {
}) })
}, },
getNotes () { getNotes () {
// TODO: support for HOST, DOMAIN and VM entities
this.notes = [] this.notes = []
api('listAnnotations', { 'entityid': this.resource.id, 'entitytype': 'VM' }).then(json => { api('listAnnotations', { 'entityid': this.resource.id, 'entitytype': this.annotationType }).then(json => {
if (json.listannotationsresponse && json.listannotationsresponse.annotation) { if (json.listannotationsresponse && json.listannotationsresponse.annotation) {
this.notes = json.listannotationsresponse.annotation this.notes = json.listannotationsresponse.annotation
} }
@ -279,12 +291,10 @@ export default {
return return
} }
this.showNotesInput = false this.showNotesInput = false
const entityType = 'VM' // TODO: support HOST and DOMAIN
const args = {} const args = {}
args['annotation'] = this.annotation
args['entityid'] = this.resource.id args['entityid'] = this.resource.id
args['entitytype'] = entityType args['entitytype'] = this.annotationType
args['annotation'] = this.annotation
api('addAnnotation', args).then(json => { api('addAnnotation', args).then(json => {
}).finally(e => { }).finally(e => {
this.getNotes() this.getNotes()
@ -327,6 +337,7 @@ export default {
line-height: 28px; line-height: 28px;
font-weight: 500; font-weight: 500;
margin-bottom: 4px; margin-bottom: 4px;
word-wrap: break-word;
} }
} }
.resource-center-detail { .resource-center-detail {