MireaFrontend/src/api/v1/setup.service.ts

61 lines
1.8 KiB
TypeScript

import {Injectable} from "@angular/core";
import ApiService, {AvailableVersion} from "@api/api.service";
import {DatabaseRequest} from "@api/v1/databaseRequest";
import {CacheRequest} from "@api/v1/cacheRequest";
import {CreateUserRequest} from "@api/v1/createUserRequest";
import {LoggingRequest} from "@api/v1/loggingRequest";
import {EmailRequest} from "@api/v1/emailRequest";
import {ScheduleConfigurationRequest} from "@api/v1/scheduleConfigurationRequest";
import {DateOnly} from "@model/DateOnly";
@Injectable()
export default class SetupService extends ApiService {
protected basePath = 'Setup/';
protected version = AvailableVersion.v1;
public checkToken(token: string) {
return this.get<boolean>('CheckToken', {token: token});
}
public setPsql(data: DatabaseRequest) {
return this.post<boolean>('SetPsql', data);
}
public setMysql(data: DatabaseRequest) {
return this.post<boolean>('SetMysql', data);
}
public setSqlite(path: string | null = null) {
return this.post<boolean>('SetSqlite', null, {path: path});
}
public setRedis(data: CacheRequest) {
return this.post<boolean>('SetRedis', data);
}
public setMemcached() {
return this.post<boolean>('SetMemcached', null);
}
public createAdmin(data: CreateUserRequest) {
return this.post<boolean>('CreateAdmin', data);
}
public setLogging(data: LoggingRequest | null = null) {
return this.post<boolean>('SetLogging', data);
}
public setEmail(data: EmailRequest | null = null) {
return this.post<boolean>('SetEmail', data);
}
public setSchedule(data: ScheduleConfigurationRequest) {
data.startTerm = new DateOnly(data.startTerm).toString();
return this.post<boolean>('SetSchedule', data);
}
public submit() {
return this.post<boolean>('Submit', null);
}
}