<commit_before>/**
 * Creates a multiple segment progress bar with independent ranges.
 * It can accept an arbitrary number of progress bars.
 *
 * @ Handlebars Usage Example:
 * {{progress-bar-adjacent numberOfBars="3"
 * barMin1="0" barMax1="20" barValue1="15" barLabel1="OS SCU Usage"
 * barMin2="40" barMax2="80" barValue2="50" barLabel2="VM SCU Usage"
 * barMin3="0" barMax3="50" barValue3="4" barLabel3="Testing Usage"}}
 *
 */
App.ProgressBarAdjacentComponent = Ember.Component.extend({
  numberOfBars: function() {
    var i = 1;
    var barCount = 0;
    while (i > barCount) {
      if (this.get('barMax' + i)) {
        i++;
        barCount++;
      } else {
        i--;
      }
    }
    return barCount;
  }.property(),
  maxTotal: 0,
  styleBinding: 'width:30px;',
  classNames: ['progress-bar-adjacent-container'],
  bars: function() {
    // Get the max total.
    var i = 1;
    while (i <= this.get('numberOfBars')) {
      var max = this.get('barMax' + i);
      this.set('maxTotal', parseInt(this.get('maxTotal')) + parseInt(max));
      i++;
    }
    var returnBars = [];
    var i = 1;
    while (i <= this.get('numberOfBars')) {
      var min = this.get('barMin' + i);
      var max = this.get('barMax' + i);
      var current = this.get('barValue' + i);
      var label = this.get('barLabel' + i);
      var title = this.get('barTitle' + i);
      returnBars.push(
        App.ProgressBarAdjacentController.create({
          min: min,
          max: max,
          maxTotal: this.get('maxTotal'),
          current: current,
          numberOfBars: this.get('numberOfBars'),
          barCount: i,
          label: label,
          title: title
        })
      );
      this.addObserver('barValue' + i, this, this.notifyBars);
      this.addObserver('barLabel' + i, this, this.notifyBars);
      this.addObserver('barTitle' + i, this, this.notifyBars);
      this.addObserver('barMin' + i, this, this.notifyBars);
      this.addObserver('barMax' + i, this, this.notifyBars);
      i++;
    }
    return returnBars;
  }.property('numberOfBars'),
  notifyBars: function() {
    this.notifyPropertyChange('bars');
  }
});



