| .. | .. |
|---|
| 10 | 10 | import { TdMediaService } from '@covalent/core'; |
|---|
| 11 | 11 | import { IComboOption, FormBase } from './base'; |
|---|
| 12 | 12 | import { ActivatedRoute, Router } from '@angular/router'; |
|---|
| 13 | +import { OrganizationsService } from '../resources/organizations'; |
|---|
| 13 | 14 | |
|---|
| 14 | 15 | |
|---|
| 15 | 16 | |
|---|
| .. | .. |
|---|
| 25 | 26 | constructor(private http: Http, |
|---|
| 26 | 27 | private licenseTypes: LicenseTypesService, |
|---|
| 27 | 28 | private packs: PacksService, |
|---|
| 29 | + private orgService: OrganizationsService, |
|---|
| 28 | 30 | router: Router, |
|---|
| 29 | 31 | toaster: ToastsManager, |
|---|
| 30 | 32 | route: ActivatedRoute, |
|---|
| .. | .. |
|---|
| 34 | 36 | } |
|---|
| 35 | 37 | |
|---|
| 36 | 38 | loadCombos(): void { |
|---|
| 37 | | - this.http.get('api/organization') |
|---|
| 38 | | - .map(response => response.json().map((org : any) => <IComboOption>{id: org.id, label: `(${org.code}) ${org.name}`})) |
|---|
| 39 | | - .subscribe( |
|---|
| 40 | | - data => super.setViewData(() => this.organizations = (<IComboOption[]>data).sort((e1, e2) => e1.label.localeCompare(e2.label))), |
|---|
| 41 | | - err => console.error('Error loading orgs') |
|---|
| 42 | | - ); |
|---|
| 39 | + this.orgService.get() |
|---|
| 40 | + .map((orgs: any[]) => orgs.map((org: any) => <IComboOption>{id: org.id, label: `(${org.code}) ${org.name}`})) |
|---|
| 41 | + .subscribe( |
|---|
| 42 | + (data: IComboOption[]) => super.setViewData(() => this.organizations = data.sort((e1: IComboOption, e2: IComboOption) => e1.label.localeCompare(e2.label))), |
|---|
| 43 | + (err: any) => console.error('Error loading orgs', err) |
|---|
| 44 | + ); |
|---|
| 45 | + |
|---|
| 43 | 46 | this.licenseTypes.get() |
|---|
| 44 | | - .map(list => list.map((lt : any) => <IComboOption>{id: lt.id, label: `(${lt.code}) ${lt.name}`})) |
|---|
| 45 | | - .subscribe( |
|---|
| 46 | | - data => super.setViewData(() => this.licensetypes = (<IComboOption[]>data).sort((e1, e2) => e1.label.localeCompare(e2.label))), |
|---|
| 47 | | - err => console.error('Error loading license types') |
|---|
| 48 | | - ); |
|---|
| 47 | + .map((list: any[]) => list.map((lt: any) => <IComboOption>{id: lt.id, label: `(${lt.code}) ${lt.name}`})) |
|---|
| 48 | + .subscribe( |
|---|
| 49 | + (data: IComboOption[]) => super.setViewData(() => this.licensetypes = data.sort((e1: IComboOption, e2: IComboOption) => e1.label.localeCompare(e2.label))), |
|---|
| 50 | + (err: any) => console.error('Error loading license types', err) |
|---|
| 51 | + ); |
|---|
| 49 | 52 | } |
|---|
| 50 | 53 | |
|---|
| 51 | 54 | goLicenses(): void { |
|---|