query_ctrl.ts 671 B

123456789101112131415161718192021222324252627
  1. import { QueryCtrl } from 'app/plugins/sdk';
  2. function makeDefaultQuery(database) {
  3. return `from(db: "${database}")
  4. |> range($range)
  5. |> limit(n:1000)
  6. `;
  7. }
  8. export class InfluxIfqlQueryCtrl extends QueryCtrl {
  9. static templateUrl = 'partials/query.editor.html';
  10. resultFormats: any[];
  11. /** @ngInject **/
  12. constructor($scope, $injector) {
  13. super($scope, $injector);
  14. if (this.target.query === undefined) {
  15. this.target.query = makeDefaultQuery(this.datasource.database);
  16. }
  17. this.resultFormats = [{ text: 'Time series', value: 'time_series' }, { text: 'Table', value: 'table' }];
  18. }
  19. getCollapsedText() {
  20. return this.target.query;
  21. }
  22. }