mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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
This commit is contained in:
parent
c14398edc8
commit
f65da93d72
@ -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));
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user