1 import { Injectable, SecurityContext } from '@angular/core';
2 import { Observable } from 'rxjs/Observable';
3 import { BehaviorSubject } from 'rxjs/BehaviorSubject';
5 import { XDSAgentService } from "../services/xdsagent.service";
7 export interface ISdk {
16 export class SdkService {
17 public Sdks$: Observable<ISdk[]>;
19 private _sdksList = [];
20 private current: ISdk;
21 private sdksSubject = <BehaviorSubject<ISdk[]>>new BehaviorSubject(this._sdksList);
23 constructor(private xdsSvr: XDSAgentService) {
25 this.Sdks$ = this.sdksSubject.asObservable();
27 this.xdsSvr.XdsConfig$.subscribe(cfg => {
28 if (!cfg || cfg.servers.length < 1) {
31 // FIXME support multiple server
32 //cfg.servers.forEach(svr => {
33 this.xdsSvr.getSdks(cfg.servers[0].id).subscribe((s) => {
35 this.sdksSubject.next(s);
40 public setCurrent(s: ISdk) {
44 public getCurrent(): ISdk {
48 public getCurrentId(): string {
49 if (this.current && this.current.id) {
50 return this.current.id;