Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Regex changes #309

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 52 additions & 4 deletions src/css/worldmap-panel.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
padding: 6px 8px;
font: 14px/16px Arial, Helvetica, sans-serif;
background: white;
background: rgba(255,255,255,0.8);
box-shadow: 0 0 15px rgba(0,0,0,0.2);
background: rgba(255, 255, 255, 0.8);
box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
border-radius: 5px;
}
.info h4 {
Expand All @@ -33,10 +33,58 @@
opacity: 0.7;
}

.leaflet-top.leaflet-left, .leaflet-bottom.leaflet-left, .leaflet-bottom.leaflet-right {
.leaflet-top.leaflet-left,
.leaflet-bottom.leaflet-left,
.leaflet-bottom.leaflet-right {
z-index: 1000;
}

.leaflet-popup-content-wrapper, .leaflet-popup-tip {
.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
color: #d8d9da !important;
}

.margin-top-8 {
margin-top: 8px;
}
.tooltip-container {
max-height: 100px;
overflow: auto;
color: #666666;
}

.info.aggregations.leaflet-control {
color: #666666;
font-size: 11px;
width: 100%;
}
.agg-container {
max-height: 90px;
overflow: auto;
}
.agg-item {
display: flex;
justify-content: space-between;
align-items: center;
}
.agg-item > div:first-child {
min-width: 70px;
display: flex;
}
.agg-label {
width: 40px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
margin-right: 2px;
}
.agg-bar {
flex: 1;
margin-left: 5px;
margin-bottom: 2px;
}

.agg-bar-progress {
background: #0078a8;
font-size: 0;
}
1 change: 0 additions & 1 deletion src/css/worldmap.light.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.worldmap-popup .leaflet-popup-content-wrapper, .worldmap-popup .leaflet-popup-tip {
background-color: #ECECEC;
color: #000 !important;
}
108 changes: 90 additions & 18 deletions src/data_formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ export default class DataFormatter {
}

if (_.isString(lastValue)) {
data.push({ key: serie.alias, value: 0, valueFormatted: lastValue, valueRounded: 0 });
data.push({
key: serie.alias,
value: 0,
valueFormatted: lastValue,
valueRounded: 0
});
} else {
const dataValue = {
key: serie.alias,
Expand All @@ -31,7 +36,7 @@ export default class DataFormatter {
locationLongitude: location.longitude,
value: serie.stats[this.ctrl.panel.valueName],
valueFormatted: lastValue,
valueRounded: 0,
valueRounded: 0
};

if (dataValue.value > highestValue) {
Expand All @@ -42,7 +47,10 @@ export default class DataFormatter {
lowestValue = dataValue.value;
}

dataValue.valueRounded = kbn.roundValue(dataValue.value, parseInt(this.ctrl.panel.decimals, 10) || 0);
dataValue.valueRounded = kbn.roundValue(
dataValue.value,
parseInt(this.ctrl.panel.decimals, 10) || 0
);
data.push(dataValue);
}
});
Expand All @@ -61,10 +69,13 @@ export default class DataFormatter {
locationLongitude: decodedGeohash.longitude,
value: value,
valueFormatted: value,
valueRounded: 0,
valueRounded: 0
};

dataValue.valueRounded = kbn.roundValue(dataValue.value, this.ctrl.panel.decimals || 0);
dataValue.valueRounded = kbn.roundValue(
dataValue.value,
this.ctrl.panel.decimals || 0
);
return dataValue;
}

