Mercurial > hg > ng2-query-ismi
changeset 2:80270f5a5735
more tinkering.
author | casties |
---|---|
date | Wed, 13 Jan 2016 11:13:07 +0100 |
parents | 59b7c3afcc6b |
children | c741a00d38de |
files | app/query.service.ts package.json |
diffstat | 2 files changed, 18 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/app/query.service.ts Mon Jan 11 19:25:53 2016 +0100 +++ b/app/query.service.ts Wed Jan 13 11:13:07 2016 +0100 @@ -8,6 +8,8 @@ @Injectable() export class QueryService { + public ismiObjectTypes; + public QUERY_MODES: QueryMode[] = [ {id: 'type_is', label:'Object type is'}, {id: 'att_contains', label: 'Attribute contains'}]; @@ -28,28 +30,27 @@ getIsmiObjectTypes() { var headers = new Headers(); - headers.append('Authorization', 'Basic ' + btoa('neo4j'+':'+'neo5j')); + headers.append('Authorization', 'Basic ' + btoa('neo4j' + ':' + 'neo5j')); headers.append('Content-Type', 'application/json'); headers.append('Accept', 'application/json'); var data = { - 'query': `MATCH (n) + 'query': `MATCH (n) WITH DISTINCT labels(n) AS labels UNWIND labels AS label RETURN DISTINCT label ORDER BY label`, - 'params': {} - }; - - console.debug("http:", this._http, " headers:", headers, " data:", data); - - var post = this._http.post('http://localhost:7474/db/data/cypher/', JSON.stringify(data), {'headers': headers}); - console.debug("post:", post); - var map = post.map(res => res.json()); - console.debug("map:", map); - map.subscribe( - data => console.debug("neo4j data=", data), - err => console.error("neo4j error=", err), - () => console.debug('neo4j query Complete') - ); + 'params': {} + }; + + this._http.post('http://localhost:7474/db/data/cypher/', JSON.stringify(data), {'headers': headers}) + .map(res => res.json()) + .subscribe( + data => { + console.debug("neo4j data=", data); + this.ismiObjectTypes = data.data.map(elem => elem[0]).filter(elem => elem[0] != "_"); + }, + err => console.error("neo4j error=", err), + () => console.debug('neo4j query Complete') + ); } } \ No newline at end of file