diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 00000000000..2e8a46f2aa3 --- /dev/null +++ b/examples/README.md @@ -0,0 +1,3 @@ +## Example plugin implementations + +[datasource-plugin-genericdatsource](https://github.com/grafana/datasource-plugin-genericdatasource/tree/3.0) \ No newline at end of file diff --git a/examples/datasource-plugin-genericdatasource/.jscs.json b/examples/datasource-plugin-genericdatasource/.jscs.json deleted file mode 100644 index dcf694dcc63..00000000000 --- a/examples/datasource-plugin-genericdatasource/.jscs.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "disallowImplicitTypeConversion": ["string"], - "disallowKeywords": ["with"], - "disallowMultipleLineBreaks": true, - "disallowMixedSpacesAndTabs": true, - "disallowTrailingWhitespace": true, - "requireSpacesInFunctionExpression": { - "beforeOpeningCurlyBrace": true - }, - "disallowSpacesInsideArrayBrackets": true, - "disallowSpacesInsideParentheses": true, - "validateIndentation": 2 -} \ No newline at end of file diff --git a/examples/datasource-plugin-genericdatasource/.jshintrc b/examples/datasource-plugin-genericdatasource/.jshintrc deleted file mode 100644 index 3725af83afc..00000000000 --- a/examples/datasource-plugin-genericdatasource/.jshintrc +++ /dev/null @@ -1,36 +0,0 @@ -{ - "browser": true, - "esnext": true, - - "bitwise":false, - "curly": true, - "eqnull": true, - "devel": true, - "eqeqeq": true, - "forin": false, - "immed": true, - "supernew": true, - "expr": true, - "indent": 2, - "latedef": true, - "newcap": true, - "noarg": true, - "noempty": true, - "undef": true, - "boss": true, - "trailing": true, - "laxbreak": true, - "laxcomma": true, - "sub": true, - "unused": true, - "maxdepth": 6, - "maxlen": 140, - - "globals": { - "System": true, - "define": true, - "require": true, - "Chromath": false, - "setImmediate": true - } -} diff --git a/examples/datasource-plugin-genericdatasource/Gruntfile.js b/examples/datasource-plugin-genericdatasource/Gruntfile.js deleted file mode 100644 index d36a4716f31..00000000000 --- a/examples/datasource-plugin-genericdatasource/Gruntfile.js +++ /dev/null @@ -1,54 +0,0 @@ -module.exports = function(grunt) { - - require('load-grunt-tasks')(grunt); - - grunt.loadNpmTasks('grunt-execute'); - grunt.loadNpmTasks('grunt-contrib-clean'); - - grunt.initConfig({ - - clean: ["dist"], - - copy: { - src_to_dist: { - cwd: 'src', - expand: true, - src: ['**/*', '!**/*.js', '!**/*.scss'], - dest: 'dist' - }, - pluginDef: { - expand: true, - src: 'plugin.json', - dest: 'dist', - } - }, - - watch: { - rebuild_all: { - files: ['src/**/*', 'plugin.json'], - tasks: ['default'], - options: {spawn: false} - }, - }, - - babel: { - options: { - sourceMap: true, - presets: ["es2015"], - plugins: ['transform-es2015-modules-systemjs', "transform-es2015-for-of"], - }, - dist: { - files: [{ - cwd: 'src', - expand: true, - src: ['**/*.js'], - dest: 'dist', - ext:'.js' - }] - }, - }, - - }); - - grunt.registerTask('default', ['clean', 'copy:src_to_dist', 'copy:pluginDef', 'babel']); -}; diff --git a/examples/datasource-plugin-genericdatasource/README.md b/examples/datasource-plugin-genericdatasource/README.md deleted file mode 100644 index 903b0fbf2f0..00000000000 --- a/examples/datasource-plugin-genericdatasource/README.md +++ /dev/null @@ -1,12 +0,0 @@ -#Generic backend datasource# - -More documentation about datasource plugins can be found in the [Docs](https://github.com/grafana/grafana/blob/master/docs/sources/plugins/datasources.md) - -Your backend need implement 4 urls - * "/" Should return 200 ok. Used for "Test connection" on the datasource config page. - * "/search" Used by the find metric options on the query tab in panels - * "/query" Should return metrics based on input - * "/annotations" should return annotations - -## Example backend implementation ## -https://gist.github.com/bergquist/bc4aa5baface3cffa109 \ No newline at end of file diff --git a/examples/datasource-plugin-genericdatasource/package.json b/examples/datasource-plugin-genericdatasource/package.json deleted file mode 100644 index 91c53734ec8..00000000000 --- a/examples/datasource-plugin-genericdatasource/package.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "name": "kentik-app", - "private": true, - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/raintank/kentik-app-poc.git" - }, - "author": "", - "license": "ISC", - "bugs": { - "url": "https://github.com/raintank/kentik-app-poc/issues" - }, - "devDependencies": { - "grunt": "~0.4.5", - "babel": "~6.5.1", - "grunt-babel": "~6.0.0", - "grunt-contrib-copy": "~0.8.2", - "grunt-contrib-watch": "^0.6.1", - "grunt-contrib-uglify": "~0.11.0", - "grunt-systemjs-builder": "^0.2.5", - "load-grunt-tasks": "~3.2.0", - "grunt-execute": "~0.2.2", - "grunt-contrib-clean": "~0.6.0" - }, - "dependencies": { - "babel-plugin-transform-es2015-modules-systemjs": "^6.5.0", - "babel-preset-es2015": "^6.5.0", - "lodash": "~4.0.0" - }, - "homepage": "https://github.com/raintank/kentik-app-poc#readme" -} diff --git a/examples/datasource-plugin-genericdatasource/plugin.json b/examples/datasource-plugin-genericdatasource/plugin.json deleted file mode 100644 index 08985726fa3..00000000000 --- a/examples/datasource-plugin-genericdatasource/plugin.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "GenericDatasource", - "id": "datasource-plugin-genericdatasource", - "type": "datasource", - - "staticRoot": ".", - - "metrics": true, - "annotations": true, - - "info": { - "description": "generic datsource plugin", - "author": { - "name": "Raintank Inc.", - "url": "http://raintank.io" - }, - "version": "0.9.0", - "updated": "2016-02-10" - }, - - "dependencies": { - "grafanaVersion": "2.6.x", - "plugins": [ ] - } -} diff --git a/examples/datasource-plugin-genericdatasource/src/css/query-editor.css b/examples/datasource-plugin-genericdatasource/src/css/query-editor.css deleted file mode 100644 index 3b678b9f368..00000000000 --- a/examples/datasource-plugin-genericdatasource/src/css/query-editor.css +++ /dev/null @@ -1,3 +0,0 @@ -.generic-datasource-query-row .query-keyword { - width: 75px; -} \ No newline at end of file diff --git a/examples/datasource-plugin-genericdatasource/src/datasource.js b/examples/datasource-plugin-genericdatasource/src/datasource.js deleted file mode 100644 index a59362f8268..00000000000 --- a/examples/datasource-plugin-genericdatasource/src/datasource.js +++ /dev/null @@ -1,75 +0,0 @@ -export class GenericDatasource { - - constructor(instanceSettings, $q, backendSrv) { - this.type = instanceSettings.type; - this.url = instanceSettings.url; - this.name = instanceSettings.name; - this.q = $q; - this.backendSrv = backendSrv; - } - - // Called once per panel (graph) - query(options) { - var query = this.buildQueryParameters(options); - - if (query.targets.length <= 0) { - return this.q.when([]); - } - - return this.backendSrv.datasourceRequest({ - url: this.url + '/query', - data: query, - method: 'POST', - headers: { 'Content-Type': 'application/json' } - }); - } - - // Required - // Used for testing datasource in datasource configuration pange - testDatasource() { - return this.backendSrv.datasourceRequest({ - url: this.url + '/', - method: 'GET' - }).then(response => { - if (response.status === 200) { - return { status: "success", message: "Data source is working", title: "Success" }; - } - }); - } - - annotationQuery(options) { - return this.backendSrv.datasourceRequest({ - url: this.url + '/annotations', - method: 'POST', - data: options - }).then(result => { - return result.data; - }); - } - - // Optional - // Required for templating - metricFindQuery(options) { - return this.backendSrv.datasourceRequest({ - url: this.url + '/search', - data: options, - method: 'POST', - headers: { 'Content-Type': 'application/json' } - }).then(this.mapToTextValue); - } - - mapToTextValue(result) { - return _.map(result.data, (d, i) => { - return { text: d, value: i}; - }); - } - - buildQueryParameters(options) { - //remove placeholder targets - options.targets = _.filter(options.targets, target => { - return target.target !== 'select metric'; - }); - - return options; - } -} diff --git a/examples/datasource-plugin-genericdatasource/src/module.js b/examples/datasource-plugin-genericdatasource/src/module.js deleted file mode 100644 index 8ab46f4edec..00000000000 --- a/examples/datasource-plugin-genericdatasource/src/module.js +++ /dev/null @@ -1,19 +0,0 @@ -import {GenericDatasource} from './datasource'; -import {GenericDatasourceQueryCtrl} from './query_ctrl'; - -class GenericConfigCtrl {} -GenericConfigCtrl.templateUrl = 'partials/config.html'; - -class GenericQueryOptionsCtrl {} -GenericQueryOptionsCtrl.templateUrl = 'partials/query.options.html'; - -class GenericAnnotationsQueryCtrl {} -GenericAnnotationsQueryCtrl.templateUrl = 'partials/annotations.editor.html' - -export { - GenericDatasource as Datasource, - GenericDatasourceQueryCtrl as QueryCtrl, - GenericConfigCtrl as ConfigCtrl, - GenericQueryOptionsCtrl as QueryOptionsCtrl, - GenericAnnotationsQueryCtrl as AnnotationsQueryCtrl -}; diff --git a/examples/datasource-plugin-genericdatasource/src/partials/annotations.editor.html b/examples/datasource-plugin-genericdatasource/src/partials/annotations.editor.html deleted file mode 100644 index f4422caa4fc..00000000000 --- a/examples/datasource-plugin-genericdatasource/src/partials/annotations.editor.html +++ /dev/null @@ -1,9 +0,0 @@ - -
Query
-
-
- -
-
- - diff --git a/examples/datasource-plugin-genericdatasource/src/partials/config.html b/examples/datasource-plugin-genericdatasource/src/partials/config.html deleted file mode 100644 index 30470039554..00000000000 --- a/examples/datasource-plugin-genericdatasource/src/partials/config.html +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/examples/datasource-plugin-genericdatasource/src/partials/query.editor.html b/examples/datasource-plugin-genericdatasource/src/partials/query.editor.html deleted file mode 100644 index b24cb0cb884..00000000000 --- a/examples/datasource-plugin-genericdatasource/src/partials/query.editor.html +++ /dev/null @@ -1,8 +0,0 @@ - - - diff --git a/examples/datasource-plugin-genericdatasource/src/partials/query.options.html b/examples/datasource-plugin-genericdatasource/src/partials/query.options.html deleted file mode 100644 index b4600118683..00000000000 --- a/examples/datasource-plugin-genericdatasource/src/partials/query.options.html +++ /dev/null @@ -1,4 +0,0 @@ -
-
-
-
diff --git a/examples/datasource-plugin-genericdatasource/src/query_ctrl.js b/examples/datasource-plugin-genericdatasource/src/query_ctrl.js deleted file mode 100644 index 30c572b6892..00000000000 --- a/examples/datasource-plugin-genericdatasource/src/query_ctrl.js +++ /dev/null @@ -1,26 +0,0 @@ -import {QueryCtrl} from 'app/plugins/sdk'; -import './css/query-editor.css!' - -export class GenericDatasourceQueryCtrl extends QueryCtrl { - - constructor($scope, $injector, uiSegmentSrv) { - super($scope, $injector); - - this.scope = $scope; - this.uiSegmentSrv = uiSegmentSrv; - this.target.target = this.target.target || 'select metric'; - } - - getOptions() { - return this.datasource.metricFindQuery(this.target) - .then(this.uiSegmentSrv.transformToSegments(false)); - // Options have to be transformed by uiSegmentSrv to be usable by metric-segment-model directive - } - - onChangeInternal() { - this.panelCtrl.refresh(); // Asks the panel to refresh data. - } -} - -GenericDatasourceQueryCtrl.templateUrl = 'partials/query.editor.html'; -