App.ProgressBarAdjacentController = Ember.ObjectController.extend({
  progressBarColors: ['progress-info', 'progress-success', 'progress-warning', 'progress-danger'],
  progressBarColor: function() {
    if (this.get('barCount') == 1) {
      return this.get('progressBarColors')[0];
    } else if (this.get('barCount') % 2 == 0) {
      return this.get('progressBarColors')[1];
    } else if (this.get('barCount') % 3 == 0) {
      return this.get('progressBarColors')[2];
    } else if (this.get('barCount') % 4 == 0) {
      return this.get('progressBarColors')[3];
    }
  }.property('progressBarColors', 'barCount'),
  progressBarBackground: function() {
   if (this.get('barCount') == 1) {
      //info -> #4bb1cf -> rgba(75, 177, 207, 0.25)
      return 'rgba(75, 177, 207, 0.25)';
    } else if (this.get('barCount') % 2 == 0) {
      // success -> #5eb95e -> rgba(94, 185, 94, 0.25)
      return 'rgba(94, 185, 94, 0.25)';
    } else if (this.get('barCount') % 3 == 0) {
      // warning -> #faa732 -> rgba(250, 167, 50, 0.25)
      return 'rgba(250, 167, 50, 0.25)';
    } else if (this.get('barCount') % 4 == 0) {
      // danger -> #dd514c ->
      return 'rgba(221, 81, 76, 0.25)';
    }
  }.property('barCount'),
  totalWidth: function() {
    globalThis = this;
    return (parseInt(this.get('max')) / parseInt(this.get('maxTotal'))) * 100;
  }.property('max', 'maxTotal'),
  currentPercentage: function() {
    return (this.get('current') - this.get('min')) / (this.get('max') - this.get('min')) * 100;
  }.property('current', 'max', 'min'),
  currentPercentageWidth: function() {
    if (this.get('currentPercentage') > 100) {
      return 100;
    } else {
      return this.get('currentPercentage');
    }
  }.property('currentPercentage'),
  isLastBar: function() {
    return (this.get('barCount') == this.get('numberOfBars'));
  }.property('numberOfBars', 'barCount'),
  isFirstBar: function() {
    return (this.get('barCount') == 1);
  }.property('barCount'),
  containerStyles: function() {<commit_msg>Fix adjacent component variable widths<commit_after>/**
 * Creates a multiple segment progress bar with independent ranges.
 * It can accept an arbitrary number of progress bars.
 *
 * @ Handlebars Usage Example:
 * {{progress-bar-adjacent numberOfBars="3"
 * barMin1="0" barMax1="20" barValue1="15" barLabel1="OS SCU Usage"
 * barMin2="40" barMax2="80" barValue2="50" barLabel2="VM SCU Usage"
 * barMin3="0" barMax3="50" barValue3="4" barLabel3="Testing Usage"}}
 *
 */
App.ProgressBarAdjacentComponent = Ember.Component.extend({
  maxTotal: 0,
  //numberOfBars: 3,
  styleBinding: 'width:30px;',
  classNames: ['progress-bar-adjacent-container'],
  bars: function() {
    //Get the number of bars.
    var i = 1;
    var barCount = 0;
    while (i > barCount) {
      if (this.get('barMax' + i)) {
        i++;
        barCount++;
      } else {
        i--;
      }
    }
    this.set('numberOfBars', barCount);
    // Get the max total.
    var i = 1;
    var maxTotal = 0;
    while (i <= this.get('numberOfBars')) {
      var max = this.get('barMax' + i);
      if (max) {
        maxTotal = parseInt(max) + parseInt(maxTotal);
      }
      i++;
    }
    this.set('maxTotal', maxTotal);
    var returnBars = [];
    var i = 1;
    while (i <= this.get('numberOfBars')) {
      var min = this.get('barMin' + i);
      var max = this.get('barMax' + i);
      var current = this.get('barValue' + i);
      var label = this.get('barLabel' + i);
      var title = this.get('barTitle' + i);
      returnBars.push(
        App.ProgressBarAdjacentController.create({
          min: min,
          max: max,
          maxTotal: this.get('maxTotal'),
          current: current,
          numberOfBars: this.get('numberOfBars'),
          barCount: i,
          label: label,
          title: title
        })
      );
      this.addObserver('barValue' + i, this, this.notifyBars);
      this.addObserver('barLabel' + i, this, this.notifyBars);
      this.addObserver('barTitle' + i, this, this.notifyBars);
      this.addObserver('barMin' + i, this, this.notifyBars);
      this.addObserver('barMax' + i, this, this.notifyBars);
      i++;
    }
    return returnBars;
  }.property('numberOfBars'),
  notifyBars: function() {
    this.notifyPropertyChange('bars');
  }
});



App.ProgressBarAdjacentController = Ember.ObjectController.extend({
  progressBarColors: ['progress-info', 'progress-success', 'progress-warning', 'progress-danger'],
  progressBarColor: function() {
    if (this.get('barCount') == 1) {
      return this.get('progressBarColors')[0];
    } else if (this.get('barCount') % 2 == 0) {
      return this.get('progressBarColors')[1];
    } else if (this.get('barCount') % 3 == 0) {
      return this.get('progressBarColors')[2];
    } else if (this.get('barCount') % 4 == 0) {
      return this.get('progressBarColors')[3];
    }
  }.property('progressBarColors', 'barCount'),
  progressBarBackground: function() {
   if (this.get('barCount') == 1) {
      //info -> #4bb1cf -> rgba(75, 177, 207, 0.25)
      return 'rgba(75, 177, 207, 0.25)';
    } else if (this.get('barCount') % 2 == 0) {
      // success -> #5eb95e -> rgba(94, 185, 94, 0.25)
      return 'rgba(94, 185, 94, 0.25)';
    } else if (this.get('barCount') % 3 == 0) {
      // warning -> #faa732 -> rgba(250, 167, 50, 0.25)
      return 'rgba(250, 167, 50, 0.25)';
    } else if (this.get('barCount') % 4 == 0) {
      // danger -> #dd514c ->
      return 'rgba(221, 81, 76, 0.25)';
    }
  }.property('barCount'),
  totalWidth: function() {
    return (parseInt(this.get('max')) / parseInt(this.get('maxTotal'))) * 100;
  }.property('max', 'maxTotal'),
  currentPercentage: function() {
    return (this.get('current') - this.get('min')) / (this.get('max') - this.get('min')) * 100;
  }.property('current', 'max', 'min'),
  currentPercentageWidth: function() {
    if (this.get('currentPercentage') > 100) {
      return 100;
    } else {
      return this.get('currentPercentage');
    }
  }.property('currentPercentage'),
  isLastBar: function() {
    return (this.get('barCount') == this.get('numberOfBars'));
  }.property('numberOfBars', 'barCount'),
  isFirstBar: function() {
    return (this.get('barCount') == 1);
  }.property('barCount'),
  containerStyles: function() {
{'fraction_non_alphanumeric': 0.1822380106571936, 'fraction_numerical': 0.035997631734754294, 'mean_word_length': 2.943043884220355, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5935264', 'n_tokens_mistral': 3104, 'n_tokens_neox': 2871, 'n_words': 629}