<commit_before>import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router';
import { Store } from '@ngxs/store';
import { FetchProject } from 'app/store/project.action';
import { ProjectState, ProjectStateModel } from 'app/store/project.state';
import { Observable } from 'rxjs';
import { flatMap, map } from 'rxjs/operators';
import { LoadOpts, Project } from '../../model/project.model';
import { RouterService } from '../router/router.service';

@Injectable()
export class ProjectResolver implements Resolve<Project> {

    resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<any> | Promise<any> | any {
        let params = this.routerService.getRouteSnapshotParams({}, state.root);
        let opts = [
            new LoadOpts('withApplicationNames', 'application_names'),
            new LoadOpts('withPipelineNames', 'pipeline_names'),
            new LoadOpts('withWorkflowNames', 'workflow_names'),
            new LoadOpts('withEnvironmentNames', 'environment_names'),
            new LoadOpts('withLabels', 'labels')
        ];

        return this.store.dispatch(new FetchProject({
            projectKey: params['key'],
            opts
        })).pipe(
            flatMap(() => this.store.selectOnce(ProjectState)),
            map((projectState: ProjectStateModel) => projectState.project)
        );
    }

    constructor(private store: Store, private routerService: RouterService) { }
}

@Injectable()
export class ProjectForWorkflowResolver implements Resolve<Project> {

    resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<any> | Promise<any> | any {
        let params = this.routerService.getRouteSnapshotParams({}, state.root);

        let opts = [
            new LoadOpts('withWorkflowNames', 'workflow_names'),
            new LoadOpts('withPipelineNames', 'pipeline_names'),
            new LoadOpts('withApplicationNames', 'application_names'),
            new LoadOpts('withEnvironments', 'environments'),
            new LoadOpts('withIntegrations', 'integrations'),
            new LoadOpts('withLabels', 'labels'),
            new LoadOpts('withKeys', 'keys')
        ];

        return this.store.dispatch(new FetchProject({
            projectKey: params['key'],
            opts
        })).pipe(
            flatMap(() => this.store.selectOnce(ProjectState)),
            map((projectState: ProjectStateModel) => projectState.project)
        );
    }

    constructor(private store: Store, private routerService: RouterService) { }
}

@Injectable()
export class ProjectForApplicationResolver implements Resolve<Project> {

    resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<any> | Promise<any> | any {
        let params = this.routerService.getRouteSnapshotParams({}, state.root);
        let opts = [
            new LoadOpts('withWorkflowNames', 'workflow_names'),<commit_msg>fix(ui): load environment names (#4455)<commit_after>import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router';
import { Store } from '@ngxs/store';
import { FetchProject } from 'app/store/project.action';
import { ProjectState, ProjectStateModel } from 'app/store/project.state';
import { Observable } from 'rxjs';
import { flatMap, map } from 'rxjs/operators';
import { LoadOpts, Project } from '../../model/project.model';
import { RouterService } from '../router/router.service';

@Injectable()
export class ProjectResolver implements Resolve<Project> {

    resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<any> | Promise<any> | any {
        let params = this.routerService.getRouteSnapshotParams({}, state.root);
        let opts = [
            new LoadOpts('withApplicationNames', 'application_names'),
            new LoadOpts('withPipelineNames', 'pipeline_names'),
            new LoadOpts('withWorkflowNames', 'workflow_names'),
            new LoadOpts('withEnvironmentNames', 'environment_names'),
            new LoadOpts('withLabels', 'labels')
        ];

        return this.store.dispatch(new FetchProject({
            projectKey: params['key'],
            opts
        })).pipe(
            flatMap(() => this.store.selectOnce(ProjectState)),
            map((projectState: ProjectStateModel) => projectState.project)
        );
    }

    constructor(private store: Store, private routerService: RouterService) { }
}

@Injectable()
export class ProjectForWorkflowResolver implements Resolve<Project> {

    resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<any> | Promise<any> | any {
        let params = this.routerService.getRouteSnapshotParams({}, state.root);

        let opts = [
            new LoadOpts('withWorkflowNames', 'workflow_names'),
            new LoadOpts('withPipelineNames', 'pipeline_names'),
            new LoadOpts('withApplicationNames', 'application_names'),
            new LoadOpts('withEnvironmentNames', 'environment_names'),
            new LoadOpts('withEnvironments', 'environments'),
            new LoadOpts('withIntegrations', 'integrations'),
            new LoadOpts('withLabels', 'labels'),
            new LoadOpts('withKeys', 'keys')
        ];

        return this.store.dispatch(new FetchProject({
            projectKey: params['key'],
            opts
        })).pipe(
            flatMap(() => this.store.selectOnce(ProjectState)),
            map((projectState: ProjectStateModel) => projectState.project)
        );
    }

    constructor(private store: Store, private routerService: RouterService) { }
}

@Injectable()
export class ProjectForApplicationResolver implements Resolve<Project> {

    resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<any> | Promise<any> | any {
        let params = this.routerService.getRouteSnapshotParams({}, state.root);
        let opts = [
            new LoadOpts('withWorkflowNames', 'workflow_names'),
{'fraction_non_alphanumeric': 0.12444297738900809, 'fraction_numerical': 0.0006601749463607857, 'mean_word_length': 3.4298245614035086, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 29, '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': '3740702', 'n_tokens_mistral': 1557, 'n_tokens_neox': 1575, 'n_words': 352}