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

Add link to dashboard in service instance table #3267

Merged
merged 2 commits into from
Dec 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
<span *ngIf="!isLink">
<ng-container *ngTemplateOutlet="valueTemplate; context: valueContext"></ng-container>
</span>
<span *ngIf="isLink">
<a [href]="linkValue" [attr.target]="linkTarget" *ngIf="isExternalLink">
<span *ngIf="isLink" class="link">
<ng-container *ngIf="showShortLink">
<div *ngIf="linkValue" class="link__short">
<a class="link__short__icon" [href]="linkValue" [attr.target]="linkTarget">
<mat-icon>launch</mat-icon>
</a>
<a [href]="linkValue" [attr.target]="linkTarget">View</a>
</div>
<ng-container *ngIf="!linkValue">
-
</ng-container>
</ng-container>
<ng-container *ngIf="!showShortLink">
<a [href]="linkValue" [attr.target]="linkTarget" *ngIf="isExternalLink">
<ng-container *ngTemplateOutlet="valueTemplate; context: valueContext"></ng-container>
</a>
<a [routerLink]="linkValue" [attr.target]="linkTarget" *ngIf="!isExternalLink">
</a>
<a [routerLink]="linkValue" [attr.target]="linkTarget" *ngIf="!isExternalLink">
<ng-container *ngTemplateOutlet="valueTemplate; context: valueContext"></ng-container>
</a>
</a>
</ng-container>
</span>

<ng-template let-value="value" #valueTemplate>
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
.link {
&__short {
display: flex;

&__icon {
font-size: 17px;

mat-icon {
font-size: 16px;
height: 16px;
margin-right: 2px;
width: 16px;
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export class TableCellDefaultComponent<T> extends TableCellCustom<T> implements
public linkValue: string;
public linkTarget = '_self';
public valueGenerator: (row: T) => string;
public showShortLink = false;

public init() {
this.setValueGenerator();
Expand All @@ -46,6 +47,10 @@ export class TableCellDefaultComponent<T> extends TableCellCustom<T> implements
this.linkTarget = '_blank';
}
this.isExternalLink = this.isLink && this.cellDefinition.externalLink;
this.showShortLink = this.cellDefinition.showShortLink;
if (this.showShortLink && !this.isExternalLink) {
throw Error('Short links must be external links');
}
}

private setSyncLink() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface ICellDefinition<T> {
getAsyncLink?: (value) => string;
newTab?: boolean;
asyncValue?: ICellAsyncValue;
showShortLink?: boolean;
}

export type CellConfigFunction<T> = (row: T) => any;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,17 @@ export class CfServiceInstancesListConfigBase implements IListConfig<APIResource
cellComponent: TableCellServicePlanComponent,
cellFlex: '1'
},
{
columnId: 'dashboard',
headerCell: () => 'Dashboard',
cellDefinition: {
externalLink: true,
getLink: (row: APIResource<IServiceInstance>) => row.entity.dashboard_url,
newTab: true,
showShortLink: true
},
cellFlex: '1'
},
{
columnId: 'tags',
headerCell: () => 'Tags',
Expand Down