Skip to content

Commit

Permalink
Grafana 8: Don't croak when unable to load/access KeybindingSrv
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
amotl committed Jun 15, 2021
1 parent 82bdd69 commit c74d0fc
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
@@ -1,6 +1,7 @@
# Changelog

## development
- Add compatibility with Grafana 8

- Add Makefile to assist in packaging and publishing
- Overlay image can now be refreshed with the dashboard. Thanks, @jreyesr!
Expand Down
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Expand Up @@ -15,6 +15,9 @@ The easiest way to invoke a development sandbox is by using Docker.
```shell
# Run with Grafana 7
docker run --publish=3000:3000 --volume=$PWD/dist:/var/lib/grafana/plugins/grafana-map-panel grafana/grafana:7.5.7

# Run with Grafana 8
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
```

Because the version of `node-sass` used as transitive dependency is apparently
Expand Down
12 changes: 10 additions & 2 deletions src/chrome.ts
Expand Up @@ -62,11 +62,19 @@ export class WorldmapChrome {
* - https://github.com/daq-tools/grafanimate/blob/0.5.5/grafanimate/grafana-studio.js
*
*/
this.getKeybindingSrv().unbind('esc', 'keydown');
try {
this.getKeybindingSrv().unbind('esc', 'keydown');
} catch (err) {
console.error(`Accessing KeybindingSrv not implemented for Grafana 8 yet.\n${err}`);
}
}

restoreEscapeKeyBinding() {
this.getKeybindingSrv().setupGlobal();
try {
this.getKeybindingSrv().setupGlobal();
} catch (err) {
console.error(`Accessing KeybindingSrv not implemented for Grafana 8 yet.\n${err}`);
}
}

getKeybindingSrv() {
Expand Down
4 changes: 4 additions & 0 deletions src/worldmap_ctrl.ts
Expand Up @@ -298,8 +298,10 @@ export default class WorldmapCtrl extends MetricsPanelCtrl {
this.panel.snapshotLocationData = this.locations;
}

console.info('Processing data');
this.processData(dataList);

console.info('Updating color mode');
this.updateColorMode();

const autoCenterMap =
Expand Down Expand Up @@ -504,6 +506,8 @@ export default class WorldmapCtrl extends MetricsPanelCtrl {

resetData() {
this.data = [];
this.data.categories = [];
this.data.thresholds = [];
//this.mapCenterMoved = true;
}

Expand Down

0 comments on commit c74d0fc

Please sign in to comment.