<commit_before>import { Component, OnInit, Input } from '@angular/core';
import { GlobalService } from '../../global.service';
import {forEach} from "@angular/router/src/utils/collection";

@Component({
  selector: '[app-variants]',
  templateUrl: './variants.component.html',
  styleUrls: ['./variants.component.scss']
})
export class VariantsComponent implements OnInit {

 @Input()  courses: any = [];
 @Input()  diagrams: any;
 @Input()  technologies: any;

 @Input() program_id: any;
 @Input() discipline: any;
 @Input() variants: any;

  constructor(
    private globalService: GlobalService,
  ) { }

  public getDisciplinesVariants(slug: string) {
    this.globalService.getElementsBySlug('get_variants/' + this.program_id, slug)
                    .subscribe(
                      variants => {
                        this.variants = variants;
                      },
                      error => console.log(error)
                    );
  }
  public addVariant(value) {
    console.log('addVariant', value);
       this.globalService.postResponseAdmin('create_variant', JSON.stringify(value))
                      .subscribe(
                      status => {

                         this.getDisciplinesVariants(this.discipline.id);
                       console.log(status);
                      },
                      error => console.log(error)
                      );
  }

  public disabledButton(): boolean {

    if (this.discipline.terms['3,5 года'] === 0 || this.discipline.terms['4 года'] === 0 || this.discipline.terms['5 лет'] === 0){
      return true;
    } else {
      return false;
    }
  }

  public addVariantSemester() {
    let value: string;
    if (this.discipline.terms['3,5 года'] > 0) {
      value = '3,5 года';
    } else  if (this.discipline.terms['4 года'] > 0) {
      value = '4 года';
    } else  if (this.discipline.terms['5 лет'] > 0) {
      value = '5 лет';
    }
    if (value) {
      const value = {program_id: this.program_id, discipline_id: this.discipline.id, term_title: '4 года'}
      console.log('addVariant', value);
      this.globalService.postResponseAdmin('create_variant', JSON.stringify(value))
        .subscribe(
          status => {

            this.getDisciplinesVariants(this.discipline.id);
            console.log(status);
          },
          error => console.log(error)
        );
    } else {
      console.log('не указан симестр')
    }
  }

    public removeVariant(value){
    console.log(value);
       this.globalService.postResponseAdmin('delete_variant', JSON.stringify(value))
                      .subscribe(
                      status => {
                         this.getDisciplinesVariants(this.discipline.id);
                       console.log(status);
                      },
                      error => console.log(error)
                      );
  }
  changeVariant(value){
    console.log(value);
    this.globalService.postResponse('change_variant', JSON.stringify(value))
                      .subscribe(<commit_msg>admin disciplines fix<commit_after>import { Component, OnInit, Input } from '@angular/core';
import { GlobalService } from '../../global.service';
import {forEach} from "@angular/router/src/utils/collection";
import {isNullOrUndefined} from "util";

@Component({
  selector: '[app-variants]',
  templateUrl: './variants.component.html',
  styleUrls: ['./variants.component.scss']
})
export class VariantsComponent implements OnInit {

 @Input()  courses: any = [];
 @Input()  diagrams: any;
 @Input()  technologies: any;

 @Input() program_id: any;
 @Input() discipline: any;
 @Input() variants: any;

  constructor(
    private globalService: GlobalService,
  ) { }

  public getDisciplinesVariants(slug: string) {
    this.globalService.getElementsBySlug('get_variants/' + this.program_id, slug)
                    .subscribe(
                      variants => {
                        this.variants = variants;
                      },
                      error => console.log(error)
                    );
  }
  public addVariant(value) {
    console.log('addVariant', value);
       this.globalService.postResponseAdmin('create_variant', JSON.stringify(value))
                      .subscribe(
                      status => {

                         this.getDisciplinesVariants(this.discipline.id);
                       console.log(status);
                      },
                      error => console.log(error)
                      );
  }

  public disabledButton(): boolean {

    if (this.discipline.terms['3,5 года'] === 0 || this.discipline.terms['4 года'] === 0 || this.discipline.terms['5 лет'] === 0){
      return true;
    } else {
      return false;
    }
  }

  public addVariantSemester() {
    let value: string;
    if (this.discipline.terms['3,5 года'] > 0) {
      value = '3,5 года';
    } else  if (this.discipline.terms['4 года'] > 0) {
      value = '4 года';
    } else  if (this.discipline.terms['5 лет'] > 0) {
      value = '5 лет';
    }
    if (value !== undefined) {
      const value = {program_id: this.program_id, discipline_id: this.discipline.id, term_title: '4 года'}
      console.log('addVariant', value);
      this.globalService.postResponseAdmin('create_variant', JSON.stringify(value))
        .subscribe(
          status => {

            this.getDisciplinesVariants(this.discipline.id);
            console.log(status);
          },
          error => console.log(error)
        );
    } else {
      console.log('не указан симестр');
    }
  }

    public removeVariant(value){
    console.log(value);
       this.globalService.postResponseAdmin('delete_variant', JSON.stringify(value))
                      .subscribe(
                      status => {
                         this.getDisciplinesVariants(this.discipline.id);
                       console.log(status);
                      },
                      error => console.log(error)
                      );
  }
  changeVariant(value){
    console.log(value);
    this.globalService.postResponse('change_variant', JSON.stringify(value))
                      .subscribe(
{'fraction_non_alphanumeric': 0.13308356409838737, 'fraction_numerical': 0.006189933213878482, 'mean_word_length': 1.9561868078960039, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, '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': '3957681', 'n_tokens_mistral': 1779, 'n_tokens_neox': 1696, 'n_words': 324}