autocomit
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Deployment, RecordDeploymentRequest, CurrentDeploymentState } from '../../shared/models/deployment.model';
|
||||
import { Page } from '../../shared/models/environment.model';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class DeploymentService {
|
||||
private readonly API_URL = '/api/deployments';
|
||||
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
getDeployments(
|
||||
filters?: {
|
||||
applicationId?: string;
|
||||
environmentId?: string;
|
||||
versionId?: string;
|
||||
dateFrom?: Date;
|
||||
dateTo?: Date;
|
||||
},
|
||||
page: number = 0,
|
||||
size: number = 20,
|
||||
sortBy: string = 'deploymentDate',
|
||||
sortDirection: string = 'desc'
|
||||
): Observable<Page<Deployment>> {
|
||||
let params = new HttpParams()
|
||||
.set('page', page.toString())
|
||||
.set('size', size.toString())
|
||||
.set('sortBy', sortBy)
|
||||
.set('sortDirection', sortDirection);
|
||||
|
||||
if (filters?.applicationId) {
|
||||
params = params.set('applicationId', filters.applicationId);
|
||||
}
|
||||
if (filters?.environmentId) {
|
||||
params = params.set('environmentId', filters.environmentId);
|
||||
}
|
||||
if (filters?.versionId) {
|
||||
params = params.set('versionId', filters.versionId);
|
||||
}
|
||||
if (filters?.dateFrom) {
|
||||
params = params.set('dateFrom', filters.dateFrom.toISOString());
|
||||
}
|
||||
if (filters?.dateTo) {
|
||||
params = params.set('dateTo', filters.dateTo.toISOString());
|
||||
}
|
||||
|
||||
return this.http.get<Page<Deployment>>(this.API_URL, { params });
|
||||
}
|
||||
|
||||
getDeployment(id: string): Observable<Deployment> {
|
||||
return this.http.get<Deployment>(`${this.API_URL}/${id}`);
|
||||
}
|
||||
|
||||
getDeploymentsByApplication(applicationId: string, page: number = 0, size: number = 20): Observable<Page<Deployment>> {
|
||||
const params = new HttpParams()
|
||||
.set('page', page.toString())
|
||||
.set('size', size.toString());
|
||||
|
||||
return this.http.get<Page<Deployment>>(
|
||||
`${this.API_URL}/by-application/${applicationId}`,
|
||||
{ params }
|
||||
);
|
||||
}
|
||||
|
||||
getDeploymentsByEnvironment(environmentId: string, page: number = 0, size: number = 20): Observable<Page<Deployment>> {
|
||||
const params = new HttpParams()
|
||||
.set('page', page.toString())
|
||||
.set('size', size.toString());
|
||||
|
||||
return this.http.get<Page<Deployment>>(
|
||||
`${this.API_URL}/by-environment/${environmentId}`,
|
||||
{ params }
|
||||
);
|
||||
}
|
||||
|
||||
getCurrentState(applicationId?: string, environmentId?: string): Observable<CurrentDeploymentState[]> {
|
||||
let params = new HttpParams();
|
||||
if (applicationId) {
|
||||
params = params.set('applicationId', applicationId);
|
||||
}
|
||||
if (environmentId) {
|
||||
params = params.set('environmentId', environmentId);
|
||||
}
|
||||
|
||||
return this.http.get<CurrentDeploymentState[]>(
|
||||
`${this.API_URL}/current`,
|
||||
{ params }
|
||||
);
|
||||
}
|
||||
|
||||
recordDeployment(data: RecordDeploymentRequest): Observable<Deployment> {
|
||||
return this.http.post<Deployment>(this.API_URL, data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Version, CreateVersionRequest, UpdateVersionRequest } from '../../shared/models/version.model';
|
||||
import { Page } from '../../shared/models/environment.model';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class VersionService {
|
||||
|
||||
constructor(private http: HttpClient) {}
|
||||
|
||||
getVersions(
|
||||
applicationId: string,
|
||||
page: number = 0,
|
||||
size: number = 20,
|
||||
sortBy: string = 'releaseDate',
|
||||
sortDirection: string = 'desc'
|
||||
): Observable<Page<Version>> {
|
||||
const params = new HttpParams()
|
||||
.set('page', page.toString())
|
||||
.set('size', size.toString())
|
||||
.set('sortBy', sortBy)
|
||||
.set('sortDirection', sortDirection);
|
||||
|
||||
return this.http.get<Page<Version>>(
|
||||
`/api/applications/${applicationId}/versions`,
|
||||
{ params }
|
||||
);
|
||||
}
|
||||
|
||||
getVersion(applicationId: string, versionId: string): Observable<Version> {
|
||||
return this.http.get<Version>(
|
||||
`/api/applications/${applicationId}/versions/${versionId}`
|
||||
);
|
||||
}
|
||||
|
||||
getLatestVersion(applicationId: string): Observable<Version> {
|
||||
return this.http.get<Version>(
|
||||
`/api/applications/${applicationId}/versions/latest`
|
||||
);
|
||||
}
|
||||
|
||||
createVersion(applicationId: string, data: CreateVersionRequest): Observable<Version> {
|
||||
return this.http.post<Version>(
|
||||
`/api/applications/${applicationId}/versions`,
|
||||
data
|
||||
);
|
||||
}
|
||||
|
||||
updateVersion(applicationId: string, versionId: string, data: UpdateVersionRequest): Observable<Version> {
|
||||
return this.http.put<Version>(
|
||||
`/api/applications/${applicationId}/versions/${versionId}`,
|
||||
data
|
||||
);
|
||||
}
|
||||
|
||||
deleteVersion(applicationId: string, versionId: string): Observable<void> {
|
||||
return this.http.delete<void>(
|
||||
`/api/applications/${applicationId}/versions/${versionId}`
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
import { ApplicationStatus } from './application.model';
|
||||
|
||||
export interface Deployment {
|
||||
id: string;
|
||||
application: {
|
||||
id: string;
|
||||
name: string;
|
||||
status: ApplicationStatus;
|
||||
businessUnitName: string;
|
||||
};
|
||||
version: {
|
||||
id: string;
|
||||
versionIdentifier: string;
|
||||
releaseDate: Date;
|
||||
};
|
||||
environment: {
|
||||
id: string;
|
||||
name: string;
|
||||
isProduction: boolean;
|
||||
};
|
||||
deploymentDate: Date;
|
||||
deployedBy?: string;
|
||||
notes?: string;
|
||||
createdAt: Date;
|
||||
}
|
||||
|
||||
export interface RecordDeploymentRequest {
|
||||
applicationId: string;
|
||||
versionId: string;
|
||||
environmentId: string;
|
||||
deploymentDate: Date;
|
||||
deployedBy?: string;
|
||||
notes?: string;
|
||||
}
|
||||
|
||||
export interface CurrentDeploymentState {
|
||||
application: {
|
||||
id: string;
|
||||
name: string;
|
||||
status: ApplicationStatus;
|
||||
businessUnitName: string;
|
||||
};
|
||||
environment: {
|
||||
id: string;
|
||||
name: string;
|
||||
isProduction: boolean;
|
||||
};
|
||||
version: {
|
||||
id: string;
|
||||
versionIdentifier: string;
|
||||
releaseDate: Date;
|
||||
};
|
||||
deploymentDate: Date;
|
||||
deployedBy?: string;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
export interface Version {
|
||||
id: string;
|
||||
applicationId: string;
|
||||
applicationName: string;
|
||||
versionIdentifier: string;
|
||||
externalReference?: string;
|
||||
releaseDate: Date;
|
||||
endOfLifeDate?: Date;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
}
|
||||
|
||||
export interface VersionSummary {
|
||||
id: string;
|
||||
versionIdentifier: string;
|
||||
releaseDate: Date;
|
||||
}
|
||||
|
||||
export interface CreateVersionRequest {
|
||||
versionIdentifier: string;
|
||||
externalReference?: string;
|
||||
releaseDate: Date;
|
||||
endOfLifeDate?: Date;
|
||||
}
|
||||
|
||||
export interface UpdateVersionRequest {
|
||||
versionIdentifier?: string;
|
||||
externalReference?: string;
|
||||
releaseDate?: Date;
|
||||
endOfLifeDate?: Date;
|
||||
}
|
||||
Reference in New Issue
Block a user