Mercurial > hg > ng2-query-ismi
changeset 13:98b435bb6c0c
more query work.
author | Robert Casties <casties@mpiwg-berlin.mpg.de> |
---|---|
date | Thu, 21 Jan 2016 14:47:00 +0100 |
parents | 1843b12eff9a |
children | 7dc7ea95ca26 |
files | app/query-app.component.ts app/query-result-row.component.ts app/query-result.component.ts app/query-select.component.ts app/query.service.ts index.html |
diffstat | 6 files changed, 51 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/app/query-app.component.ts Thu Jan 21 11:16:13 2016 +0100 +++ b/app/query-app.component.ts Thu Jan 21 14:47:00 2016 +0100 @@ -11,7 +11,7 @@ @Component({ selector: 'query-app', template: ` - <h1>Angular2 query builder</h1> + <h1>ISMI-Lab Query Builder</h1> <div>Select a query step:</div> <query-select *ngFor="#step of querySteps; #i=index;" [queryStep]="step" [index]="i"
--- a/app/query-result-row.component.ts Thu Jan 21 11:16:13 2016 +0100 +++ b/app/query-result-row.component.ts Thu Jan 21 14:47:00 2016 +0100 @@ -1,9 +1,13 @@ import {Component} from 'angular2/core'; @Component({ - selector: 'query-result-row', + selector: 'tr.resultRow', template: ` + <td *ngIf="rowType=='node'">[{{rowData.ismi_id}}]</td> <td *ngIf="rowType=='node'">{{rowData.label}}</td> + <td *ngIf="rowType=='node' && rowData.link"> + <a href="https://ismi-dev.mpiwg-berlin.mpg.de/om4-ismi/browse/entityDetails.xhtml?eid={{rowData.ismi_id}}" target="_blank">view in OpenMind</a> + </td> <td *ngIf="rowType=='text'">{{rowData}}</td> `, inputs: ['rowData', 'rowType']
--- a/app/query-result.component.ts Thu Jan 21 11:16:13 2016 +0100 +++ b/app/query-result.component.ts Thu Jan 21 14:47:00 2016 +0100 @@ -12,10 +12,12 @@ <p>Query results ({{queryState.resultInfo}}):</p> <table> <tr> + <th *ngIf="queryState.resultTypes=='node'">ID</th> <th *ngIf="queryState.resultTypes=='node'">Label</th> + <th *ngIf="queryState.resultTypes=='node'">Link</th> </tr> - <tr *ngFor="#row of queryState.results"> - <query-result-row [rowData]="row" [rowType]="queryState.resultTypes"></query-result-row> + <tr class="resultRow" *ngFor="#row of queryState.results" + [rowData]="row" [rowType]="queryState.resultTypes"> </tr> </table> </div>
--- a/app/query-select.component.ts Thu Jan 21 11:16:13 2016 +0100 +++ b/app/query-select.component.ts Thu Jan 21 14:47:00 2016 +0100 @@ -96,12 +96,29 @@ if (opt) { step = {'mode': this.selectedMode, 'relationType': opt}; } - } else if (this.selectedMode.id == 'att_contains' || this.selectedMode.id == 'att_contains_norm') { + } else if (this.selectedMode.id == 'att_contains') { var att = this.selectedOption; var val = this.queryInput; if (att && val) { step = {'mode': this.selectedMode, 'attribute': att, 'value': val}; } + } else if (this.selectedMode.id == 'att_contains_norm') { + var att = this.selectedOption; + var val = this.queryInput; + if (att && val) { + this._queryService.fetchNormalizedString(val) + .subscribe( + data => { + console.debug("openmind norm data=", data); + step = {'mode': this.selectedMode, 'attribute': att, 'value': val, 'normValue': data.normalized_text}; + this._queryService.setQueryStep(this.index, step); + this.queryChanged.emit(this._queryService.getState()); + }, + err => console.error("openmind norm error=", err), + () => console.debug("openmind norm query Complete") + ); + return; + } } if (step != null) {
--- a/app/query.service.ts Thu Jan 21 11:16:13 2016 +0100 +++ b/app/query.service.ts Thu Jan 21 14:47:00 2016 +0100 @@ -10,7 +10,10 @@ @Injectable() export class QueryService { - public neo4jBaseUrl = 'http://localhost:7474/db/data'; + public neo4jBaseUrl = 'https://ismi-dev.mpiwg-berlin.mpg.de/neo4j-ismi/db/data'; + //public neo4jBaseUrl = 'http://localhost:7474/db/data'; + public openMindBaseUrl = 'https://ismi-dev.mpiwg-berlin.mpg.de/om4-ismi/'; + //public openMindBaseUrl = 'http://localhost:18080/ismi-richfaces/': public state: QueryState; public ismiObjectTypes: any; @@ -138,6 +141,7 @@ updateQuery() { this.createCypherQuery(); + this.state.resultInfo = 'loading...'; // run query for result table var resQuery = this.state.resultCypherQuery; var queryParams = this.state.cypherQueryParams; @@ -210,4 +214,20 @@ // return Observable return resp; } + + fetchNormalizedString(text: string) { + console.debug("fetching normalized string: ", text); + var headers = new Headers(); + headers.append('Accept', 'application/json'); + // put headers in options + var opts = {'headers': headers}; + // make get request asynchronously + var url = this.openMindBaseUrl+'jsonInterface?method=normalize_string&type=arabic_translit&text='; + url += text; + var resp = this._http.get(url, opts) + // filter result as JSON + .map(res => res.json()); + // return Observable + return resp; + } } \ No newline at end of file
--- a/index.html Thu Jan 21 11:16:13 2016 +0100 +++ b/index.html Thu Jan 21 14:47:00 2016 +0100 @@ -1,7 +1,7 @@ <html> <head> - <title>Angular 2 QuickStart</title> + <title>ISMI Query Builder</title> <!-- 1. Load libraries --> <script src="node_modules/angular2/bundles/angular2-polyfills.js"></script> @@ -28,7 +28,7 @@ <!-- 3. Display the application --> <body> - <query-app>Loading...</query-app> + <query-app>Loading... Query Builder</query-app> </body> </html>