├── Gruntfile.js ├── LICENSE ├── README.md ├── dist ├── README.md ├── css │ └── query-editor.css ├── datasource.js ├── datasource.js.map ├── img │ ├── ntopng_logo.svg │ └── simpleJson_logo.svg ├── module.js ├── module.js.map ├── partials │ ├── annotations.editor.html │ ├── config.html │ ├── query.editor.html │ └── query.options.html ├── plugin.json ├── query_ctrl.js └── query_ctrl.js.map ├── package.json ├── spec ├── datasource_spec.js └── test-main.js ├── src ├── css │ └── query-editor.css ├── datasource.js ├── img │ ├── ntopng_logo.svg │ └── simpleJson_logo.svg ├── module.js ├── partials │ ├── annotations.editor.html │ ├── config.html │ ├── query.editor.html │ └── query.options.html ├── plugin.json └── query_ctrl.js └── yarn.lock /Gruntfile.js: -------------------------------------------------------------------------------- 1 | module.exports = function(grunt) { 2 | 3 | require('load-grunt-tasks')(grunt); 4 | 5 | grunt.loadNpmTasks('grunt-execute'); 6 | grunt.loadNpmTasks('grunt-contrib-clean'); 7 | 8 | grunt.initConfig({ 9 | 10 | clean: ["dist"], 11 | 12 | copy: { 13 | src_to_dist: { 14 | cwd: 'src', 15 | expand: true, 16 | src: ['**/*', '!**/*.js', '!**/*.scss'], 17 | dest: 'dist' 18 | }, 19 | pluginDef: { 20 | expand: true, 21 | src: ['README.md'], 22 | dest: 'dist' 23 | } 24 | }, 25 | 26 | watch: { 27 | rebuild_all: { 28 | files: ['src/**/*'], 29 | tasks: ['default'], 30 | options: {spawn: false} 31 | } 32 | }, 33 | 34 | babel: { 35 | options: { 36 | sourceMap: true, 37 | presets: ['es2015'] 38 | }, 39 | dist: { 40 | options: { 41 | plugins: ['transform-es2015-modules-systemjs', 'transform-es2015-for-of'] 42 | }, 43 | files: [{ 44 | cwd: 'src', 45 | expand: true, 46 | src: ['**/*.js'], 47 | dest: 'dist', 48 | ext:'.js' 49 | }] 50 | }, 51 | distTestNoSystemJs: { 52 | files: [{ 53 | cwd: 'src', 54 | expand: true, 55 | src: ['**/*.js'], 56 | dest: 'dist/test', 57 | ext:'.js' 58 | }] 59 | }, 60 | distTestsSpecsNoSystemJs: { 61 | files: [{ 62 | expand: true, 63 | cwd: 'spec', 64 | src: ['**/*.js'], 65 | dest: 'dist/test/spec', 66 | ext:'.js' 67 | }] 68 | } 69 | }, 70 | 71 | mochaTest: { 72 | test: { 73 | options: { 74 | reporter: 'spec' 75 | }, 76 | src: ['dist/test/spec/test-main.js', 'dist/test/spec/*_spec.js'] 77 | } 78 | } 79 | }); 80 | 81 | grunt.registerTask('default', ['clean', 'copy:src_to_dist', 'copy:pluginDef', 'babel', 'mochaTest']); 82 | }; 83 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (C) 2013-17 - ntop.org 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Discontinuation Notice 2 | ---------------------- 3 | 4 | ntop has redicected resources and focus to the integration of InfluxDB, which is natively supported in ntopng starting from version 3.8. For this reason, support and development for this plugin have been discontinued in favour of the InfluxDB Grafana datasource plugin https://grafana.com/docs/features/datasources/influxdb/. 5 | 6 | To start using InfluxDB with ntopng please refer to the documentation: https://www.ntop.org/guides/ntopng/basic_concepts/timeseries.html#influxdb-driver 7 | 8 | ## ntopng Datasource 9 | 10 | The official ntopng Grafana datasource plugin lets you quickly 11 | navigate ntopng data from inside the beautiful Grafana dashboards. 12 | 13 | ### Setting Up the Datasource 14 | 15 | To set up the datasource visit Grafana Datasources page and select the 16 | green button `Add a datasource`. Select `ntopng` as the datasource 17 | `Type` in the page that opens. 18 | 19 | The HTTP url must point to a running ntopng instance, to the endpoint 20 | `/lua/modules/grafana`. The `Access` method must be set to 21 | `Direct`. An example of a full HTTP url that assumes there is an 22 | ntopng instance running on `localhost` port `3001` is the following: 23 | 24 | `http://localhost:3001/lua/modules/grafana` 25 | 26 | Tick `Basic Auth` if your ntopng instance has authentication enabled 27 | and specify a username-password pair in fields `User` and 28 | `Password`. The pair must identify an ntopng user. Leave the `Basic 29 | Auth` checkbock unticked if ntopng has no authentication 30 | (`--disable-login`). 31 | 32 | Finally, hit the button `Save and Test` to verify the datasource is 33 | working properly. A green message `Success: Data souce is working` 34 | appears to confirm the datasource is properly set up. 35 | 36 | ### Supported metrics 37 | 38 | Once the datasource is set up, ntopng metrics can be charted in any 39 | Grafana dashboard. 40 | 41 | Supported metrics are: 42 | - Interface metrics 43 | - Host metrics 44 | 45 | Metrics that identify an interface are prefixed with a `interface_` 46 | that precedes the actual interface name. Similarly, metrics that 47 | identify an host are prefixed with a `host_` followed by the actual 48 | host ip address. 49 | 50 | Interface and host metrics have a suffix that contain the type of 51 | metric (i.e., `traffic` for traffic rates and traffic totals orT 52 | `allprotocols` for layer-7 application protocol rates). 53 | The type of metric is followed by the unit of measure (i.e., `bps` 54 | for bits per second, `pps` for packets per second, and `bytes`). 55 | 56 | #### Interface Metrics 57 | 58 | Supported interface metrics are: 59 | - Traffic rates, in bits and packets per second 60 | - Traffic totals, both in Bytes and packets 61 | - Application protocol rates, in bits per second 62 | 63 | #### Host Metrics 64 | 65 | Supported host metrics are: 66 | - Traffic rate in bits per second 67 | - Traffic total in Bytes 68 | - Application protocol rates in bits per second. 69 | -------------------------------------------------------------------------------- /dist/README.md: -------------------------------------------------------------------------------- 1 | ## ntopng Datasource 2 | 3 | The official ntopng Grafana datasource plugin lets you quickly 4 | navigate ntopng data from inside the beautiful Grafana dashboards. 5 | 6 | ### Setting Up the Datasource 7 | 8 | To set up the datasource visit Grafana Datasources page and select the 9 | green button `Add a datasource`. Select `ntopng` as the datasource 10 | `Type` in the page that opens. 11 | 12 | The HTTP url must point to a running ntopng instance, to the endpoint 13 | `/lua/modules/grafana`. The `Access` method must be set to 14 | `Direct`. An example of a full HTTP url that assumes there is an 15 | ntopng instance running on `localhost` port `3001` is the following: 16 | 17 | `http://localhost:3001/lua/modules/grafana` 18 | 19 | Tick `Basic Auth` if your ntopng instance has authentication enabled 20 | and specify a username-password pair in fields `User` and 21 | `Password`. The pair must identify an ntopng user. Leave the `Basic 22 | Auth` checkbock unticked if ntopng has no authentication 23 | (`--disable-login`). 24 | 25 | Finally, hit the button `Save and Test` to verify the datasource is 26 | working properly. A green message `Success: Data souce is working` 27 | appears to confirm the datasource is properly set up. 28 | 29 | ### Supported metrics 30 | 31 | Once the datasource is set up, ntopng metrics can be charted in any 32 | Grafana dashboard. 33 | 34 | Supported metrics are: 35 | - Interface metrics 36 | - Host metrics 37 | 38 | Metrics that identify an interface are prefixed with a `interface_` 39 | that precedes the actual interface name. Similarly, metrics that 40 | identify an host are prefixed with a `host_` followed by the actual 41 | host ip address. 42 | 43 | Interface and host metrics have a suffix that contain the type of 44 | metric (i.e., `traffic` for traffic rates and traffic totals or 45 | `allprotocols` for layer-7 application protocol rates). 46 | The type of metric is followed by the unit of measure (i.e., `bps` 47 | for bits per second, `pps` for packets per second, and `bytes`). 48 | 49 | #### Interface Metrics 50 | 51 | Supported interface metrics are: 52 | - Traffic rates, in bits and packets per second 53 | - Traffic totals, both in Bytes and packets 54 | - Application protocol rates, in bits per second 55 | 56 | #### Host Metrics 57 | 58 | Supported host metrics are: 59 | - Traffic rate in bits per second 60 | - Traffic total in Bytes 61 | - Application protocol rates in bits per second. 62 | -------------------------------------------------------------------------------- /dist/css/query-editor.css: -------------------------------------------------------------------------------- 1 | .generic-datasource-query-row .query-keyword { 2 | width: 75px; 3 | } -------------------------------------------------------------------------------- /dist/datasource.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | System.register(['lodash'], function (_export, _context) { 4 | "use strict"; 5 | 6 | var _, _createClass, GenericDatasource; 7 | 8 | function _classCallCheck(instance, Constructor) { 9 | if (!(instance instanceof Constructor)) { 10 | throw new TypeError("Cannot call a class as a function"); 11 | } 12 | } 13 | 14 | return { 15 | setters: [function (_lodash) { 16 | _ = _lodash.default; 17 | }], 18 | execute: function () { 19 | _createClass = function () { 20 | function defineProperties(target, props) { 21 | for (var i = 0; i < props.length; i++) { 22 | var descriptor = props[i]; 23 | descriptor.enumerable = descriptor.enumerable || false; 24 | descriptor.configurable = true; 25 | if ("value" in descriptor) descriptor.writable = true; 26 | Object.defineProperty(target, descriptor.key, descriptor); 27 | } 28 | } 29 | 30 | return function (Constructor, protoProps, staticProps) { 31 | if (protoProps) defineProperties(Constructor.prototype, protoProps); 32 | if (staticProps) defineProperties(Constructor, staticProps); 33 | return Constructor; 34 | }; 35 | }(); 36 | 37 | _export('GenericDatasource', GenericDatasource = function () { 38 | function GenericDatasource(instanceSettings, $q, backendSrv, templateSrv) { 39 | _classCallCheck(this, GenericDatasource); 40 | 41 | this.type = instanceSettings.type; 42 | this.url = instanceSettings.url; 43 | this.name = instanceSettings.name; 44 | this.q = $q; 45 | this.backendSrv = backendSrv; 46 | this.templateSrv = templateSrv; 47 | this.withCredentials = instanceSettings.withCredentials; 48 | this.headers = { 'Content-Type': 'application/json' }; 49 | if (typeof instanceSettings.basicAuth === 'string' && instanceSettings.basicAuth.length > 0) { 50 | this.headers['Authorization'] = instanceSettings.basicAuth; 51 | } 52 | } 53 | 54 | _createClass(GenericDatasource, [{ 55 | key: 'query', 56 | value: function query(options) { 57 | var query = this.buildQueryParameters(options); 58 | query.targets = query.targets.filter(function (t) { 59 | return !t.hide; 60 | }); 61 | 62 | if (query.targets.length <= 0) { 63 | return this.q.when({ data: [] }); 64 | } 65 | 66 | return this.doRequest({ 67 | url: this.url + '/query', 68 | data: query, 69 | method: 'POST' 70 | }); 71 | } 72 | }, { 73 | key: 'testDatasource', 74 | value: function testDatasource() { 75 | return this.doRequest({ 76 | url: this.url + '/', 77 | method: 'GET' 78 | }).then(function (response) { 79 | if (response.status === 200) { 80 | return { status: "success", message: "Data source is working", title: "Success" }; 81 | } 82 | }); 83 | } 84 | }, { 85 | key: 'annotationQuery', 86 | value: function annotationQuery(options) { 87 | var query = this.templateSrv.replace(options.annotation.query, {}, 'glob'); 88 | var annotationQuery = { 89 | range: options.range, 90 | annotation: { 91 | name: options.annotation.name, 92 | datasource: options.annotation.datasource, 93 | enable: options.annotation.enable, 94 | iconColor: options.annotation.iconColor, 95 | query: query 96 | }, 97 | rangeRaw: options.rangeRaw 98 | }; 99 | 100 | return this.doRequest({ 101 | url: this.url + '/annotations', 102 | method: 'POST', 103 | data: annotationQuery 104 | }).then(function (result) { 105 | return result.data; 106 | }); 107 | } 108 | }, { 109 | key: 'metricFindQuery', 110 | value: function metricFindQuery(query) { 111 | var interpolated = { 112 | target: this.templateSrv.replace(query, null, 'regex') 113 | }; 114 | 115 | return this.doRequest({ 116 | url: this.url + '/search', 117 | data: interpolated, 118 | method: 'POST' 119 | }).then(this.mapToTextValue); 120 | } 121 | }, { 122 | key: 'mapToTextValue', 123 | value: function mapToTextValue(result) { 124 | return _.map(result.data, function (d, i) { 125 | if (d && d.text && d.value) { 126 | return { text: d.text, value: d.value }; 127 | } else if (_.isObject(d)) { 128 | return { text: d, value: i }; 129 | } 130 | return { text: d, value: d }; 131 | }); 132 | } 133 | }, { 134 | key: 'doRequest', 135 | value: function doRequest(options) { 136 | options.withCredentials = this.withCredentials; 137 | options.headers = this.headers; 138 | 139 | return this.backendSrv.datasourceRequest(options); 140 | } 141 | }, { 142 | key: 'buildQueryParameters', 143 | value: function buildQueryParameters(options) { 144 | var _this = this; 145 | 146 | //remove placeholder targets 147 | options.targets = _.filter(options.targets, function (target) { 148 | return target.target !== 'select metric'; 149 | }); 150 | 151 | var targets = _.map(options.targets, function (target) { 152 | return { 153 | target: _this.templateSrv.replace(target.target, options.scopedVars, 'regex'), 154 | refId: target.refId, 155 | hide: target.hide, 156 | type: target.type || 'timeserie' 157 | }; 158 | }); 159 | 160 | options.targets = targets; 161 | 162 | return options; 163 | } 164 | }]); 165 | 166 | return GenericDatasource; 167 | }()); 168 | 169 | _export('GenericDatasource', GenericDatasource); 170 | } 171 | }; 172 | }); 173 | //# sourceMappingURL=datasource.js.map 174 | -------------------------------------------------------------------------------- /dist/datasource.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["../src/datasource.js"],"names":["_","GenericDatasource","instanceSettings","$q","backendSrv","templateSrv","type","url","name","q","withCredentials","headers","basicAuth","length","options","query","buildQueryParameters","targets","filter","t","hide","when","data","doRequest","method","then","response","status","message","title","replace","annotation","annotationQuery","range","datasource","enable","iconColor","rangeRaw","result","interpolated","target","mapToTextValue","map","d","i","text","value","isObject","datasourceRequest","scopedVars","refId"],"mappings":";;;;;;;;;;;;;;;AAAOA,O;;;;;;;;;;;;;;;;;;;;;mCAEMC,iB;AAEX,mCAAYC,gBAAZ,EAA8BC,EAA9B,EAAkCC,UAAlC,EAA8CC,WAA9C,EAA2D;AAAA;;AACzD,eAAKC,IAAL,GAAYJ,iBAAiBI,IAA7B;AACA,eAAKC,GAAL,GAAWL,iBAAiBK,GAA5B;AACA,eAAKC,IAAL,GAAYN,iBAAiBM,IAA7B;AACA,eAAKC,CAAL,GAASN,EAAT;AACA,eAAKC,UAAL,GAAkBA,UAAlB;AACA,eAAKC,WAAL,G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F,CAAR,EAAWG,OAAOH,CAAlB,EAAP;AACD,aAPM,CAAP;AAQD;;;oCAES7B,O,EAAS;AACjBA,oBAAQJ,eAAR,GAA0B,KAAKA,eAA/B;AACAI,oBAAQH,OAAR,GAAkB,KAAKA,OAAvB;;AAEA,mBAAO,KAAKP,UAAL,CAAgB4C,iBAAhB,CAAkClC,OAAlC,CAAP;AACD;;;+CAEoBA,O,EAAS;AAAA;;AAC5B;AACAA,oBAAQG,OAAR,GAAkBjB,EAAEkB,MAAF,CAASJ,QAAQG,OAAjB,EAA0B,kBAAU;AACpD,qBAAOuB,OAAOA,MAAP,KAAkB,eAAzB;AACD,aAFiB,CAAlB;;AAIA,gBAAIvB,UAAUjB,EAAE0C,GAAF,CAAM5B,QAAQG,OAAd,EAAuB,kBAAU;AAC7C,qBAAO;AACLuB,wBAAQ,MAAKnC,WAAL,CAAiByB,OAAjB,CAAyBU,OAAOA,MAAhC,EAAwC1B,QAAQmC,UAAhD,EAA4D,OAA5D,CADH;AAELC,uBAAOV,OAAOU,KAFT;AAGL9B,sBAAMoB,OAAOpB,IAHR;AAILd,sBAAMkC,OAAOlC,IAAP,IAAe;AAJhB,eAAP;AAMD,aAPa,CAAd;;AASAQ,oBAAQG,OAAR,GAAkBA,OAAlB;;AAEA,mBAAOH,OAAP;AACD","file":"datasource.js","sourcesContent":["import _ from \"lodash\";\n\nexport class GenericDatasource {\n\n constructor(instanceSettings, $q, backendSrv, templateSrv) {\n this.type = instanceSettings.type;\n this.url = instanceSettings.url;\n this.name = instanceSettings.name;\n this.q = $q;\n this.backendSrv = backendSrv;\n this.templateSrv = templateSrv;\n this.withCredentials = instanceSettings.withCredentials;\n this.headers = {'Content-Type': 'application/json'};\n if (typeof instanceSettings.basicAuth === 'string' && instanceSettings.basicAuth.length > 0) {\n this.headers['Authorization'] = instanceSettings.basicAuth;\n }\n }\n\n query(options) {\n var query = this.buildQueryParameters(options);\n query.targets = query.targets.filter(t => !t.hide);\n\n if (query.targets.length <= 0) {\n return this.q.when({data: []});\n }\n\n return this.doRequest({\n url: this.url + '/query',\n data: query,\n method: 'POST'\n });\n }\n\n testDatasource() {\n return this.doRequest({\n url: this.url + '/',\n method: 'GET',\n }).then(response => {\n if (response.status === 200) {\n return { status: \"success\", message: \"Data source is working\", title: \"Success\" };\n }\n });\n }\n\n annotationQuery(options) {\n var query = this.templateSrv.replace(options.annotation.query, {}, 'glob');\n var annotationQuery = {\n range: options.range,\n annotation: {\n name: options.annotation.name,\n datasource: options.annotation.datasource,\n enable: options.annotation.enable,\n iconColor: options.annotation.iconColor,\n query: query\n },\n rangeRaw: options.rangeRaw\n };\n\n return this.doRequest({\n url: this.url + '/annotations',\n method: 'POST',\n data: annotationQuery\n }).then(result => {\n return result.data;\n });\n }\n\n metricFindQuery(query) {\n var interpolated = {\n target: this.templateSrv.replace(query, null, 'regex')\n };\n\n return this.doRequest({\n url: this.url + '/search',\n data: interpolated,\n method: 'POST',\n }).then(this.mapToTextValue);\n }\n\n mapToTextValue(result) {\n return _.map(result.data, (d, i) => {\n if (d && d.text && d.value) {\n return { text: d.text, value: d.value };\n } else if (_.isObject(d)) {\n return { text: d, value: i};\n }\n return { text: d, value: d };\n });\n }\n\n doRequest(options) {\n options.withCredentials = this.withCredentials;\n options.headers = this.headers;\n\n return this.backendSrv.datasourceRequest(options);\n }\n\n buildQueryParameters(options) {\n //remove placeholder targets\n options.targets = _.filter(options.targets, target => {\n return target.target !== 'select metric';\n });\n\n var targets = _.map(options.targets, target => {\n return {\n target: this.templateSrv.replace(target.target, options.scopedVars, 'regex'),\n refId: target.refId,\n hide: target.hide,\n type: target.type || 'timeserie'\n };\n });\n\n options.targets = targets;\n\n return options;\n }\n}\n"]} -------------------------------------------------------------------------------- /dist/img/ntopng_logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | image/svg+xml 8 | 9 | 10 | 11 | 12 | 13 | 14 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /dist/img/simpleJson_logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 536 | 537 | 538 | 539 | 540 | 541 | 542 | 543 | 544 | 545 | 546 | 548 | 549 | 550 | 551 | 552 | 553 | 554 | 555 | 556 | 557 | 558 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 | 612 | 613 | 614 | 615 | 619 | 620 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 634 | 635 | 636 | -------------------------------------------------------------------------------- /dist/module.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | System.register(['./datasource', './query_ctrl'], function (_export, _context) { 4 | "use strict"; 5 | 6 | var GenericDatasource, GenericDatasourceQueryCtrl, GenericConfigCtrl, GenericQueryOptionsCtrl, GenericAnnotationsQueryCtrl; 7 | 8 | function _classCallCheck(instance, Constructor) { 9 | if (!(instance instanceof Constructor)) { 10 | throw new TypeError("Cannot call a class as a function"); 11 | } 12 | } 13 | 14 | return { 15 | setters: [function (_datasource) { 16 | GenericDatasource = _datasource.GenericDatasource; 17 | }, function (_query_ctrl) { 18 | GenericDatasourceQueryCtrl = _query_ctrl.GenericDatasourceQueryCtrl; 19 | }], 20 | execute: function () { 21 | _export('ConfigCtrl', GenericConfigCtrl = function GenericConfigCtrl() { 22 | _classCallCheck(this, GenericConfigCtrl); 23 | }); 24 | 25 | GenericConfigCtrl.templateUrl = 'partials/config.html'; 26 | 27 | _export('QueryOptionsCtrl', GenericQueryOptionsCtrl = function GenericQueryOptionsCtrl() { 28 | _classCallCheck(this, GenericQueryOptionsCtrl); 29 | }); 30 | 31 | GenericQueryOptionsCtrl.templateUrl = 'partials/query.options.html'; 32 | 33 | _export('AnnotationsQueryCtrl', GenericAnnotationsQueryCtrl = function GenericAnnotationsQueryCtrl() { 34 | _classCallCheck(this, GenericAnnotationsQueryCtrl); 35 | }); 36 | 37 | GenericAnnotationsQueryCtrl.templateUrl = 'partials/annotations.editor.html'; 38 | 39 | _export('Datasource', GenericDatasource); 40 | 41 | _export('QueryCtrl', GenericDatasourceQueryCtrl); 42 | 43 | _export('ConfigCtrl', GenericConfigCtrl); 44 | 45 | _export('QueryOptionsCtrl', GenericQueryOptionsCtrl); 46 | 47 | _export('AnnotationsQueryCtrl', GenericAnnotationsQueryCtrl); 48 | } 49 | }; 50 | }); 51 | //# sourceMappingURL=module.js.map 52 | -------------------------------------------------------------------------------- /dist/module.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["../src/module.js"],"names":["GenericDatasource","GenericDatasourceQueryCtrl","GenericConfigCtrl","templateUrl","GenericQueryOptionsCtrl","GenericAnnotationsQueryCtrl"],"mappings":";;;;;;;;;;;;;;;AAAQA,uB,eAAAA,iB;;AACAC,gC,eAAAA,0B;;;4BAEFC,iB;;;;AACNA,wBAAkBC,WAAlB,GAAgC,sBAAhC;;kCAEMC,uB;;;;AACNA,8BAAwBD,WAAxB,GAAsC,6BAAtC;;sCAEME,2B;;;;AACNA,kCAA4BF,WAA5B,GAA0C,kCAA1C;;4BAGEH,iB;;2BACAC,0B;;4BACAC,iB;;kCACAE,uB;;sCACAC,2B","file":"module.js","sourcesContent":["import {GenericDatasource} from './datasource';\nimport {GenericDatasourceQueryCtrl} from './query_ctrl';\n\nclass GenericConfigCtrl {}\nGenericConfigCtrl.templateUrl = 'partials/config.html';\n\nclass GenericQueryOptionsCtrl {}\nGenericQueryOptionsCtrl.templateUrl = 'partials/query.options.html';\n\nclass GenericAnnotationsQueryCtrl {}\nGenericAnnotationsQueryCtrl.templateUrl = 'partials/annotations.editor.html'\n\nexport {\n GenericDatasource as Datasource,\n GenericDatasourceQueryCtrl as QueryCtrl,\n GenericConfigCtrl as ConfigCtrl,\n GenericQueryOptionsCtrl as QueryOptionsCtrl,\n GenericAnnotationsQueryCtrl as AnnotationsQueryCtrl\n};\n"]} -------------------------------------------------------------------------------- /dist/partials/annotations.editor.html: -------------------------------------------------------------------------------- 1 | 2 |
Query
3 |
4 |
5 | 6 |
7 |
8 | 9 | 10 | -------------------------------------------------------------------------------- /dist/partials/config.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /dist/partials/query.editor.html: -------------------------------------------------------------------------------- 1 | 2 |
3 |
4 | 5 |
6 | 7 |
8 |