<commit_before>import { Component, OnInit, OnDestroy } from '@angular/core';
import { environment } from 'environments/environment';
import { SelectedRouteService } from 'app/services/selected-route/selected-route';
import { Subscription } from 'rxjs/Subscription';
import { DomainService } from 'app/services/domain/domain.service';
import { BusinessAdminGuard } from 'app/guards/business-admin-guard';
import { MonitorGuard } from 'app/guards/monitor-guard';
import { WindowRefService } from 'app/services/window/window.service';
import { UserGuard } from 'app/guards/user-guard';
import { TaskanaEngineService } from '../../services/taskana-engine/taskana-engine.service';
import { expandRight } from 'app/shared/animations/expand.animation';
@Component({
  selector: 'taskana-nav-bar',
  templateUrl: './nav-bar.component.html',
  styleUrls: ['./nav-bar.component.scss'],
  animations: [expandRight],
})
export class NavBarComponent implements OnInit, OnDestroy {

  selectedRoute = '';
  route: string;
  title = '';

  titleAdministration = 'Administration';
  titleWorkbaskets = 'Workbaskets';
  titleClassifications = 'Classifications';
  titleMonitor = 'Monitor';
  titleWorkplace = 'Workplace';
  showNavbar = false;
  domains: Array<string> = [];
  selectedDomain: string;

  adminUrl = './administration';
  monitorUrl = './monitor';
  workplaceUrl = './workplace';

  administrationAccess = false;
  monitorAccess = false;
  workplaceAccess = false;

  selectedRouteSubscription: Subscription;
  getDomainsSubscription: Subscription;

  constructor(
    private selectedRouteService: SelectedRouteService,
    private domainService: DomainService,
    private taskanaEngineService: TaskanaEngineService,
    private window: WindowRefService) { }

  ngOnInit() {
    this.selectedRouteSubscription = this.selectedRouteService.getSelectedRoute().subscribe((value: string) => {
      this.selectedRoute = value;
      this.setTitle(value);
    });
    this.getDomainsSubscription = this.domainService.getDomains().subscribe(domains => {
      this.domains = domains;
    });

    this.domainService.getSelectedDomain().subscribe(domain => {
      this.selectedDomain = domain;
    });

    this.administrationAccess = this.taskanaEngineService.hasRole(BusinessAdminGuard.roles);
    this.monitorAccess = this.taskanaEngineService.hasRole(MonitorGuard.roles);
    this.workplaceAccess = this.taskanaEngineService.hasRole(UserGuard.roles);
  }

  switchDomain(domain) {
    this.domainService.switchDomain(domain);
  }

  toogleNavBar() {
    this.showNavbar = !this.showNavbar;
  }


  logout() {
    this.window.nativeWindow.location.href = environment.taskanaRestUrl + '/login?logout';
  }

  showDomainSelector(): boolean {
    return this.selectedRoute.indexOf('administration') !== -1
      || this.selectedRoute.indexOf('workbaskets') !== -1
      || this.selectedRoute.indexOf('classifications') !== -1
  }

  private setTitle(value: string = 'workbaskets') {
    if (value.indexOf('workbaskets') === 0) {
      this.title = this.titleWorkbaskets;
    } else if (value.indexOf('classifications') === 0) {
      this.title = this.titleClassifications;<commit_msg>TSK-624 Redirect to logout page on logout<commit_after>import { Component, OnInit, OnDestroy } from '@angular/core';
import { environment } from 'environments/environment';
import { SelectedRouteService } from 'app/services/selected-route/selected-route';
import { Subscription } from 'rxjs/Subscription';
import { DomainService } from 'app/services/domain/domain.service';
import { BusinessAdminGuard } from 'app/guards/business-admin-guard';
import { MonitorGuard } from 'app/guards/monitor-guard';
import { WindowRefService } from 'app/services/window/window.service';
import { UserGuard } from 'app/guards/user-guard';
import { TaskanaEngineService } from '../../services/taskana-engine/taskana-engine.service';
import { expandRight } from 'app/shared/animations/expand.animation';
@Component({
  selector: 'taskana-nav-bar',
  templateUrl: './nav-bar.component.html',
  styleUrls: ['./nav-bar.component.scss'],
  animations: [expandRight],
})
export class NavBarComponent implements OnInit, OnDestroy {

  selectedRoute = '';
  route: string;
  title = '';

  titleAdministration = 'Administration';
  titleWorkbaskets = 'Workbaskets';
  titleClassifications = 'Classifications';
  titleMonitor = 'Monitor';
  titleWorkplace = 'Workplace';
  showNavbar = false;
  domains: Array<string> = [];
  selectedDomain: string;

  adminUrl = './administration';
  monitorUrl = './monitor';
  workplaceUrl = './workplace';

  administrationAccess = false;
  monitorAccess = false;
  workplaceAccess = false;

  selectedRouteSubscription: Subscription;
  getDomainsSubscription: Subscription;

  constructor(
    private selectedRouteService: SelectedRouteService,
    private domainService: DomainService,
    private taskanaEngineService: TaskanaEngineService,
    private window: WindowRefService) { }

  ngOnInit() {
    this.selectedRouteSubscription = this.selectedRouteService.getSelectedRoute().subscribe((value: string) => {
      this.selectedRoute = value;
      this.setTitle(value);
    });
    this.getDomainsSubscription = this.domainService.getDomains().subscribe(domains => {
      this.domains = domains;
    });

    this.domainService.getSelectedDomain().subscribe(domain => {
      this.selectedDomain = domain;
    });

    this.administrationAccess = this.taskanaEngineService.hasRole(BusinessAdminGuard.roles);
    this.monitorAccess = this.taskanaEngineService.hasRole(MonitorGuard.roles);
    this.workplaceAccess = this.taskanaEngineService.hasRole(UserGuard.roles);
  }

  switchDomain(domain) {
    this.domainService.switchDomain(domain);
  }

  toogleNavBar() {
    this.showNavbar = !this.showNavbar;
  }


  logout() {
    this.window.nativeWindow.location.href = environment.taskanaRestUrl + '/logout';
  }

  showDomainSelector(): boolean {
    return this.selectedRoute.indexOf('administration') !== -1
      || this.selectedRoute.indexOf('workbaskets') !== -1
      || this.selectedRoute.indexOf('classifications') !== -1
  }

  private setTitle(value: string = 'workbaskets') {
    if (value.indexOf('workbaskets') === 0) {
      this.title = this.titleWorkbaskets;
    } else if (value.indexOf('classifications') === 0) {
      this.title = this.titleClassifications;
{'fraction_non_alphanumeric': 0.12982126058325494, 'fraction_numerical': 0.0020382565067419253, 'mean_word_length': 4.556620209059234, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '5102236', 'n_tokens_mistral': 1857, 'n_tokens_neox': 1805, 'n_words': 331}