feat/ajout-de-fonctionnalites (#1)
All checks were successful
Auto Tag Develop / tag (push) Successful in 6s

Reviewed-on: #1
Co-authored-by: tristan <tristan@yuno.malio.fr>
Co-committed-by: tristan <tristan@yuno.malio.fr>
This commit was merged in pull request #1.
This commit is contained in:
2026-04-06 14:23:20 +00:00
committed by Autin
parent f80578c26a
commit 8f585b4be8
52 changed files with 6536 additions and 434 deletions

View File

@@ -0,0 +1,41 @@
import type { Application, ApplicationWrite } from './dto/application'
import { type HydraCollection, extractHydraMembers } from '~/utils/api'
export function getApplications(): Promise<Application[]> {
const api = useApi()
return api.get<Application[]>('/applications', undefined, {
toast: false,
}).then((response) => {
if (Array.isArray(response)) {
return response
}
return extractHydraMembers(response as HydraCollection<Application>)
})
}
export function getApplication(slug: string): Promise<Application> {
return useApi().get<Application>(`/applications/${slug}`, undefined, {
toast: false,
})
}
export function createApplication(data: ApplicationWrite): Promise<Application> {
return useApi().post<Application>('/applications', data, {
toastSuccessKey: 'success.applications.create',
toastErrorKey: 'errors.applications.create',
})
}
export function updateApplication(slug: string, data: Partial<ApplicationWrite>): Promise<Application> {
return useApi().patch<Application>(`/applications/${slug}`, data, {
toastSuccessKey: 'success.applications.update',
toastErrorKey: 'errors.applications.update',
})
}
export function deleteApplication(slug: string): Promise<void> {
return useApi().delete<void>(`/applications/${slug}`, undefined, {
toastSuccessKey: 'success.applications.delete',
toastErrorKey: 'errors.applications.delete',
})
}

View File

@@ -0,0 +1,13 @@
import type { DashboardResponse, EnvironmentHealth } from './dto/dashboard'
export function getDashboard(): Promise<DashboardResponse> {
return useApi().get<DashboardResponse>('/dashboard', undefined, {
toast: false,
})
}
export function getEnvironmentHealth(envId: number): Promise<EnvironmentHealth> {
return useApi().get<EnvironmentHealth>(`/environments/${envId}/health`, undefined, {
toast: false,
})
}

View File

@@ -0,0 +1,13 @@
import type { TagListResponse, DeployResult } from './dto/deploy'
export function getAvailableTags(slug: string): Promise<TagListResponse> {
return useApi().get<TagListResponse>(`/applications/${slug}/tags`, undefined, {
toast: false,
})
}
export function deploy(envId: number, tag: string): Promise<DeployResult> {
return useApi().post<DeployResult>(`/environments/${envId}/deploy`, { tag }, {
toast: false,
})
}

View File

@@ -0,0 +1,46 @@
type LogFile = {
id?: number
label: string
path: string
}
type Environment = {
id?: number
'@id'?: string
name: string
containerName: string
deployScriptPath: string
maintenanceFilePath: string
appUrl?: string
logFiles: LogFile[]
maintenance: boolean
}
type EnvironmentWrite = {
name: string
containerName: string
deployScriptPath: string
maintenanceFilePath: string
appUrl?: string
logFiles: LogFile[]
}
type Application = {
id?: number
'@id'?: string
slug: string
name: string
registryImage: string
description?: string
giteaUrl?: string
createdAt?: string
environments?: Environment[]
}
type ApplicationWrite = {
name: string
slug: string
registryImage: string
description?: string
giteaUrl?: string
}

View File

@@ -0,0 +1,27 @@
type DashboardEnvironment = {
id: number
name: string
status: string
version: string
}
type DashboardApplication = {
name: string
slug: string
giteaUrl?: string
environments: DashboardEnvironment[]
}
type DashboardResponse = {
applications: DashboardApplication[]
}
type EnvironmentHealth = {
status: string
version: string
startedAt: string
cpuPercent: number
memoryUsage: string
memoryLimit: string
memoryPercent: number
}

View File

@@ -0,0 +1,9 @@
type TagListResponse = {
tags: string[]
}
type DeployResult = {
success: boolean
output: string
tag: string
}

View File

@@ -1,10 +0,0 @@
export type ManagedApplication = {
slug: string
name: string
maintenance: boolean
}
export type ManagedApplicationCollection = {
'hydra:member'?: ManagedApplication[]
member?: ManagedApplication[]
}

View File

@@ -0,0 +1,36 @@
import type { Environment, EnvironmentWrite } from './dto/application'
export function createEnvironment(appSlug: string, data: EnvironmentWrite): Promise<Environment> {
return useApi().post<Environment>(`/applications/${appSlug}/environments`, data, {
toastSuccessKey: 'success.environments.create',
toastErrorKey: 'errors.environments.create',
})
}
export function updateEnvironment(id: number, data: Partial<EnvironmentWrite>): Promise<Environment> {
return useApi().patch<Environment>(`/environments/${id}`, data, {
toastSuccessKey: 'success.environments.update',
toastErrorKey: 'errors.environments.update',
})
}
export function deleteEnvironment(id: number): Promise<void> {
return useApi().delete<void>(`/environments/${id}`, undefined, {
toastSuccessKey: 'success.environments.delete',
toastErrorKey: 'errors.environments.delete',
})
}
export function toggleMaintenance(id: number, maintenance: boolean): Promise<Environment> {
const successKey = maintenance
? 'success.environments.activateMaintenance'
: 'success.environments.deactivateMaintenance'
const errorKey = maintenance
? 'errors.environments.activateMaintenance'
: 'errors.environments.deactivateMaintenance'
return useApi().post<Environment>(`/environments/${id}/maintenance`, { maintenance }, {
toastSuccessKey: successKey,
toastErrorKey: errorKey,
})
}

View File

@@ -1,33 +0,0 @@
import type { ManagedApplication, ManagedApplicationCollection } from './dto/managed-application'
function normalizeManagedApplications(response: ManagedApplication[] | ManagedApplicationCollection): ManagedApplication[] {
if (Array.isArray(response)) {
return response
}
return response['hydra:member'] ?? response.member ?? []
}
export async function getManagedApplications(): Promise<ManagedApplication[]> {
const api = useApi()
const response = await api.get<ManagedApplication[] | ManagedApplicationCollection>('/applications')
return normalizeManagedApplications(response)
}
export function setApplicationMaintenance(slug: string, maintenance: boolean) {
const api = useApi()
return api.post<ManagedApplication>(
`/applications/${slug}/maintenance`,
{ maintenance },
{
toastSuccessKey: maintenance
? 'success.applications.activateMaintenance'
: 'success.applications.deactivateMaintenance',
toastErrorKey: maintenance
? 'errors.applications.activateMaintenance'
: 'errors.applications.deactivateMaintenance'
}
)
}