github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/ui/app/components/das/recommendation-accordion.js (about) 1 import Component from '@glimmer/component'; 2 import { action } from '@ember/object'; 3 import { tracked } from '@glimmer/tracking'; 4 import { task, timeout } from 'ember-concurrency'; 5 import { htmlSafe } from '@ember/template'; 6 import Ember from 'ember'; 7 import ResourcesDiffs from 'nomad-ui/utils/resources-diffs'; 8 9 export default class DasRecommendationAccordionComponent extends Component { 10 @tracked waitingToProceed = false; 11 @tracked closing = false; 12 @tracked animationContainerStyle = htmlSafe(''); 13 14 @(task(function* () { 15 this.closing = true; 16 this.animationContainerStyle = htmlSafe( 17 `height: ${this.accordionElement.clientHeight}px` 18 ); 19 20 yield timeout(10); 21 22 this.animationContainerStyle = htmlSafe('height: 0px'); 23 24 // The 450ms for the animation to complete, set in CSS as $timing-slow 25 yield timeout(Ember.testing ? 0 : 450); 26 27 this.waitingToProceed = false; 28 }).drop()) 29 proceed; 30 31 @action 32 inserted(element) { 33 this.accordionElement = element; 34 this.waitingToProceed = true; 35 } 36 37 get show() { 38 return !this.args.summary.isProcessed || this.waitingToProceed; 39 } 40 41 get diffs() { 42 const summary = this.args.summary; 43 const taskGroup = summary.taskGroup; 44 45 return new ResourcesDiffs( 46 taskGroup, 47 taskGroup.count, 48 this.args.summary.recommendations, 49 this.args.summary.excludedRecommendations 50 ); 51 } 52 }