# HG changeset patch # User casties # Date 1454353855 -3600 # Node ID 4926885f8a99b3bd0f28dc1c796408bb13284bde # Parent 193271b6b9d261b7e24f9bd74688ffd9ec3001b5 selectable result columns. nicer cypher query output. diff -r 193271b6b9d2 -r 4926885f8a99 app/query-result-table.component.ts --- a/app/query-result-table.component.ts Mon Feb 01 17:29:04 2016 +0100 +++ b/app/query-result-table.component.ts Mon Feb 01 20:10:55 2016 +0100 @@ -10,7 +10,7 @@ template: `
Cypher query: -
{{queryState.resultCypherQuery}}
+
{{queryState.getQueryText()}}

Query result

{{resultInfo}}
@@ -24,6 +24,15 @@ results per page.
+
+
+ Columns: + + {{col.name}} + + +
+
Page {{page}} of {{numPages}}
; public columns: Array; + public allColumns: Array; public rows: Array; @@ -71,11 +81,12 @@ //filtering: {filterString: '', columnName: 'position'} }; - ngOnChanges() { - console.debug("result table changed! queryState=", this.queryState?this.queryState.resultColumns:''); + ngOnChanges(changes: any) { + console.debug("result table changed! changes=", changes); this.data = this.queryState.results; - this.columns = this.queryState.resultColumns; - this.config.sorting = this.queryState.resultColumns; + this.allColumns = this.queryState.resultColumns; + this.columns = this.allColumns.filter(c => c.show); + this.config.sorting = this.columns; this.showTable = (this.data.length < 1000); this.onChangeTable(this.config, null); } @@ -95,6 +106,12 @@ } } + onSelectCols(event: any) { + console.debug("select cols:", this.allColumns); + this.columns = this.allColumns.filter(c => c.show); + this.config.sorting = this.columns; + } + changePage(page:any, data:Array = this.data):Array { let start = (page.page - 1) * page.itemsPerPage; let end = page.itemsPerPage > -1 ? (start + page.itemsPerPage) : data.length; @@ -142,8 +159,9 @@ Object.assign(this.config.sorting, config.sorting); } - let filteredData = this.changeFilter(this.data, this.config); - let sortedData = this.changeSort(filteredData, this.config); + //let filteredData = this.changeFilter(this.data, this.config); + //let sortedData = this.changeSort(filteredData, this.config); + let sortedData = this.changeSort(this.data, this.config); this.rows = (page && config.paging) ? this.changePage(page, sortedData) : sortedData; this.length = sortedData.length; diff -r 193271b6b9d2 -r 4926885f8a99 app/query-state.ts --- a/app/query-state.ts Mon Feb 01 17:29:04 2016 +0100 +++ b/app/query-state.ts Mon Feb 01 20:10:55 2016 +0100 @@ -16,4 +16,16 @@ public resultRelations: any[]; public resultColumns: any[]; + getQueryText() { + let text = this.resultCypherQuery; + let hasParams = false; + for (let k in this.cypherQueryParams) { + if (!hasParams) { + hasParams = true; + text += '\n'; + } + text += `[${k}='${this.cypherQueryParams[k]}'] `; + } + return text; + } } \ No newline at end of file diff -r 193271b6b9d2 -r 4926885f8a99 app/result-column.ts --- a/app/result-column.ts Mon Feb 01 17:29:04 2016 +0100 +++ b/app/result-column.ts Mon Feb 01 20:10:55 2016 +0100 @@ -2,10 +2,12 @@ public name: string; public title: string; public sort: any; + public show: boolean; - constructor (name: string, title: string, sort='') { + constructor (name: string, title: string, sort='', show=false) { this.name = name; this.title = title; this.sort = sort; + this.show = show; } } \ No newline at end of file diff -r 193271b6b9d2 -r 4926885f8a99 app/result-type.ts --- a/app/result-type.ts Mon Feb 01 17:29:04 2016 +0100 +++ b/app/result-type.ts Mon Feb 01 20:10:55 2016 +0100 @@ -13,22 +13,22 @@ this.deniedAttributes = deniedAttributes; } - getColumns(attributes: string[], allAttributes=false) { + getColumns(attributes: string[], allAttributes=true) { let atts = attributes.slice(); let cols = []; // allowed attributes this.allowedAttributes.forEach(att => { let idx = atts.indexOf(att); if (idx > -1) { - cols.push(new ResultColumn(att, att)); + cols.push(new ResultColumn(att, att, '', true)); atts[idx] = null; } }); // then other attributes if (allAttributes) { atts.forEach(att => { - if (att != null && this.deniedAttributes.indexOf(att) > -1) { - cols.push(new ResultColumn(att, att)); + if (att != null && att[0] != '_' && this.deniedAttributes.indexOf(att) < 0) { + cols.push(new ResultColumn(att, att, '', false)); } }); }