Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scalability: Change application list in service instance table row from vertical to chip list #2915

Merged
merged 5 commits into from
Sep 11, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
WIP
  • Loading branch information
richard-cox committed Aug 24, 2018
commit beb378c0873dcb5de8f513a1dcc2922a9f5905af
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<span *ngIf="!chips || !chips.length">None</span>
<mat-chip-list class="app-chips" [ngClass]="{'mat-chip-list__stacked': stacked, 'mat-chip-list__rtl': orientation==='rtl'}" *ngIf="chips && chips.length">
<mat-chip class="app-chip" *ngFor="let chip of chips | slice:0:limit" [ngClass]="chip.color ? chip.color : ''">{{chip[displayProperty]}}
<mat-chip class="app-chip" *ngFor="let chip of chips | slice:0:limit" [ngClass]="chip.color ? chip.color : ''">
<!-- //TODO: RC-->
<a [routerLink]="[chip.url.link]" [queryParams]="{ 'breadcrumbs': chip.url.params }">{{chip[displayProperty]}}</a>
<ng-container *ngIf="chip.clearAction && !(chip.hideClearButton$ | async)">
<mat-icon *ngIf="!chip.busy || !(chip.busy | async)" (click)="chip.clearAction(chip)" class="app-chip__close">close</mat-icon>
<mat-spinner *ngIf="chip.busy && (chip.busy | async)" diameter="15" class="app-chip__busy-spinner"></mat-spinner>
Expand Down
4 changes: 4 additions & 0 deletions src/frontend/app/shared/components/chips/chips.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export class AppChip<T = string> implements IAppChip<T> {
hideClearButton$?: Observable<boolean>;
busy?: Observable<boolean>;
color?: string;
url?: {
link: string,
params?: string
};
}

@Component({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
<div class="bound-apps" *ngFor="let app of boundApps">
<a [routerLink]="[app.url]" [queryParams]="{ 'breadcrumbs': config?.breadcrumbs }">{{app.appName}}</a>
</div>
<div *ngIf="boundApps && boundApps.length===0">
None
</div>
<app-chips [chips]="boundApps$ | async" [stacked]="false" lowerLimit="5" displayProperty="value"></app-chips>
Original file line number Diff line number Diff line change
@@ -1,28 +1,52 @@
import { Component, Input } from '@angular/core';
import { Component, Input, OnInit, OnDestroy } from '@angular/core';
import { BehaviorSubject, combineLatest, Observable } from 'rxjs';

import { IServiceInstance } from '../../../../../../core/cf-api-svc.types';
import { APIResource } from '../../../../../../store/types/api.types';
import { AppChip } from '../../../../chips/chips.component';
import { TableCellCustom } from '../../../list.types';
import { first, map } from 'rxjs/operators';

interface BoundApp {
appName: string;
url: string;
}
@Component({
selector: 'app-table-cell-service-instance-apps-attached',
templateUrl: './table-cell-service-instance-apps-attached.component.html',
styleUrls: ['./table-cell-service-instance-apps-attached.component.scss']
})
export class TableCellServiceInstanceAppsAttachedComponent extends TableCellCustom<APIResource<IServiceInstance>> {
boundApps: BoundApp[];
export class TableCellServiceInstanceAppsAttachedComponent extends TableCellCustom<APIResource<IServiceInstance>> implements OnInit {

boundApps$: Observable<AppChip[]>;
config$ = new BehaviorSubject(null);
row$ = new BehaviorSubject(null);

@Input('config')
set config(config: any) {
this.config$.next(config);
}

@Input('row')
set row(row: any) {
this.boundApps = row ? row.entity.service_bindings.map(binding => {
return {
appName: binding.entity.app.entity.name,
url: `/applications/${binding.entity.cfGuid}/${binding.entity.app.metadata.guid}`,
};
}) : [];
set row(row: APIResource<IServiceInstance>) {
this.row$.next(row);
}

ngOnInit(): void {
this.boundApps$ = combineLatest([
this.config$.asObservable().pipe(first()),
this.row$
]).pipe(
map(([config, row]) => {
console.log('!!!!!!!!!');
return row ? row.entity.service_bindings.map(binding => {
return {
value: binding.entity.app.entity.name,
url: {
link: `/applications/${binding.entity.cfGuid}/${binding.entity.app.metadata.guid}`,
params: config.breadcrumbs,
}
};
}) : [];
}),
first()
);
}

}