Commit 577beebc by Daniel Lee Committed by GitHub

azuremonitor: revert to clearing chained dropdowns (#17212)

* azuremonitor: revert to clearing chained dropdowns

After feedback from users, changing back to clearing
dropdowns to the right in the chain. E.g. if the user
changes the subscription dropdown which is first in
the chain then all the dependent dropdowns to the right
should be cleared (reset to default values).

Also, now triggers getting subscriptions every time the
dropdown menu is shown rather than just the first time.
It is apparently common to add subscriptions while
building queries.
parent a96b522a
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<div class="gf-form" ng-if="ctrl.target.queryType === 'Azure Monitor' || ctrl.target.queryType === 'Azure Log Analytics'"> <div class="gf-form" ng-if="ctrl.target.queryType === 'Azure Monitor' || ctrl.target.queryType === 'Azure Log Analytics'">
<label class="gf-form-label query-keyword width-9">Subscription</label> <label class="gf-form-label query-keyword width-9">Subscription</label>
<gf-form-dropdown model="ctrl.target.subscription" allow-custom="true" lookup-text="true" <gf-form-dropdown model="ctrl.target.subscription" allow-custom="true" lookup-text="true"
get-options="ctrl.subscriptions" on-change="ctrl.onSubscriptionChange()" css-class="min-width-12"> get-options="ctrl.getSubscriptions()" on-change="ctrl.onSubscriptionChange()" css-class="min-width-12">
</gf-form-dropdown> </gf-form-dropdown>
</div> </div>
<div class="gf-form gf-form--grow"> <div class="gf-form gf-form--grow">
......
...@@ -197,6 +197,8 @@ export class AzureMonitorQueryCtrl extends QueryCtrl { ...@@ -197,6 +197,8 @@ export class AzureMonitorQueryCtrl extends QueryCtrl {
if (!this.target.subscription && this.subscriptions.length > 0) { if (!this.target.subscription && this.subscriptions.length > 0) {
this.target.subscription = this.subscriptions[0].value; this.target.subscription = this.subscriptions[0].value;
} }
return this.subscriptions;
}); });
} }
...@@ -204,6 +206,18 @@ export class AzureMonitorQueryCtrl extends QueryCtrl { ...@@ -204,6 +206,18 @@ export class AzureMonitorQueryCtrl extends QueryCtrl {
if (this.target.queryType === 'Azure Log Analytics') { if (this.target.queryType === 'Azure Log Analytics') {
return this.getWorkspaces(); return this.getWorkspaces();
} }
if (this.target.queryType === 'Azure Monitor') {
this.target.azureMonitor.resourceGroup = this.defaultDropdownValue;
this.target.azureMonitor.metricDefinition = this.defaultDropdownValue;
this.target.azureMonitor.resourceName = this.defaultDropdownValue;
this.target.azureMonitor.metricName = this.defaultDropdownValue;
this.target.azureMonitor.aggregation = '';
this.target.azureMonitor.timeGrains = [];
this.target.azureMonitor.timeGrain = '';
this.target.azureMonitor.dimensions = [];
this.target.azureMonitor.dimension = '';
}
} }
/* Azure Monitor Section */ /* Azure Monitor Section */
...@@ -279,6 +293,12 @@ export class AzureMonitorQueryCtrl extends QueryCtrl { ...@@ -279,6 +293,12 @@ export class AzureMonitorQueryCtrl extends QueryCtrl {
} }
onResourceGroupChange() { onResourceGroupChange() {
this.target.azureMonitor.metricDefinition = this.defaultDropdownValue;
this.target.azureMonitor.resourceName = this.defaultDropdownValue;
this.target.azureMonitor.metricName = this.defaultDropdownValue;
this.target.azureMonitor.aggregation = '';
this.target.azureMonitor.timeGrains = [];
this.target.azureMonitor.timeGrain = '';
this.target.azureMonitor.dimensions = []; this.target.azureMonitor.dimensions = [];
this.target.azureMonitor.dimension = ''; this.target.azureMonitor.dimension = '';
} }
...@@ -286,11 +306,18 @@ export class AzureMonitorQueryCtrl extends QueryCtrl { ...@@ -286,11 +306,18 @@ export class AzureMonitorQueryCtrl extends QueryCtrl {
onMetricDefinitionChange() { onMetricDefinitionChange() {
this.target.azureMonitor.resourceName = this.defaultDropdownValue; this.target.azureMonitor.resourceName = this.defaultDropdownValue;
this.target.azureMonitor.metricName = this.defaultDropdownValue; this.target.azureMonitor.metricName = this.defaultDropdownValue;
this.target.azureMonitor.aggregation = '';
this.target.azureMonitor.timeGrains = [];
this.target.azureMonitor.timeGrain = '';
this.target.azureMonitor.dimensions = []; this.target.azureMonitor.dimensions = [];
this.target.azureMonitor.dimension = ''; this.target.azureMonitor.dimension = '';
} }
onResourceNameChange() { onResourceNameChange() {
this.target.azureMonitor.metricName = this.defaultDropdownValue;
this.target.azureMonitor.aggregation = '';
this.target.azureMonitor.timeGrains = [];
this.target.azureMonitor.timeGrain = '';
this.target.azureMonitor.dimensions = []; this.target.azureMonitor.dimensions = [];
this.target.azureMonitor.dimension = ''; this.target.azureMonitor.dimension = '';
} }
...@@ -312,6 +339,7 @@ export class AzureMonitorQueryCtrl extends QueryCtrl { ...@@ -312,6 +339,7 @@ export class AzureMonitorQueryCtrl extends QueryCtrl {
this.target.azureMonitor.aggOptions = metadata.supportedAggTypes || [metadata.primaryAggType]; this.target.azureMonitor.aggOptions = metadata.supportedAggTypes || [metadata.primaryAggType];
this.target.azureMonitor.aggregation = metadata.primaryAggType; this.target.azureMonitor.aggregation = metadata.primaryAggType;
this.target.azureMonitor.timeGrains = [{ text: 'auto', value: 'auto' }].concat(metadata.supportedTimeGrains); this.target.azureMonitor.timeGrains = [{ text: 'auto', value: 'auto' }].concat(metadata.supportedTimeGrains);
this.target.azureMonitor.timeGrain = 'auto';
this.target.azureMonitor.dimensions = metadata.dimensions; this.target.azureMonitor.dimensions = metadata.dimensions;
if (metadata.dimensions.length > 0) { if (metadata.dimensions.length > 0) {
......
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