Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
Rohit Yadav 2020-03-27 15:39:53 +05:30
parent 30b74f51be
commit b8c054bac2
5 changed files with 19 additions and 222 deletions

View File

@ -24,8 +24,8 @@
> >
<a-form-item <a-form-item
v-for="(item, index) in dataResource" v-for="(item, index) in dataResource"
v-if="checkExistFields(item.resourcetypename)"
:key="index" :key="index"
v-if="item.resourcetypename !== 'project'"
:v-bind="item.resourcetypename" :v-bind="item.resourcetypename"
:label="getFieldLabel(item.resourcetypename)"> :label="getFieldLabel(item.resourcetypename)">
<a-input-number <a-input-number
@ -40,7 +40,7 @@
v-if="!disabled" v-if="!disabled"
:loading="formLoading" :loading="formLoading"
type="primary" type="primary"
@click="handleSubmit">{{ this.$t('apply') }}</a-button> @click="handleSubmit">{{ $t('submit') }}</a-button>
</div> </div>
</a-form> </a-form>
</a-spin> </a-spin>
@ -50,7 +50,7 @@
import { api } from '@/api' import { api } from '@/api'
export default { export default {
name: 'ResourcesTab', name: 'ResourceLimitTab',
props: { props: {
resource: { resource: {
type: Object, type: Object,
@ -64,10 +64,6 @@ export default {
type: Object, type: Object,
default: () => {} default: () => {}
}, },
fields: {
type: Array,
default: () => []
},
disabled: { disabled: {
type: Boolean, type: Boolean,
default: false default: false
@ -177,21 +173,8 @@ export default {
}) })
}) })
}, },
checkExistFields (resourcetypename) {
const fieldExists = this.fields.filter((item) => item.field === resourcetypename)
if (fieldExists && fieldExists.length > 0) {
return true
}
return false
},
getFieldLabel (resourcetypename) { getFieldLabel (resourcetypename) {
const field = this.fields.filter((item) => item.field === resourcetypename) return this.$t('max' + resourcetypename.replace('_', ''))
if (field && field.length > 0) {
return this.$t(field[0].title)
}
return resourcetypename
} }
} }
} }
@ -199,8 +182,6 @@ export default {
<style lang="less" scoped> <style lang="less" scoped>
.card-footer { .card-footer {
text-align: right;
button + button { button + button {
margin-left: 8px; margin-left: 8px;
} }

View File

@ -182,54 +182,8 @@ export const asyncRouterMap = [
params: { params: {
projectid: 'id' projectid: 'id'
}, },
fields: [
{
field: 'network',
title: 'maxnetwork'
},
{
field: 'volume',
title: 'maxvolume'
},
{
field: 'public_ip',
title: 'maxpublic_ip'
},
{
field: 'template',
title: 'maxtemplate'
},
{
field: 'user_vm',
title: 'maxuser_vm'
},
{
field: 'snapshot',
title: 'maxsnapshot'
},
{
field: 'vpc',
title: 'maxvpc'
},
{
field: 'cpu',
title: 'maxcpu'
},
{
field: 'memory',
title: 'maxmemory'
},
{
field: 'primary_storage',
title: 'maxprimary_storage'
},
{
field: 'secondary_storage',
title: 'maxsecondary_storage'
}
],
show: (record, route, user) => { return ['Admin'].includes(user.roletype) }, show: (record, route, user) => { return ['Admin'].includes(user.roletype) },
component: () => import('@/components/view/ResourcesTab.vue') component: () => import('@/components/view/ResourceLimitTab.vue')
} }
] ]
}, },

View File

