[ADF-3877][Task Filters cloud] - APS2 - The first filter from the list is not selected as default after reloading the same app (#4142)

This commit is contained in:
siva kumar 2019-01-15 23:15:18 +05:30 committed by Eugenio Romano
parent 5b2887fea1
commit 4bd87b4543
6 changed files with 76 additions and 37 deletions

View File

@ -17,6 +17,7 @@
import { Component } from '@angular/core';
import { Router } from '@angular/router';
import { CloudLayoutService } from './services/cloud-layout.service';
@Component({
templateUrl: './apps-cloud-demo.component.html'
@ -24,10 +25,11 @@ import { Router } from '@angular/router';
export class AppsCloudDemoComponent {
constructor(private router: Router) {
constructor(private router: Router, private cloudLayoutService: CloudLayoutService) {
}
onAppClick(app) {
this.cloudLayoutService.setCurrentTaskFilterParam({key: 'my-tasks'});
this.router.navigate([`/cloud/${app.name}`]);
}
}

View File

@ -1,12 +1,12 @@
<mat-accordion>
<mat-expansion-panel [expanded]="true" (opened)="panelOpenStateTask = true" (closed)="panelOpenStateTask = false" data-automation-id='Task Filters'>
<mat-expansion-panel [expanded]="expandTaskFilter" (opened)="onTaskFilterOpen()" (closed)="onTaskFilterClose()" data-automation-id='Task Filters'>
<mat-expansion-panel-header>
<mat-panel-title>
Task Filters
</mat-panel-title>
</mat-expansion-panel-header>
<adf-cloud-task-filters
*ngIf="panelOpenStateTask"
*ngIf="expandTaskFilter"
[appName]="appName"
[showIcons]="true"
[filterParam]="currentTaskFilter$ | async"
@ -14,14 +14,14 @@
</adf-cloud-task-filters>
</mat-expansion-panel>
<mat-expansion-panel (opened)="panelOpenStateProcess = true" (closed)="panelOpenStateProcess = false" data-automation-id='Process Filters'>
<mat-expansion-panel [expanded]="expandProcessFilter" (opened)="onProcessFilterOpen()" (closed)="onProcessFilterClose()" data-automation-id='Process Filters'>
<mat-expansion-panel-header>
<mat-panel-title>
Process Filters
</mat-panel-title>
</mat-expansion-panel-header>
<adf-cloud-process-filters
*ngIf="panelOpenStateProcess"
*ngIf="expandProcessFilter"
[appName]="appName"
[showIcons]="true"
[filterParam]="currentProcessFilter$ | async"

View File

@ -18,42 +18,78 @@
import { Component, ViewEncapsulation, Input, OnInit } from '@angular/core';
import { Observable } from 'rxjs';
import { CloudLayoutService } from './services/cloud-layout.service';
import { Router } from '@angular/router';
import { Router, ActivatedRoute } from '@angular/router';
@Component({
selector: 'app-cloud-filters-demo',
templateUrl: './cloud-filters-demo.component.html',
styleUrls: ['cloud-filters-demo.component.scss'],
encapsulation: ViewEncapsulation.None
selector: 'app-cloud-filters-demo',
templateUrl: './cloud-filters-demo.component.html',
styleUrls: ['cloud-filters-demo.component.scss'],
encapsulation: ViewEncapsulation.None
})
export class CloudFiltersDemoComponent implements OnInit {
@Input()
appName: string;
@Input()
appName: string;
panelOpenStateTask: boolean;
panelOpenStateProcess: boolean;
currentTaskFilter$: Observable<any>;
currentProcessFilter$: Observable<any>;
currentTaskFilter$: Observable<any>;
currentProcessFilter$: Observable<any>;
toggleTaskFilter = true;
toggleProcessFilter = true;
constructor(private cloudLayoutService: CloudLayoutService, private router: Router) {
}
expandTaskFilter = true;
expandProcessFilter = false;
ngOnInit() {
this.currentTaskFilter$ = this.cloudLayoutService.getCurrentTaskFilterParam();
this.currentProcessFilter$ = this.cloudLayoutService.getCurrentProcessFilterParam();
}
constructor(
private cloudLayoutService: CloudLayoutService,
private router: Router,
private route: ActivatedRoute
) {}
onTaskFilterSelected(filter) {
this.cloudLayoutService.setCurrentTaskFilterParam({id: filter.id});
const currentFilter = Object.assign({}, filter);
this.router.navigate([`/cloud/${this.appName}/tasks/`], { queryParams: currentFilter });
}
ngOnInit() {
this.currentTaskFilter$ = this.cloudLayoutService.getCurrentTaskFilterParam();
this.currentProcessFilter$ = this.cloudLayoutService.getCurrentProcessFilterParam();
let root = '';
if ( this.route.snapshot && this.route.snapshot.firstChild) {
root = this.route.snapshot.firstChild.url[0].path;
if (root === 'tasks') {
this.expandTaskFilter = true;
this.expandProcessFilter = false;
} else if (root === 'processes') {
this.expandProcessFilter = true;
this.expandTaskFilter = false;
}
}
}
onProcessFilterSelected(filter) {
this.cloudLayoutService.setCurrentProcessFilterParam({id: filter.id});
const currentFilter = Object.assign({}, filter);
this.router.navigate([`/cloud/${this.appName}/processes/`], { queryParams: currentFilter });
}
onTaskFilterSelected(filter) {
this.cloudLayoutService.setCurrentTaskFilterParam({id: filter.id});
const currentFilter = Object.assign({}, filter);
this.router.navigate([`/cloud/${this.appName}/tasks/`], { queryParams: currentFilter });
}
onProcessFilterSelected(filter) {
this.cloudLayoutService.setCurrentProcessFilterParam({id: filter.id});
const currentFilter = Object.assign({}, filter);
this.router.navigate([`/cloud/${this.appName}/processes/`], { queryParams: currentFilter });
}
onTaskFilterOpen(): boolean {
this.expandTaskFilter = true;
this.expandProcessFilter = false;
return this.toggleTaskFilter;
}
onTaskFilterClose(): boolean {
return !this.toggleTaskFilter;
}
onProcessFilterOpen(): boolean {
this.expandProcessFilter = true;
this.expandTaskFilter = false;
return this.toggleProcessFilter;
}
onProcessFilterClose(): boolean {
return !this.toggleProcessFilter;
}
}

View File

@ -48,5 +48,4 @@ export class CloudLayoutService {
setCurrentProcessFilterParam(param) {
this.filterProcessSubject.next(param);
}
}

View File

@ -44,12 +44,13 @@ export class StartProcessCloudDemoComponent implements OnInit {
}
onStartProcessSuccess() {
this.router.navigate([`/cloud/${this.applicationName}`]);
this.cloudLayoutService.setCurrentProcessFilterParam({ key: 'running-processes' });
this.router.navigate([`/cloud/${this.applicationName}/processes`]);
}
onCancelStartProcess() {
this.router.navigate([`/cloud/${this.applicationName}`]);
this.cloudLayoutService.setCurrentProcessFilterParam({ key: 'all-processes' });
this.router.navigate([`/cloud/${this.applicationName}/processes`]);
}
openSnackMessage(event: any) {

View File

@ -41,12 +41,13 @@ export class StartTaskCloudDemoComponent implements OnInit {
}
onStartTaskSuccess() {
this.router.navigate([`/cloud/${this.applicationName}`]);
this.cloudLayoutService.setCurrentTaskFilterParam({key: 'my-tasks'});
this.router.navigate([`/cloud/${this.applicationName}/tasks`]);
}
onCancelStartTask() {
this.router.navigate([`/cloud/${this.applicationName}`]);
this.cloudLayoutService.setCurrentTaskFilterParam({key: 'my-tasks'});
this.router.navigate([`/cloud/${this.applicationName}/tasks`]);
}
openSnackMessage(event: any) {