github.com/Ilhicas/nomad@v1.0.4-0.20210304152020-e86851182bc3/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(`height: ${this.accordionElement.clientHeight}px`);
    17  
    18      yield timeout(10);
    19  
    20      this.animationContainerStyle = htmlSafe('height: 0px');
    21  
    22      // The 450ms for the animation to complete, set in CSS as $timing-slow
    23      yield timeout(Ember.testing ? 0 : 450);
    24  
    25      this.waitingToProceed = false;
    26    }).drop())
    27    proceed;
    28  
    29    @action
    30    inserted(element) {
    31      this.accordionElement = element;
    32      this.waitingToProceed = true;
    33    }
    34  
    35    get show() {
    36      return !this.args.summary.isProcessed || this.waitingToProceed;
    37    }
    38  
    39    get diffs() {
    40      const summary = this.args.summary;
    41      const taskGroup = summary.taskGroup;
    42  
    43      return new ResourcesDiffs(
    44        taskGroup,
    45        taskGroup.count,
    46        this.args.summary.recommendations,
    47        this.args.summary.excludedRecommendations
    48      );
    49    }
    50  }