Skip to content

Commit

Permalink
use webpack not grunt
Browse files Browse the repository at this point in the history
  • Loading branch information
ryantxu committed Aug 28, 2018
1 parent 6d09f37 commit 6cdc22c
Show file tree
Hide file tree
Showing 13 changed files with 3,305 additions and 1,677 deletions.
136 changes: 0 additions & 136 deletions Gruntfile.js

This file was deleted.

67 changes: 35 additions & 32 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
{
"name": "natel-plotly-panel",
"version": "0.0.5",
"version": "0.0.5-dev",
"description": "Plot.ly Panel Plugin for Grafana",
"scripts": {
"build": "grunt",
"dev": "grunt watch",
"test": "./node_modules/karma/bin/karma start",
"build": "webpack --config webpack.config.prod.js",
"dev": "webpack --mode development",
"watch": "webpack --mode development --watch",
"test": "jest --config jest.config.js",
"release": "node release.js",
"precommit": "pretty-quick --staged",
"pretty": "prettier --write src/**/*.ts"
},
"author": "ryantxu",
"license": "MIT",
"keywords": ["plotly", "scatter", "grafana", "plugin", "panel"],
"keywords": [
"plotly",
"scatter",
"grafana",
"plugin",
"panel"
],
"repository": {
"type": "git",
"url": "https://github.com/NatelEnergy/grafana-plotly-panel.git"
Expand All @@ -25,38 +33,33 @@
"semi": true
},
"dependencies": {
"jquery": "^3.2.1",
"lodash": "^4.17.10",
"moment": "^2.22.2",
"q": "^1.5.0",
"systemjs": "^0.21.4",
"moment": "^2.22.1",
"plotly.js": "^1.39"
},
"devDependencies": {
"@types/lodash": "^4.14.74",
"@types/plotly.js": "^1.38.0",
"grafana-sdk-mocks": "github:grafana/grafana-sdk-mocks",
"grunt": "^1.0.2",
"grunt-contrib-clean": "^1.1.0",
"grunt-contrib-copy": "^1.0.0",
"grunt-contrib-watch": "^1.0.0",
"grunt-string-replace": "^1.3",
"grunt-ts": "^6.0.0-beta.17",
"grunt-tslint": "^5.0.1",
"husky": "^0.14.3",
"karma": "^1.7.0",
"karma-chrome-launcher": "^2.2.0",
"karma-expect": "^1.1.3",
"karma-mocha": "^1.3.0",
"karma-phantomjs-launcher": "^1.0.4",
"karma-sinon": "^1.0.5",
"karma-systemjs": "^0.16.0",
"load-grunt-tasks": "^3.5.2",
"plugin-typescript": "^8.0.0",
"prettier": "1.10.2",
"grafana-sdk-mocks": "github:ryantxu/grafana-sdk-mocks",
"@types/jest": "^23.3.1",
"@types/lodash": "^4.14.74",
"babel-core": "^6.26.3",
"babel-jest": "^23.0.1",
"babel-loader": "^7.1.4",
"babel-preset-env": "^1.7.0",
"clean-webpack-plugin": "^0.1.19",
"copy-webpack-plugin": "^4.5.1",
"css-loader": "^1.0.0",
"replace-in-file-webpack-plugin": "^1.0.6",
"jest": "^23.0.1",
"ng-annotate-webpack-plugin": "^0.3.0",
"style-loader": "^0.22",
"prettier": "^1.14",
"pretty-quick": "^1.4.1",
"sinon": "^3.2.1",
"systemjs-plugin-css": "^0.1.35",
"tslint": "^5.8.0",
"typescript": "^3.0.1"
"ts-jest": "^23",
"ts-loader": "^4.3.0",
"typescript": "^3",
"webpack": "^4.9.1",
"webpack-cli": "^3.1"
}
}
31 changes: 31 additions & 0 deletions specs/lib/template_srv_stub.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import _ from 'lodash';

