34 lines
1.3 KiB
TypeScript
34 lines
1.3 KiB
TypeScript
import { Injectable } from '@angular/core';
|
|
import { HttpClient } from '@angular/common/http';
|
|
import { Observable } from 'rxjs';
|
|
import { GitConnectRequest, GitStatusResponse, PublishResponse } from '../models/deployment';
|
|
|
|
@Injectable({ providedIn: 'root' })
|
|
export class DeploymentService {
|
|
constructor(private http: HttpClient) {}
|
|
|
|
exportSite(siteId: string): Observable<Blob> {
|
|
return this.http.get(`/api/sites/${siteId}/export`, { responseType: 'blob' });
|
|
}
|
|
|
|
getGitStatus(siteId: string): Observable<GitStatusResponse> {
|
|
return this.http.get<GitStatusResponse>(`/api/sites/${siteId}/git/status`);
|
|
}
|
|
|
|
connectGit(siteId: string, request: GitConnectRequest): Observable<Record<string, string>> {
|
|
return this.http.post<Record<string, string>>(`/api/sites/${siteId}/git/connect`, request);
|
|
}
|
|
|
|
disconnectGit(siteId: string): Observable<Record<string, string>> {
|
|
return this.http.post<Record<string, string>>(`/api/sites/${siteId}/git/disconnect`, {});
|
|
}
|
|
|
|
publish(siteId: string): Observable<PublishResponse> {
|
|
return this.http.post<PublishResponse>(`/api/sites/${siteId}/publish`, {});
|
|
}
|
|
|
|
unpublish(siteId: string): Observable<Record<string, string>> {
|
|
return this.http.post<Record<string, string>>(`/api/sites/${siteId}/unpublish`, {});
|
|
}
|
|
}
|