audit-log.service.ts 1.1 KB
Newer Older
kunw's avatar
kunw committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
import { Injectable } from '@angular/core';
import { Http, Headers, RequestOptions } from '@angular/http';

import { BaseService } from '../service/base.service';

import { AuditLog } from './audit-log';

import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/map';
import 'rxjs/add/observable/throw';

export const urlPrefix = '';

@Injectable()
export class AuditLogService extends BaseService {
  
  constructor(private http: Http) {
    super();
  }

  listAuditLogs(queryParam: AuditLog): Observable<AuditLog[]> {
    return this.http
               .post(urlPrefix + `/api/projects/${queryParam.project_id}/logs/filter`, {
                  begin_timestamp: queryParam.begin_timestamp,
                  end_timestamp: queryParam.end_timestamp,
                  keywords: queryParam.keywords,
                  operation: queryParam.operation,
                  project_id: queryParam.project_id,
                  username: queryParam.username })
                .map(response=>response.json() as AuditLog[])
                .catch(error=>this.handleError(error));
  }

}