Skip to content

Commit

Permalink
fix: load dashboard panels in sequence, WIP
Browse files Browse the repository at this point in the history
Firefox is hanging when all the panels try to load at once. Let's WIP and
see if loading in series works better -- then once it is working, we
can try to optimize the load order / speed later.
  • Loading branch information
billyc committed Feb 7, 2022
1 parent 1e26a5b commit 8e42dec
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 11 deletions.
5 changes: 5 additions & 0 deletions src/charts/links.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ link-volumes.deck-map(
:config="config"
:thumbnail="false"
:datamanager="datamanager"
@isLoaded="isLoaded"
)

</template>
Expand All @@ -28,6 +29,10 @@ export default class VueComponent extends Vue {
// console.log(this.fileSystemConfig)
// console.log('subfolder', this.subfolder)
// console.log('config', this.config)
// this.$emit('isLoaded')
}
private isLoaded() {
this.$emit('isLoaded')
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/TopSheet/TopSheet.vue
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ export default class VueComponent extends Vue {
this.table = []
// this.table = [{ title: message, value: '', style: { backgroundColor: 'yellow' } }]
}
this.$emit('isLoaded')
}
private processWorkerMessage(message: MessageEvent) {
Expand All @@ -130,9 +129,11 @@ export default class VueComponent extends Vue {
break
case 'results':
this.table = data.results
this.$emit('isLoaded')
break
default:
// shouldn't be here
this.$emit('isLoaded')
console.error(data)
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/viz-configurator/VizConfigurator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ export default class VueComponent extends Vue {
private clickedExport() {
let suggestedFilename = 'viz-links-export.yaml'
const configFile = this.yamlConfig.toLocaleLowerCase()
const configFile = this.yamlConfig?.toLocaleLowerCase() || ''
if (configFile.endsWith('yaml') || configFile.endsWith('yml')) {
suggestedFilename = this.yamlConfig
}
Expand Down
14 changes: 11 additions & 3 deletions src/plugins/links-gl/LinkVolumes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,11 @@ class MyPlugin extends Vue {
private isDarkMode = this.$store.state.colorScheme === ColorScheme.DarkMode
private isDataLoaded = false
private setDataIsLoaded() {
this.isDataLoaded = true
this.$emit('isLoaded', true)
}
public buildFileApi() {
const filesystem = this.getFileSystem(this.root)
this.myState.fileApi = new HTTPFileSystem(filesystem)
Expand Down Expand Up @@ -341,7 +346,10 @@ class MyPlugin extends Vue {
}
@Watch('$store.state.colorScheme') private swapTheme() {
this.isDarkMode = this.$store.state.colorScheme === ColorScheme.DarkMode
setTimeout(
() => (this.isDarkMode = this.$store.state.colorScheme === ColorScheme.DarkMode),
100
)
}
private arrayBufferToBase64(buffer: any) {
Expand Down Expand Up @@ -779,7 +787,7 @@ class MyPlugin extends Vue {
this.csvData.dataTable[LOOKUP_COLUMN].values = lookup
this.myState.statusMessage = ''
this.isDataLoaded = true
this.setDataIsLoaded()
}
private handleDatasetisLoaded(datasetId: string) {
Expand Down Expand Up @@ -815,7 +823,7 @@ class MyPlugin extends Vue {
// last dataset
if (datasetKeys.length === Object.keys(this.vizDetails.datasets).length) {
this.isDataLoaded = true
this.setDataIsLoaded()
this.myState.statusMessage = ''
console.log({ DATASETS: this.datasets })
}
Expand Down
13 changes: 7 additions & 6 deletions src/views/DashBoard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,17 @@


//- card contents
.spinner-box(v-if="getCardComponent(card)"
:id="card.id"
:class="{'is-loaded': card.isLoaded}"
)
.spinner-box(v-if="getCardComponent(card)" :id="card.id" :class="{'is-loaded': numberOfShownCards >= card.number}")

component.dash-card(
v-if="numberOfShownCards >= card.number"
:is="getCardComponent(card)"
:fileSystemConfig="fileSystemConfig"
:subfolder="xsubfolder"
:files="fileList"
:yaml="card.props.configFile"
:config="card.props"
:datamanager="datamanager"
:style="{opacity: opacity[card.id]}"
:cardId="card.id"
:cardTitle="card.title"
:allConfigFiles="allConfigFiles"
Expand Down Expand Up @@ -273,9 +270,10 @@ export default class VueComponent extends Vue {
cards.forEach(card => {
card.id = `card-id-${numCard}`
card.isLoaded = false
card.number = numCard
// Vue is weird about new properties: use Vue.set() instead
Vue.set(this.opacity, card.id, 0.1)
Vue.set(this.opacity, card.id, 0.15)
Vue.set(this.infoToggle, card.id, false)
numCard++
Expand All @@ -285,6 +283,8 @@ export default class VueComponent extends Vue {
}
}
private numberOfShownCards = 1
@Watch('$store.state.locale') updateLabels() {
this.title = this.getDashboardLabel('title')
this.description = this.getDashboardLabel('description')
Expand All @@ -310,6 +310,7 @@ export default class VueComponent extends Vue {
private async handleCardIsLoaded(card: any) {
card.isLoaded = true
this.opacity[card.id] = 1.0
this.numberOfShownCards++
}
}
</script>
Expand Down

0 comments on commit 8e42dec

Please sign in to comment.