File
Implements
Metadata
| selector |
app-config-selection-page |
| templateUrl |
./config-selection-page.component.html |
Methods
|
getProjects
|
getProjects()
|
|
|
|
|
|
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()
|
|
|
|
|
|
onClientChange
|
onClientChange(event)
|
|
|
|
|
|
onProjectChange
|
onProjectChange(event)
|
|
|
|
|
|
__
|
Default value : strings
|
|
|
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 with directive