export default class TemplateSrvStub {
variables = [];
templateSettings = {interpolate: /\[\[([\s\S]+?)\]\]/g};
data = {};

replace(text) {
return _.template(text, this.templateSettings)(this.data);
}

getAdhocFilters() {
return [];
}

variableExists() {
return false;
}

highlightVariablesAsHtml(str) {
return str;
}

setGrafanaVariable(name, value) {
this.data[name] = value;
}

init() {}
fillVariableValuesForUrl() {}
updateTemplateData() {}
}
19 changes: 19 additions & 0 deletions specs/panel.jest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
///<reference path="../node_modules/@types/jest/index.d.ts" />

import moment from 'moment';

import TemplateSrv from './lib/template_srv_stub';

import {PlotlyPanelCtrl} from '../src/module';

describe('Plotly Panel', () => {
// $scope, $injector, $window, private $rootScope, public uiSegmentSrv
const ds = new PlotlyPanelCtrl(null, null, null, null, null);

// Skip those for now because they rely on real template expansion
describe('check Defaults', () => {
it('it should use default configs', () => {
expect(ds.panel).toBe(PlotlyPanelCtrl.defaults);
});
});
});
1 change: 1 addition & 0 deletions src/SeriesWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export class SeriesWrapperSeries extends SeriesWrapper {
this.setFirst(arr[0]);
return false;
}
return true; // continue
});
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export class EditorHelper {

getSeriesSegs(withRemove = false): Promise<any[]> {
return new Promise((resolve, reject) => {
let series = [];
let series: any[] = [];
if (false && withRemove) {
series.push(
this.ctrl.uiSegmentSrv.newSegment({
Expand Down Expand Up @@ -413,7 +413,7 @@ export class EditorHelper {
'line-nw-open',
];

let segs = [];
let segs: any[] = [];
_.forEach(txt, val => {
segs.push(this.ctrl.uiSegmentSrv.newSegment(val));
});
Expand Down
6 changes: 3 additions & 3 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class PlotlyPanelCtrl extends MetricsPanelCtrl {
this.events.on('refresh', this.onRefresh.bind(this));
}

getCssRule(selectorText) {
getCssRule(selectorText): CSSStyleRule | null {
const styleSheets = document.styleSheets;
for (let idx = 0; idx < styleSheets.length; idx += 1) {
const styleSheet = styleSheets[idx] as CSSStyleSheet;
Expand All @@ -144,6 +144,7 @@ class PlotlyPanelCtrl extends MetricsPanelCtrl {
}
}
}
return null;
}

onResize() {
Expand Down Expand Up @@ -426,10 +427,9 @@ class PlotlyPanelCtrl extends MetricsPanelCtrl {
let refId = _.get(this.panel, 'targets[' + sidx + '].refId');
if (!refId) {
console.log('Missing Targets: ', this.panel.targets);
let refId = String.fromCharCode('A'.charCodeAt(0) + sidx);
refId = String.fromCharCode('A'.charCodeAt(0) + sidx);
}
if (series.columns) {
const length = series.rows.length;
for (let i = 0; i < series.columns.length; i++) {
finfo.push(new SeriesWrapperTable(refId, series, i));
}
Expand Down
6 changes: 6 additions & 0 deletions tsconfig.jest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "./tsconfig",
"compilerOptions": {
"allowSyntheticDefaultImports": true
}
}
25 changes: 25 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"compileOnSave": false,
"compilerOptions": {
"target": "es5",
"module": "es6",
"rootDir": "./src",
"jsx": "react",
"lib": ["dom", "es2015", "es2016"],
"declaration": false,
"allowSyntheticDefaultImports": true,
"inlineSourceMap": false,
"sourceMap": true,
"noEmitOnError": false,
"emitDecoratorMetadata": false,
"experimentalDecorators": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitUseStrict": true,
"noImplicitAny": false,
"noUnusedLocals": true,
"strictNullChecks": true
},
"include": ["./src/**/*.ts", "./src/**/*.tsx"],
"exclude": ["node_modules"]
}
Loading

0 comments on commit 6cdc22c

Please sign in to comment.