diff 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
line wrap: on
line diff
--- a/src/app/query-result-table.component.ts	Tue Mar 28 20:03:36 2017 +0200
+++ b/src/app/query-result-table.component.ts	Wed Mar 29 17:16:10 2017 +0200
@@ -5,7 +5,7 @@
 @Component({
     selector: 'query-result',
     template: `
-    <div *ngIf="queryState?.results">
+    <div *ngIf="queryState?.numResults > 0">
         <span>Cypher query:</span>
         <pre>{{queryState.getQueryText()}}</pre>
         <h2>Query result</h2>
@@ -47,7 +47,10 @@
             </ng-table>
         </div>
     </div>
-        `,
+    <div *ngIf="!(queryState?.numResults > 0)">
+        <h2>No results found</h2>
+    </div>
+       `,
     inputs: ['queryState', 'resultInfo']
 })
 
@@ -78,12 +81,14 @@
     ngOnChanges(changes: any) {
         console.debug("result table changed! changes=", changes);
         this.data = this.queryState.results;
-        this.allColumns = this.queryState.resultColumns;
-        this.columns = this.allColumns.filter(c => c.show);
-        this.config.sorting = this.columns;
-        this.config.paging = {'page': this.currentPage, 'itemsPerPage': this.itemsPerPage};
-        this.showTable = (this.data.length < 1000);
-        this.onChangeTable(this.config);
+        if (this.data.length > 0) {
+            this.allColumns = this.queryState.resultColumns;
+            this.columns = this.allColumns.filter(c => c.show);
+            this.config.sorting = this.columns;
+            this.config.paging = {'page': this.currentPage, 'itemsPerPage': this.itemsPerPage};
+            this.showTable = (this.data.length < 1000);
+            this.onChangeTable(this.config);
+        }
     }
     
     ngOnInit() {