ui: Moves fetchdata() to the created() (#4811)

This PR to move fetchData() to created() insteadof mount()
This commit is contained in:
Hoang Nguyen 2021-04-05 15:58:00 +07:00 committed by GitHub
parent 43257f8300
commit 4dcd9a2329
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
113 changed files with 161 additions and 214 deletions

View File

@ -58,7 +58,7 @@ export default {
loading: false
}
},
mounted () {
created () {
this.fetchData()
},
methods: {

View File

@ -57,7 +57,7 @@ export default {
loading: false
}
},
mounted () {
created () {
this.fetchData()
},
methods: {

View File

@ -64,7 +64,7 @@ export default {
this.domainError = this.error
}
},
mounted () {
created () {
this.fetchData()
},
methods: {

View File

@ -150,7 +150,7 @@ export default {
this.updateResource(newItem)
}
},
mounted () {
created () {
this.updateResource(this.resource)
},
methods: {

View File

@ -143,7 +143,7 @@ export default {
}
}
},
mounted () {
created () {
this.fetchData()
},
methods: {

View File

@ -73,7 +73,7 @@ export default {
beforeCreate () {
this.form = this.$form.createForm(this)
},
mounted () {
created () {
this.fetchData()
},
watch: {

View File

@ -120,7 +120,7 @@ export default {
this.scopeKey = ''
}
},
mounted () {
created () {
this.fetchData()
},
watch: {

View File

@ -424,8 +424,7 @@ export default {
eventBus.$on('exec-action', (action, isGroupAction) => {
this.execAction(action, isGroupAction)
})
},
mounted () {
if (this.device === 'desktop') {
this.pageSize = 20
}

View File

@ -134,8 +134,6 @@ export default {
}
},
created () {
},
mounted () {
this.fetchData()
},
methods: {

View File

@ -119,7 +119,7 @@ export default {
loading: false
}
},
mounted () {
created () {
this.fetchData()
},
methods: {

View File

@ -64,7 +64,7 @@ export default {
beforeCreate () {
this.form = this.$form.createForm(this)
},
mounted () {
created () {
this.fetchData()
},
methods: {

View File

@ -63,7 +63,7 @@ export default {
closeSchedule: this.closeAction
}
},
mounted () {
created () {
this.fetchData()
},
methods: {

View File

@ -99,7 +99,7 @@ export default {
loading: false
}
},
mounted () {
created () {
for (const group of this.resource.affinitygroup) {
this.selectedRowKeys.push(group.id)
}

View File

@ -361,8 +361,6 @@ export default {
name: ''
}
]
},
mounted () {
this.fetchData()
},
methods: {

View File

@ -113,8 +113,6 @@ export default {
name: ''
}
]
},
mounted () {
this.fetchData()
},
methods: {

View File

@ -109,7 +109,7 @@ export default {
this.apiParams[param.name] = param
})
},
mounted () {
created () {
this.fetchData()
},
methods: {

View File

@ -1109,8 +1109,7 @@ export default {
this.form.getFieldDecorator('cpunumber', { initialValue: undefined, preserve: true })
this.form.getFieldDecorator('cpuSpeed', { initialValue: undefined, preserve: true })
this.form.getFieldDecorator('memory', { initialValue: undefined, preserve: true })
},
mounted () {
this.dataPreFill = this.preFillContent && Object.keys(this.preFillContent).length > 0 ? this.preFillContent : {}
this.fetchData()
},

View File

@ -88,7 +88,7 @@ export default {
this.apiParams[param.name] = param
})
},
mounted () {
created () {
this.fetchData()
},
methods: {

View File

@ -203,6 +203,7 @@ export default {
if (!this.isAdmin()) {
this.vmColumns = this.vmColumns.filter(x => x.dataIndex !== 'instancename')
}
this.handleFetchData()
},
watch: {
resource (newData, oldData) {
@ -220,7 +221,6 @@ export default {
}
},
mounted () {
this.handleFetchData()
this.setCurrentTab()
},
methods: {

View File

@ -132,7 +132,7 @@ export default {
]
}
},
mounted () {
created () {
this.fetchData()
},
methods: {

View File

@ -110,8 +110,6 @@ export default {
},
created () {
this.originalSize = !this.isObjectEmpty(this.resource) ? this.resource.size : 1
},
mounted () {
this.fetchData()
},
methods: {

View File

@ -84,7 +84,7 @@ export default {
memoryKey: 'details[0].memory'
}
},
mounted () {
created () {
this.fetchData({
keyword: '',
pageSize: 10,

View File

@ -149,7 +149,7 @@ export default {
this.apiParams[param.name] = param
})
},
mounted () {
created () {
if (this.$store.getters.userInfo.roletype === 'Admin') {
this.fetchPods()
this.fetchClusters()

View File

@ -90,8 +90,6 @@ export default {
})
},
created () {
},
mounted () {
this.fetchData()
},
methods: {

View File

@ -153,7 +153,7 @@ export default {
}
}
},
mounted () {
created () {
this.fetchData()
},
watch: {
@ -163,11 +163,6 @@ export default {
}
}
},
created () {
setTimeout(() => {
// to do after initial timeout
}, 1000)
},
methods: {
getStatus (value) {
if (value > 85) {

View File

@ -55,8 +55,10 @@ export default {
showOnboarding: false
}
},
mounted () {
created () {
this.fetchData()
},
mounted () {
this.showCapacityDashboard = Object.prototype.hasOwnProperty.call(store.getters.apis, 'listCapacity')
this.project = false
if (store.getters.project && store.getters.project.id) {

View File

@ -131,7 +131,7 @@ export default {
beforeCreate () {
this.form = this.$form.createForm(this)
},
mounted () {
created () {
this.project = store.getters.project
this.fetchData()
this.$store.watch(

View File

@ -257,7 +257,7 @@ export default {
})
}
},
mounted () {
created () {
this.fetchData()
},
methods: {

View File

@ -234,8 +234,6 @@ export default {
}
]
this.selectedFilter = this.filters[0].id
},
mounted () {
this.fetchData()
},
methods: {

View File

@ -229,8 +229,6 @@ export default {
this.apiConfig.params.forEach(param => {
this.apiParams[param.name] = param
})
},
mounted () {
this.fetchData()
},
methods: {

View File

@ -66,7 +66,7 @@ export default {
beforeCreate () {
this.form = this.$form.createForm(this)
},
mounted () {
created () {
this.fetchData()
},
methods: {

View File

@ -132,7 +132,7 @@ export default {
loading: false
}
},
mounted () {
created () {
this.fetchRoles()
},
beforeCreate () {

View File

@ -165,8 +165,6 @@ export default {
break
}
}
},
mounted () {
if (this.action.dataView && this.action.icon === 'edit') {
this.fillEditFormFieldValues()
}

View File

@ -125,15 +125,15 @@ export default {
beforeCreate () {
this.form = this.$form.createForm(this)
},
mounted () {
this.fetchData()
},
beforeRouteUpdate (to, from, next) {
next()
},
beforeRouteLeave (to, from, next) {
next()
},
created () {
this.fetchData()
},
watch: {
'$route' (to, from) {
if (to.fullPath !== from.fullPath && !to.fullPath.includes('action/')) {

View File

@ -137,7 +137,7 @@ export default {
this.apiParams[param.name] = param
})
},
mounted () {
created () {
this.fetchData()
},
methods: {

View File

@ -144,7 +144,7 @@ export default {
apis: []
}
},
mounted () {
created () {
this.apis = Object.keys(this.$store.getters.apis).sort((a, b) => a.localeCompare(b))
this.fetchData()
},

View File

@ -140,8 +140,6 @@ export default {
}
]
this.detailColumn = ['name', 'certificate', 'certchain']
},
mounted () {
this.fetchData()
},
methods: {

View File

@ -190,8 +190,6 @@ export default {
name: this.$t('label.all.zone')
}
]
},
mounted () {
this.fetchData()
},
methods: {

View File

@ -191,8 +191,6 @@ export default {
(userInfo.account !== this.resource.account || userInfo.domain !== this.resource.domain)) {
this.columns = this.columns.filter(col => { return col.dataIndex !== 'status' })
}
},
mounted () {
this.fetchData()
},
watch: {

View File

@ -411,8 +411,6 @@ export default {
this.$set(this.format, 'opts', [])
this.$set(this.osTypes, 'loading', false)
this.$set(this.osTypes, 'opts', [])
},
mounted () {
this.fetchData()
},
computed: {

View File

@ -204,8 +204,6 @@ export default {
(userInfo.account !== this.resource.account || userInfo.domain !== this.resource.domain)) {
this.columns = this.columns.filter(col => { return col.dataIndex !== 'status' })
}
},
mounted () {
this.fetchData()
},
watch: {

View File

@ -88,8 +88,6 @@ export default {
name: this.$t('state.disabled')
}
]
},
mounted () {
this.fetchData()
},
methods: {

View File

@ -145,7 +145,7 @@ export default {
) : this.projects
}
},
mounted () {
created () {
this.isImageTypeIso = this.$route.meta.name === 'iso'
this.fetchData()
},

View File

@ -343,7 +343,7 @@ export default {
this.apiParams[param.name] = param
})
},
mounted () {
created () {
this.fetchData()
},
methods: {

View File

@ -181,7 +181,7 @@ export default {
beforeCreate () {
this.form = this.$form.createForm(this)
},
mounted () {
created () {
this.fetchData()
},
methods: {

View File

@ -150,7 +150,7 @@ export default {
}
}
},
mounted () {
created () {
this.fetchData()
},
methods: {

View File

@ -73,7 +73,7 @@ export default {
columns: []
}
},
mounted () {
created () {
this.fetchData()
},
watch: {

View File

@ -171,7 +171,7 @@ export default {
}
}
},
mounted () {
created () {
this.fetchData()
},
methods: {

View File

@ -125,7 +125,7 @@ export default {
fetchLoading: false
}
},
mounted () {
created () {
this.fetchData()
},
watch: {

View File

@ -221,7 +221,7 @@ export default {
this.apiParams[param.name] = param
})
},
mounted () {
created () {
this.fetchData()
},
methods: {

View File

@ -99,7 +99,7 @@ export default {
beforeCreate () {
this.form = this.$form.createForm(this)
},
mounted () {
created () {
this.fetchImageStores()
},
methods: {

View File

@ -147,7 +147,7 @@ export default {
beforeCreate () {
this.form = this.$form.createForm(this)
},
mounted () {
created () {
this.fetchData()
},
methods: {

View File

@ -61,7 +61,7 @@ export default {
resourcesList: []
}
},
mounted () {
created () {
this.fetchData()
},
methods: {

View File

@ -184,7 +184,7 @@ export default {
beforeCreate () {
this.form = this.$form.createForm(this)
},
mounted () {
created () {
this.fetchData()
},
watch: {

View File

@ -145,7 +145,7 @@ export default {
}
},
inject: ['parentFetchData'],
mounted () {
created () {
this.fetchData()
},
methods: {

View File

@ -40,7 +40,7 @@ export default {
fetchLoading: false
}
},
mounted () {
created () {
this.fetchData()
},
watch: {

View File

@ -129,7 +129,7 @@ export default {
]
}
},
mounted () {
created () {
this.fetchData()
},
watch: {

View File

@ -192,7 +192,7 @@ export default {
beforeCreate () {
this.form = this.$form.createForm(this)
},
mounted () {
created () {
this.fetchData()
},
watch: {

View File

@ -271,7 +271,7 @@ export default {
beforeCreate () {
this.form = this.$form.createForm(this)
},
mounted () {
created () {
this.fetchData()
},
watch: {

View File

@ -180,7 +180,7 @@ export default {
beforeCreate () {
this.form = this.$form.createForm(this)
},
mounted () {
created () {
this.fetchData()
},
watch: {

View File

@ -35,7 +35,8 @@
:itemNsp="item"
:nsp="nsps[item.title]"
:resourceId="resource.id"
:zoneId="resource.zoneid"/>
:zoneId="resource.zoneid"
:tabKey="tabKey"/>
</a-tab-pane>
</a-tabs>
</a-spin>
@ -1107,7 +1108,7 @@ export default {
beforeCreate () {
this.form = this.$form.createForm(this)
},
mounted () {
created () {
this.fetchData()
},
watch: {
@ -1128,6 +1129,9 @@ export default {
},
methods: {
fetchData () {
if (!this.resource || !('id' in this.resource)) {
return
}
this.fetchServiceProvider()
},
fetchServiceProvider (name) {

View File

@ -89,7 +89,7 @@ export default {
fetchLoading: false
}
},
mounted () {
created () {
if (this.resource.id) {
this.fetchData()
}

View File

@ -103,45 +103,38 @@ export default {
},
inject: ['provideSetNsp', 'provideExecuteAction'],
watch: {
loading (newValue, oldValue) {
if (newValue !== oldValue && !newValue) {
this.fetchData()
}
},
nsp (newData, oldData) {
if (newData && Object.keys(newData).length > 0) {
this.nsp = newData
this.resource = this.nsp
this.$set(this.resource, 'zoneid', this.zoneId)
this.provideSetNsp(this.resource)
this.fetchData()
}
}
},
mounted () {
if (!this.nsp || Object.keys(this.nsp).length === 0) {
this.resource = {
name: this.itemNsp.title,
state: 'Disabled',
physicalnetworkid: this.resourceId,
zoneid: this.zoneId
}
} else {
this.resource = this.nsp
this.$set(this.resource, 'zoneid', this.zoneId)
}
if (this.itemNsp && Object.keys(this.itemNsp).length > 0) {
this.provider = this.itemNsp
this.provideSetNsp(this.resource)
nsp () {
this.fetchData()
}
},
created () {
if (!this.resourceId || !this.zoneId) {
return
}
this.fetchData()
},
methods: {
async fetchData () {
if (!this.provider.lists || this.provider.lists.length === 0) {
return
if (!this.nsp || Object.keys(this.nsp).length === 0) {
this.resource = {
name: this.itemNsp.title,
state: 'Disabled',
physicalnetworkid: this.resourceId,
zoneid: this.zoneId
}
} else {
this.resource = this.nsp
this.$set(this.resource, 'zoneid', this.zoneId)
}
if (this.itemNsp && Object.keys(this.itemNsp).length > 0) {
this.provider = this.itemNsp
this.provideSetNsp(this.resource)
if (!this.provider.lists || this.provider.lists.length === 0) {
return
}
this.provider.lists.map(this.fetchOptions)
}
this.provider.lists.map(this.fetchOptions)
},
async fetchOptions (args) {
if (!args || Object.keys(args).length === 0) {

View File

@ -131,7 +131,7 @@ export default {
this.updateResource(newItem)
}
},
mounted () {
created () {
this.updateResource(this.resource)
},
methods: {

View File

@ -85,7 +85,7 @@ export default {
fetchLoading: false
}
},
mounted () {
created () {
this.fetchData()
},
watch: {

View File

@ -93,7 +93,7 @@ export default {
fetchLoading: false
}
},
mounted () {
created () {
this.fetchData()
},
watch: {

View File

@ -699,7 +699,7 @@ export default {
options: ['primaryStorageScope', 'primaryStorageProtocol', 'provider']
}
},
mounted () {
created () {
this.currentStep = this.prefillContent.resourceStep ? this.prefillContent.resourceStep : 0
if (this.stepChild && this.stepChild !== '') {
this.currentStep = this.steps.findIndex(item => item.fromKey === this.stepChild)

View File

@ -369,7 +369,7 @@ export default {
]
}
},
mounted () {
created () {
this.physicalNetworks = this.prefillContent.physicalNetworks
this.steps = this.filteredSteps()
this.currentStep = this.prefillContent.networkStep ? this.prefillContent.networkStep : 0

View File

@ -394,6 +394,8 @@ export default {
this.$emit('fieldsChanged', changedFields)
}
})
this.fetchData()
},
mounted () {
this.form.setFieldsValue({
@ -414,41 +416,6 @@ export default {
localstorageenabled: this.localstorageenabled,
localstorageenabledforsystemvm: this.localstorageenabledforsystemvm
})
const cForm = this.form
api('listHypervisors', { listAll: true }).then(json => {
this.hypervisors = json.listhypervisorsresponse.hypervisor
if ('listSimulatorHAStateTransitions' in this.$store.getters.apis) {
this.hypervisors.push({ name: 'Simulator' })
}
cForm.setFieldsValue({
hypervisor: this.currentHypervisor
})
})
if (!this.isAdvancedZone || this.securityGroupsEnabled) {
api('listNetworkOfferings', { state: 'Enabled', guestiptype: 'Shared' }).then(json => {
this.networkOfferings = {}
json.listnetworkofferingsresponse.networkoffering.forEach(offering => {
this.setupNetworkOfferingAdditionalFlags(offering)
this.networkOfferings[offering.id] = offering
})
this.availableNetworkOfferings = this.getAvailableNetworkOfferings(this.currentHypervisor)
cForm.setFieldsValue({
networkOfferingId: this.currentNetworkOfferingId
})
})
}
api('listDomains', { listAll: true }).then(json => {
this.domains = {}
json.listdomainsresponse.domain.forEach(dom => {
this.domains[dom.id] = dom
})
cForm.setFieldsValue({
domain: this.domain
})
})
},
computed: {
isAdvancedZone () {
@ -532,6 +499,42 @@ export default {
}
},
methods: {
fetchData () {
const cForm = this.form
api('listHypervisors', { listAll: true }).then(json => {
this.hypervisors = json.listhypervisorsresponse.hypervisor
if ('listSimulatorHAStateTransitions' in this.$store.getters.apis) {
this.hypervisors.push({ name: 'Simulator' })
}
cForm.setFieldsValue({
hypervisor: this.currentHypervisor
})
})
if (!this.isAdvancedZone || this.securityGroupsEnabled) {
api('listNetworkOfferings', { state: 'Enabled', guestiptype: 'Shared' }).then(json => {
this.networkOfferings = {}
json.listnetworkofferingsresponse.networkoffering.forEach(offering => {
this.setupNetworkOfferingAdditionalFlags(offering)
this.networkOfferings[offering.id] = offering
})
this.availableNetworkOfferings = this.getAvailableNetworkOfferings(this.currentHypervisor)
cForm.setFieldsValue({
networkOfferingId: this.currentNetworkOfferingId
})
})
}
api('listDomains', { listAll: true }).then(json => {
this.domains = {}
json.listdomainsresponse.domain.forEach(dom => {
this.domains[dom.id] = dom
})
cForm.setFieldsValue({
domain: this.domain
})
})
},
handleSubmit (e) {
e.preventDefault()
this.form.validateFields((err, values) => {

View File

@ -229,7 +229,7 @@ export default {
ruleFormMode: 'edit'
}
},
mounted () {
created () {
this.fetchData()
},
watch: {

View File

@ -303,8 +303,6 @@ export default {
name: ' '
}
]
},
mounted () {
this.fetchData()
},
methods: {

View File

@ -275,8 +275,6 @@ export default {
name: ' '
}
]
},
mounted () {
this.fetchData()
},
methods: {

View File

@ -475,8 +475,6 @@ export default {
})
},
created () {
},
mounted () {
this.fetchData()
},
methods: {

View File

@ -147,7 +147,7 @@ export default {
this.apiParams[param.name] = param
})
},
mounted () {
created () {
this.fetchData()
},
methods: {

View File

@ -156,7 +156,7 @@ export default {
]
}
},
mounted () {
created () {
this.fetchData()
},
filters: {

View File

@ -155,7 +155,7 @@ export default {
pageSize: 10
}
},
mounted () {
created () {
this.fetchData()
},
methods: {

View File

@ -198,7 +198,7 @@ export default {
]
}
},
mounted () {
created () {
this.fetchData()
},
filters: {

View File

@ -147,7 +147,7 @@ export default {
]
}
},
mounted () {
created () {
this.fetchData()
},
watch: {

View File

@ -256,7 +256,7 @@ export default {
return val.toUpperCase()
}
},
mounted () {
created () {
this.fetchData()
},
methods: {

View File

@ -119,7 +119,7 @@ export default {
fetchLoading: false
}
},
mounted () {
created () {
this.fetchData()
},
methods: {

View File

@ -97,7 +97,7 @@ export default {
]
}
},
mounted () {
created () {
this.fetchData()
},
watch: {

View File

@ -189,7 +189,7 @@ export default {
listPublicIpAddress: []
}
},
mounted () {
created () {
this.fetchData()
},
watch: {

View File

@ -521,7 +521,7 @@ export default {
searchQuery: null
}
},
mounted () {
created () {
this.fetchData()
},
watch: {

View File

@ -367,7 +367,7 @@ export default {
searchQuery: null
}
},
mounted () {
created () {
this.fetchData()
},
watch: {

View File

@ -85,7 +85,7 @@ export default {
}
}
},
mounted () {
created () {
if ('id' in this.resource) {
this.fetchData()
}

View File

@ -103,7 +103,7 @@ export default {
]
}
},
mounted () {
created () {
this.fetchData()
},
watch: {

View File

@ -101,7 +101,7 @@ export default {
newRoute: null
}
},
mounted () {
created () {
this.fetchData()
},
watch: {

View File

@ -408,7 +408,7 @@ export default {
this.setCurrentTab()
}
},
mounted () {
created () {
this.handleFetchData()
this.setCurrentTab()
},

View File

@ -373,7 +373,7 @@ export default {
}
}
},
mounted () {
created () {
this.fetchData()
},
watch: {

View File

@ -86,7 +86,7 @@ export default {
}
},
inject: ['parentFetchData', 'parentToggleLoading'],
mounted () {
created () {
this.fetchData()
},
watch: {

View File

@ -819,8 +819,6 @@ export default {
name: this.$t('label.all.zone')
}
]
},
mounted () {
if (this.$route.meta.name === 'systemoffering') {
this.isSystem = true
}

View File

@ -484,8 +484,6 @@ export default {
name: this.$t('label.all.zone')
}
]
},
mounted () {
this.fetchData()
this.isPublic = this.isAdmin()
},

View File

@ -525,8 +525,6 @@ export default {
name: this.$t('label.all.zone')
}
]
},
mounted () {
this.fetchData()
},
methods: {

View File

@ -205,8 +205,6 @@ export default {
name: this.$t('label.all.zone')
}
]
},
mounted () {
this.fetchData()
},
methods: {

View File

@ -129,7 +129,7 @@ export default {
this.apiParams[param.name] = param
})
},
mounted () {
created () {
this.fetchData()
},
inject: ['parentFetchData'],

View File

@ -148,8 +148,6 @@ export default {
name: this.$t('label.all.zone')
}
]
},
mounted () {
this.fetchData()
},
methods: {

View File

@ -34,7 +34,7 @@ import { api } from '@/api'
export default {
name: 'CloudianPlugin',
mounted () {
created () {
this.doSso()
},
data () {

View File

@ -75,7 +75,7 @@ export default {
loading: false
}
},
mounted () {
created () {
this.fetchData()
},
methods: {

View File

@ -93,7 +93,7 @@ export default {
}
}
},
mounted () {
created () {
this.fetchData()
},
methods: {

View File

@ -51,7 +51,7 @@ export default {
pattern: 'YYYY-MM-DD'
}
},
mounted () {
created () {
this.fetchData()
},
watch: {

Some files were not shown because too many files have changed in this diff Show More