<commit_before>/* jshint browser: true */
/* jshint unused: false */
/* global frontendConfig, arangoHelper, Joi, Backbone, window, $ */

(function () {
  'use strict';

  window.SettingsView = Backbone.View.extend({
    el: '#content',

    initialize: function (options) {
      this.collectionName = options.collectionName;
      this.model = this.collection;
    },

    events: {
    },

    render: function () {
      this.breadcrumb();
      window.arangoHelper.buildCollectionSubNav(this.collectionName, 'Settings');

      this.renderSettings();
    },

    breadcrumb: function () {
      $('#subNavigationBar .breadcrumb').html(
        'Collection: ' + this.collectionName
      );
    },

    unloadCollection: function () {
      var unloadCollectionCallback = function (error) {
        if (error) {
          arangoHelper.arangoError('Collection error', this.model.get('name') + ' could not be unloaded.');
        } else if (error === undefined) {
          this.model.set('status', 'unloading');
          this.render();
        } else {
          if (window.location.hash === '#collections') {
            this.model.set('status', 'unloaded');
            this.render();
          } else {
            arangoHelper.arangoNotification('Collection ' + this.model.get('name') + ' unloaded.');
          }
        }
      }.bind(this);

      this.model.unloadCollection(unloadCollectionCallback);
      window.modalView.hide();
    },

    loadCollection: function () {
      var loadCollectionCallback = function (error) {
        if (error) {
          arangoHelper.arangoError('Collection error', this.model.get('name') + ' could not be loaded.');
        } else if (error === undefined) {
          this.model.set('status', 'loading');
          this.render();
        } else {
          if (window.location.hash === '#collections') {
            this.model.set('status', 'loaded');
            this.render();
          } else {
            arangoHelper.arangoNotification('Collection ' + this.model.get('name') + ' loaded.');
          }
        }
      }.bind(this);

      this.model.loadCollection(loadCollectionCallback);
      window.modalView.hide();
    },

    truncateCollection: function () {
      this.model.truncateCollection();
      window.modalView.hide();
    },

    deleteCollection: function () {
      this.model.destroy(
        {
          error: function () {
            arangoHelper.arangoError('Could not delete collection.');
          },
          success: function () {
            window.App.navigate('#collections', {trigger: true});
          }
        }
      );
    },

    saveModifiedCollection: function () {
      var callback = function (error, isCoordinator) {
        if (error) {
          arangoHelper.arangoError('Error', 'Could not get coordinator info');
        } else {
          var newname;
          if (isCoordinator) {
            newname = this.model.get('name');
          } else {
            newname = $('#change-collection-name').val();
          }
          var status = this.model.get('status');<commit_msg>optimized behaviour in ui during truncation<commit_after>/* jshint browser: true */
/* jshint unused: false */
/* global frontendConfig, arangoHelper, Joi, Backbone, window, $ */

(function () {
  'use strict';

  window.SettingsView = Backbone.View.extend({
    el: '#content',

    initialize: function (options) {
      this.collectionName = options.collectionName;
      this.model = this.collection;
    },

    events: {
    },

    render: function () {
      this.breadcrumb();
      window.arangoHelper.buildCollectionSubNav(this.collectionName, 'Settings');

      this.renderSettings();
    },

    breadcrumb: function () {
      $('#subNavigationBar .breadcrumb').html(
        'Collection: ' + this.collectionName
      );
    },

    unloadCollection: function () {
      var unloadCollectionCallback = function (error) {
        if (error) {
          arangoHelper.arangoError('Collection error', this.model.get('name') + ' could not be unloaded.');
        } else if (error === undefined) {
          this.model.set('status', 'unloading');
          this.render();
        } else {
          if (window.location.hash === '#collections') {
            this.model.set('status', 'unloaded');
            this.render();
          } else {
            arangoHelper.arangoNotification('Collection ' + this.model.get('name') + ' unloaded.');
          }
        }
      }.bind(this);

      this.model.unloadCollection(unloadCollectionCallback);
      window.modalView.hide();
    },

    loadCollection: function () {
      var loadCollectionCallback = function (error) {
        if (error) {
          arangoHelper.arangoError('Collection error', this.model.get('name') + ' could not be loaded.');
        } else if (error === undefined) {
          this.model.set('status', 'loading');
          this.render();
        } else {
          if (window.location.hash === '#collections') {
            this.model.set('status', 'loaded');
            this.render();
          } else {
            arangoHelper.arangoNotification('Collection ' + this.model.get('name') + ' loaded.');
          }
        }
      }.bind(this);

      this.model.loadCollection(loadCollectionCallback);
      window.modalView.hide();
    },

    truncateCollection: function () {
      this.model.truncateCollection();
      $('.modal-delete-confirmation').hide();
      window.modalView.hide();
    },

    deleteCollection: function () {
      this.model.destroy(
        {
          error: function () {
            arangoHelper.arangoError('Could not delete collection.');
          },
          success: function () {
            window.App.navigate('#collections', {trigger: true});
          }
        }
      );
    },

    saveModifiedCollection: function () {
      var callback = function (error, isCoordinator) {
        if (error) {
          arangoHelper.arangoError('Error', 'Could not get coordinator info');
        } else {
          var newname;
          if (isCoordinator) {
            newname = this.model.get('name');
          } else {
            newname = $('#change-collection-name').val();
          }
          var status = this.model.get('status');
{'fraction_non_alphanumeric': 0.14578005115089515, 'fraction_numerical': 0.0, 'mean_word_length': 2.1300650325162582, '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': '982432', 'n_tokens_mistral': 1707, 'n_tokens_neox': 1687, 'n_words': 321}