]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard_v2: add router link table template
authorTiago Melo <tmelo@suse.com>
Wed, 14 Feb 2018 16:28:32 +0000 (16:28 +0000)
committerRicardo Dias <rdias@suse.com>
Mon, 5 Mar 2018 13:07:10 +0000 (13:07 +0000)
Signed-off-by: Tiago Melo <tmelo@suse.com>
src/pybind/mgr/dashboard_v2/frontend/src/app/shared/datatable/datatable.module.ts
src/pybind/mgr/dashboard_v2/frontend/src/app/shared/datatable/table-key-value/table-key-value.component.spec.ts
src/pybind/mgr/dashboard_v2/frontend/src/app/shared/datatable/table/table.component.html
src/pybind/mgr/dashboard_v2/frontend/src/app/shared/datatable/table/table.component.spec.ts
src/pybind/mgr/dashboard_v2/frontend/src/app/shared/datatable/table/table.component.ts
src/pybind/mgr/dashboard_v2/frontend/src/app/shared/enum/cell-template.enum.ts

index 1c3b8701e17205240fc890d693c926b94bf3a227..df7ca994dad453d04c94dcb2f4b4396d7db43eb8 100644 (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,
index 12f3893b6144e85143129e61d62e7a3013420bd8..4bbca79b78fe539ee8ea30737d02e21508d2224d 100644 (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();
   }));
index 8779c937baf9425941659240a89eaadf4d21441e..043362f73933b1a05f0a1c352de68f936b3b3623 100644 (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>
index 37b204ddf658a96b7ff41a042088ce62b7cc911d..43c9ce1a7aa9bf7ba737bb18ee9026ee95017efe 100644 (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();
     })
   );
index 2cb66623ad93d0192ef41522c2c9baeb9394ee38..db158649453e53922f330066ac8a1c8f51d3c593 100644 (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) {
index 88959e0bad8148607c5016ba2761ddf6a2b62e7e..7c85bbe08c7e4b1e7c4945d23d7f7d812787db54 100644 (file)
@@ -1,4 +1,5 @@
 export enum CellTemplate {
   bold = 'bold',
-  sparkline = 'sparkline'
+  sparkline = 'sparkline',
+  routerLink = 'routerLink'
 }