mgr/dashboard_v2: add router link table template

Signed-off-by: Tiago Melo <tmelo@suse.com>
This commit is contained in:
Tiago Melo 2018-02-14 16:28:32 +00:00 committed by Ricardo Dias
parent afd896da40
commit 1a9619d9b3
No known key found for this signature in database
GPG Key ID: 74390C579BD37B68
6 changed files with 17 additions and 4 deletions

View File

@ -1,6 +1,7 @@
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';
import { NgxDatatableModule } from '@swimlane/ngx-datatable';
@ -16,7 +17,8 @@ import { TableComponent } from './table/table.component';
NgxDatatableModule,
FormsModule,
PipesModule,
ComponentsModule
ComponentsModule,
RouterModule
],
declarations: [
TableComponent,

View File

@ -1,5 +1,6 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { FormsModule } from '@angular/forms';
import { RouterTestingModule } from '@angular/router/testing';
import { NgxDatatableModule } from '@swimlane/ngx-datatable';
@ -14,7 +15,7 @@ describe('TableKeyValueComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ TableComponent, TableKeyValueComponent ],
imports: [ FormsModule, NgxDatatableModule, ComponentsModule ]
imports: [ FormsModule, NgxDatatableModule, ComponentsModule, RouterTestingModule ]
})
.compileComponents();
}));

View File

@ -80,3 +80,9 @@
let-value="value">
<cd-sparkline [data]="value"></cd-sparkline>
</ng-template>
<ng-template #routerLinkTpl
let-row="row"
let-value="value">
<a [routerLink]="[row.cdLink]">{{ value }}</a>
</ng-template>

View File

@ -1,5 +1,6 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { FormsModule } from '@angular/forms';
import { RouterTestingModule } from '@angular/router/testing';
import { NgxDatatableModule, TableColumn } from '@swimlane/ngx-datatable';
@ -26,7 +27,7 @@ describe('TableComponent', () => {
async(() => {
TestBed.configureTestingModule({
declarations: [TableComponent],
imports: [NgxDatatableModule, FormsModule, ComponentsModule]
imports: [NgxDatatableModule, FormsModule, ComponentsModule, RouterTestingModule]
}).compileComponents();
})
);

View File

@ -28,6 +28,7 @@ export class TableComponent implements AfterContentChecked, OnInit, OnChanges {
@ViewChild(TableDetailsDirective) detailTemplate: TableDetailsDirective;
@ViewChild('tableCellBoldTpl') tableCellBoldTpl: TemplateRef<any>;
@ViewChild('sparklineTpl') sparklineTpl: TemplateRef<any>;
@ViewChild('routerLinkTpl') routerLinkTpl: TemplateRef<any>;
// This is the array with the items to be shown.
@Input() data: any[];
@ -102,6 +103,7 @@ export class TableComponent implements AfterContentChecked, OnInit, OnChanges {
_addTemplates () {
this.cellTemplates.bold = this.tableCellBoldTpl;
this.cellTemplates.sparkline = this.sparklineTpl;
this.cellTemplates.routerLink = this.routerLinkTpl;
}
ngOnChanges(changes) {

View File

@ -1,4 +1,5 @@
export enum CellTemplate {
bold = 'bold',
sparkline = 'sparkline'
sparkline = 'sparkline',
routerLink = 'routerLink'
}