mirror of
https://github.com/timberjoegithub/grafana-statusmap.git
synced 2026-07-21 23:42:03 +00:00
fix: cleanup dist folder, change README
- move images for README into docs/img - move libs/* into utils. libs folder is copied into dist by grafana-toolkit - remove d3-scale-chromatic sources, use it from dependencies - update compatible versions in README - update installation info
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import * as d3 from 'd3';
|
||||
import * as d3ScaleChromaticOrig from 'd3-scale-chromatic';
|
||||
|
||||
// Add GnYlRd color schema to d3-scale-chromatic
|
||||
|
||||
let GnYlRdScheme = new Array(3)
|
||||
.concat(
|
||||
'91cf60ffffbffc8d59',
|
||||
'1a9641a6d96afdae61d7191c',
|
||||
'1a9641a6d96affffbffdae61d7191c',
|
||||
'1a985091cf60d9ef8bfee08bfc8d59d73027',
|
||||
'1a985091cf60d9ef8bffffbffee08bfc8d59d73027',
|
||||
'1a985066bd63a6d96ad9ef8bfee08bfdae61f46d43d73027',
|
||||
'1a985066bd63a6d96ad9ef8bffffbffee08bfdae61f46d43d73027',
|
||||
'0068371a985066bd63a6d96ad9ef8bfee08bfdae61f46d43d73027a50026',
|
||||
'0068371a985066bd63a6d96ad9ef8bffffbffee08bfdae61f46d43d73027a50026'
|
||||
)
|
||||
.map(function(specifier) {
|
||||
var n = (specifier.length / 6) | 0,
|
||||
colors = new Array(n),
|
||||
i = 0;
|
||||
while (i < n) {
|
||||
colors[i] = '#' + specifier.slice(i * 6, ++i * 6);
|
||||
}
|
||||
return colors;
|
||||
});
|
||||
|
||||
let GnYlRd = d3.interpolateRgbBasis(GnYlRdScheme[GnYlRdScheme.length - 1]);
|
||||
|
||||
let d3ScaleChromatic = {
|
||||
...d3ScaleChromaticOrig,
|
||||
interpolateGnYlRd: GnYlRd,
|
||||
};
|
||||
|
||||
export { d3ScaleChromatic };
|
||||
@@ -0,0 +1,4 @@
|
||||
export interface AppEvent<T> {
|
||||
readonly name: string;
|
||||
payload?: T;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import { AppEvent } from './appEvents';
|
||||
|
||||
export interface GraphHoverPayload {
|
||||
pos: any;
|
||||
panel: {
|
||||
id: number;
|
||||
};
|
||||
}
|
||||
|
||||
export var graphHover: AppEvent<GraphHoverPayload> | string = { name: 'graph-hover' };
|
||||
export var graphHoverClear: AppEvent<any> | string = { name: 'graph-hover-clear' };
|
||||
|
||||
export function fallbackToStringEvents() {
|
||||
graphHover = 'graph-hover';
|
||||
graphHoverClear = 'graph-hover-clear';
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
import * as CoreEvents from './events';
|
||||
import * as PanelEvents from './panelEvents';
|
||||
export { CoreEvents, PanelEvents };
|
||||
@@ -0,0 +1,29 @@
|
||||
import { AppEvent } from './appEvents';
|
||||
|
||||
export interface DataQueryError {
|
||||
data?: {
|
||||
message?: string;
|
||||
error?: string;
|
||||
};
|
||||
message?: string;
|
||||
status?: string;
|
||||
statusText?: string;
|
||||
refId?: string;
|
||||
cancelled?: boolean;
|
||||
}
|
||||
|
||||
export var refresh: AppEvent<undefined> | string = { name: 'refresh' };
|
||||
export var render: AppEvent<any> | string = { name: 'render' };
|
||||
export var dataError: AppEvent<DataQueryError> | string = { name: 'data-error' };
|
||||
export var dataReceived: AppEvent<any[]> | string = { name: 'data-received' };
|
||||
export var dataSnapshotLoad: AppEvent<any[]> | string = { name: 'data-snapshot-load' };
|
||||
export var editModeInitialized: AppEvent<undefined> | string = { name: 'init-edit-mode' };
|
||||
|
||||
export function fallbackToStringEvents() {
|
||||
refresh = 'refresh';
|
||||
render = 'render';
|
||||
dataError = 'data-error';
|
||||
dataReceived = 'data-received';
|
||||
dataSnapshotLoad = 'data-snapshot-load';
|
||||
editModeInitialized = 'init-edit-mode';
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
1. @grafana/data is not supported in grafana 5.x and 6.2. The workaround is
|
||||
the module `./util/grafana/events` that include copy-pasted events
|
||||
from @grafana/data and app/core from grafana sources.
|
||||
|
||||
2. Newly Grafana versions flood Console with
|
||||
"Usage strings as events is deprecated ..." messages.
|
||||
This module has a function to detect if Grafana’s Emitter support AppEvent style event ids.
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import { Emitter } from 'grafana/app/core/utils/emitter';
|
||||
|
||||
// Old Grafana releases use strings as event ids and
|
||||
// new event ids in form of object {name: "event-id"} are not
|
||||
// supported properly: first defined listener will receive
|
||||
// all emitted events despite of the value in 'name' field.
|
||||
//
|
||||
// This method detects this behaviour and return true
|
||||
// only for new Grafana versions.
|
||||
export function hasAppEventCompatibleEmitter(emitter: Emitter): boolean {
|
||||
// Grafana 7.4 has new event bus for Angular plugins. It is has a 'subscribe' method.
|
||||
let emitterProto = Object.getPrototypeOf(emitter);
|
||||
if (Object.prototype.hasOwnProperty.call(emitterProto, 'subscribe')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
let receiveEvents = 0;
|
||||
let eventId: any = { name: 'non-existed-event-id' };
|
||||
let eventId2: any = { name: 'non-existed-event-id-2' };
|
||||
emitter.on(eventId, function() {
|
||||
receiveEvents++;
|
||||
});
|
||||
emitter.emit(eventId);
|
||||
emitter.emit(eventId2);
|
||||
emitter.removeAllListeners(eventId);
|
||||
|
||||
// New Grafana versions should receive one event.
|
||||
return receiveEvents === 1;
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
import * as Polygrafill from './funcs';
|
||||
export { Polygrafill };
|
||||
Reference in New Issue
Block a user