<commit_before>import { Component, EventEmitter, Output, Injector } from '@angular/core';

// LIBRARIES
import { Schema, SchemaSearchFacade } from '@picturepark/sdk-v1-angular';

// COMPONENTS
import { BaseBrowserComponent } from '../../shared-module/components/browser-base/browser-base.component';

@Component({
  selector: 'pp-schema-browser',
  templateUrl: './schema-browser.component.html',
  styleUrls: [
    '../../shared-module/components/browser-base/browser-base.component.scss',
    './schema-browser.component.scss',
  ],
  // changeDetection: ChangeDetectionStrategy.OnPush
})
export class SchemaBrowserComponent extends BaseBrowserComponent<Schema> {
  @Output() public activeSchemaChange = new EventEmitter<Schema>();

  public selectedSchemaIndex: number;

  constructor(public facade: SchemaSearchFacade, injector: Injector) {
    super('SchemaBrowserComponent', injector, facade);
  }

  async init(): Promise<void> {
    // Trigger load
    this.facade.patchRequestState({});
  }

  initSort(): void {
    this.sortingTypes = [
      {
        field: 'relevance',
        name: this.translationService.translate('SortMenu.Relevance'),
      },
      {
        field: 'names.en', // TODO BRO: Fix
        name: this.translationService.translate('SortMenu.FileName'),
      },
      {
        field: 'audit.creationDate',
        name: this.translationService.translate('SortMenu.CreationDate'),
      },
      {
        field: 'audit.modificationDate',
        name: this.translationService.translate('SortMenu.ModificationDate'),
      },
    ];
    this.activeSortingType = this.sortingTypes[0];

    this.views = [
      {
        name: 'Small',
        icon: 'collections',
        type: 'thumbnailSmall',
      },
    ];
    this.activeView = this.views[0];
  }

  onScroll(): void {
    this.loadData();
  }

  checkContains(elementClassName: string): boolean {
    const containClasses = ['browser__items'];
    return containClasses.some(iClass => elementClassName.includes(iClass));
  }

  public setUpActiveSchema(schema: Schema): void {
    if (schema.childCount > 0 && !this.facade.searchRequestState.parentSchema) {
      this.facade.patchRequestState({ parentSchema: schema });
    } else {
      this.activeSchemaChange.emit(schema);
    }
  }

  public selectedSchemaChange(index: number): void {
    this.selectedSchemaIndex = index;
  }
}<commit_msg>PP9-10588: Dont modify the search state in the schema browser component.<commit_after>import { Component, EventEmitter, Output, Injector } from '@angular/core';

// LIBRARIES
import { Schema, SchemaSearchFacade } from '@picturepark/sdk-v1-angular';

// COMPONENTS
import { BaseBrowserComponent } from '../../shared-module/components/browser-base/browser-base.component';

@Component({
  selector: 'pp-schema-browser',
  templateUrl: './schema-browser.component.html',
  styleUrls: [
    '../../shared-module/components/browser-base/browser-base.component.scss',
    './schema-browser.component.scss',
  ],
  // changeDetection: ChangeDetectionStrategy.OnPush
})
export class SchemaBrowserComponent extends BaseBrowserComponent<Schema> {
  @Output() public activeSchemaChange = new EventEmitter<Schema>();
  @Output() public parentSchemaChange = new EventEmitter<Schema>();

  public selectedSchemaIndex: number;

  constructor(public facade: SchemaSearchFacade, injector: Injector) {
    super('SchemaBrowserComponent', injector, facade);
  }

  async init(): Promise<void> {
    // Trigger load
    this.facade.patchRequestState({});
  }

  initSort(): void {
    this.sortingTypes = [
      {
        field: 'relevance',
        name: this.translationService.translate('SortMenu.Relevance'),
      },
      {
        field: 'names.en', // TODO BRO: Fix
        name: this.translationService.translate('SortMenu.FileName'),
      },
      {
        field: 'audit.creationDate',
        name: this.translationService.translate('SortMenu.CreationDate'),
      },
      {
        field: 'audit.modificationDate',
        name: this.translationService.translate('SortMenu.ModificationDate'),
      },
    ];
    this.activeSortingType = this.sortingTypes[0];

    this.views = [
      {
        name: 'Small',
        icon: 'collections',
        type: 'thumbnailSmall',
      },
    ];
    this.activeView = this.views[0];
  }

  onScroll(): void {
    this.loadData();
  }

  checkContains(elementClassName: string): boolean {
    const containClasses = ['browser__items'];
    return containClasses.some(iClass => elementClassName.includes(iClass));
  }

  public setUpActiveSchema(schema: Schema): void {
    if (schema.childCount > 0) {
      this.parentSchemaChange.emit(schema);
    } else {
      this.activeSchemaChange.emit(schema);
    }
  }

  public selectedSchemaChange(index: number): void {
    this.selectedSchemaIndex = index;
  }
}
{'fraction_non_alphanumeric': 0.13591228796028135, 'fraction_numerical': 0.0028961522548613984, 'mean_word_length': 3.3285586392121753, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 14, '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': '1096177', 'n_tokens_mistral': 1415, 'n_tokens_neox': 1391, 'n_words': 250}