Skip to content

Commit ca62cd7

Browse files
committed
Improve initialisation and refresh behaviour
1 parent 7166343 commit ca62cd7

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
- Limit effective zoom level by new "Maximum zoom level" option
5353
- Fix transformation machinery for data in timeseries format
5454
- Acquire location data again after being cleared out when hitting an empty dataset
55+
- Improve initialisation and refresh behaviour
5556

5657
## v0.2.0
5758

src/worldmap_ctrl.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ export default class WorldmapCtrl extends MetricsPanelCtrl {
9797
chrome: WorldmapChrome;
9898
errors: ErrorManager;
9999

100+
initializing: boolean;
101+
100102
/** @ngInject **/
101103
constructor($scope, $injector, $element, $document, contextSrv, templateSrv, $location) {
102104
super($scope, $injector);
@@ -105,6 +107,8 @@ export default class WorldmapCtrl extends MetricsPanelCtrl {
105107
this.$document = $document;
106108
this.contextSrv = contextSrv;
107109

110+
this.initializing = true;
111+
108112
this.errors = new ErrorManager();
109113
this.errors.registerDomains('data', 'location');
110114

@@ -236,17 +240,17 @@ export default class WorldmapCtrl extends MetricsPanelCtrl {
236240
/*
237241
* Conditionally refresh the plugin, but not if it's still loading.
238242
*/
239-
const loading = this.loading != false;
240-
console.log('Still loading:', loading);
241-
if (!loading) {
243+
console.log('Still initializing:', this.initializing);
244+
if (!this.initializing) {
242245
this.refresh();
243246
}
244247
}
245248

246249
onRefresh() {
247-
console.info('Refreshing panel');
250+
console.info('Refreshing panel. initializing=', this.initializing);
248251
this.errors.reset('data');
249-
if (_.isEmpty(this.locations) && _.isEmpty(this.panel.snapshotLocationData)) {
252+
253+
if (!this.loading && !this.initializing && (_.isEmpty(this.locations) && _.isEmpty(this.panel.snapshotLocationData))) {
250254
this.loadLocationData(true);
251255
}
252256
}
@@ -264,6 +268,9 @@ export default class WorldmapCtrl extends MetricsPanelCtrl {
264268

265269
console.info('Data received:', dataList);
266270

271+
// Is this the right place to indicate the plugin has been initialized?
272+
this.initializing = false;
273+
267274
try {
268275
this.processData(dataList);
269276

0 commit comments

Comments
 (0)