Skip to content

Commit

Permalink
Merge pull request #1 from KWMSys/feature/implement_rainrecorder
Browse files Browse the repository at this point in the history
Implement rain recorder support
  • Loading branch information
MadBiceps authored Apr 26, 2021
2 parents e2064dc + 8b36b55 commit 973e5f0
Show file tree
Hide file tree
Showing 10 changed files with 25,213 additions and 298 deletions.
24,773 changes: 24,773 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/__mocks__/grafana/app/core/utils/kbn.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const kbn: any = {};

kbn.regexEscape = value => {
kbn.regexEscape = (value) => {
return value.replace(/[\\^$*+?.()|[\]{}\/]/g, '\\$&');
};

Expand Down
20 changes: 10 additions & 10 deletions src/data_formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ export default class DataFormatter {
let highestValue = 0;
let lowestValue = Number.MAX_VALUE;

this.ctrl.series.forEach(serie => {
this.ctrl.series.forEach((serie) => {
const lastPoint = _.last(serie.datapoints);
const lastValue = _.isArray(lastPoint) ? lastPoint[0] : null;
const location = _.find(this.ctrl.locations, loc => {
const location = _.find(this.ctrl.locations, (loc) => {
return loc.key.toUpperCase() === serie.alias.toUpperCase();
});
const timestamp = _.isArray(lastPoint) ? lastPoint[1] : null;
Expand Down Expand Up @@ -53,8 +53,8 @@ export default class DataFormatter {

// Add data which are not in series
Object.keys(this.ctrl.store)
.filter(x => this.ctrl.store.hasOwnProperty(x) && data.find(y => y.key === x) == null)
.map(x => {
.filter((x) => this.ctrl.store.hasOwnProperty(x) && data.find((y) => y.key === x) == null)
.map((x) => {
console.log('Fill data');
data.push(this.ctrl.store[x].data);
});
Expand Down Expand Up @@ -99,15 +99,15 @@ export default class DataFormatter {
let highestValue = 0;
let lowestValue = Number.MAX_VALUE;

dataList.forEach(result => {
dataList.forEach((result) => {
if (result.type === 'table') {
const columnNames = {};

result.columns.forEach((column, columnIndex) => {
columnNames[column.text] = columnIndex;
});

result.rows.forEach(row => {
result.rows.forEach((row) => {
const encodedGeohash = row[columnNames[this.ctrl.panel.esGeoPoint]];
const decodedGeohash = decodeGeoHash(encodedGeohash);
const locationName = this.ctrl.panel.esLocationName
Expand All @@ -131,7 +131,7 @@ export default class DataFormatter {
data.lowestValue = lowestValue;
data.valueRange = highestValue - lowestValue;
} else {
result.datapoints.forEach(datapoint => {
result.datapoints.forEach((datapoint) => {
const encodedGeohash = datapoint[this.ctrl.panel.esGeoPoint];
const decodedGeohash = decodeGeoHash(encodedGeohash);
const locationName = this.ctrl.panel.esLocationName
Expand Down Expand Up @@ -167,7 +167,7 @@ export default class DataFormatter {
columnNames[columnIndex] = column.text;
});

tableData.rows.forEach(row => {
tableData.rows.forEach((row) => {
const datapoint = {};

row.forEach((value, columnIndex) => {
Expand All @@ -187,7 +187,7 @@ export default class DataFormatter {
let highestValue = 0;
let lowestValue = Number.MAX_VALUE;

tableData[0].forEach(datapoint => {
tableData[0].forEach((datapoint) => {
let key;
let longitude;
let latitude;
Expand Down Expand Up @@ -238,7 +238,7 @@ export default class DataFormatter {
let highestValue = 0;
let lowestValue = Number.MAX_VALUE;

this.ctrl.series.forEach(point => {
this.ctrl.series.forEach((point) => {
const dataValue = {
key: point.key,
locationName: point.name,
Expand Down
4 changes: 2 additions & 2 deletions src/geohash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ export default function decodeGeoHash(geohash) {
lon[1] = 180.0;
let base32Decoded;

geohash.split('').forEach(item => {
geohash.split('').forEach((item) => {
base32Decoded = BASE32.indexOf(item);
BITS.forEach(mask => {
BITS.forEach((mask) => {
if (isEven) {
refineInterval(lon, base32Decoded, mask);
} else {
Expand Down
399 changes: 192 additions & 207 deletions src/partials/editor.html

Large diffs are not rendered by default.

60 changes: 30 additions & 30 deletions src/plugin.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
{
"type": "panel",
"name": "Worldmap Panel",
"id": "grafana-worldmap-panel",
"type": "panel",
"name": "Worldmap Panel Ultimate",
"id": "grafana-worldmap-panel-ultimate",

"info": {
"description": "World Map panel for Grafana. Displays time series data or geohash data from Elasticsearch overlaid on a world map.",
"author": {
"name": "Grafana Labs",
"url": "https://grafana.com"
"info": {
"description": "World Map panel for Grafana. Displays time series data or geohash data from Elasticsearch overlaid on a world map.",
"author": {
"name": "Grafana Labs",
"url": "https://grafana.com"
},
"keywords": ["worldmap", "panel"],
"logos": {
"small": "images/worldmap_logo.svg",
"large": "images/worldmap_logo.svg"
},
"links": [
{ "name": "Project site", "url": "https://github.com/grafana/worldmap-panel" },
{ "name": "MIT License", "url": "https://github.com/grafana/worldmap-panel/blob/master/LICENSE" }
],
"screenshots": [
{ "name": "World", "path": "images/worldmap-world.png" },
{ "name": "USA", "path": "images/worldmap-usa.png" },
{ "name": "Light Theme", "path": "images/worldmap-light-theme.png" }
],
"version": "1.0.1",
"updated": "Fri May 15 14:40:24 MDT 2020"
},
"keywords": ["worldmap", "panel"],
"logos": {
"small": "images/worldmap_logo.svg",
"large": "images/worldmap_logo.svg"
},
"links": [
{"name": "Project site", "url": "https://github.com/grafana/worldmap-panel"},
{"name": "MIT License", "url": "https://github.com/grafana/worldmap-panel/blob/master/LICENSE"}
],
"screenshots": [
{"name": "World", "path": "images/worldmap-world.png"},
{"name": "USA", "path": "images/worldmap-usa.png"},
{"name": "Light Theme", "path": "images/worldmap-light-theme.png"}
],
"version": "1.0.1",
"updated": "Fri May 15 14:40:24 MDT 2020"
},

"dependencies": {
"grafanaVersion": "3.x.x",
"plugins": [ ]
}
}
"dependencies": {
"grafanaVersion": "3.x.x",
"plugins": []
}
}
60 changes: 30 additions & 30 deletions src/plugin.json.tmpl
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
{
"type": "panel",
"name": "Worldmap Panel",
"id": "grafana-worldmap-panel",
"type": "panel",
"name": "Worldmap Panel Ultimate",
"id": "grafana-worldmap-panel-ultimate",

"info": {
"description": "World Map panel for Grafana. Displays time series data or geohash data from Elasticsearch overlaid on a world map.",
"author": {
"name": "Grafana Labs",
"url": "https://grafana.com"
"info": {
"description": "World Map panel for Grafana. Displays time series data or geohash data from Elasticsearch overlaid on a world map.",
"author": {
"name": "Grafana Labs",
"url": "https://grafana.com"
},
"keywords": ["worldmap", "panel"],
"logos": {
"small": "images/worldmap_logo.svg",
"large": "images/worldmap_logo.svg"
},
"links": [
{ "name": "Project site", "url": "https://github.com/grafana/worldmap-panel" },
{ "name": "MIT License", "url": "https://github.com/grafana/worldmap-panel/blob/master/LICENSE" }
],
"screenshots": [
{ "name": "World", "path": "images/worldmap-world.png" },
{ "name": "USA", "path": "images/worldmap-usa.png" },
{ "name": "Light Theme", "path": "images/worldmap-light-theme.png" }
],
"version": "1.0.1",
"updated": "Fri May 15 14:40:24 MDT 2020"
},
"keywords": ["worldmap", "panel"],
"logos": {
"small": "images/worldmap_logo.svg",
"large": "images/worldmap_logo.svg"
},
"links": [
{"name": "Project site", "url": "https://github.com/grafana/worldmap-panel"},
{"name": "MIT License", "url": "https://github.com/grafana/worldmap-panel/blob/master/LICENSE"}
],
"screenshots": [
{"name": "World", "path": "images/worldmap-world.png"},
{"name": "USA", "path": "images/worldmap-usa.png"},
{"name": "Light Theme", "path": "images/worldmap-light-theme.png"}
],
"version": "%VERSION%",
"updated": "%TODAY%"
},

"dependencies": {
"grafanaVersion": "3.x.x",
"plugins": [ ]
}
}
"dependencies": {
"grafanaVersion": "3.x.x",
"plugins": []
}
}
5 changes: 1 addition & 4 deletions src/worldmap.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ describe('Worldmap', () => {

describe('when the data has one point', () => {
beforeEach(() => {
ctrl.data = new DataBuilder()
.withCountryAndValue('SE', 1)
.withDataRange(1, 1, 0)
.build();
ctrl.data = new DataBuilder().withCountryAndValue('SE', 1).withDataRange(1, 1, 0).build();
ctrl.panel.circleMaxSize = '10';
worldMap.drawCircles();
});
Expand Down
Loading

0 comments on commit 973e5f0

Please sign in to comment.