Expand Down Expand Up @@ -93,7 +104,12 @@ export default class DataFormatter {
: encodedGeohash;
const value = row[columnNames[this.ctrl.panel.esMetric]];

const dataValue = this.createDataValue(encodedGeohash, decodedGeohash, locationName, value);
const dataValue = this.createDataValue(
encodedGeohash,
decodedGeohash,
locationName,
value
);
if (dataValue.value > highestValue) {
highestValue = dataValue.value;
}
Expand All @@ -117,7 +133,12 @@ export default class DataFormatter {
: encodedGeohash;
const value = datapoint[this.ctrl.panel.esMetric];

const dataValue = this.createDataValue(encodedGeohash, decodedGeohash, locationName, value);
const dataValue = this.createDataValue(
encodedGeohash,
decodedGeohash,
locationName,
value
);
if (dataValue.value > highestValue) {
highestValue = dataValue.value;
}
Expand Down Expand Up @@ -169,30 +190,53 @@ export default class DataFormatter {
let key;
let longitude;
let latitude;
let metricFieldChoosen: number;
let metricFieldNaN;

if (this.ctrl.panel.tableQueryOptions.queryType === 'geohash') {
const encodedGeohash = datapoint[this.ctrl.panel.tableQueryOptions.geohashField];
const encodedGeohash =
datapoint[this.ctrl.panel.tableQueryOptions.geohashField];
const decodedGeohash = decodeGeoHash(encodedGeohash);

latitude = decodedGeohash.latitude;
longitude = decodedGeohash.longitude;
key = encodedGeohash;
} else {
latitude = datapoint[this.ctrl.panel.tableQueryOptions.latitudeField];
longitude = datapoint[this.ctrl.panel.tableQueryOptions.longitudeField];
longitude =
datapoint[this.ctrl.panel.tableQueryOptions.longitudeField];
key = `${latitude}_${longitude}`;
}

let locationName;
if (this.ctrl.panel.tableQueryOptions.metricField === 'TAS') {
locationName = (datapoint[this.ctrl.panel.tableQueryOptions.labelField] || datapoint["Name"]);
if (datapoint["State"] === "ACTIVE"){
metricFieldChoosen = 11;
}else{
metricFieldChoosen = -1;
}
metricFieldNaN = true;
} else {
metricFieldChoosen =
datapoint[this.ctrl.panel.tableQueryOptions.metricField];
metricFieldNaN = false;
locationName = (datapoint[this.ctrl.panel.tableQueryOptions.labelField] || "n/a");
}
const dataValue = {
key: key,
locationName: datapoint[this.ctrl.panel.tableQueryOptions.labelField] || 'n/a',
locationName: locationName,
locationLatitude: latitude,
locationLongitude: longitude,
value: datapoint[this.ctrl.panel.tableQueryOptions.metricField],
valueFormatted: datapoint[this.ctrl.panel.tableQueryOptions.metricField],
value: metricFieldChoosen || 0,
valueFormatted:
datapoint[this.ctrl.panel.tableQueryOptions.metricField],
valueRounded: 0,
isMetricFieldNaN: metricFieldNaN
};

if (this.ctrl.panel.aggregationLegendField !== '') {
dataValue[`agg-${this.ctrl.panel.aggregationLegendField}`] =
datapoint[this.ctrl.panel.aggregationLegendField];
}
if (dataValue.value > highestValue) {
highestValue = dataValue.value;
}
Expand All @@ -201,10 +245,38 @@ export default class DataFormatter {
lowestValue = dataValue.value;
}

dataValue.valueRounded = kbn.roundValue(dataValue.value, this.ctrl.panel.decimals || 0);
data.push(dataValue);
dataValue.valueRounded = kbn.roundValue(
dataValue.value,
this.ctrl.panel.decimals || 0
);
if (latitude && longitude) {
data.push(dataValue);
}
});

// Getting the List of columns from the table row
data.columns = Object.keys(tableData[0][0] || []);
// Aggregations
if (
(this.ctrl.panel.aggregationLegendField !== '' &&
data.columns.indexOf(this.ctrl.panel.aggregationLegendField) > -1) ||
!tableData[0][0]
) {
data.aggregations = _.countBy(
data,
`agg-${this.ctrl.panel.aggregationLegendField}`
);
data.aggregations.unknown =
data.aggregations.Undefined || 0 + data.aggregations[''] || 0;
delete data.aggregations.undefined;
delete data.aggregations[''];
data.aggregationSortedList = Object.keys(data.aggregations).sort(
function(a, b) {
return data.aggregations[b] - data.aggregations[a];
}
);
} else {
data.aggregations = {};
}
data.highestValue = highestValue;
data.lowestValue = lowestValue;
data.valueRange = highestValue - lowestValue;
Expand All @@ -223,7 +295,7 @@ export default class DataFormatter {
locationLatitude: point.latitude,
locationLongitude: point.longitude,
value: point.value !== undefined ? point.value : 1,
valueRounded: 0,
valueRounded: 0
};
if (dataValue.value > highestValue) {
highestValue = dataValue.value;
Expand Down
Loading