Skip to content

Commit

Permalink
Fix compose memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
katrinDY committed Aug 18, 2023
1 parent b96ea0e commit 95cf245
Show file tree
Hide file tree
Showing 76 changed files with 869 additions and 33 deletions.
15 changes: 15 additions & 0 deletions client/web/compose/src/components/Admin/Module/DalSettings.vue
Expand Up @@ -195,6 +195,10 @@ export default {
this.fetchConnections()
},
beforeDestroy () {
this.setDefaultValues()
},
methods: {
async fetchConnections () {
this.processing = true
Expand Down Expand Up @@ -263,6 +267,17 @@ export default {
getOptionKey ({ connectionID }) {
return connectionID
},
setDefaultValues () {
this.processing = false
this.connections = []
this.moduleFields = []
this.moduleFieldEncoding = []
this.selectedGroup = ''
this.systemFields = []
this.systemFieldEncoding = []
this.optionsGroups = []
},
},
}
</script>
Expand Up @@ -153,13 +153,18 @@ export default {
const fields = [...existingFields].map(name => this.module.fields.find(field => field.name === name))
this[value].result.push({ lang, fields })
existingFields.clear()
})
})
}
},
},
},
beforeDestroy () {
this.setDefaultValues()
},
methods: {
onSave () {
const discovery = {
Expand All @@ -182,6 +187,14 @@ export default {
discovery,
})
},
setDefaultValues () {
this.public = {}
this.private = {}
this.protected = {}
this.currentTabIndex = 0
this.currentLang = undefined
},
},
}
</script>
Expand Down
Expand Up @@ -295,7 +295,6 @@ export default {
},
computed: {
//
// shared modules
//
Expand Down Expand Up @@ -382,6 +381,10 @@ export default {
this.preload()
},
beforeDestroy () {
this.setDefaultValues()
},
methods: {
async preload () {
await this.$FederationAPI.nodeSearch({ status: 'paired' })
Expand Down Expand Up @@ -732,6 +735,19 @@ export default {
this.moduleMappings[nodeID] = mm
},
setDefaultValues () {
this.showModal = false
this.servers = []
this.moduleFields = []
this.sharedModule = null
this.sharedModules = {}
this.sharedModulesMapped = {}
this.exposedModules = {}
this.moduleMappings = {}
this.downstream = {}
this.upstream = {}
},
},
}
</script>
Expand Down
Expand Up @@ -68,10 +68,18 @@ export default {
})
},
beforeDestroy () {
this.setDefaultValues()
},
methods: {
onSave () {
this.$emit('updateFields', this.filteredFields)
},
setDefaultValues () {
this.filteredFields = []
},
},
}
</script>
Expand Down
10 changes: 10 additions & 0 deletions client/web/compose/src/components/Admin/Page/Builder/Selector.vue
Expand Up @@ -222,6 +222,10 @@ export default {
}
},
beforeDestroy () {
this.setDefaultValues()
},
methods: {
isOptionDisabled (type) {
return (!this.recordPage && type.recordPageOnly) || this.disabledKinds.includes(type.block.kind)
Expand All @@ -230,6 +234,12 @@ export default {
getBlockLabel ({ title, kind }) {
return title || kind
},
setDefaultValues () {
this.current = undefined
this.selectedExistingBlock = undefined
this.types = []
},
},
}
</script>
13 changes: 13 additions & 0 deletions client/web/compose/src/components/Chart/Report/GenericChart.vue
Expand Up @@ -519,6 +519,10 @@ export default {
}
},
beforeDestroy () {
this.setDefaultValues()
},
methods: {
hasRelativeDisplay: compose.chartUtil.hasRelativeDisplay,
Expand All @@ -536,6 +540,15 @@ export default {
chartTypeChanged (metric) {
metric.relativeValue = false
},
setDefaultValues () {
this.chartTypes = []
this.legendPositions = []
this.axisLabelPositions = []
this.tensionSteps = []
this.lineStyleOptions = []
this.scatterSymbolOptions = []
},
},
}
</script>
Expand Down
12 changes: 12 additions & 0 deletions client/web/compose/src/components/Chart/Report/ReportEdit.vue
Expand Up @@ -639,6 +639,10 @@ export default {
},
},
beforeDestroy () {
this.setDefaultValues()
},
methods: {
hasRelativeDisplay: compose.chartUtil.hasRelativeDisplay,
Expand Down Expand Up @@ -675,6 +679,14 @@ export default {
isTemporalField (name) {
return this.dimensionFields.some(f => f.value === name && f.kind === 'DateTime')
},
setDefaultValues () {
this.metricAggregates = []
this.dimensionModifiers = []
this.predefinedFilters = []
this.alignments = []
this.orientations = []
},
},
}
</script>
12 changes: 11 additions & 1 deletion client/web/compose/src/components/Common/Grid.vue
Expand Up @@ -146,7 +146,8 @@ export default {
},
beforeDestroy () {
window.removeEventListener('resize', this.windowResizeThrottledHandler)
this.setDefaultValues()
this.destroyEvents()
},
methods: {
Expand All @@ -167,6 +168,15 @@ export default {
({ x, y, w, h, i }) => new compose.PageBlockMaker({ ...this.blocks[i], xywh: [x, y, w, h] }),
))
},
setDefaultValues () {
this.layout = []
this.boundingRects = []
},
destroyEvents () {
window.removeEventListener('resize', this.windowResizeThrottledHandler)
},
},
}
</script>
Expand Down
11 changes: 11 additions & 0 deletions client/web/compose/src/components/Common/RecordListFilter.vue
Expand Up @@ -353,6 +353,10 @@ export default {
},
},
beforeDestroy () {
this.setDefaultValues()
},
created () {
// Change all module fields to single value to keep multi value fields and single value
const module = JSON.parse(JSON.stringify(this.module || {}))
Expand Down Expand Up @@ -658,6 +662,13 @@ export default {
getOptionKey ({ name }) {
return name
},
setDefaultValues () {
this.componentFilter = []
this.conditions = []
this.mock = {}
this.preventPopoverClose = false
},
},
}
</script>
Expand Down
Expand Up @@ -399,6 +399,10 @@ export default {
this.liveExample = this.field.options.display === 'number' ? 123.45679 : 33.45679
},
beforeDestroy () {
this.setDefaultValues()
},
methods: {
addThreshold () {
this.field.options.thresholds.push({ value: 0, variant: 'success' })
Expand All @@ -409,6 +413,13 @@ export default {
this.field.options.thresholds.splice(index, 1)
}
},
setDefaultValues () {
this.liveExample = undefined
this.displayOptions = []
this.variants = []
this.mock = {}
},
},
}
</script>
Expand Up @@ -109,7 +109,6 @@ export default {
data () {
return {
selected: null,
selectOptions: [
{ text: this.$t('kind.select.optionType.default'), value: 'default', allowDuplicates: true },
{ text: this.$t('kind.select.optionType.multiple'), value: 'multiple' },
Expand Down
Expand Up @@ -219,6 +219,10 @@ export default {
}
},
beforeDestroy () {
this.setDefaultValues()
},
methods: {
handleAddOption () {
this.f.options.options.push({
Expand All @@ -234,6 +238,11 @@ export default {
this.f.options.isUniqueMultiValue = true
}
},
setDefaultValues () {
this.newOption = {}
this.options = []
},
},
}
</script>
Expand Up @@ -93,6 +93,10 @@ export default {
})
},
beforeDestroy () {
this.setDefaultValues()
},
methods: {
getOptionKey ({ roleID }) {
return roleID
Expand All @@ -104,6 +108,11 @@ export default {
this.f.options.isUniqueMultiValue = true
}
},
setDefaultValues () {
this.selectOptions = []
this.roleOptions = []
},
},
}
</script>
11 changes: 11 additions & 0 deletions client/web/compose/src/components/ModuleFields/Editor/Geometry.vue
Expand Up @@ -298,6 +298,10 @@ export default {
}
},
beforeDestroy () {
this.setDefaultValues()
},
methods: {
openMap (index) {
this.localValueIndex = index
Expand Down Expand Up @@ -421,6 +425,13 @@ export default {
this.toastErrorHandler(this.$t('notification:field-geometry.geolocationErrors.locationSearchFailed'))()
})
},
setDefaultValues () {
this.localValue = undefined
this.localValueIndex = undefined
this.map = {}
this.geoSearch = {}
},
},
}
</script>
13 changes: 13 additions & 0 deletions client/web/compose/src/components/ModuleFields/Editor/Record.vue
Expand Up @@ -296,6 +296,10 @@ export default {
}
},
beforeDestroy () {
this.setDefaultValues()
},
methods: {
...mapActions({
findModuleByID: 'module/findByID',
Expand Down Expand Up @@ -465,6 +469,7 @@ export default {
}
mappedIDs[r.recordID] = relatedRecordValue.join(relatedLabelField.options.multiDelimiter)
relatedRecordIDs.clear()
}
} else if (relatedField.kind === 'User') {
this.processing = true
Expand Down Expand Up @@ -515,6 +520,14 @@ export default {
getOptionKey ({ value }) {
return value
},
setDefaultValues () {
this.processing = false
this.query = ''
this.records = []
this.recordValues = {}
this.filter = {}
},
},
}
</script>

0 comments on commit 95cf245

Please sign in to comment.