mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
azuremonitor: move files into grafana
Initial port of the code from the plugin - lots of small things to fix.
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import AzureLogAnalyticsDatasource from './azure_log_analytics/azure_log_analytics_datasource';
|
||||
import config from 'app/core/config';
|
||||
import { isVersionGtOrEq } from './version';
|
||||
|
||||
export class AzureMonitorConfigCtrl {
|
||||
static templateUrl = 'public/app/plugins/datasource/grafana-azure-monitor-datasource/partials/config.html';
|
||||
current: any;
|
||||
azureLogAnalyticsDatasource: any;
|
||||
workspaces: any[];
|
||||
hasRequiredGrafanaVersion: boolean;
|
||||
|
||||
/** @ngInject */
|
||||
constructor($scope, backendSrv, $q) {
|
||||
this.hasRequiredGrafanaVersion = this.hasMinVersion();
|
||||
this.current.jsonData.cloudName = this.current.jsonData.cloudName || 'azuremonitor';
|
||||
this.current.jsonData.azureLogAnalyticsSameAs = this.current.jsonData.azureLogAnalyticsSameAs || false;
|
||||
|
||||
if (this.current.id) {
|
||||
this.current.url = '/api/datasources/proxy/' + this.current.id;
|
||||
this.azureLogAnalyticsDatasource = new AzureLogAnalyticsDatasource(this.current, backendSrv, null, $q);
|
||||
this.getWorkspaces();
|
||||
}
|
||||
}
|
||||
|
||||
hasMinVersion(): boolean {
|
||||
return isVersionGtOrEq(config.buildInfo.version, '5.2');
|
||||
}
|
||||
|
||||
showMinVersionWarning() {
|
||||
return !this.hasRequiredGrafanaVersion && this.current.secureJsonFields.logAnalyticsClientSecret;
|
||||
}
|
||||
|
||||
getWorkspaces() {
|
||||
if (!this.azureLogAnalyticsDatasource.isConfigured()) {
|
||||
return;
|
||||
}
|
||||
|
||||
return this.azureLogAnalyticsDatasource.getWorkspaces().then(workspaces => {
|
||||
this.workspaces = workspaces;
|
||||
if (this.workspaces.length > 0) {
|
||||
this.current.jsonData.logAnalyticsDefaultWorkspace =
|
||||
this.current.jsonData.logAnalyticsDefaultWorkspace || this.workspaces[0].value;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user