@ -109,54 +109,8 @@ export default {
account: 'name', account: 'name',
domainid: 'domainid' domainid: 'domainid'
}, },
fields: [
{
field: 'network',
title: 'networkLimit'
},
{
field: 'volume',
title: 'volumeLimit'
},
{
field: 'public_ip',
title: 'ipLimit'
},
{
field: 'template',
title: 'templateLimit'
},
{
field: 'user_vm',
title: 'vmLimit'
},
{
field: 'snapshot',
title: 'snapshotLimit'
},
{
field: 'vpc',
title: 'vpcLimit'
},
{
field: 'cpu',
title: 'cpuLimit'
},
{
field: 'memory',
title: 'memoryLimit'
},
{
field: 'primary_storage',
title: 'primaryStorageLimit'
},
{
field: 'secondary_storage',
title: 'secondaryStorageLimit'
}
],
show: (record, route, user) => { return ['Admin'].includes(user.roletype) }, show: (record, route, user) => { return ['Admin'].includes(user.roletype) },
component: () => import('@/components/view/ResourcesTab.vue') component: () => import('@/components/view/ResourceLimitTab.vue')
} }
], ],
actions: [ actions: [
@ -298,54 +252,8 @@ export default {
params: { params: {
domainid: 'id' domainid: 'id'
}, },
fields: [
{
field: 'network',
title: 'networkLimit'
},
{
field: 'volume',
title: 'volumeLimit'
},
{
field: 'public_ip',
title: 'ipLimit'
},
{
field: 'template',
title: 'templateLimit'
},
{
field: 'user_vm',
title: 'vmLimit'
},
{
field: 'snapshot',
title: 'snapshotLimit'
},
{
field: 'vpc',
title: 'vpcLimit'
},
{
field: 'cpu',
title: 'cpuLimit'
},
{
field: 'memory',
title: 'memoryLimit'
},
{
field: 'primary_storage',
title: 'primaryStorageLimit'
},
{
field: 'secondary_storage',
title: 'secondaryStorageLimit'
}
],
show: (record, route, user) => { return ['Admin'].includes(user.roletype) }, show: (record, route, user) => { return ['Admin'].includes(user.roletype) },
component: () => import('@/components/view/ResourcesTab.vue') component: () => import('@/components/view/ResourceLimitTab.vue')
} }
], ],
treeView: true, treeView: true,

View File

@ -38,54 +38,8 @@ export default {
params: { params: {
projectid: 'id' projectid: 'id'
}, },
fields: [
{
field: 'network',
title: 'maxnetwork'
},
{
field: 'volume',
title: 'maxvolume'
},
{
field: 'public_ip',
title: 'maxpublic_ip'
},
{
field: 'template',
title: 'maxtemplate'
},
{
field: 'user_vm',
title: 'maxuser_vm'
},
{
field: 'snapshot',
title: 'maxsnapshot'
},
{
field: 'vpc',
title: 'maxvpc'
},
{
field: 'cpu',
title: 'maxcpu'
},
{
field: 'memory',
title: 'maxmemory'
},
{
field: 'primary_storage',
title: 'maxprimary_storage'
},
{
field: 'secondary_storage',
title: 'maxsecondary_storage'
}
],
show: (record, route, user) => { return ['Admin'].includes(user.roletype) }, show: (record, route, user) => { return ['Admin'].includes(user.roletype) },
component: () => import('@/components/view/ResourcesTab.vue') component: () => import('@/components/view/ResourceLimitTab.vue')
} }
], ],
actions: [ actions: [

View File

@ -701,18 +701,18 @@
"managedstate": "Managed State", "managedstate": "Managed State",
"managementServers": "Number of Management Servers", "managementServers": "Number of Management Servers",
"masternodes": "Master nodes", "masternodes": "Master nodes",
"maxuser_vm": "Max. user VMs", "maxuservm": "Max. User VMs",
"maxpublic_ip": "Max. public IPs", "maxpublicip": "Max. Public IPs",
"maxvolume": "Max. volumes", "maxvolume": "Max. Volumes",
"maxsnapshot": "Max. snapshots", "maxsnapshot": "Max. Snapshots",
"maxtemplate": "Max. templates", "maxtemplate": "Max. Templates",
"maxproject": "Max. projects", "maxproject": "Max. Projects",
"maxnetwork": "Max. networks", "maxnetwork": "Max. Networks",
"maxvpc": "Max. VPCs", "maxvpc": "Max. VPCs",
"maxcpu": "Max. CPU cores", "maxcpu": "Max. CPU Cores",
"maxmemory": "Max. memory (MiB)", "maxmemory": "Max. Memory (MiB)",
"maxprimary_storage": "Max. primary (GiB)", "maxprimarystorage": "Max. Primary Storage (GiB)",
"maxsecondary_storage": "Max. secondary (GiB)", "maxsecondarystorage": "Max. Secondary Storage (GiB)",
"maxCPUNumber": "Max CPU Cores", "maxCPUNumber": "Max CPU Cores",
"maxInstance": "Max Instances", "maxInstance": "Max Instances",
"maxIops": "Max IOPS", "maxIops": "Max IOPS",