3 * Copyright (C) 2017 "IoT.bzh"
4 * Author Sebastien Douheret <sebastien@iot.bzh>
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 import { Injectable, SecurityContext } from '@angular/core';
20 import { Observable } from 'rxjs/Observable';
21 import { BehaviorSubject } from 'rxjs/BehaviorSubject';
23 import { XDSAgentService } from '../services/xdsagent.service';
25 import 'rxjs/add/observable/throw';
27 export interface ISdk {
36 export class SdkService {
37 public Sdks$: Observable<ISdk[]>;
39 private _sdksList = [];
40 private current: ISdk;
41 private sdksSubject = <BehaviorSubject<ISdk[]>>new BehaviorSubject(this._sdksList);
43 constructor(private xdsSvr: XDSAgentService) {
45 this.Sdks$ = this.sdksSubject.asObservable();
47 this.xdsSvr.XdsConfig$.subscribe(cfg => {
48 if (!cfg || cfg.servers.length < 1) {
51 // FIXME support multiple server
52 // cfg.servers.forEach(svr => {
53 this.xdsSvr.getSdks(cfg.servers[0].id).subscribe((s) => {
55 this.sdksSubject.next(s);
60 public setCurrent(s: ISdk) {
64 public getCurrent(): ISdk {
68 public getCurrentId(): string {
69 if (this.current && this.current.id) {
70 return this.current.id;
75 public add(sdk: ISdk): Observable<ISdk> {
77 return Observable.throw('Not implement yet');
80 public delete(sdk: ISdk): Observable<ISdk> {
82 return Observable.throw('Not implement yet');