# HG changeset patch # User casties # Date 1453491206 -3600 # Node ID 930fe7460f6bd93842b9d1da2a3b28cda7985bd4 # Parent 34cd764e234b244745dadb538121e26eba7b8811 result table shows all attributes now. diff -r 34cd764e234b -r 930fe7460f6b app/query-result-row.component.ts --- a/app/query-result-row.component.ts Fri Jan 22 17:32:33 2016 +0100 +++ b/app/query-result-row.component.ts Fri Jan 22 20:33:26 2016 +0100 @@ -3,19 +3,25 @@ @Component({ selector: 'tr.resultRow', template: ` - [{{rowData.ismi_id}}] - {{rowData.label}} - - view in OpenMind + + Link + {{rowData[col.name]}} - {{rowData}} + + {{rowData}} `, - inputs: ['rowData', 'rowType'] + inputs: ['rowData', 'rowType', 'columns'] }) export class QueryResultRowComponent { + public rowType: string; public rowData: any; - public rowType: string; + public columns: any[]; + /* ngOnInit() { + console.debug("row init! columns=", this.columns, " rowData=", this.rowData); + } */ } diff -r 34cd764e234b -r 930fe7460f6b app/query-result.component.ts --- a/app/query-result.component.ts Fri Jan 22 17:32:33 2016 +0100 +++ b/app/query-result.component.ts Fri Jan 22 20:33:26 2016 +0100 @@ -12,12 +12,12 @@

Query results ({{queryState.resultInfo}}):

- - - + + [rowData]="row" [rowType]="queryState.resultTypes" + [columns]="queryState.resultColumns">
IDLabelLink{{col?col.label:col}}
@@ -26,20 +26,8 @@ inputs: ['queryState'] }) -export class QueryResultComponent implements OnInit { +export class QueryResultComponent { public queryState: QueryState; - - ngOnChanges() { - console.debug("result changed!"); - } - - ngOnInit() { - this.setup(); - } - - setup() { - console.debug("result init!"); - } - + } diff -r 34cd764e234b -r 930fe7460f6b app/query-state.ts --- a/app/query-state.ts Fri Jan 22 17:32:33 2016 +0100 +++ b/app/query-state.ts Fri Jan 22 20:33:26 2016 +0100 @@ -12,8 +12,8 @@ public numResults: number; public resultTypes: string; public resultInfo: string; - - public nextQueryRelations: any[]; - public nextQueryAttributes: any[]; + public resultAttributes: string[]; + public resultRelations: any[]; + public resultColumns: any[]; } \ No newline at end of file diff -r 34cd764e234b -r 930fe7460f6b app/query.service.ts --- a/app/query.service.ts Fri Jan 22 17:32:33 2016 +0100 +++ b/app/query.service.ts Fri Jan 22 20:33:26 2016 +0100 @@ -44,13 +44,13 @@ if (queryMode.id === 'type_is') { options = this.objectTypes; } else if (queryMode.id === 'relation_is') { - options = this.state.nextQueryRelations; + options = this.state.resultRelations; } else if (queryMode.id === 'att_contains') { - options = this.state.nextQueryAttributes; + options = this.filterAttributes(this.state.resultAttributes); } else if (queryMode.id === 'att_contains_norm') { - options = this.state.nextQueryAttributes; + options = this.filterAttributes(this.state.resultAttributes, true); } else if (queryMode.id === 'att_num_range') { - options = this.state.nextQueryAttributes; + options = this.filterAttributes(this.state.resultAttributes); } console.debug("getQueryOptions returns: ", options); return options; @@ -237,8 +237,9 @@ */ if (this.state.attributesCypherQuery) { resIdx += 1; - this.state.nextQueryAttributes = data.results[resIdx].data.map(elem => elem.row[0]) - .filter(elem => elem[0] != "_" && !this.excludedAttributes[elem]); + var atts = data.results[resIdx].data.map(elem => elem.row[0]); + this.state.resultAttributes = atts; + this.state.resultColumns = this.getColumns(atts); } /* * results for relations list @@ -249,7 +250,7 @@ .filter(elem => elem[0] != "_"); // add inverse relations var invrels = rels.concat(rels.map((r) => this.invRelPrefix + r)); - this.state.nextQueryRelations = invrels; + this.state.resultRelations = invrels; } }, err => console.error("neo4j result error=", err), @@ -257,6 +258,41 @@ ); } + + filterAttributes(attributes: string[], normalized=false) { + var atts = []; + if (normalized) { + attributes.forEach((att) => { + if (att.substr(0, 3) == "_n_") { + atts.push(att.substr(3)); + } + }); + } else { + atts = attributes.filter(elem => elem[0] != "_" && !this.excludedAttributes[elem]); + } + return atts; + } + + /** + * Return nice column objects + */ + getColumns(attributes: string[]) { + var cols = []; + if (attributes.indexOf('ismi_id') > -1) { + cols.push({'name': 'ismi_id', 'label': 'ISMI ID'}); + } + if (attributes.indexOf('label') > -1) { + cols.push({'name': 'label', 'label': 'Label'}); + } + attributes.forEach((att) => { + if (att != 'ismi_id' && att != 'label' && att != 'type' && att[0] != '_') { + cols.push({'name': att, 'label': att}); + } + }); + + return cols; + } + /** * Run the given queries on the Neo4J server. *