Skip to content

Commit

Permalink
Fix babel issues
Browse files Browse the repository at this point in the history
  • Loading branch information
westc committed Nov 13, 2020
1 parent 1e8f481 commit 4eb440c
Show file tree
Hide file tree
Showing 3 changed files with 3,719 additions and 2,555 deletions.
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,18 @@
"license": "MIT",
"devDependencies": {
"@grafana/data": "next",
"@grafana/ui": "next",
"@grafana/toolkit": "next",
"@grafana/ui": "next",
"@types/grafana": "github:CorpGlory/types-grafana.git"
},
"resolutions": {
"@babel/preset-env": "7.9.0"
},
"engines": {
"node": ">=12 <13"
},
"dependencies": {
"@babel/preset-env": "^7.12.1",
"babel-loader": "^8.2.1"
}
}
21 changes: 16 additions & 5 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import config from 'grafana/app/core/config';
import jQuery from 'jquery';
import { DataFrame } from '@grafana/data';

const SEL_DISABLE_DOWNLOAD_CSV = '<llow-csv><ble-csv><llow-download><ble-download>'.replace(/<(.+?)>/g, ':not([data-disa$1])');
const SEL_DISABLE_DOWNLOAD_CSV = '<llow-csv><ble-csv><llow-download><ble-download>'.replace(
/<(.+?)>/g,
':not([data-disa$1])'
);

const DEFAULT_PANEL_SETTINGS = {
html: '<h2>Output of available datasets:</h2>\n<div><pre>{{ JSON.stringify(dataset, null, 2) }}</pre></div>',
Expand Down Expand Up @@ -209,7 +212,9 @@ export default class SimpleCtrl extends MetricsPanelCtrl {
.reduce((carry, table, index) => {
if (jQuery(table).is(SEL_DISABLE_DOWNLOAD_CSV)) {
carry.push({
text: table.getAttribute('data-title') ? `Export "${table.getAttribute('data-title')}" As CSV` : `Export Table #${index + 1} As CSV`,
text: table.getAttribute('data-title')
? `Export "${table.getAttribute('data-title')}" As CSV`
: `Export Table #${index + 1} As CSV`,
icon: 'fa fa-fw fa-table',
click: `ctrl.csvifyTable(${index})`,
});
Expand Down Expand Up @@ -399,7 +404,8 @@ export default class SimpleCtrl extends MetricsPanelCtrl {
{ headers: columnNames }
);
let blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8' });
let fileName = this.panel.title + JS.formatDate(new Date(), " (YYYY-MM-DD 'at' H.mm.ss)") + `.dataset-${data.raw.refId}.csv`;
let fileName =
this.panel.title + JS.formatDate(new Date(), " (YYYY-MM-DD 'at' H.mm.ss)") + `.dataset-${data.raw.refId}.csv`;
saveAs(blob, fileName);
}

Expand Down Expand Up @@ -454,7 +460,11 @@ export default class SimpleCtrl extends MetricsPanelCtrl {
toParams(objValues, opt_prefixVar) {
return Object.entries(objValues)
.reduce((arrParams, [key, value]) => {
return arrParams.concat(JS.toArray(value).map(value => this.encode((opt_prefixVar ? 'var-' : '') + key) + '=' + this.encode(value)));
return arrParams.concat(
JS.toArray(value).map(
value => this.encode((opt_prefixVar ? 'var-' : '') + key) + '=' + this.encode(value)
)
);
}, [])
.join('&');
},
Expand All @@ -475,7 +485,8 @@ export default class SimpleCtrl extends MetricsPanelCtrl {
getVarValues(opt_filter, opt_negate) {
if (opt_filter && 'function' !== typeof opt_filter) {
let arrFilter = JS.toArray(opt_filter);
opt_filter = key => arrFilter.some(filter => (filter instanceof RegExp ? filter.test(key) : filter === key));
opt_filter = key =>
arrFilter.some(filter => (filter instanceof RegExp ? filter.test(key) : filter === key));
}

return ctrl.templateSrv.variables.reduce((values, variable) => {
Expand Down
Loading

0 comments on commit 4eb440c

Please sign in to comment.