mirror of
https://github.com/timberjoegithub/grafana-statusmap.git
synced 2026-07-22 15:53:09 +00:00
feat: use grafana-toolkit to build a plugin
- fix linter warnings - use yarn: remove Gruntfile.js and package-lock.json ++
This commit is contained in:
@@ -2,31 +2,31 @@ import _ from 'lodash';
|
||||
|
||||
function migrate_V0_V1(panel: any) {
|
||||
// Remove unused fields.
|
||||
if (_.has(panel, "xAxis.labelFormat")) {
|
||||
if (_.has(panel, 'xAxis.labelFormat')) {
|
||||
delete panel.xAxis.labelFormat;
|
||||
}
|
||||
if (_.has(panel, "xAxis.minBucketWidthToShowWeekends")) {
|
||||
if (_.has(panel, 'xAxis.minBucketWidthToShowWeekends')) {
|
||||
delete panel.xAxis.minBucketWidthToShowWeekends;
|
||||
}
|
||||
if (_.has(panel, "xAxis.showCrosshair")) {
|
||||
if (_.has(panel, 'xAxis.showCrosshair')) {
|
||||
delete panel.xAxis.showCrosshair;
|
||||
}
|
||||
if (_.has(panel, "xAxis.showWeekends")) {
|
||||
if (_.has(panel, 'xAxis.showWeekends')) {
|
||||
delete panel.xAxis.showWeekends;
|
||||
}
|
||||
if (_.has(panel, "yAxis.showCrosshair")) {
|
||||
if (_.has(panel, 'yAxis.showCrosshair')) {
|
||||
delete panel.yAxis.showCrosshair;
|
||||
}
|
||||
if (_.has(panel, "data.unitFormat")) {
|
||||
if (_.has(panel, 'data.unitFormat')) {
|
||||
delete panel.data;
|
||||
}
|
||||
|
||||
// Migrate cardSpacing value. Seems rare (update from version 0.0.2).
|
||||
if (_.has(panel, "cards.cardSpacing")) {
|
||||
if (!_.has(panel, "cards.cardVSpacing")) {
|
||||
if (_.has(panel, 'cards.cardSpacing')) {
|
||||
if (!_.has(panel, 'cards.cardVSpacing')) {
|
||||
if (panel.cards.cardSpacing) {
|
||||
panel.cards.cardVSpacing = panel.cards.cardSpacing
|
||||
panel.cards.cardHSpacing = panel.cards.cardSpacing
|
||||
panel.cards.cardVSpacing = panel.cards.cardSpacing;
|
||||
panel.cards.cardHSpacing = panel.cards.cardSpacing;
|
||||
}
|
||||
}
|
||||
delete panel.cards.cardSpacing;
|
||||
@@ -34,22 +34,22 @@ function migrate_V0_V1(panel: any) {
|
||||
|
||||
// Migrate initial config for urls in tooltip (pull/86).
|
||||
// 'usingUrl' was used to show tooltip with urls on click or not.
|
||||
if (_.has(panel, "usingUrl")) {
|
||||
if (!_.has(panel, "tooltip.freezeOnClick")) {
|
||||
if (_.has(panel, 'usingUrl')) {
|
||||
if (!_.has(panel, 'tooltip.freezeOnClick')) {
|
||||
panel.tooltip.freezeOnClick = panel.usingUrl;
|
||||
}
|
||||
delete panel.usingUrl;
|
||||
}
|
||||
|
||||
// 'urls' array is now tooltip.items array. Also items are changed.
|
||||
if (_.has(panel, "urls")) {
|
||||
if (!_.has(panel, "tooltip.items")) {
|
||||
if (_.has(panel, 'urls')) {
|
||||
if (!_.has(panel, 'tooltip.items')) {
|
||||
panel.tooltip.items = [];
|
||||
let hasRealItems = true;
|
||||
if (panel.urls.length == 0) {
|
||||
if (panel.urls.length === 0) {
|
||||
hasRealItems = false;
|
||||
}
|
||||
if (panel.urls.length == 1) {
|
||||
if (panel.urls.length === 1) {
|
||||
let url = panel.urls[0];
|
||||
if (url.base_url === '' && url.label === '') {
|
||||
hasRealItems = false;
|
||||
@@ -64,19 +64,19 @@ function migrate_V0_V1(panel: any) {
|
||||
urlIcon: _.toString(url.icon_fa),
|
||||
urlToLowerCase: url.forcelowercase,
|
||||
valueDateFormat: '',
|
||||
}
|
||||
};
|
||||
// replace $vars with new ${__vars} if url template is not empty
|
||||
if (item.urlTemplate !== "") {
|
||||
if (item.urlTemplate !== '') {
|
||||
// $time was a graph time with prepended &
|
||||
item.urlTemplate = _.replace(url.base_url, /\$time/g, "&${__url_time_range}");
|
||||
item.urlTemplate = _.replace(url.base_url, /\$time/g, '&${__url_time_range}');
|
||||
// $series_label was a y axis label
|
||||
item.urlTemplate = _.replace(item.urlTemplate, /\$series_label/, "${__y_label}");
|
||||
item.urlTemplate = _.replace(item.urlTemplate, /\$series_label/, '${__y_label}');
|
||||
// $series_extra was a value from bucket. This value has format options and index.
|
||||
let valueVar = "__value";
|
||||
let valueVar = '__value';
|
||||
if (url.useExtraSeries === true) {
|
||||
// index?
|
||||
if (url.extraSeries.index > -1) {
|
||||
valueVar += "_" + url.extraSeries.index;
|
||||
valueVar += '_' + url.extraSeries.index;
|
||||
}
|
||||
|
||||
let format = _.toString(url.extraSeries.format);
|
||||
@@ -97,14 +97,13 @@ function migrate_V0_V1(panel: any) {
|
||||
|
||||
// create statusmap metadata
|
||||
panel.statusmap = {
|
||||
"ConfigVersion": "v1",
|
||||
}
|
||||
ConfigVersion: 'v1',
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
export function migratePanelConfig(panel: any) {
|
||||
if (_.has(panel, "statusmap")) {
|
||||
if (panel.statusmap.ConfigVersion == "v1") {
|
||||
if (_.has(panel, 'statusmap')) {
|
||||
if (panel.statusmap.ConfigVersion === 'v1') {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
@@ -112,4 +111,3 @@ export function migratePanelConfig(panel: any) {
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user