harbor/src/portal/src/app/config/gc/gc.service.ts
Meina Zhou aefb97dec8 Implement gc UI
Signed-off-by: Meina Zhou <meinaz@vmware.com>
2018-09-20 13:21:22 +08:00

64 lines
1.7 KiB
TypeScript

import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import { Observable, Subscription, Subject, of } from 'rxjs';
import { catchError, map } from 'rxjs/operators';
import { GcApiRepository } from './gc.api.repository';
import { ErrorHandler } from '@harbor/ui';
import { GcJobData } from './gcLog';
@Injectable()
export class GcRepoService {
constructor(private http: Http,
private gcApiRepository: GcApiRepository,
private errorHandler: ErrorHandler) {
}
public manualGc(): Observable <any> {
let param = {
"schedule": {
"type": "Manual"
}
};
return this.gcApiRepository.postSchedule(param);
}
public getJobs(): Observable <GcJobData []> {
return this.gcApiRepository.getJobs();
}
public getLog(id): Observable <any> {
return this.gcApiRepository.getLog(id);
}
public getSchedule(): Observable <any> {
return this.gcApiRepository.getSchedule();
}
public postScheduleGc(type, offTime, weekday ?): Observable <any> {
let param = {
"schedule": {
"type": type,
"offtime": offTime,
}
};
if (weekday) {
param.schedule["weekday"] = weekday;
}
return this.gcApiRepository.postSchedule(param);
}
public putScheduleGc(type, offTime, weekday ?): Observable <any> {
let param = {
"schedule": {
"type": type,
"offtime": offTime,
}
};
if (weekday) {
param.schedule["weekday"] = weekday;
}
return this.gcApiRepository.putSchedule(param);
}
}