<commit_before>import {Component, Input} from '@angular/core';
import {FormControl, FormGroup, Validators} from '@angular/forms';
import {ActivatedRoute, Router} from '@angular/router';
import {List} from 'immutable';
import {Observable} from 'rxjs/Observable';

import {CohortSearchActions} from '../redux';

import {Cohort, CohortsService, Workspace} from 'generated';

const COHORT_TYPE = 'AoU_Discover';


@Component({
  selector: 'app-overview',
  templateUrl: './overview.component.html',
  styleUrls: [
    './overview.component.css',
    '../../styles/buttons.css',
  ]
})
export class OverviewComponent {
  @Input() chartData$: Observable<List<any>>;
  @Input() total$: Observable<number>;
  @Input() isRequesting$: Observable<boolean>;

  cohortForm = new FormGroup({
    name: new FormControl('', [Validators.required]),
    description: new FormControl()
  });

  stackChart = false;
  showGenderChart = true;
  showComboChart = true;

  constructor(
    private actions: CohortSearchActions,
    private cohortApi: CohortsService,
    private route: ActivatedRoute,
    private router: Router,
  ) {}

  get name() {
    return this.cohortForm.get('name');
  }

  modalChange(value) {
    if (!value) {
      this.cohortForm.reset();
    }
  }

  submit() {
    const ns: Workspace['namespace'] = this.route.snapshot.params.ns;
    const wsid: Workspace['id'] = this.route.snapshot.params.wsid;

    const name = this.cohortForm.get('name').value;
    const description = this.cohortForm.get('description').value;
    const criteria = JSON.stringify(this.actions.mapAll());
    const cohort = <Cohort>{name, description, criteria, type: COHORT_TYPE};
    const goBack = (_) => this.router.navigate(['workspaces', ns, wsid]);
    this.cohortApi.createCohort(ns, wsid, cohort).subscribe(goBack);
  }

  toggleChartMode() {
    this.stackChart = !this.stackChart;
  }

  toggleShowGender() {
    this.showGenderChart = !this.showGenderChart;
  }

  toggleShowCombo() {
    this.showComboChart = !this.showComboChart;
  }
}<commit_msg>[RW-678][risk=no] Redirect to cohorts list after creating a cohort (#971)<commit_after>import {Component, Input} from '@angular/core';
import {FormControl, FormGroup, Validators} from '@angular/forms';
import {ActivatedRoute, Router} from '@angular/router';
import {List} from 'immutable';
import {Observable} from 'rxjs/Observable';

import {CohortSearchActions} from '../redux';

import {Cohort, CohortsService, Workspace} from 'generated';

const COHORT_TYPE = 'AoU_Discover';


@Component({
  selector: 'app-overview',
  templateUrl: './overview.component.html',
  styleUrls: [
    './overview.component.css',
    '../../styles/buttons.css',
  ]
})
export class OverviewComponent {
  @Input() chartData$: Observable<List<any>>;
  @Input() total$: Observable<number>;
  @Input() isRequesting$: Observable<boolean>;

  cohortForm = new FormGroup({
    name: new FormControl('', [Validators.required]),
    description: new FormControl()
  });

  stackChart = false;
  showGenderChart = true;
  showComboChart = true;

  constructor(
    private actions: CohortSearchActions,
    private cohortApi: CohortsService,
    private route: ActivatedRoute,
    private router: Router,
  ) {}

  get name() {
    return this.cohortForm.get('name');
  }

  modalChange(value) {
    if (!value) {
      this.cohortForm.reset();
    }
  }

  submit() {
    const ns: Workspace['namespace'] = this.route.snapshot.params.ns;
    const wsid: Workspace['id'] = this.route.snapshot.params.wsid;

    const name = this.cohortForm.get('name').value;
    const description = this.cohortForm.get('description').value;
    const criteria = JSON.stringify(this.actions.mapAll());
    const cohort = <Cohort>{name, description, criteria, type: COHORT_TYPE};
    this.cohortApi.createCohort(ns, wsid, cohort).subscribe((_) => {
      this.router.navigate(['workspaces', ns, wsid, 'cohorts']);
    });
  }

  toggleChartMode() {
    this.stackChart = !this.stackChart;
  }

  toggleShowGender() {
    this.showGenderChart = !this.showGenderChart;
  }

  toggleShowCombo() {
    this.showComboChart = !this.showComboChart;
  }
}
{'fraction_non_alphanumeric': 0.1492645285748734, 'fraction_numerical': 0.0014468290330359296, 'mean_word_length': 4.185, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, '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': '2365514', 'n_tokens_mistral': 1376, 'n_tokens_neox': 1308, 'n_words': 280}