src/app/history/shared/history.service.ts
        
| Methods | 
| 
 | 
| getControllerHistory | ||||||
| getControllerHistory(clusterName: string) | ||||||
| Defined in src/app/history/shared/history.service.ts:10 | ||||||
| 
                        Parameters :
                        
                         
 
                        Returns :          any | 
| getInstanceHistory | 
| getInstanceHistory(clusterName: string, instanceName: string) | 
| Defined in src/app/history/shared/history.service.ts:16 | 
| 
                        Returns :          any | 
| Protected parseHistory | ||||||
| parseHistory(data: any) | ||||||
| Defined in src/app/history/shared/history.service.ts:23 | ||||||
| 
                        Parameters :
                        
                         
 
                        Returns :          History[] | 
| Public can | 
| can() | 
| Inherited from          HelixService | 
| Defined in          HelixService:14 | 
| 
                        Returns :      Observable<any> | 
| Protected delete | ||||||
| delete(path: string) | ||||||
| Inherited from          HelixService | ||||||
| Defined in          HelixService:48 | ||||||
| 
                        Parameters :
                        
                         
 
                        Returns :      Observable<any> | 
| Protected errorHandler | ||||||
| errorHandler(error: any) | ||||||
| Inherited from          HelixService | ||||||
| Defined in          HelixService:68 | ||||||
| 
                        Parameters :
                        
                         
 
                        Returns :          any | 
| Protected getHeaders | 
| getHeaders() | 
| Inherited from          HelixService | 
| Defined in          HelixService:61 | 
| 
                        Returns :          any | 
| Protected getHelixKey | 
| getHelixKey() | 
| Inherited from          HelixService | 
| Defined in          HelixService:56 | 
| 
                        Returns :          string | 
| Protected post | 
| post(path: string, data: any) | 
| Inherited from          HelixService | 
| Defined in          HelixService:32 | 
| 
                        Returns :      Observable<any> | 
| Protected put | 
| put(path: string, data: string) | 
| Inherited from          HelixService | 
| Defined in          HelixService:40 | 
| 
                        Returns :      Observable<any> | 
| Protected request | 
| request(path: string, helix?: string) | 
| Inherited from          HelixService | 
| Defined in          HelixService:20 | 
| 
                        Returns :      Observable<any> | 
import { Injectable } from '@angular/core';
import { map } from 'rxjs/operators';
import * as _ from 'lodash';
import { HelixService } from '../../core/helix.service';
import { History } from './history.model';
@Injectable()
export class HistoryService extends HelixService {
  getControllerHistory(clusterName: string) {
    return this.request(`/clusters/${clusterName}/controller/history`).pipe(
      map((data) => this.parseHistory(data.history))
    );
  }
  getInstanceHistory(clusterName: string, instanceName: string) {
    return this.request(
      `/clusters/${clusterName}/instances/${instanceName}/history`
    ).pipe(map((data) => this.parseHistory(data.listFields.HISTORY)));
    // TODO: implement data.simpleFields.LAST_OFFLINE_TIME
  }
  protected parseHistory(data: any): History[] {
    const histories: History[] = [];
    if (data) {
      for (const record of data) {
        // controller: {DATE=2017-04-13-22:33:55, CONTROLLER=ltx1-app1133.stg.linkedin.com_12923, TIME=1492122835198}
        // instance: {DATE=2017-05-01T08:21:42:114, SESSION=55a8e28052bcb56, TIME=1493626902114}
        const history = new History();
        for (const seg of _.words(record, /[^{}, ]+/g)) {
          const name = _.words(seg, /[^=]+/g)[0];
          const value = _.words(seg, /[^=]+/g)[1];
          if (name == 'DATE') {
            history.date = value;
          } else if (name == 'CONTROLLER') {
            history.controller = value;
          } else if (name == 'SESSION') {
            history.session = value;
          } else if (name == 'TIME') {
            history.time = +value;
          }
        }
        histories.push(history);
      }
    }
    return histories;
  }
}