Skip to content

Commit 13ca085

Browse files
config: implement API arg remappings
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
1 parent 135ddf8 commit 13ca085

File tree

18 files changed

+479
-95
lines changed

18 files changed

+479
-95
lines changed

ui/src/components/view/InfoCard.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@
308308

309309
<div class="account-center-tags" v-if="$route.meta.related">
310310
<span v-for="item in $route.meta.related" :key="item.path">
311-
<router-link :to="{ path: '/' + item.name + '?' + item.param + '=' + resource.id }">
311+
<router-link :to="{ path: '/' + item.name + '?' + item.param + '=' + (item.param === 'account' ? resource.name + '&domainid=' + resource.domainid : resource.id) }">
312312
<a-button style="margin-right: 10px">
313313
View {{ $t(item.title) }}
314314
</a-button>

ui/src/config/router.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export function generateRouterMap (section) {
5555
keepAlive: true,
5656
icon: child.icon,
5757
docHelp: child.docHelp,
58+
hidden: child.hidden,
5859
permission: child.permission,
5960
resourceType: child.resourceType,
6061
params: child.params ? child.params : {},
@@ -73,6 +74,7 @@ export function generateRouterMap (section) {
7374
name: child.name,
7475
keepAlive: true,
7576
icon: child.icon,
77+
hidden: child.hidden,
7678
permission: child.permission,
7779
resourceType: child.resourceType,
7880
params: child.params ? child.params : {},
@@ -119,6 +121,7 @@ export function generateRouterMap (section) {
119121
keepAlive: true,
120122
icon: section.icon,
121123
docHelp: section.docHelp,
124+
hidden: section.hidden,
122125
permission: section.permission,
123126
resourceType: section.resourceType,
124127
params: section.params ? section.params : {},

ui/src/config/section/compute.js

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -154,27 +154,6 @@ export default {
154154
}
155155
}
156156
},
157-
{
158-
api: 'migrateVirtualMachine',
159-
icon: 'drag',
160-
label: 'label.migrate.instance.to.host',
161-
dataView: true,
162-
show: (record) => { return ['Running'].includes(record.state) }
163-
},
164-
{
165-
api: 'migrateVirtualMachineWithVolume',
166-
icon: 'export',
167-
label: 'Migrate VM with Volume(s)',
168-
dataView: true,
169-
show: (record) => { return ['Running'].includes(record.state) }
170-
},
171-
{
172-
api: 'migrateVirtualMachine',
173-
icon: 'drag',
174-
label: 'label.migrate.instance.to.ps',
175-
dataView: true,
176-
show: (record) => { return ['Stopped'].includes(record.state) }
177-
},
178157
{
179158
api: 'updateVMAffinityGroup',
180159
icon: 'swap',
@@ -199,6 +178,42 @@ export default {
199178
args: ['serviceofferingid'],
200179
show: (record) => { return ['Stopped'].includes(record.state) }
201180
},
181+
{
182+
api: 'migrateVirtualMachine',
183+
icon: 'drag',
184+
label: 'label.migrate.instance.to.host',
185+
dataView: true,
186+
show: (record) => { return ['Running'].includes(record.state) },
187+
args: ['hostid', 'virtualmachineid'],
188+
mapping: {
189+
virtualmachineid: {
190+
value: (record) => { return record.id }
191+
}
192+
}
193+
},
194+
{
195+
api: 'migrateVirtualMachineWithVolume',
196+
icon: 'export',
197+
label: 'Migrate VM with Volume(s)',
198+
dataView: true,
199+
show: (record) => { return ['Running'].includes(record.state) }
200+
},
201+
{
202+
api: 'migrateVirtualMachine',
203+
icon: 'drag',
204+
label: 'label.migrate.instance.to.ps',
205+
dataView: true,
206+
show: (record) => { return ['Stopped'].includes(record.state) },
207+
args: ['storageid', 'virtualmachineid'],
208+
mapping: {
209+
storageid: {
210+
api: 'listStoragePools'
211+
},
212+
virtualmachineid: {
213+
value: (record) => { return record.id }
214+
}
215+
}
216+
},
202217
{
203218
api: 'resetPasswordForVirtualMachine',
204219
icon: 'key',

ui/src/config/section/event.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,32 @@ export default {
2222
permission: ['listEvents'],
2323
columns: ['username', 'description', 'state', 'level', 'type', 'account', 'domain', 'created'],
2424
details: ['username', 'id', 'description', 'state', 'level', 'type', 'account', 'domain', 'created'],
25-
related: [{
26-
name: 'event',
27-
title: 'Event Timeline',
28-
param: 'startid'
29-
}],
3025
actions: [
3126
{
3227
api: 'archiveEvents',
3328
icon: 'book',
3429
label: 'Archive Event',
30+
listView: true,
3531
dataView: true,
36-
args: ['ids']
32+
args: ['ids'],
33+
mapping: {
34+
ids: {
35+
value: (record) => { return record.id }
36+
}
37+
}
3738
},
3839
{
3940
api: 'deleteEvents',
4041
icon: 'delete',
4142
label: 'Delete Event',
43+
listView: true,
4244
dataView: true,
43-
args: ['ids']
45+
args: ['ids'],
46+
mapping: {
47+
ids: {
48+
value: (record) => { return record.id }
49+
}
50+
}
4451
}
4552
]
4653
}

ui/src/config/section/iam.js

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ export default {
8585
permission: ['listAccounts'],
8686
columns: ['name', 'state', 'firstname', 'lastname', 'rolename', 'roletype', 'domain'],
8787
details: ['name', 'id', 'rolename', 'roletype', 'domain', 'networkdomain', 'iptotal', 'vmtotal', 'volumetotal', 'receivedbytes', 'sentbytes', 'vmlimit', 'iplimit', 'volumelimit', 'snapshotlimit', 'templatelimit', 'vpclimit', 'cpulimit', 'memorylimit', 'networklimit', 'primarystoragelimit', 'secondarystoragelimit'],
88+
related: [{
89+
name: 'accountuser',
90+
title: 'Users',
91+
param: 'account'
92+
}],
8893
actions: [
8994
{
9095
api: 'createAccount',
@@ -105,7 +110,15 @@ export default {
105110
icon: 'sync',
106111
label: 'Update Resource Count',
107112
dataView: true,
108-
args: ['account', 'domainid']
113+
args: ['account', 'domainid'],
114+
mapping: {
115+
account: {
116+
value: (record) => { return record.account }
117+
},
118+
domainid: {
119+
value: (record) => { return record.domainid }
120+
}
121+
}
109122
},
110123
{
111124
api: 'enableAccount',
@@ -121,25 +134,32 @@ export default {
121134
label: 'Disable Account',
122135
dataView: true,
123136
show: (record) => { return record.state === 'enabled' },
124-
params: { lock: 'false' }
137+
args: ['lock'],
138+
mapping: {
139+
lock: {
140+
value: (record) => { return false }
141+
}
142+
}
125143
},
126144
{
127145
api: 'disableAccount',
128146
icon: 'lock',
129147
label: 'Lock account',
130148
dataView: true,
131149
show: (record) => { return record.state === 'enabled' },
132-
args: ['lock']
150+
args: ['lock'],
151+
mapping: {
152+
lock: {
153+
value: (record) => { return true }
154+
}
155+
}
133156
},
134157
{
135158
api: 'deleteAccount',
136159
icon: 'delete',
137160
label: 'Delete account',
138161
dataView: true,
139-
hidden: (record) => { return record.name === 'admin' },
140-
args: [
141-
'id'
142-
]
162+
hidden: (record) => { return record.name === 'admin' }
143163
}
144164
]
145165
},
@@ -206,14 +226,24 @@ export default {
206226
icon: 'plus',
207227
label: 'Create Role',
208228
listView: true,
209-
args: ['name', 'description', 'type']
229+
args: ['name', 'description', 'type'],
230+
mapping: {
231+
type: {
232+
options: ['Admin', 'DomainAdmin', 'User']
233+
}
234+
}
210235
},
211236
{
212237
api: 'updateRole',
213238
icon: 'edit',
214239
label: 'Edit Role',
215240
dataView: true,
216-
args: ['name', 'description', 'type']
241+
args: ['name', 'description', 'type'],
242+
mapping: {
243+
type: {
244+
options: ['Admin', 'DomainAdmin', 'User']
245+
}
246+
}
217247
},
218248
{
219249
api: 'deleteRole',

ui/src/config/section/infra.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// under the License.
1717

1818
import zones from '@/config/section/infra/zones'
19+
import phynetworks from '@/config/section/infra/phynetworks'
1920
import pods from '@/config/section/infra/pods'
2021
import clusters from '@/config/section/infra/clusters'
2122
import hosts from '@/config/section/infra/hosts'
@@ -38,6 +39,7 @@ export default {
3839
component: () => import('@/views/infra/InfraSummary.vue')
3940
},
4041
zones,
42+
phynetworks,
4143
pods,
4244
clusters,
4345
hosts,
@@ -48,7 +50,7 @@ export default {
4850
{
4951
name: 'cpusocket',
5052
title: 'CPU Sockets',
51-
icon: 'api',
53+
icon: 'inbox',
5254
permission: ['listHosts'],
5355
params: { type: 'routing' },
5456
columns: ['hypervisor', 'hosts', 'cpusockets']
@@ -73,14 +75,24 @@ export default {
7375
icon: 'book',
7476
label: 'Archive Alert',
7577
dataView: true,
76-
args: ['ids']
78+
args: ['ids'],
79+
mapping: {
80+
ids: {
81+
value: (record) => { return record.id }
82+
}
83+
}
7784
},
7885
{
7986
api: 'deleteAlerts',
8087
icon: 'delete',
8188
label: 'Delete Alert',
8289
dataView: true,
83-
args: ['ids']
90+
args: ['ids'],
91+
mapping: {
92+
ids: {
93+
value: (record) => { return record.id }
94+
}
95+
}
8496
}
8597
]
8698
}

0 commit comments

Comments
 (0)