Commit f65da93d by Shavonn Brown Committed by GitHub

Azure Monitor: Use default from datasource if not saved on dashboard/query (#20899)

* use default from datasource if not saved on dash/query

* find datasource default workspace in returned workspace list

* don't need the find

* fix dropdown
parent c14398ed
......@@ -87,7 +87,11 @@ export default class AzureLogAnalyticsDatasource {
);
const generated = querystringBuilder.generate();
const workspace = this.templateSrv.replace(item.workspace, options.scopedVars);
let workspace = this.templateSrv.replace(item.workspace, options.scopedVars);
if (!workspace && this.defaultOrFirstWorkspace) {
workspace = this.defaultOrFirstWorkspace;
}
const url = `${this.baseUrl}/${workspace}/query?${generated.uriString}`;
......
......@@ -118,7 +118,7 @@
<div class="gf-form">
<label class="gf-form-label query-keyword width-9">Workspace</label>
<gf-form-dropdown model="ctrl.target.azureLogAnalytics.workspace" allow-custom="true" lookup-text="true"
get-options="ctrl.workspaces" on-change="ctrl.refresh()" css-class="min-width-12">
get-options="ctrl.getWorkspaces()" on-change="ctrl.refresh()" css-class="min-width-12">
</gf-form-dropdown>
<div class="gf-form">
<div class="width-1"></div>
......
......@@ -537,9 +537,18 @@ export class AzureMonitorQueryCtrl extends QueryCtrl {
.getWorkspaces(this.target.subscription)
.then((list: any[]) => {
this.workspaces = list;
if (list.length > 0 && !this.target.azureLogAnalytics.workspace) {
this.target.azureLogAnalytics.workspace = list[0].value;
if (this.datasource.azureLogAnalyticsDatasource.defaultOrFirstWorkspace) {
this.target.azureLogAnalytics.workspace = this.datasource.azureLogAnalyticsDatasource.defaultOrFirstWorkspace;
}
if (!this.target.azureLogAnalytics.workspace) {
this.target.azureLogAnalytics.workspace = list[0].value;
}
}
return this.workspaces;
})
.catch(this.handleQueryCtrlError.bind(this));
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment