diff --git a/ui/src/main.js b/ui/src/main.js index 064314b98de..9fbae3e0acd 100644 --- a/ui/src/main.js +++ b/ui/src/main.js @@ -26,7 +26,7 @@ import './core/lazy_use' import './core/ext' import './permission' // permission control import './utils/filter' // global filter -import { pollJobPlugin, notifierPlugin, toLocaleDatePlugin, configUtilPlugin } from './utils/plugins' +import { pollJobPlugin, notifierPlugin, toLocaleDatePlugin, configUtilPlugin, apiMetaUtilPlugin } from './utils/plugins' import { VueAxios } from './utils/request' Vue.config.productionTip = false @@ -51,3 +51,4 @@ fetch('config.json').then(response => response.json()).then(config => { }) Vue.use(configUtilPlugin) +Vue.use(apiMetaUtilPlugin) diff --git a/ui/src/utils/plugins.js b/ui/src/utils/plugins.js index 3276eea63e7..87e4e74ff38 100644 --- a/ui/src/utils/plugins.js +++ b/ui/src/utils/plugins.js @@ -185,3 +185,20 @@ export const configUtilPlugin = { } } } + +export const apiMetaUtilPlugin = { + install (Vue) { + Vue.prototype.$getApiParams = function () { + var apiParams = {} + for (var argument of arguments) { + var apiConfig = this.$store.getters.apis[argument] || {} + if (apiConfig && apiConfig.params) { + apiConfig.params.forEach(param => { + apiParams[param.name] = param + }) + } + } + return apiParams + } + } +} diff --git a/ui/src/views/compute/CreateKubernetesCluster.vue b/ui/src/views/compute/CreateKubernetesCluster.vue index b824e8bf633..c6834da3d02 100644 --- a/ui/src/views/compute/CreateKubernetesCluster.vue +++ b/ui/src/views/compute/CreateKubernetesCluster.vue @@ -342,11 +342,7 @@ export default { }, beforeCreate () { this.form = this.$form.createForm(this) - this.apiConfig = this.$store.getters.apis.createKubernetesCluster || {} - this.apiParams = {} - this.apiConfig.params.forEach(param => { - this.apiParams[param.name] = param - }) + this.apiParams = this.$getApiParams('createKubernetesCluster') }, created () { this.networks = [ diff --git a/ui/src/views/compute/CreateSSHKeyPair.vue b/ui/src/views/compute/CreateSSHKeyPair.vue index 81fa7c57b7d..b15e1fafd94 100644 --- a/ui/src/views/compute/CreateSSHKeyPair.vue +++ b/ui/src/views/compute/CreateSSHKeyPair.vue @@ -94,17 +94,7 @@ export default { }, beforeCreate () { this.form = this.$form.createForm(this) - this.apiConfig = this.$store.getters.apis.createSSHKeyPair || {} - this.apiParams = {} - this.apiConfig.params.forEach(param => { - this.apiParams[param.name] = param - }) - this.apiConfig = this.$store.getters.apis.registerSSHKeyPair || {} - this.apiConfig.params.forEach(param => { - if (!(param.name in this.apiParams)) { - this.apiParams[param.name] = param - } - }) + this.apiParams = this.$getApiParams('createSSHKeyPair', 'registerSSHKeyPair') }, created () { this.domains = [ diff --git a/ui/src/views/compute/CreateSnapshotWizard.vue b/ui/src/views/compute/CreateSnapshotWizard.vue index 4fc39162479..2594b05bdbf 100644 --- a/ui/src/views/compute/CreateSnapshotWizard.vue +++ b/ui/src/views/compute/CreateSnapshotWizard.vue @@ -103,11 +103,7 @@ export default { }, beforeCreate () { this.form = this.$form.createForm(this) - this.apiConfig = this.$store.getters.apis.createSnapshot || {} - this.apiParams = {} - this.apiConfig.params.forEach(param => { - this.apiParams[param.name] = param - }) + this.apiParams = this.$getApiParams('createSnapshot') }, created () { this.fetchData() diff --git a/ui/src/views/compute/DestroyVM.vue b/ui/src/views/compute/DestroyVM.vue index 46fb3c32e73..56bbb45ab59 100644 --- a/ui/src/views/compute/DestroyVM.vue +++ b/ui/src/views/compute/DestroyVM.vue @@ -82,11 +82,7 @@ export default { }, beforeCreate () { this.form = this.$form.createForm(this) - this.apiParams = {} - var apiConfig = this.$store.getters.apis.destroyVirtualMachine || {} - apiConfig.params.forEach(param => { - this.apiParams[param.name] = param - }) + this.apiParams = this.$getApiParams('destroyVirtualMachine') }, created () { this.fetchData() diff --git a/ui/src/views/compute/EditVM.vue b/ui/src/views/compute/EditVM.vue index c9f342ba392..c97e7e53e9f 100644 --- a/ui/src/views/compute/EditVM.vue +++ b/ui/src/views/compute/EditVM.vue @@ -138,11 +138,7 @@ export default { }, beforeCreate () { this.form = this.$form.createForm(this) - this.apiParams = {} - const apiConfig = this.$store.getters.apis.updateVirtualMachine || {} - apiConfig.params.forEach(param => { - this.apiParams[param.name] = param - }) + this.apiParams = this.$getApiParams('updateVirtualMachine') }, created () { this.fetchData() diff --git a/ui/src/views/compute/ScaleKubernetesCluster.vue b/ui/src/views/compute/ScaleKubernetesCluster.vue index 11dd4bf7f95..5c6a101f55e 100644 --- a/ui/src/views/compute/ScaleKubernetesCluster.vue +++ b/ui/src/views/compute/ScaleKubernetesCluster.vue @@ -102,11 +102,7 @@ export default { }, beforeCreate () { this.form = this.$form.createForm(this) - this.apiConfig = this.$store.getters.apis.scaleKubernetesCluster || {} - this.apiParams = {} - this.apiConfig.params.forEach(param => { - this.apiParams[param.name] = param - }) + this.apiParams = this.$getApiParams('scaleKubernetesCluster') }, created () { this.originalSize = !this.isObjectEmpty(this.resource) ? this.resource.size : 1 diff --git a/ui/src/views/compute/StartVirtualMachine.vue b/ui/src/views/compute/StartVirtualMachine.vue index beb82c74807..83efee55b3c 100644 --- a/ui/src/views/compute/StartVirtualMachine.vue +++ b/ui/src/views/compute/StartVirtualMachine.vue @@ -143,11 +143,7 @@ export default { inject: ['parentFetchData'], beforeCreate () { this.form = this.$form.createForm(this) - this.apiConfig = this.$store.getters.apis.startVirtualMachine || {} - this.apiParams = {} - this.apiConfig.params.forEach(param => { - this.apiParams[param.name] = param - }) + this.apiParams = this.$getApiParams('startVirtualMachine') }, created () { if (this.$store.getters.userInfo.roletype === 'Admin') { diff --git a/ui/src/views/compute/UpgradeKubernetesCluster.vue b/ui/src/views/compute/UpgradeKubernetesCluster.vue index e681b2f228d..be88fd6a360 100644 --- a/ui/src/views/compute/UpgradeKubernetesCluster.vue +++ b/ui/src/views/compute/UpgradeKubernetesCluster.vue @@ -83,11 +83,7 @@ export default { }, beforeCreate () { this.form = this.$form.createForm(this) - this.apiConfig = this.$store.getters.apis.upgradeKubernetesCluster || {} - this.apiParams = {} - this.apiConfig.params.forEach(param => { - this.apiParams[param.name] = param - }) + this.apiParams = this.$getApiParams('upgradeKubernetesCluster') }, created () { this.fetchData() diff --git a/ui/src/views/iam/AddAccount.vue b/ui/src/views/iam/AddAccount.vue index bb0359b2372..1b61f2d5ca7 100644 --- a/ui/src/views/iam/AddAccount.vue +++ b/ui/src/views/iam/AddAccount.vue @@ -243,19 +243,7 @@ export default { }, beforeCreate () { this.form = this.$form.createForm(this) - this.apiConfig = this.$store.getters.apis.createAccount || {} - this.apiParams = {} - if (this.apiConfig.params) { - this.apiConfig.params.forEach(param => { - this.apiParams[param.name] = param - }) - } - this.apiConfig = this.$store.getters.apis.authorizeSamlSso || {} - if (this.apiConfig.params) { - this.apiConfig.params.forEach(param => { - this.apiParams[param.name] = param - }) - } + this.apiParams = this.$getApiParams('createAccount', 'authorizeSamlSso') }, created () { this.fetchData() diff --git a/ui/src/views/iam/AddUser.vue b/ui/src/views/iam/AddUser.vue index efec6657f54..e9ac516073e 100644 --- a/ui/src/views/iam/AddUser.vue +++ b/ui/src/views/iam/AddUser.vue @@ -222,15 +222,7 @@ export default { }, created () { this.form = this.$form.createForm(this) - this.apiConfig = this.$store.getters.apis.createUser || {} - this.apiParams = {} - this.apiConfig.params.forEach(param => { - this.apiParams[param.name] = param - }) - this.apiConfig = this.$store.getters.apis.authorizeSamlSso || { params: [] } - this.apiConfig.params.forEach(param => { - this.apiParams[param.name] = param - }) + this.apiParams = this.$getApiParams('createUser', 'authorizeSamlSso') this.fetchData() }, methods: { diff --git a/ui/src/views/iam/ChangeUserPassword.vue b/ui/src/views/iam/ChangeUserPassword.vue index 27fc269bf38..3570cd51580 100644 --- a/ui/src/views/iam/ChangeUserPassword.vue +++ b/ui/src/views/iam/ChangeUserPassword.vue @@ -98,11 +98,7 @@ export default { }, beforeCreate () { this.form = this.$form.createForm(this) - this.apiParams = {} - this.apiConfig = this.$store.getters.apis.updateUser || {} - this.apiConfig.params.forEach(param => { - this.apiParams[param.name] = param - }) + this.apiParams = this.$getApiParams('updateUser') }, methods: { isAdminOrDomainAdmin () { diff --git a/ui/src/views/iam/CreateRole.vue b/ui/src/views/iam/CreateRole.vue index 7531f74b054..89e41e301bd 100644 --- a/ui/src/views/iam/CreateRole.vue +++ b/ui/src/views/iam/CreateRole.vue @@ -25,7 +25,7 @@ {{ $t('label.name') }} - + @@ -33,23 +33,23 @@ v-decorator="['name', { rules: [{ required: true, message: $t('message.error.required.input') }] }]" - :placeholder="createRoleApiParams.name.description" + :placeholder="apiParams.name.description" autoFocus /> {{ $t('label.description') }} - + + :placeholder="apiParams.description.description" /> - + {{ $t('label.based.on') }} @@ -74,7 +74,7 @@ {{ $t('label.type') }} - + @@ -82,7 +82,7 @@ v-decorator="['type', { rules: [{ required: true, message: $t('message.error.select') }] }]" - :placeholder="createRoleApiParams.type.description"> + :placeholder="apiParams.type.description"> {{ role }} @@ -92,7 +92,7 @@ {{ $t('label.role') }} - + @@ -100,7 +100,7 @@ v-decorator="['roleid', { rules: [{ required: true, message: $t('message.error.select') }] }]" - :placeholder="createRoleApiParams.roleid.description"> + :placeholder="apiParams.roleid.description"> { - this.createRoleApiParams[param.name] = param - }) + this.apiParams = this.$getApiParams('createRole') }, watch: { '$route' (to, from) { diff --git a/ui/src/views/iam/EditUser.vue b/ui/src/views/iam/EditUser.vue index e9662b1cb4a..3a3bbf2e5c9 100644 --- a/ui/src/views/iam/EditUser.vue +++ b/ui/src/views/iam/EditUser.vue @@ -131,11 +131,7 @@ export default { }, beforeCreate () { this.form = this.$form.createForm(this) - this.apiConfig = this.$store.getters.apis.updateUser || {} - this.apiParams = {} - this.apiConfig.params.forEach(param => { - this.apiParams[param.name] = param - }) + this.apiParams = this.$getApiParams('updateUser') }, created () { this.fetchData() diff --git a/ui/src/views/iam/ImportRole.vue b/ui/src/views/iam/ImportRole.vue index 278f8dae863..931671df450 100644 --- a/ui/src/views/iam/ImportRole.vue +++ b/ui/src/views/iam/ImportRole.vue @@ -54,7 +54,7 @@ {{ $t('label.name') }} - + @@ -62,26 +62,26 @@ v-decorator="['name', { rules: [{ required: true, message: $t('message.error.required.input') }] }]" - :placeholder="importRoleApiParams.name.description" + :placeholder="apiParams.name.description" autoFocus /> {{ $t('label.description') }} - + + :placeholder="apiParams.description.description" /> {{ $t('label.type') }} - + @@ -89,7 +89,7 @@ v-decorator="['type', { rules: [{ required: true, message: $t('message.error.select') }] }]" - :placeholder="importRoleApiParams.type.description"> + :placeholder="apiParams.type.description"> {{ role }} @@ -99,7 +99,7 @@ {{ $t('label.forced') }} - + @@ -133,11 +133,7 @@ export default { }, beforeCreate () { this.form = this.$form.createForm(this) - this.apiConfig = this.$store.getters.apis.importRole || {} - this.importRoleApiParams = {} - this.apiConfig.params.forEach(param => { - this.importRoleApiParams[param.name] = param - }) + this.apiParams = this.$getApiParams('importRole') }, methods: { handleRemove (file) { diff --git a/ui/src/views/image/AddKubernetesSupportedVersion.vue b/ui/src/views/image/AddKubernetesSupportedVersion.vue index 863be6328de..d3355152e81 100644 --- a/ui/src/views/image/AddKubernetesSupportedVersion.vue +++ b/ui/src/views/image/AddKubernetesSupportedVersion.vue @@ -177,11 +177,7 @@ export default { }, beforeCreate () { this.form = this.$form.createForm(this) - this.apiConfig = this.$store.getters.apis.addKubernetesSupportedVersion || {} - this.apiParams = {} - this.apiConfig.params.forEach(param => { - this.apiParams[param.name] = param - }) + this.apiParams = this.$getApiParams('addKubernetesSupportedVersion') }, created () { this.zones = [ diff --git a/ui/src/views/image/IsoZones.vue b/ui/src/views/image/IsoZones.vue index 2e987014358..a4b089cd2b1 100644 --- a/ui/src/views/image/IsoZones.vue +++ b/ui/src/views/image/IsoZones.vue @@ -158,11 +158,7 @@ export default { }, beforeCreate () { this.form = this.$form.createForm(this) - this.apiConfigParams = (this.$store.getters.apis.copyIso && this.$store.getters.apis.copyIso.params) || [] - this.apiParams = {} - this.apiConfigParams.forEach(param => { - this.apiParams[param.name] = param - }) + this.apiParams = this.$getApiParams('copyIso') }, created () { this.columns = [ diff --git a/ui/src/views/image/RegisterOrUploadIso.vue b/ui/src/views/image/RegisterOrUploadIso.vue index b2284df3e4e..0cdc6e75c35 100644 --- a/ui/src/views/image/RegisterOrUploadIso.vue +++ b/ui/src/views/image/RegisterOrUploadIso.vue @@ -193,11 +193,7 @@ export default { }, beforeCreate () { this.form = this.$form.createForm(this) - this.apiConfig = this.$store.getters.apis.registerIso || {} - this.apiParams = {} - this.apiConfig.params.forEach(param => { - this.apiParams[param.name] = param - }) + this.apiParams = this.$getApiParams('registerIso') }, created () { this.zones = [] diff --git a/ui/src/views/image/RegisterOrUploadTemplate.vue b/ui/src/views/image/RegisterOrUploadTemplate.vue index db18b3a6248..4e3ed435ab3 100644 --- a/ui/src/views/image/RegisterOrUploadTemplate.vue +++ b/ui/src/views/image/RegisterOrUploadTemplate.vue @@ -403,11 +403,7 @@ export default { }, beforeCreate () { this.form = this.$form.createForm(this) - this.apiConfig = this.$store.getters.apis.registerTemplate || {} - this.apiParams = {} - this.apiConfig.params.forEach(param => { - this.apiParams[param.name] = param - }) + this.apiParams = this.$getApiParams('registerTemplate') }, created () { this.$set(this.zones, 'loading', false) diff --git a/ui/src/views/image/TemplateZones.vue b/ui/src/views/image/TemplateZones.vue index 20551202c03..89bbdd75e34 100644 --- a/ui/src/views/image/TemplateZones.vue +++ b/ui/src/views/image/TemplateZones.vue @@ -169,11 +169,7 @@ export default { }, beforeCreate () { this.form = this.$form.createForm(this) - this.apiConfigParams = (this.$store.getters.apis.copyTemplate && this.$store.getters.apis.copyTemplate.params) || [] - this.apiParams = {} - this.apiConfigParams.forEach(param => { - this.apiParams[param.name] = param - }) + this.apiParams = this.$getApiParams('copyTemplate') }, created () { this.columns = [ diff --git a/ui/src/views/image/UpdateKubernetesSupportedVersion.vue b/ui/src/views/image/UpdateKubernetesSupportedVersion.vue index 93e4d459842..114086884da 100644 --- a/ui/src/views/image/UpdateKubernetesSupportedVersion.vue +++ b/ui/src/views/image/UpdateKubernetesSupportedVersion.vue @@ -71,11 +71,7 @@ export default { }, beforeCreate () { this.form = this.$form.createForm(this) - this.apiConfig = this.$store.getters.apis.updateKubernetesSupportedVersion || {} - this.apiParams = {} - this.apiConfig.params.forEach(param => { - this.apiParams[param.name] = param - }) + this.apiParams = this.$getApiParams('updateKubernetesSupportedVersion') }, created () { this.states = [ diff --git a/ui/src/views/infra/AddPrimaryStorage.vue b/ui/src/views/infra/AddPrimaryStorage.vue index 061f84ce5f9..c923bb4ef7e 100644 --- a/ui/src/views/infra/AddPrimaryStorage.vue +++ b/ui/src/views/infra/AddPrimaryStorage.vue @@ -337,11 +337,7 @@ export default { }, beforeCreate () { this.form = this.$form.createForm(this) - this.apiParams = {} - var apiConfig = this.$store.getters.apis.createStoragePool || {} - apiConfig.params.forEach(param => { - this.apiParams[param.name] = param - }) + this.apiParams = this.$getApiParams('createStoragePool') }, created () { this.fetchData() diff --git a/ui/src/views/infra/InfraSummary.vue b/ui/src/views/infra/InfraSummary.vue index 46707a40021..444669e1345 100644 --- a/ui/src/views/infra/InfraSummary.vue +++ b/ui/src/views/infra/InfraSummary.vue @@ -215,11 +215,7 @@ export default { }, beforeCreate () { this.form = this.$form.createForm(this) - this.apiParams = {} - var apiConfig = this.$store.getters.apis.uploadCustomCertificate || {} - apiConfig.params.forEach(param => { - this.apiParams[param.name] = param - }) + this.apiParams = this.$getApiParams('uploadCustomCertificate') }, created () { this.fetchData() diff --git a/ui/src/views/infra/network/EditTrafficLabel.vue b/ui/src/views/infra/network/EditTrafficLabel.vue index 559e85756f5..aad05f1f13e 100644 --- a/ui/src/views/infra/network/EditTrafficLabel.vue +++ b/ui/src/views/infra/network/EditTrafficLabel.vue @@ -136,13 +136,7 @@ export default { }, beforeCreate () { this.form = this.$form.createForm(this) - this.apiConfig = this.$store.getters.apis.updateTrafficType || {} - this.apiParams = {} - if (this.apiConfig.params) { - this.apiConfig.params.forEach(param => { - this.apiParams[param.name] = param - }) - } + this.apiParams = this.$getApiParams('updateTrafficType') }, inject: ['parentFetchData'], created () { diff --git a/ui/src/views/infra/routers/RouterHealthCheck.vue b/ui/src/views/infra/routers/RouterHealthCheck.vue index 86ff8e4d1af..897ca7e34ff 100644 --- a/ui/src/views/infra/routers/RouterHealthCheck.vue +++ b/ui/src/views/infra/routers/RouterHealthCheck.vue @@ -120,11 +120,7 @@ export default { }, beforeCreate () { this.form = this.$form.createForm(this) - this.apiConfigParams = (this.$store.getters.apis.getRouterHealthCheckResults && this.$store.getters.apis.getRouterHealthCheckResults.params) || [] - this.apiParams = {} - this.apiConfigParams.forEach(param => { - this.apiParams[param.name] = param - }) + this.apiParams = this.$getApiParams('getRouterHealthCheckResults') }, watch: { resource: function (newItem, oldItem) { diff --git a/ui/src/views/network/CreateIsolatedNetworkForm.vue b/ui/src/views/network/CreateIsolatedNetworkForm.vue index 135e6bc3ff1..8bda05378c3 100644 --- a/ui/src/views/network/CreateIsolatedNetworkForm.vue +++ b/ui/src/views/network/CreateIsolatedNetworkForm.vue @@ -290,11 +290,7 @@ export default { }, beforeCreate () { this.form = this.$form.createForm(this) - this.apiConfig = this.$store.getters.apis.createNetwork || {} - this.apiParams = {} - this.apiConfig.params.forEach(param => { - this.apiParams[param.name] = param - }) + this.apiParams = this.$getApiParams('createNetwork') }, created () { this.domains = [ diff --git a/ui/src/views/network/CreateL2NetworkForm.vue b/ui/src/views/network/CreateL2NetworkForm.vue index 9771e282238..45860e80b82 100644 --- a/ui/src/views/network/CreateL2NetworkForm.vue +++ b/ui/src/views/network/CreateL2NetworkForm.vue @@ -262,11 +262,7 @@ export default { }, beforeCreate () { this.form = this.$form.createForm(this) - this.apiConfig = this.$store.getters.apis.createNetwork || {} - this.apiParams = {} - this.apiConfig.params.forEach(param => { - this.apiParams[param.name] = param - }) + this.apiParams = this.$getApiParams('createNetwork') }, created () { this.domains = [ diff --git a/ui/src/views/network/CreateSharedNetworkForm.vue b/ui/src/views/network/CreateSharedNetworkForm.vue index e2556047380..d2356dbc73a 100644 --- a/ui/src/views/network/CreateSharedNetworkForm.vue +++ b/ui/src/views/network/CreateSharedNetworkForm.vue @@ -468,11 +468,7 @@ export default { }, beforeCreate () { this.form = this.$form.createForm(this) - this.apiConfig = this.$store.getters.apis.createNetwork || {} - this.apiParams = {} - this.apiConfig.params.forEach(param => { - this.apiParams[param.name] = param - }) + this.apiParams = this.$getApiParams('createNetwork') }, created () { this.fetchData() diff --git a/ui/src/views/network/CreateVlanIpRange.vue b/ui/src/views/network/CreateVlanIpRange.vue index 60f638ee423..99c0edc37b2 100644 --- a/ui/src/views/network/CreateVlanIpRange.vue +++ b/ui/src/views/network/CreateVlanIpRange.vue @@ -214,11 +214,7 @@ export default { }, created () { this.form = this.$form.createForm(this) - this.apiConfig = this.$store.getters.apis.createVlanIpRange || {} - this.apiParams = {} - this.apiConfig.params.forEach(param => { - this.apiParams[param.name] = param - }) + this.apiParams = this.$getApiParams('createVlanIpRange') this.fetchData() }, methods: { diff --git a/ui/src/views/network/CreateVpc.vue b/ui/src/views/network/CreateVpc.vue index 4d3ebffd03a..91662a0b0e6 100644 --- a/ui/src/views/network/CreateVpc.vue +++ b/ui/src/views/network/CreateVpc.vue @@ -141,11 +141,7 @@ export default { }, beforeCreate () { this.form = this.$form.createForm(this) - this.apiParams = {} - var apiConfig = this.$store.getters.apis.createVPC || [] - apiConfig.params.forEach(param => { - this.apiParams[param.name] = param - }) + this.apiParams = this.$getApiParams('createVPC') }, created () { this.fetchData() diff --git a/ui/src/views/network/CreateVpnCustomerGateway.vue b/ui/src/views/network/CreateVpnCustomerGateway.vue index 666bece867b..bc62ba2549f 100644 --- a/ui/src/views/network/CreateVpnCustomerGateway.vue +++ b/ui/src/views/network/CreateVpnCustomerGateway.vue @@ -326,11 +326,7 @@ export default { }, beforeCreate () { this.form = this.$form.createForm(this) - this.apiParams = {} - var apiConfig = this.$store.getters.apis.createVpnCustomerGateway || {} - apiConfig.params.forEach(param => { - this.apiParams[param.name] = param - }) + this.apiParams = this.$getApiParams('createVpnCustomerGateway') }, methods: { closeModal () { diff --git a/ui/src/views/offering/AddComputeOffering.vue b/ui/src/views/offering/AddComputeOffering.vue index 1c13dc3dca1..b1e2c1d593b 100644 --- a/ui/src/views/offering/AddComputeOffering.vue +++ b/ui/src/views/offering/AddComputeOffering.vue @@ -806,11 +806,7 @@ export default { this.selectedZoneIndex = values.zoneid } }) - this.apiParams = {} - var apiConfig = this.$store.getters.apis.createServiceOffering || {} - apiConfig.params.forEach(param => { - this.apiParams[param.name] = param - }) + this.apiParams = this.$getApiParams('createServiceOffering') }, created () { this.zones = [ diff --git a/ui/src/views/offering/AddDiskOffering.vue b/ui/src/views/offering/AddDiskOffering.vue index 0b724b69a11..61c3bbee438 100644 --- a/ui/src/views/offering/AddDiskOffering.vue +++ b/ui/src/views/offering/AddDiskOffering.vue @@ -471,11 +471,7 @@ export default { this.selectedZoneIndex = values.zoneid } }) - this.apiParams = {} - var apiConfig = this.$store.getters.apis.createDiskOffering || {} - apiConfig.params.forEach(param => { - this.apiParams[param.name] = param - }) + this.apiParams = this.$getApiParams('createDiskOffering') }, created () { this.zones = [ diff --git a/ui/src/views/offering/AddNetworkOffering.vue b/ui/src/views/offering/AddNetworkOffering.vue index 910bc2bb8ab..9c244d631e9 100644 --- a/ui/src/views/offering/AddNetworkOffering.vue +++ b/ui/src/views/offering/AddNetworkOffering.vue @@ -512,11 +512,7 @@ export default { }, beforeCreate () { this.form = this.$form.createForm(this) - this.apiParams = {} - var apiConfig = this.$store.getters.apis.createNetworkOffering || {} - apiConfig.params.forEach(param => { - this.apiParams[param.name] = param - }) + this.apiParams = this.$getApiParams('createNetworkOffering') }, created () { this.zones = [ diff --git a/ui/src/views/offering/AddVpcOffering.vue b/ui/src/views/offering/AddVpcOffering.vue index cbe2db18cad..9b3f10e49f0 100644 --- a/ui/src/views/offering/AddVpcOffering.vue +++ b/ui/src/views/offering/AddVpcOffering.vue @@ -192,11 +192,7 @@ export default { }, beforeCreate () { this.form = this.$form.createForm(this) - this.apiParams = {} - var apiConfig = this.$store.getters.apis.createVPCOffering || {} - apiConfig.params.forEach(param => { - this.apiParams[param.name] = param - }) + this.apiParams = this.$getApiParams('createVPCOffering') }, created () { this.zones = [ diff --git a/ui/src/views/offering/ImportBackupOffering.vue b/ui/src/views/offering/ImportBackupOffering.vue index 370b908798b..39686822dd7 100644 --- a/ui/src/views/offering/ImportBackupOffering.vue +++ b/ui/src/views/offering/ImportBackupOffering.vue @@ -123,11 +123,7 @@ export default { }, beforeCreate () { this.form = this.$form.createForm(this) - this.apiParams = {} - var apiConfig = this.$store.getters.apis.importBackupOffering || {} - apiConfig.params.forEach(param => { - this.apiParams[param.name] = param - }) + this.apiParams = this.$getApiParams('importBackupOffering') }, created () { this.fetchData() diff --git a/ui/src/views/project/AddAccountOrUserToProject.vue b/ui/src/views/project/AddAccountOrUserToProject.vue index f65cdc6ae04..067b58125c5 100644 --- a/ui/src/views/project/AddAccountOrUserToProject.vue +++ b/ui/src/views/project/AddAccountOrUserToProject.vue @@ -193,12 +193,7 @@ export default { } this.apiParams = {} for (var api of apis) { - const details = {} - const apiConfig = this.$store.getters.apis[api] - apiConfig.params.forEach(param => { - details[param.name] = param - }) - this.apiParams[api] = details + this.apiParams[api] = this.$getApiParams(api) } }, methods: { diff --git a/ui/src/views/project/InvitationTokenTemplate.vue b/ui/src/views/project/InvitationTokenTemplate.vue index b510e39a704..29054da9a81 100644 --- a/ui/src/views/project/InvitationTokenTemplate.vue +++ b/ui/src/views/project/InvitationTokenTemplate.vue @@ -56,11 +56,7 @@ export default { name: 'InvitationTokenTemplate', beforeCreate () { this.form = this.$form.createForm(this) - this.apiConfig = this.$store.getters.apis.updateProjectInvitation || {} - this.apiParams = {} - this.apiConfig.params.forEach(param => { - this.apiParams[param.name] = param - }) + this.apiParams = this.$getApiParams('updateProjectInvitation') }, data () { return { diff --git a/ui/src/views/project/InvitationsTemplate.vue b/ui/src/views/project/InvitationsTemplate.vue index f6adc6e0013..36d116eb39b 100644 --- a/ui/src/views/project/InvitationsTemplate.vue +++ b/ui/src/views/project/InvitationsTemplate.vue @@ -156,11 +156,7 @@ export default { this.page = 1 this.pageSize = 10 this.itemCount = 0 - this.apiConfig = this.$store.getters.apis.listProjectInvitations || {} - this.apiParams = {} - this.apiConfig.params.forEach(param => { - this.apiParams[param.name] = param - }) + this.apiParams = this.$getApiParams('listProjectInvitations') if (this.apiParams.userid) { this.columns.splice(2, 0, { title: this.$t('label.user'), diff --git a/ui/src/views/storage/AttachVolume.vue b/ui/src/views/storage/AttachVolume.vue index fd859d3daef..a3e358e7e09 100644 --- a/ui/src/views/storage/AttachVolume.vue +++ b/ui/src/views/storage/AttachVolume.vue @@ -62,11 +62,7 @@ export default { }, beforeCreate () { this.form = this.$form.createForm(this) - this.apiConfig = this.$store.getters.apis.attachVolume || {} - this.apiParams = {} - this.apiConfig.params.forEach(param => { - this.apiParams[param.name] = param - }) + this.apiParams = this.$getApiParams('attachVolume') }, created () { this.fetchData() diff --git a/ui/src/views/storage/CreateVolume.vue b/ui/src/views/storage/CreateVolume.vue index a27ca6332b1..3feacb843e9 100644 --- a/ui/src/views/storage/CreateVolume.vue +++ b/ui/src/views/storage/CreateVolume.vue @@ -114,11 +114,7 @@ export default { }, beforeCreate () { this.form = this.$form.createForm(this) - this.apiParams = {} - var apiConfig = this.$store.getters.apis.createVolume || {} - apiConfig.params.forEach(param => { - this.apiParams[param.name] = param - }) + this.apiParams = this.$getApiParams('createVolume') }, created () { this.fetchData() diff --git a/ui/src/views/storage/TakeSnapshot.vue b/ui/src/views/storage/TakeSnapshot.vue index c6de71f4bca..7ec0053db66 100644 --- a/ui/src/views/storage/TakeSnapshot.vue +++ b/ui/src/views/storage/TakeSnapshot.vue @@ -123,11 +123,7 @@ export default { }, beforeCreate () { this.form = this.$form.createForm(this) - this.apiConfig = this.$store.getters.apis.createSnapshot || {} - this.apiParams = {} - this.apiConfig.params.forEach(param => { - this.apiParams[param.name] = param - }) + this.apiParams = this.$getApiParams('createSnapshot') }, mounted () { this.quiescevm = this.resource.quiescevm diff --git a/ui/src/views/storage/UploadLocalVolume.vue b/ui/src/views/storage/UploadLocalVolume.vue index 7a37182bbec..49961e86f68 100644 --- a/ui/src/views/storage/UploadLocalVolume.vue +++ b/ui/src/views/storage/UploadLocalVolume.vue @@ -142,11 +142,7 @@ export default { }, beforeCreate () { this.form = this.$form.createForm(this) - this.apiParams = {} - var apiConfig = this.$store.getters.apis.getUploadParamsForVolume || {} - apiConfig.params.forEach(param => { - this.apiParams[param.name] = param - }) + this.apiParams = this.$getApiParams('getUploadParamsForVolume') }, created () { this.listZones() diff --git a/ui/tests/common/index.js b/ui/tests/common/index.js index e9c8deb0321..628e059f3e4 100644 --- a/ui/tests/common/index.js +++ b/ui/tests/common/index.js @@ -21,11 +21,12 @@ import mockRouter from '../mock/mockRouter' import localVue from '../setup' import { mount } from '@vue/test-utils' -import { pollJobPlugin, notifierPlugin, configUtilPlugin } from '@/utils/plugins' +import { pollJobPlugin, notifierPlugin, configUtilPlugin, apiMetaUtilPlugin } from '@/utils/plugins' localVue.use(pollJobPlugin) localVue.use(notifierPlugin) localVue.use(configUtilPlugin) +localVue.use(apiMetaUtilPlugin) function createMockRouter (newRoutes = []) { let routes = []