github.com/in4it/ecs-deploy@v0.0.42-0.20240508120354-ed77ff16df25/webapp/src/app/service-detail/service-detail.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 ServiceDetail {
    10    public versions: {}
    11    public serviceName: string
    12    constructor(public service: {}) { }
    13  }
    14  
    15  import { Injectable } from '@angular/core';
    16  
    17  @Injectable()
    18  export class ServiceDetailService {
    19  
    20    private sl$: AsyncSubject<ServiceDetail>
    21    private sl: ServiceDetail = new ServiceDetail({})
    22  
    23    constructor(private http: HttpClient, private auth: AuthService) { } 
    24  
    25    getServiceDetail(serviceName: string) {
    26      this.sl$ = new AsyncSubject<ServiceDetail>()
    27      this.sl.serviceName = serviceName
    28      this.getService(serviceName).subscribe(data => {
    29        // Read the result field from the JSON response.
    30        this.sl.service = data['service'];
    31        this.sl$.next(this.sl)
    32        this.sl$.complete()
    33      });
    34      return this.sl$
    35    }
    36  
    37    getService(serviceName: string) {
    38      return this.http.get('/ecs-deploy/api/v1/service/describe/'+serviceName, {headers: new HttpHeaders().set('Authorization', "Bearer " + this.auth.getToken())})
    39    }
    40  
    41    getVersions() {
    42      return this.http.get('/ecs-deploy/api/v1/service/describe/'+this.sl.serviceName+'/versions', {headers: new HttpHeaders().set('Authorization', "Bearer " + this.auth.getToken())})
    43    }
    44    getDeployment(version) {
    45      return this.http.get('/ecs-deploy/api/v1/deploy/get/'+this.sl.serviceName+'/'+version, {headers: new HttpHeaders().set('Authorization', "Bearer " + this.auth.getToken())})
    46    }
    47    deploy(serviceName, version) {
    48      return this.http.post('/ecs-deploy/api/v1/deploy/'+serviceName+'/'+version, {}, {headers: new HttpHeaders().set('Authorization', "Bearer " + this.auth.getToken())})
    49    }
    50    listParameters() {
    51      return this.http.get('/ecs-deploy/api/v1/service/parameter/'+this.sl.serviceName+'/list', {headers: new HttpHeaders().set('Authorization', "Bearer " + this.auth.getToken())})
    52    }
    53    putParameter(data) {
    54      return this.http.post('/ecs-deploy/api/v1/service/parameter/'+this.sl.serviceName+'/put', data, {headers: new HttpHeaders().set('Authorization', "Bearer " + this.auth.getToken())})
    55    }
    56    deleteParameter(serviceName, selectedParameter) {
    57      return this.http.post('/ecs-deploy/api/v1/service/parameter/'+serviceName+'/delete/' + selectedParameter, {}, {headers: new HttpHeaders().set('Authorization', "Bearer " + this.auth.getToken())})
    58    }
    59    setDesiredCount(data) {
    60      return this.http.post('/ecs-deploy/api/v1/service/scale/'+this.sl.serviceName+'/' + data.desiredCount, {}, {headers: new HttpHeaders().set('Authorization', "Bearer " + this.auth.getToken())})
    61    }
    62    getTaskDefinition() {
    63      return this.http.get('/ecs-deploy/api/v1/service/describe/'+this.sl.serviceName+'/taskdefinition', {headers: new HttpHeaders().set('Authorization', "Bearer " + this.auth.getToken())})
    64    }
    65    runTask(data) {
    66      return this.http.post('/ecs-deploy/api/v1/service/runtask/'+this.sl.serviceName, data, {headers: new HttpHeaders().set('Authorization', "Bearer " + this.auth.getToken())})
    67    }
    68    describeTasks() {
    69      return this.http.get('/ecs-deploy/api/v1/service/describe/'+this.sl.serviceName+'/tasks', {headers: new HttpHeaders().set('Authorization', "Bearer " + this.auth.getToken())})
    70    }
    71    getServiceLog(params) {
    72      return this.http.get('/ecs-deploy/api/v1/service/log/'+this.sl.serviceName+'/get/'+params.taskArn+'/'+params.containerName+'/'+params.start+'/'+params.end, {headers: new HttpHeaders().set('Authorization', "Bearer " + this.auth.getToken())})
    73    }
    74    putAutoscaling(data) {
    75      return this.http.post('/ecs-deploy/api/v1/service/autoscaling/'+this.sl.serviceName+'/put', data, {headers: new HttpHeaders().set('Authorization', "Bearer " + this.auth.getToken())})
    76    }
    77    getAutoscaling() {
    78      return this.http.get('/ecs-deploy/api/v1/service/autoscaling/'+this.sl.serviceName+'/get', {headers: new HttpHeaders().set('Authorization', "Bearer " + this.auth.getToken())})
    79    }
    80    deleteAutoscalingPolicy(serviceName, selectedItem) {
    81      return this.http.post('/ecs-deploy/api/v1/service/autoscaling/'+serviceName+'/delete/'+selectedItem, {}, {headers: new HttpHeaders().set('Authorization', "Bearer " + this.auth.getToken())})
    82    }
    83    disableAutoscaling(serviceName) {
    84      return this.http.post('/ecs-deploy/api/v1/service/autoscaling/'+serviceName+'/delete', {}, {headers: new HttpHeaders().set('Authorization', "Bearer " + this.auth.getToken())})
    85    }
    86  }