Mercurial > hg > ng2-query-ismi
annotate app/query-select.component.ts @ 4:351c3df28602
work on result component.
| author | casties |
|---|---|
| date | Wed, 13 Jan 2016 16:01:47 +0100 |
| parents | c741a00d38de |
| children | b06a5d61afed |
| rev | line source |
|---|---|
|
1
59b7c3afcc6b
first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
1 import {Component, OnInit} from 'angular2/core'; |
|
59b7c3afcc6b
first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
2 import {HTTP_PROVIDERS} from 'angular2/http'; |
|
59b7c3afcc6b
first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
3 |
|
59b7c3afcc6b
first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
4 import {QueryService} from './query.service'; |
|
59b7c3afcc6b
first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
5 import {QueryMode} from './query-mode'; |
|
59b7c3afcc6b
first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
6 |
| 0 | 7 |
| 8 @Component({ | |
| 9 selector: 'query-select', | |
| 10 template: ` | |
| 11 <p>Selected option: {{selectedQuery}}</p> | |
|
3
c741a00d38de
first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
1
diff
changeset
|
12 <select (change)="onSelectMode($event)"> |
|
1
59b7c3afcc6b
first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
13 <option *ngFor="#mode of queryModes" [value]="mode.id"> |
|
59b7c3afcc6b
first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
14 {{mode.label}} |
| 0 | 15 </option> |
| 16 </select> | |
| 17 <select [(ngModel)]="selectedQuery"> | |
|
1
59b7c3afcc6b
first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
18 <option *ngFor="#option of query2Options" [value]="option"> |
| 0 | 19 {{option}} |
| 20 </option> | |
| 21 </select> | |
|
1
59b7c3afcc6b
first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
22 `, |
|
59b7c3afcc6b
first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
23 providers: [QueryService, HTTP_PROVIDERS] |
| 0 | 24 }) |
|
1
59b7c3afcc6b
first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
25 |
|
59b7c3afcc6b
first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
26 export class QuerySelectComponent implements OnInit { |
|
59b7c3afcc6b
first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
27 public queryModes; |
| 0 | 28 public selectedQuery = 'unknown'; |
|
1
59b7c3afcc6b
first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
29 public query2Options; |
|
59b7c3afcc6b
first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
30 |
|
59b7c3afcc6b
first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
31 constructor(private _queryService: QueryService) {} |
|
59b7c3afcc6b
first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
32 |
|
59b7c3afcc6b
first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
33 ngOnInit() { |
| 4 | 34 this.setup(); |
|
1
59b7c3afcc6b
first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
35 } |
|
59b7c3afcc6b
first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
36 |
| 4 | 37 setup() { |
|
1
59b7c3afcc6b
first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
38 this.queryModes = this._queryService.getQueryModes(); |
|
3
c741a00d38de
first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
1
diff
changeset
|
39 this._queryService.setupIsmiObjectTypes(); |
|
1
59b7c3afcc6b
first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
40 } |
| 0 | 41 |
|
3
c741a00d38de
first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
1
diff
changeset
|
42 onSelectMode(event: any) { |
|
1
59b7c3afcc6b
first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
43 var selected = event.target.value; |
|
3
c741a00d38de
first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
1
diff
changeset
|
44 var mode = this.queryModes.find(mode => mode.id === selected); |
|
c741a00d38de
first list of object types :-)
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
1
diff
changeset
|
45 this._queryService.getQueryOptions(mode).then( |
|
1
59b7c3afcc6b
first interface and http request.
Robert Casties <casties@mpiwg-berlin.mpg.de>
parents:
0
diff
changeset
|
46 options => this.query2Options = options); |
| 0 | 47 } |
| 48 } |
