Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
Rohit Yadav 2020-03-27 15:56:36 +05:30
parent b8c054bac2
commit 2a32d56ab3
7 changed files with 24 additions and 51 deletions

View File

@ -27,7 +27,7 @@
:key="index"
v-if="item.resourcetypename !== 'project'"
:v-bind="item.resourcetypename"
:label="getFieldLabel(item.resourcetypename)">
:label="$t('max' + item.resourcetypename.replace('_', ''))">
<a-input-number
style="width: 100%;"
v-decorator="[item.resourcetype, {
@ -37,7 +37,7 @@
</a-form-item>
<div class="card-footer">
<a-button
v-if="!disabled"
v-if="!($route.meta.name === 'domain' && resource.level === 0)"
:loading="formLoading"
type="primary"
@click="handleSubmit">{{ $t('submit') }}</a-button>
@ -59,14 +59,6 @@ export default {
loading: {
type: Boolean,
default: false
},
params: {
type: Object,
default: () => {}
},
disabled: {
type: Boolean,
default: false
}
},
data () {
@ -91,13 +83,20 @@ export default {
}
},
methods: {
async fetchData () {
getParams () {
const params = {}
Object.keys(this.params).forEach((field) => {
const resourceField = this.params[field]
const fieldVal = this.resource[resourceField] ? this.resource[resourceField] : null
params[field] = fieldVal
})
if (this.$route.meta.name === 'account') {
params.account = this.resource.name
params.domainid = this.resource.domainid
} else if (this.$route.meta.name === 'domain') {
params.domainid = this.resource.id
} else { // project
params.projectid = this.resource.id
}
return params
},
async fetchData () {
const params = this.getParams()
try {
this.formLoading = true
this.dataResource = await this.listResourceLimits(params)
@ -118,13 +117,7 @@ export default {
return
}
const arrAsync = []
const params = {}
Object.keys(this.params).forEach((field) => {
const resourceField = this.params[field]
const fieldVal = this.resource[resourceField] ? this.resource[resourceField] : null
params[field] = fieldVal
})
const params = this.getParams()
for (const key in values) {
const input = values[key]
@ -157,6 +150,7 @@ export default {
api('listResourceLimits', params).then(json => {
if (json.listresourcelimitsresponse.resourcelimit) {
dataResource = json.listresourcelimitsresponse.resourcelimit
dataResource.sort((a, b) => a.resourcetype - b.resourcetype)
}
resolve(dataResource)
}).catch(error => {
@ -172,9 +166,6 @@ export default {
reject(error)
})
})
},
getFieldLabel (resourcetypename) {
return this.$t('max' + resourcetypename.replace('_', ''))
}
}
}

View File

@ -44,13 +44,7 @@
:tab="$t(tab.name)"
:key="tab.name"
v-if="showHideTab(tab)">
<component
:is="tab.component"
:resource="resource"
:loading="loading"
:tab="activeTab"
:params="tab.params"
:fields="tab.fields"/>
<component :is="tab.component" :resource="resource" :loading="loading" :tab="activeTab" />
</a-tab-pane>
</a-tabs>
</a-card>

View File

@ -68,10 +68,7 @@
:items="items"
:tab="tabActive"
:loading="loading"
:bordered="false"
:params="tab.params"
:fields="tab.fields"
:disabled="resource && resource.level === 0" />
:bordered="false" />
</a-tab-pane>
</a-tabs>
</a-card>

View File

@ -178,7 +178,7 @@ export const asyncRouterMap = [
component: () => import('@/views/project/AccountsTab')
},
{
name: 'resources',
name: 'limits',
params: {
projectid: 'id'
},

View File

@ -104,11 +104,7 @@ export default {
component: () => import('@/components/view/SettingsTab.vue')
},
{
name: 'resources',
params: {
account: 'name',
domainid: 'domainid'
},
name: 'limits',
show: (record, route, user) => { return ['Admin'].includes(user.roletype) },
component: () => import('@/components/view/ResourceLimitTab.vue')
}
@ -248,10 +244,7 @@ export default {
component: () => import('@/components/view/SettingsTab.vue')
},
{
name: 'resources',
params: {
domainid: 'id'
},
name: 'limits',
show: (record, route, user) => { return ['Admin'].includes(user.roletype) },
component: () => import('@/components/view/ResourceLimitTab.vue')
}

View File

@ -34,10 +34,7 @@ export default {
component: () => import('@/views/project/AccountsTab.vue')
},
{
name: 'resources',
params: {
projectid: 'id'
},
name: 'limits',
show: (record, route, user) => { return ['Admin'].includes(user.roletype) },
component: () => import('@/components/view/ResourceLimitTab.vue')
}

View File

@ -686,6 +686,7 @@
"lbdevicename": "Type",
"lbdevicestate": "Status",
"level": "Level",
"limits": "Limits",
"limitcpuuse": "CPU Cap",
"linklocalip": "Link Local IP Address",
"loadbalancerinstance": "Assigned VMs",