<commit_before>import { Injectable } from "@angular/core";
import { NgbModal } from "@ng-bootstrap/ng-bootstrap";
import { Dataset } from "chipster-js-common";
import * as log from "loglevel";
import { EMPTY } from "rxjs";
import { mergeMap } from "rxjs/operators";
import { ErrorService } from "../../../../core/errorhandler/error.service";
import { SessionData } from "../../../../model/session/session-data";
import {
  Tags,
  TypeTagService,
} from "../../../../shared/services/typetag.service";
import { DialogModalService } from "../dialogmodal/dialogmodal.service";
import { WrangleModalComponent } from "../wrangle-modal/wrangle-modal.component";
import { DatasetHistoryModalComponent } from "./dataset-history-modal/dataset-history-modal.component";

@Injectable()
export class DatasetModalService {
  constructor(
    private ngbModal: NgbModal,
    private dialogModalService: DialogModalService,
    private errorService: ErrorService,
    private typeTagService: TypeTagService
  ) {}

  public openDatasetHistoryModal(
    dataset: Dataset,
    sessionData: SessionData
  ): void {
    const modalRef = this.ngbModal.open(DatasetHistoryModalComponent, {
      size: "xl",
    });
    modalRef.componentInstance.dataset = dataset;
    modalRef.componentInstance.sessionData = sessionData;
  }

  public openWrangleModal(dataset: Dataset, sessionData: SessionData): void {
    if (dataset.size > WrangleModalComponent.FILE_SIZE_LIMIT * 1024 * 1024) {
      this.dialogModalService.openNotificationModal(
        "Converting file not possible",
        "The file is too big to be converted. The size limit is " +
          WrangleModalComponent.FILE_SIZE_LIMIT +
          " MB at the moment but it will be removed in the future."
      );
      return;
    }

    if (
      !(
        this.typeTagService.has(sessionData, dataset, Tags.TEXT) ||
        this.typeTagService.has(sessionData, dataset, Tags.TSV)
      )
    ) {
      this.dialogModalService.openNotificationModal(
        "Converting file not possible",
        "Convert only works for tab delimeted text files."<commit_msg>Check file type before size for Convert<commit_after>import { Injectable } from "@angular/core";
import { NgbModal } from "@ng-bootstrap/ng-bootstrap";
import { Dataset } from "chipster-js-common";
import * as log from "loglevel";
import { EMPTY } from "rxjs";
import { mergeMap } from "rxjs/operators";
import { ErrorService } from "../../../../core/errorhandler/error.service";
import { SessionData } from "../../../../model/session/session-data";
import {
  Tags,
  TypeTagService,
} from "../../../../shared/services/typetag.service";
import { DialogModalService } from "../dialogmodal/dialogmodal.service";
import { WrangleModalComponent } from "../wrangle-modal/wrangle-modal.component";
import { DatasetHistoryModalComponent } from "./dataset-history-modal/dataset-history-modal.component";

@Injectable()
export class DatasetModalService {
  constructor(
    private ngbModal: NgbModal,
    private dialogModalService: DialogModalService,
    private errorService: ErrorService,
    private typeTagService: TypeTagService
  ) {}

  public openDatasetHistoryModal(
    dataset: Dataset,
    sessionData: SessionData
  ): void {
    const modalRef = this.ngbModal.open(DatasetHistoryModalComponent, {
      size: "xl",
    });
    modalRef.componentInstance.dataset = dataset;
    modalRef.componentInstance.sessionData = sessionData;
  }

  public openWrangleModal(dataset: Dataset, sessionData: SessionData): void {
    if (
      !(
        this.typeTagService.has(sessionData, dataset, Tags.TEXT) ||
        this.typeTagService.has(sessionData, dataset, Tags.TSV)
      )
    ) {
      this.dialogModalService.openNotificationModal(
        "Converting file not possible",
        "Convert only works for tab delimeted text files."
      );
      return;
    }

    if (dataset.size > WrangleModalComponent.FILE_SIZE_LIMIT * 1024 * 1024) {
      this.dialogModalService.openNotificationModal(
        "Converting file not possible",
        "The file is too big to be converted. The size limit is " +
          WrangleModalComponent.FILE_SIZE_LIMIT +
          " MB at the moment but it will be removed in the future."
{'fraction_non_alphanumeric': 0.11678486997635934, 'fraction_numerical': 0.0037825059101654845, 'mean_word_length': 3.42110762800418, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '140601', 'n_tokens_mistral': 1191, 'n_tokens_neox': 1178, 'n_words': 295}