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

61 lines
1.8 KiB
TypeScript
Raw Normal View History

2024-06-05 21:45:21 +03:00
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";
2024-06-11 00:17:09 +03:00
import {DateOnly} from "@model/DateOnly";
2024-06-05 21:45:21 +03:00
@Injectable()
export default class SetupService extends ApiService {
2024-06-06 23:31:34 +03:00
protected basePath = 'Setup/';
public readonly version = AvailableVersion.v1;
2024-06-05 21:45:21 +03:00
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);
}
2024-06-06 23:31:34 +03:00
public setSqlite(path: string | null = null) {
2024-06-05 21:45:21 +03:00
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);
}
2024-06-06 23:31:34 +03:00
public setLogging(data: LoggingRequest | null = null) {
2024-06-05 21:45:21 +03:00
return this.post<boolean>('SetLogging', data);
}
2024-06-06 23:31:34 +03:00
public setEmail(data: EmailRequest | null = null) {
2024-06-05 21:45:21 +03:00
return this.post<boolean>('SetEmail', data);
}
public setSchedule(data: ScheduleConfigurationRequest) {
2024-06-11 00:17:09 +03:00
data.startTerm = new DateOnly(data.startTerm).toString();
2024-06-05 21:45:21 +03:00
return this.post<boolean>('SetSchedule', data);
}
public submit() {
return this.post<boolean>('Submit', null);
}
}