Mercurial > hg > ng2-query-ismi
comparison src/app/query-result-table.component.ts @ 57:d7c947909ab8 ng2-table
renamed query-app.module to app.module. loading query from url fragment works now.
author | casties |
---|---|
date | Wed, 29 Mar 2017 17:16:10 +0200 |
parents | 4341c1b4e3ae |
children |
comparison
equal
deleted
inserted
replaced
56:b22e52a128a8 | 57:d7c947909ab8 |
---|---|
3 import {QueryState} from './query-state'; | 3 import {QueryState} from './query-state'; |
4 | 4 |
5 @Component({ | 5 @Component({ |
6 selector: 'query-result', | 6 selector: 'query-result', |
7 template: ` | 7 template: ` |
8 <div *ngIf="queryState?.results"> | 8 <div *ngIf="queryState?.numResults > 0"> |
9 <span>Cypher query:</span> | 9 <span>Cypher query:</span> |
10 <pre>{{queryState.getQueryText()}}</pre> | 10 <pre>{{queryState.getQueryText()}}</pre> |
11 <h2>Query result</h2> | 11 <h2>Query result</h2> |
12 <pre>{{resultInfo}}</pre> | 12 <pre>{{resultInfo}}</pre> |
13 <div *ngIf="showTable"><button (click)="showTable=false">hide results</button></div> | 13 <div *ngIf="showTable"><button (click)="showTable=false">hide results</button></div> |
45 (tableChanged)="onChangeTable($event)" | 45 (tableChanged)="onChangeTable($event)" |
46 [rows]="rows" [columns]="columns"> | 46 [rows]="rows" [columns]="columns"> |
47 </ng-table> | 47 </ng-table> |
48 </div> | 48 </div> |
49 </div> | 49 </div> |
50 `, | 50 <div *ngIf="!(queryState?.numResults > 0)"> |
51 <h2>No results found</h2> | |
52 </div> | |
53 `, | |
51 inputs: ['queryState', 'resultInfo'] | 54 inputs: ['queryState', 'resultInfo'] |
52 }) | 55 }) |
53 | 56 |
54 export class QueryResultTableComponent implements OnInit { | 57 export class QueryResultTableComponent implements OnInit { |
55 | 58 |
76 }; | 79 }; |
77 | 80 |
78 ngOnChanges(changes: any) { | 81 ngOnChanges(changes: any) { |
79 console.debug("result table changed! changes=", changes); | 82 console.debug("result table changed! changes=", changes); |
80 this.data = this.queryState.results; | 83 this.data = this.queryState.results; |
81 this.allColumns = this.queryState.resultColumns; | 84 if (this.data.length > 0) { |
82 this.columns = this.allColumns.filter(c => c.show); | 85 this.allColumns = this.queryState.resultColumns; |
83 this.config.sorting = this.columns; | 86 this.columns = this.allColumns.filter(c => c.show); |
84 this.config.paging = {'page': this.currentPage, 'itemsPerPage': this.itemsPerPage}; | 87 this.config.sorting = this.columns; |
85 this.showTable = (this.data.length < 1000); | 88 this.config.paging = {'page': this.currentPage, 'itemsPerPage': this.itemsPerPage}; |
86 this.onChangeTable(this.config); | 89 this.showTable = (this.data.length < 1000); |
90 this.onChangeTable(this.config); | |
91 } | |
87 } | 92 } |
88 | 93 |
89 ngOnInit() { | 94 ngOnInit() { |
90 console.debug("result table init!"); | 95 console.debug("result table init!"); |
91 } | 96 } |