File

src/app/core/containers/config-selection-page/config-selection-page.component.ts

Implements

OnInit

Metadata

selector app-config-selection-page
templateUrl ./config-selection-page.component.html

Index

Properties
Methods

Constructor

constructor(configService: ConfigService, activatedRoute: ActivatedRoute, router: Router, toastService: ToastService, projectService: ProjectService, clientService: ClientService)
Parameters :
Name Type Optional
configService ConfigService No
activatedRoute ActivatedRoute No
router Router No
toastService ToastService No
projectService ProjectService No
clientService ClientService No

Methods

getClients
getClients()
Returns : any
getProjects
getProjects()
Returns : any
makeBackButton
makeBackButton()
Returns : { routerLink: {}; queryParams: { project: any; }; name: string; }
makeQueryParams
makeQueryParams()
Returns : { project: any; client: any; }
makeState
makeState()
Returns : { projects: [any]; clients: [any]; }
Async ngOnInit
ngOnInit()
Returns : any
onClientChange
onClientChange(event)
Parameters :
Name Optional
event No
Returns : void
onProjectChange
onProjectChange(event)
Parameters :
Name Optional
event No
Returns : void

Properties

__
Default value : strings
clientId
clients
Type : [Client]
projectId
projects
Type : [Project]
import { Component, OnInit } from '@angular/core';
import {Project} from '@app/pages/models/project';
import {Client} from '@app/pages/models/client';
import {ConfigService} from '@app/pages/services/config.service';
import {ActivatedRoute, Router} from '@angular/router';
import {ToastService} from '@app/shared/services/toast.service';
import {ProjectService} from '@app/pages/services/project.service';
import {ClientService} from '@app/pages/services/client.service';
import strings from '@i18n/strings.json';

@Component({
  selector: 'app-config-selection-page',
  templateUrl: './config-selection-page.component.html',
  // styleUrls: ['./config-selection-page.component.scss']
})
export class ConfigSelectionPageComponent implements OnInit {
  __ = strings;

  projectId;
  clientId;
  projects: [Project];
  clients: [Client];

  constructor(
    private configService: ConfigService,
    private activatedRoute: ActivatedRoute,
    private router: Router,
    private toastService: ToastService,
    private projectService: ProjectService,
    private clientService: ClientService) {}

  async ngOnInit() {
    this.projectId = this.activatedRoute.snapshot.queryParams.project;
    this.clientId = this.activatedRoute.snapshot.queryParams.client;

    this.projects = await this.getProjects();
    this.clients = await this.getClients();
  }

  getProjects() {
    if (!this.projectId) { return; }
    const {projects} = history.state;
    return (projects ? projects : this.projectService.getAllProjects());
  }

  getClients() {
    if (!this.clientId) { return; }
    const {clients} = history.state;
    return (clients ? clients : this.clientService.getAllClients());
  }

  onProjectChange(event) {
    this.projectId = event.id;
    const tempObject = {...this.activatedRoute.snapshot.queryParams};
    tempObject.project = this.projectId;
    this.router.navigate(['/configs'], {queryParams: tempObject});
  }

  onClientChange(event) {
    this.clientId = event.id;
    const tempObject = {...this.activatedRoute.snapshot.queryParams};
    tempObject.client = this.clientId;
    this.router.navigate(['/configs'], {queryParams: tempObject});
  }

  makeState() {
    return {projects: this.projects, clients: this.clients};
  }

  makeQueryParams() {
    return {project: this.projectId, client: this.clientId};
  }

  makeBackButton() {
    if (!this.clientId || !this.projectId) { return; }
    return {routerLink: ['/clients'], queryParams: {project: this.projectId}, name: 'Applications'};
  }
}
<div class="container-flex">
  <app-left-sidebar [backButton]="makeBackButton()"></app-left-sidebar>
  <div class="container-main full-width">
    <div aria-label="breadcrumb" class="breadcrumb">
      <div class="breadcrumb-item">
        <div class="breadcrumb-item-label">{{__.project}}:</div>
        <app-dropdown *ngIf="projects" [data]="projects" [selected]="projectId" (change)="onProjectChange($event)"></app-dropdown>
      </div>
      <div class="breadcrumb-item">
        <div class="breadcrumb-item-label">{{__.application}}:</div>
        <app-dropdown *ngIf="clients" [data]="clients" [selected]="clientId" (change)="onClientChange($event)"></app-dropdown>
      </div>
    </div>
    <div class="container-content center">
      <h2>{{__.configurations}}</h2>
      <div>
        <h1>Edit Application Configuration for</h1>
        <div>
          <a class="btn btn-primary fixed-width" [routerLink]="['/configs']" [queryParams]="makeQueryParams()" [state]="makeState()">All Groups and Users</a>
        </div>
        <div>
          <a class="btn btn-primary fixed-width" [routerLink]="['/groups']" [queryParams]="makeQueryParams()" [state]="makeState()">Selected Groups</a>
        </div>
        <div>
          <a class="btn btn-primary fixed-width" [routerLink]="['/users']" [queryParams]="makeQueryParams()" [state]="makeState()">Selected Users</a>
        </div>
      </div>
    </div>
  </div>
</div>
Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""