grafana/public/app/plugins/datasource/grafana-azure-monitor-datasource/annotations_query_ctrl.ts
Daniel Lee dd96f2a522 azuremonitor: move files into grafana
Initial port of the code from the plugin - lots of small things to fix.
2019-01-17 10:55:03 +01:00

33 lines
952 B
TypeScript

export class AzureMonitorAnnotationsQueryCtrl {
static templateUrl = 'partials/annotations.editor.html';
datasource: any;
annotation: any;
workspaces: any[];
defaultQuery = '<your table>\n| where $__timeFilter() \n| project TimeGenerated, Text=YourTitleColumn, Tags="tag1,tag2"';
/** @ngInject */
constructor() {
this.annotation.queryType = this.annotation.queryType || 'Azure Log Analytics';
this.annotation.rawQuery = this.annotation.rawQuery || this.defaultQuery;
this.getWorkspaces();
}
getWorkspaces() {
if (this.workspaces && this.workspaces.length > 0) {
return this.workspaces;
}
return this.datasource
.getAzureLogAnalyticsWorkspaces()
.then(list => {
this.workspaces = list;
if (list.length > 0 && !this.annotation.workspace) {
this.annotation.workspace = list[0].value;
}
return this.workspaces;
})
.catch(() => {});
}
}