Browse Source

Do not disable Apply button when unit is in LEARNING state #401 (#402)

master
Evgeny Smyshlyaev 4 years ago committed by GitHub
parent
commit
c3b674515f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      src/panel/graph_panel/graph_ctrl.ts
  2. 2
      src/panel/graph_panel/partials/analytic_units_5.x.html
  3. 2
      src/panel/graph_panel/partials/analytic_units_6.x.html
  4. 27
      src/panel/graph_panel/partials/relearning_confirmation.html

17
src/panel/graph_panel/graph_ctrl.ts

@ -629,7 +629,22 @@ class GraphCtrl extends MetricsPanelCtrl {
this.analyticsController.redetectAll(from, to);
}
async runDetectInCurrentRange(analyticUnit: AnalyticUnit) {
async runDetectInCurrentRange(analyticUnit: AnalyticUnit): Promise<void> {
if(analyticUnit.status === 'LEARNING') {
let modalScope = this.$scope.$new(true);
modalScope.confirm = async () => {
await this._runDetectInCurrentRange(analyticUnit);
};
appEvents.emit('show-modal', {
src: `${this.partialsPath}/relearning_confirmation.html`,
scope: modalScope
});
} else {
await this._runDetectInCurrentRange(analyticUnit);
}
}
async _runDetectInCurrentRange(analyticUnit: AnalyticUnit): Promise<void> {
const { from, to } = this.rangeTimestamp;
if(analyticUnit.changed) {

2
src/panel/graph_panel/partials/analytic_units_5.x.html

@ -126,7 +126,7 @@
<label class="gf-form-label"
ng-click="ctrl.runDetectInCurrentRange(analyticUnit)"
ng-disabled="analyticUnit.status === 'LEARNING' || analyticUnit.saving"
ng-disabled="analyticUnit.saving"
bs-tooltip="'Learn & Detect'"
>
<a class="pointer">

2
src/panel/graph_panel/partials/analytic_units_6.x.html

@ -115,7 +115,7 @@
<button class="query-editor-row__action"
ng-click="ctrl.runDetectInCurrentRange(analyticUnit)"
ng-disabled="analyticUnit.status === 'LEARNING' || analyticUnit.saving"
ng-disabled="analyticUnit.saving"
bs-tooltip="'Learn & Detect'"
>
<a class="pointer">

27
src/panel/graph_panel/partials/relearning_confirmation.html

@ -0,0 +1,27 @@
<div class="modal-body" ng-cloak>
<div class="modal-header">
<h2 class="modal-header-title">
<i class="fa"></i>
<span class="p-l-1">
Confirm re-learning
</span>
</h2>
<a class="modal-header-close" ng-click="dismiss()">
<i class="fa fa-remove"></i>
</a>
</div>
<div class="modal-content text-center">
<div class="confirm-modal-text">
<span>
Analytic unit is learning. Do you want to cancel it and re-learn?
</span>
</div>
<div class="confirm-modal-buttons">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-danger btn-ok" data-dismiss="modal" ng-click="confirm()">Yes</button>
</div>
</div>
</div>
Loading…
Cancel
Save