<commit_before>import Component from '@ember/component';
import { inject as service } from "@ember/service";
import AlertifyHandler from 'explorviz-frontend/mixins/alertify-handler';
import FileSaverMixin from 'ember-cli-file-saver/mixins/file-saver';
import ENV from 'explorviz-frontend/config/environment';

export default Component.extend(AlertifyHandler, FileSaverMixin, {

  ajax: service('ajax'),
  landscapeRepo: service("repos/landscape-repository"),
  renderingService: service("rendering-service"),
  reloadHandler: service("reload-handler"),
  viewImporter: service("view-importer"),

  actions: {

    exportState() {
      // Pause timeshift
      this.get('reloadHandler').stopExchange();
      // Update query parameters
      this.get('urlBuilder').requestURL();

      this.set('viewImporter.importedURL', true);

      this.set('timestamp', this.get('state').timestamp);
      this.set('appID', this.get('state').appID);

      this.set('camX', this.get('state').camX);
      this.set('camY', this.get('state').camY);
      this.set('camZ', this.get('state').camZ);

      // handle landscape or application
      if(this.get('showLandscape')){
        this.set('condition', this.get('state').landscapeCondition);
      }
      else{
        this.set('condition', this.get('state').appCondition);
      }
    },

    resetView() {
      this.set('viewImporter.importedURL', false);
      this.get('renderingService').reSetupScene();
      this.get('reloadHandler').startExchange();
    },

    exportLandscape(){
      const currentLandscape = this.get('landscapeRepo.latestLandscape');
      const currentTimestamp = currentLandscape.get('timestamp');
      const currentCalls = currentLandscape.get('overallCalls');

      this.get('ajax').raw(ENV.APP.API_ROOT + '/landscape/export/' + currentTimestamp, {
        'id':this,
        dataType: 'text',
        options: {
          arraybuffer: true
        }
      }
      ).then((content) => {
        this.saveFileAs(currentTimestamp + '-' + currentCalls +'.expl', content.payload, 'text/plain');
      }).catch((error) => {
        this.debug('error in exportLandscape', error);
      });
    }

  }

});<commit_msg>added: HTTP Basic Authentication Header<commit_after>import Component from '@ember/component';
import { inject as service } from "@ember/service";
import AlertifyHandler from 'explorviz-frontend/mixins/alertify-handler';
import FileSaverMixin from 'ember-cli-file-saver/mixins/file-saver';
import ENV from 'explorviz-frontend/config/environment';

export default Component.extend(AlertifyHandler, FileSaverMixin, {

  ajax: service('ajax'),
  landscapeRepo: service("repos/landscape-repository"),
  renderingService: service("rendering-service"),
  reloadHandler: service("reload-handler"),
  viewImporter: service("view-importer"),
  session: service(),

  actions: {

    exportState() {
      // Pause timeshift
      this.get('reloadHandler').stopExchange();
      // Update query parameters
      this.get('urlBuilder').requestURL();

      this.set('viewImporter.importedURL', true);

      this.set('timestamp', this.get('state').timestamp);
      this.set('appID', this.get('state').appID);

      this.set('camX', this.get('state').camX);
      this.set('camY', this.get('state').camY);
      this.set('camZ', this.get('state').camZ);

      // handle landscape or application
      if(this.get('showLandscape')){
        this.set('condition', this.get('state').landscapeCondition);
      }
      else{
        this.set('condition', this.get('state').appCondition);
      }
    },

    resetView() {
      this.set('viewImporter.importedURL', false);
      this.get('renderingService').reSetupScene();
      this.get('reloadHandler').startExchange();
    },

    exportLandscape(){
      const currentLandscape = this.get('landscapeRepo.latestLandscape');
      const currentTimestamp = currentLandscape.get('timestamp');
      const currentCalls = currentLandscape.get('overallCalls');

      const { access_token } = this.get('session.data.authenticated');

      this.get('ajax').raw(ENV.APP.API_ROOT + '/landscape/export/' + currentTimestamp, {
        'id':this,
        headers: { 'Authorization': `Basic ${access_token}` },
        dataType: 'text',
        options: {
          arraybuffer: true
        }
      }
      ).then((content) => {
        this.saveFileAs(currentTimestamp + '-' + currentCalls +'.expl', content.payload, 'text/plain');
      }).catch((error) => {
        this.debug('error in exportLandscape', error);
      });
    }

  }

});
{'fraction_non_alphanumeric': 0.16231629743364773, 'fraction_numerical': 0.0, 'mean_word_length': 3.431486880466472, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '6538758', 'n_tokens_mistral': 1359, 'n_tokens_neox': 1330, 'n_words': 217}