Force drain button in the drain info box

This commit is contained in:
Michael Lange 2019-11-19 00:12:34 -08:00
parent 82a62089b3
commit faa15bc581
2 changed files with 48 additions and 3 deletions

View File

@ -43,6 +43,7 @@ export default Controller.extend(Sortable, Searchable, {
eligibilityError: null, eligibilityError: null,
stopDrainError: null, stopDrainError: null,
drainError: null,
showDrainNotification: false, showDrainNotification: false,
showDrainUpdateNotification: false, showDrainUpdateNotification: false,
showDrainStoppedNotification: false, showDrainStoppedNotification: false,
@ -82,6 +83,17 @@ export default Controller.extend(Sortable, Searchable, {
} }
}).drop(), }).drop(),
forceDrain: task(function*() {
try {
yield this.model.forceDrain({
IgnoreSystemJobs: this.model.drainStrategy.ignoreSystemJobs,
});
} catch (err) {
const error = messageFromAdapterError(err) || 'Could not force drain';
this.set('drainError', error);
}
}).drop(),
triggerDrainNotification: observer('model.isDraining', function() { triggerDrainNotification: observer('model.isDraining', function() {
if (!this.model.isDraining && this.flagAsDraining) { if (!this.model.isDraining && this.flagAsDraining) {
this.set('showDrainNotification', true); this.set('showDrainNotification', true);
@ -102,5 +114,10 @@ export default Controller.extend(Sortable, Searchable, {
drainNotify(isUpdating) { drainNotify(isUpdating) {
this.set('showDrainUpdateNotification', isUpdating); this.set('showDrainUpdateNotification', isUpdating);
}, },
drainError(err) {
const error = messageFromAdapterError(err) || 'Could not run drain';
this.set('drainError', error);
},
}, },
}); });

View File

@ -22,7 +22,20 @@
</div> </div>
</div> </div>
<div class="column is-centered is-minimum"> <div class="column is-centered is-minimum">
<button data-test-stop-drain-error-dismiss class="button is-danger" onclick={{action (mut eligibilityError) ""}}>Okay</button> <button data-test-stop-drain-error-dismiss class="button is-danger" onclick={{action (mut stopDrainError) ""}}>Okay</button>
</div>
</div>
{{/if}}
{{#if drainError}}
<div class="columns">
<div class="column">
<div data-test-drain-error class="notification is-danger">
<h3 class="title is-4" data-test-drain-error-title>Drain Error</h3>
<p data-test-drain-error-message>{{drainError}}</p>
</div>
</div>
<div class="column is-centered is-minimum">
<button data-test-drain-error-dismiss class="button is-danger" onclick={{action (mut drainError) ""}}>Okay</button>
</div> </div>
</div> </div>
{{/if}} {{/if}}
@ -105,7 +118,10 @@
{{/if}} {{/if}}
</div> </div>
<div class="toolbar-item is-right-aligned is-top-aligned"> <div class="toolbar-item is-right-aligned is-top-aligned">
{{drain-popover client=model onDrain=(action "drainNotify")}} {{drain-popover
client=model
onDrain=(action "drainNotify")
onError=(action "drainError")}}
</div> </div>
</div> </div>
@ -187,7 +203,19 @@
{{if model.drainStrategy.ignoreSystemJobs "No" "Yes"}} {{if model.drainStrategy.ignoreSystemJobs "No" "Yes"}}
</span> </span>
</div> </div>
<button class="button is-warning is-small pull-right">Force Drain</button> {{#if (not model.drainStrategy.isForced)}}
<div class="pull-right">
{{two-step-button
alignRight=true
isInfoAction=true
idleText="Force Drain"
cancelText="Cancel"
confirmText="Yes, Force Drain"
confirmationMessage="Are you sure you want to force drain?"
awaitingConfirmation=forceDrain.isRunning
onConfirm=(perform forceDrain)}}
</div>
{{/if}}
</div> </div>
</div> </div>
<div class="boxed-section-body"> <div class="boxed-section-body">