@@ -4,12 +4,16 @@ import {
44  Component , 
55  ViewChild , 
66}  from  '@angular/core' ; 
7+ import  {  DomSanitizer ,  SafeHtml  }  from  '@angular/platform-browser' ; 
78import  { 
89  TsPaginatorComponent , 
910  TsPaginatorMenuItem , 
1011}  from  '@terminus/ui/paginator' ; 
1112import  {  TsSortDirective  }  from  '@terminus/ui/sort' ; 
12- import  {  TsTableDataSource  }  from  '@terminus/ui/table' ; 
13+ import  { 
14+   TsColumn , 
15+   TsTableDataSource , 
16+ }  from  '@terminus/ui/table' ; 
1317import  { 
1418  merge , 
1519  Observable , 
@@ -76,10 +80,14 @@ const COLUMNS_SOURCE_GITHUB = [
7680
7781export  interface  GithubApi  { 
7882  items : GithubIssue [ ] ; 
83+   // NOTE: Format controlled by GitHub 
84+   // eslint-disable-next-line camelcase 
7985  total_count : number ; 
8086} 
8187
8288export  interface  GithubIssue  { 
89+   // NOTE: Format controlled by GitHub 
90+   // eslint-disable-next-line camelcase 
8391  created_at : string ; 
8492  number : string ; 
8593  state : string ; 
@@ -92,11 +100,10 @@ export interface GithubIssue {
92100export  class  ExampleHttpDao  { 
93101  constructor ( private  http : HttpClient )  { } 
94102
95-   getRepoIssues ( sort : string ,  order : string ,  page : number ,  perPage : number ) : Observable < GithubApi >  { 
96-     const  href  =  ' https://api.github.com/search/issues' ; 
103+   public   getRepoIssues ( sort : string ,  order : string ,  page : number ,  perPage : number ) : Observable < GithubApi >  { 
104+     const  href  =  ` https://api.github.com/search/issues` ; 
97105    const  requestUrl  =  `${ href }  ; 
98106    const  requestParams  =  `&sort=${ sort } ${ order } ${ page  +  1 } ${ perPage }  ; 
99- 
100107    return  this . http . get < GithubApi > ( `${ requestUrl } ${ requestParams }  ) ; 
101108  } 
102109} 
@@ -108,35 +115,61 @@ export class ExampleHttpDao {
108115  styleUrls : [ './table.component.scss' ] , 
109116} ) 
110117export  class  TableComponent  implements  AfterViewInit  { 
111-   allColumns  =  COLUMNS_SOURCE_GITHUB . slice ( 0 ) ; 
112-   displayedColumns :  string [ ]  =  [ 
118+   public   allColumns  =  COLUMNS_SOURCE_GITHUB . slice ( 0 ) ; 
119+   public   displayedColumns  =  [ 
113120    'title' , 
114121    'updated' , 
115122    'comments' , 
116123    'assignee' , 
117124    'number' , 
118125    'labels' , 
119126    'created' , 
120-     'id' , 
121127    'body' , 
128+     'id' , 
129+     'html_url' , 
130+   ] ; 
131+   public  exampleDatabase ! : ExampleHttpDao ; 
132+   public  dataSource  =  new  TsTableDataSource < GithubIssue > ( ) ; 
133+   public  resultsLength  =  0 ; 
134+   public  resizableColumns : TsColumn [ ]  =  [ 
135+     { 
136+       name : 'title' , 
137+       width : '400px' , 
138+     } , 
139+     {  name : 'updated'  } , 
140+     {  name : 'comments'  } , 
141+     { 
142+       name : 'assignee' , 
143+       width : '160px' , 
144+     } , 
145+     {  name : 'number'  } , 
146+     { 
147+       name : 'labels' , 
148+       width : '260px' , 
149+     } , 
150+     {  name : 'created'  } , 
151+     {  name : 'id'  } , 
152+     { 
153+       name : 'body' , 
154+       width : '500px' , 
155+     } , 
156+     {  name : 'html_url'  } , 
122157  ] ; 
123-   exampleDatabase ! : ExampleHttpDao ; 
124-   dataSource : TsTableDataSource < GithubIssue >  =  new  TsTableDataSource ( ) ; 
125-   resultsLength  =  0 ; 
126158
127-   @ViewChild ( TsSortDirective ,  { static : true } ) 
128-   sort ! : TsSortDirective ; 
159+   @ViewChild ( TsSortDirective ,  {   static : true   } ) 
160+   public   sort ! : TsSortDirective ; 
129161
130-   @ViewChild ( TsPaginatorComponent ,  { static : true } ) 
131-   paginator ! : TsPaginatorComponent ; 
162+   @ViewChild ( TsPaginatorComponent ,  {   static : true   } ) 
163+   public   readonly   paginator ! : TsPaginatorComponent ; 
132164
133165
134166  constructor ( 
167+     private  domSanitizer : DomSanitizer , 
135168    private  http : HttpClient , 
136169  )  { } 
137170
138171
139-   ngAfterViewInit ( ) : void { 
172+   public   ngAfterViewInit ( ) : void { 
140173    this . exampleDatabase  =  new  ExampleHttpDao ( this . http ) ; 
141174
142175    // If the user changes the sort order, reset back to the first page. 
@@ -171,12 +204,16 @@ export class TableComponent implements AfterViewInit {
171204  } 
172205
173206
174-   perPageChange ( e : number ) : void { 
207+   public   perPageChange ( e : number ) : void { 
175208    console . log ( 'DEMO records per page changed: ' ,  e ) ; 
176209  } 
177210
178-   onPageSelect ( e : TsPaginatorMenuItem ) : void { 
211+   public   onPageSelect ( e : TsPaginatorMenuItem ) : void { 
179212    console . log ( 'DEMO page selected: ' ,  e ) ; 
180213  } 
181214
215+   public  sanitize ( content ) : SafeHtml  { 
216+     return  this . domSanitizer . bypassSecurityTrustHtml ( content ) ; 
217+   } 
218+ 
182219} 
0 commit comments