<commit_before>/**
 * Created by faisal on 3/27/15.
 */

import Ember from 'ember';

export default Ember.Component.extend({
  classNames: ['filter-bar'],
  // master_params: {},
  dirty: false,
  filter_repr: function() {
    return JSON.stringify(this.get('master_params'));
  }.property(
    'master_params.alters.min_sent',
    'master_params.alters.selected_alter_list.[]',
    'master_params.alters.alter_list_type',
    'master_params.tokens.list.[]'
  ),

  init: function() {
    this._super(...arguments);

    // this.set('master_params', {});
    this.set('master_params.alters', {});
    this.set('master_params.tokens', {});
  },

  masterDirty: function() {
    this.set('dirty', true);
  }.observes(
    'master_params.alters.min_sent',
    'master_params.alters.selected_alter_list.[]',
    'master_params.alters.alter_list_type',
    'master_params.tokens.list.[]'
  ),

  actions: {
    'toggleFilters': function() {
      this.$(".filter-items").slideToggle(300);
    },
    'applyFilter': function() {
      this.sendAction('action', this.get('master_params'));
      this.set('dirty', false);
    }
  }
});<commit_msg>Attempting to save filter settings between sessions, still WIP<commit_after>/**
 * Created by faisal on 3/27/15.
 */

import Ember from 'ember';

export default Ember.Component.extend({
  localSettings: Ember.inject.service('local-settings'),

  classNames: ['filter-bar'],
  // master_params: {},
  dirty: false,
  filter_repr: function() {
    return JSON.stringify(this.get('master_params'));
  }.property(
    'master_params.alters.min_sent',
    'master_params.alters.selected_alter_list.[]',
    'master_params.alters.alter_list_type',
    'master_params.tokens.list.[]'
  ),

  init: function() {
    this._super(...arguments);

    // ensure the necessary endpoints exist
    this.set('master_params.alters', {});
    this.set('master_params.tokens', {});

    let ourParams = this.get('localSettings').get('settings.master_params');

    console.log("Loaded params: ", ourParams);

    if (ourParams) {
      Ember.assign(this.get('master_params'), ourParams);
      this.notifyPropertyChange('master_params');
    }
  },

  masterDirty: function() {
    this.set('dirty', true);
  }.observes(
    'master_params.alters.min_sent',
    'master_params.alters.selected_alter_list.[]',
    'master_params.alters.alter_list_type',
    'master_params.tokens.list.[]'
  ),

  actions: {
    'toggleFilters': function() {
      this.$(".filter-items").toggle(300);
    },
    'applyFilter': function() {
      let master_params = this.get('master_params');

      // cache the settings in local storage so we can reload them when the page reloads
      this.get('localSettings').set('settings.master_params', master_params);

      console.log("Saved params: ", this.get('localSettings').get('settings.master_params'));

      this.sendAction('action', master_params);
      this.set('dirty', false);
    }
  }
});
{'fraction_non_alphanumeric': 0.1712351945854484, 'fraction_numerical': 0.0054145516074450084, 'mean_word_length': 3.6772151898734178, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4379836', 'n_tokens_mistral': 980, 'n_tokens_neox': 947, 'n_words': 152}