annotations_query_ctrl.ts 952 B

1234567891011121314151617181920212223242526272829303132
  1. export class AzureMonitorAnnotationsQueryCtrl {
  2. static templateUrl = 'partials/annotations.editor.html';
  3. datasource: any;
  4. annotation: any;
  5. workspaces: any[];
  6. defaultQuery = '<your table>\n| where $__timeFilter() \n| project TimeGenerated, Text=YourTitleColumn, Tags="tag1,tag2"';
  7. /** @ngInject */
  8. constructor() {
  9. this.annotation.queryType = this.annotation.queryType || 'Azure Log Analytics';
  10. this.annotation.rawQuery = this.annotation.rawQuery || this.defaultQuery;
  11. this.getWorkspaces();
  12. }
  13. getWorkspaces() {
  14. if (this.workspaces && this.workspaces.length > 0) {
  15. return this.workspaces;
  16. }
  17. return this.datasource
  18. .getAzureLogAnalyticsWorkspaces()
  19. .then(list => {
  20. this.workspaces = list;
  21. if (list.length > 0 && !this.annotation.workspace) {
  22. this.annotation.workspace = list[0].value;
  23. }
  24. return this.workspaces;
  25. })
  26. .catch(() => {});
  27. }
  28. }