github.com/in4it/ecs-deploy@v0.0.42-0.20240508120354-ed77ff16df25/webapp/src/app/service-list/service-list.service.ts (about)

     1  
     2  
     3  
     4  import { AsyncSubject } from 'rxjs';
     5  import {HttpClient, HttpHeaders } from '@angular/common/http';
     6  import { AuthService } from '../services/auth.service';
     7  
     8  
     9  export class ServiceList {
    10    constructor(public services: string[]) { }
    11  }
    12  
    13  import { Injectable } from '@angular/core';
    14  
    15  @Injectable()
    16  export class ServiceListService {
    17  
    18    private sl: ServiceList = new ServiceList([])
    19    private sl$: AsyncSubject<ServiceList> = new AsyncSubject<ServiceList>()
    20      
    21    constructor(private http: HttpClient, private auth: AuthService) { } 
    22  
    23    getServiceList() {
    24      this.getServices().subscribe(data => {
    25        // Read the result field from the JSON response.
    26        this.sl.services = data['services'];
    27        this.sl$.next(this.sl)    
    28        this.sl$.complete()
    29      });
    30      return this.sl$
    31    }
    32  
    33    getServices() {
    34      return this.http.get('/ecs-deploy/api/v1/service/describe', {headers: new HttpHeaders().set('Authorization', "Bearer " + this.auth.getToken())})
    35    }
    36  }