@@ -4,7 +4,7 @@ import {HttpClient} from '@angular/common/http';
44import { MatDialog } from '@angular/material/dialog' ;
55import { MatPaginator } from '@angular/material/paginator' ;
66import { MatSort } from '@angular/material/sort' ;
7- import { Issue } from './models/issue ' ;
7+ import { Passenger } from './models/passenger ' ;
88import { DataSource } from '@angular/cdk/collections' ;
99import { AddDialogComponent } from './dialogs/add/add.dialog.component' ;
1010import { EditDialogComponent } from './dialogs/edit/edit.dialog.component' ;
@@ -44,9 +44,9 @@ export class AppComponent implements OnInit {
4444 this . loadData ( ) ;
4545 }
4646
47- addNew ( issue : Issue ) {
47+ addNew ( passenger : Passenger ) {
4848 const dialogRef = this . dialog . open ( AddDialogComponent , {
49- data : { dataKey : issue }
49+ data : { dataKey : passenger }
5050 } ) ;
5151
5252 dialogRef . afterClosed ( ) . subscribe ( result => {
@@ -98,6 +98,7 @@ export class AppComponent implements OnInit {
9898
9999 public loadData ( ) {
100100 this . exampleDatabase = new DataService ( this . httpClient ) ;
101+ // tslint:disable-next-line: no-use-before-declare
101102 this . dataSource = new ExampleDataSource ( this . exampleDatabase , this . paginator , this . sort ) ;
102103 fromEvent ( this . filter . nativeElement , 'keyup' )
103104 // .debounceTime(150)
@@ -111,7 +112,7 @@ export class AppComponent implements OnInit {
111112 }
112113}
113114
114- export class ExampleDataSource extends DataSource < Issue > {
115+ export class ExampleDataSource extends DataSource < Passenger > {
115116 _filterChange = new BehaviorSubject ( '' ) ;
116117
117118 get filter ( ) : string {
@@ -122,8 +123,8 @@ export class ExampleDataSource extends DataSource<Issue> {
122123 this . _filterChange . next ( filter ) ;
123124 }
124125
125- filteredData : Issue [ ] = [ ] ;
126- renderedData : Issue [ ] = [ ] ;
126+ filteredData : Passenger [ ] = [ ] ;
127+ renderedData : Passenger [ ] = [ ] ;
127128
128129 constructor ( public _exampleDatabase : DataService ,
129130 public _paginator : MatPaginator ,
@@ -134,7 +135,7 @@ export class ExampleDataSource extends DataSource<Issue> {
134135 }
135136
136137 /** Connect function called by the table to retrieve one stream containing the data to render. */
137- connect ( ) : Observable < Issue [ ] > {
138+ connect ( ) : Observable < Passenger [ ] > {
138139 // Listen for any changes in the base data, sorting, filtering, or pagination
139140 const displayDataChanges = [
140141 this . _exampleDatabase . dataChange ,
@@ -143,17 +144,17 @@ export class ExampleDataSource extends DataSource<Issue> {
143144 this . _paginator . page
144145 ] ;
145146
146- this . _exampleDatabase . getAllIssues ( ) ;
147+ this . _exampleDatabase . getAllPassengers ( ) ;
147148
148149
149150 return merge ( ...displayDataChanges ) . pipe ( map ( ( ) => {
150151 // Filter data
151- this . filteredData = this . _exampleDatabase . data . slice ( ) . filter ( ( issue : Issue ) => {
152+ this . filteredData = this . _exampleDatabase . data . slice ( ) . filter ( ( passenger : Passenger ) => {
152153
153- const searchStr = ( issue . passengerid + issue . pClass +
154- issue . name + issue . sex + issue . age + issue . sibsp +
155- issue . parch + issue . ticket + issue . fare + issue . cabin +
156- issue . embarked ) . toLowerCase ( ) ;
154+ const searchStr = ( passenger . passengerid + passenger . pClass +
155+ passenger . name + passenger . sex + passenger . age + passenger . sibsp +
156+ passenger . parch + passenger . ticket + passenger . fare + passenger . cabin +
157+ passenger . embarked ) . toLowerCase ( ) ;
157158
158159 return searchStr . indexOf ( this . filter . toLowerCase ( ) ) !== - 1 ;
159160 } ) ;
@@ -173,7 +174,7 @@ export class ExampleDataSource extends DataSource<Issue> {
173174
174175
175176 /** Returns a sorted copy of the database data. */
176- sortData ( data : Issue [ ] ) : Issue [ ] {
177+ sortData ( data : Passenger [ ] ) : Passenger [ ] {
177178 if ( ! this . _sort . active || this . _sort . direction === '' ) {
178179 return data ;
179180 }
0 commit comments