Skip to content

Commit c74d0fc

Browse files
committed
Grafana 8: Don't croak when unable to load/access KeybindingSrv
Apparently, this service component will have to be addressed differently on Grafana 8. By now, this update will just ignore / skip anything related to that, so we only lack a minor feature about disabling any keyboard navigation.
1 parent 82bdd69 commit c74d0fc

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Changelog
22

33
## development
4+
- Add compatibility with Grafana 8
45

56
- Add Makefile to assist in packaging and publishing
67
- Overlay image can now be refreshed with the dashboard. Thanks, @jreyesr!

CONTRIBUTING.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ The easiest way to invoke a development sandbox is by using Docker.
1515
```shell
1616
# Run with Grafana 7
1717
docker run --publish=3000:3000 --volume=$PWD/dist:/var/lib/grafana/plugins/grafana-map-panel grafana/grafana:7.5.7
18+
19+
# Run with Grafana 8
20+
docker run --publish=3000:3000 --volume=$PWD/dist:/var/lib/grafana/plugins/grafana-map-panel --env=GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS=grafana-map-panel grafana/grafana:8.0.0
1821
```
1922

2023
Because the version of `node-sass` used as transitive dependency is apparently

src/chrome.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,19 @@ export class WorldmapChrome {
6262
* - https://github.com/daq-tools/grafanimate/blob/0.5.5/grafanimate/grafana-studio.js
6363
*
6464
*/
65-
this.getKeybindingSrv().unbind('esc', 'keydown');
65+
try {
66+
this.getKeybindingSrv().unbind('esc', 'keydown');
67+
} catch (err) {
68+
console.error(`Accessing KeybindingSrv not implemented for Grafana 8 yet.\n${err}`);
69+
}
6670
}
6771

6872
restoreEscapeKeyBinding() {
69-
this.getKeybindingSrv().setupGlobal();
73+
try {
74+
this.getKeybindingSrv().setupGlobal();
75+
} catch (err) {
76+
console.error(`Accessing KeybindingSrv not implemented for Grafana 8 yet.\n${err}`);
77+
}
7078
}
7179

7280
getKeybindingSrv() {

src/worldmap_ctrl.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,10 @@ export default class WorldmapCtrl extends MetricsPanelCtrl {
298298
this.panel.snapshotLocationData = this.locations;
299299
}
300300

301+
console.info('Processing data');
301302
this.processData(dataList);
302303

304+
console.info('Updating color mode');
303305
this.updateColorMode();
304306

305307
const autoCenterMap =
@@ -504,6 +506,8 @@ export default class WorldmapCtrl extends MetricsPanelCtrl {
504506

505507
resetData() {
506508
this.data = [];
509+
this.data.categories = [];
510+
this.data.thresholds = [];
507511
//this.mapCenterMoved = true;
508512
}
509513

0 commit comments

Comments
 (0)