Skip to content

Commit

Permalink
feat: ✨ backEnd route get all applications
Browse files Browse the repository at this point in the history
  • Loading branch information
KomsteRr committed Dec 18, 2024
1 parent eea313c commit e4170ef
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 29 deletions.
14 changes: 5 additions & 9 deletions client/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,9 @@ function close() {
</script>

<template>
<DsfrHeader
v-model="searchQuery"
:service-description="serviceDescription"
:service-title="serviceTitle"
:logo-text="logoText"
:quick-links="authenticated ? authenticatedQuickLinks : unauthenticatedQuickLinks"
show-beta
/>
<DsfrHeader v-model="searchQuery" :service-description="serviceDescription" :service-title="serviceTitle"
:logo-text="logoText" :quick-links="authenticated ? authenticatedQuickLinks : unauthenticatedQuickLinks"
show-beta />

<div class="fr-container fr-mt-3w fr-mt-md-5w fr-mb-5w">
<router-view />
Expand All @@ -104,7 +99,8 @@ function close() {
</p>
</DsfrConsent> -->

<ReloadPrompt :offline-ready="offlineReady" :need-refresh="needRefresh" @close="close" @update-service-worker="updateServiceWorker" />
<ReloadPrompt :offline-ready="offlineReady" :need-refresh="needRefresh" @close="close"
@update-service-worker="updateServiceWorker" />

<AppToaster :messages="toaster.messages" @close-message="toaster.removeMessage($event)" />
</template>
10 changes: 9 additions & 1 deletion server/src/application/application.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class ApplicationController {
private readonly applicationService: ApplicationService,
private readonly userService: UserService,
private readonly exportService: ExportService,
) {}
) { }

@Post()
@ApiOperation({ summary: 'Créer une nouvelle application' })
Expand Down Expand Up @@ -121,6 +121,14 @@ export class ApplicationController {
}
}

@Get()
@ApiOperation({ summary: 'Récupérer les applications' })
@ApiResponse({ status: 200, description: 'Liste des applications' })
async getApplications() {
return await this.applicationService.getApplications();
}


@Patch(':id')
async update(
@Param('id') id: string,
Expand Down
44 changes: 25 additions & 19 deletions server/src/application/application.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { Prisma, Application } from '@prisma/client';
@Injectable()
export class ApplicationService {
applications: any;
constructor(private prisma: PrismaService) {}
constructor(private prisma: PrismaService) { }

public async createApplication(
ownerId: string,
Expand Down Expand Up @@ -62,20 +62,20 @@ export class ApplicationService {
const whereClause: Prisma.ApplicationWhereInput = {
...(label
? {
label: {
contains: label,
mode: Prisma.QueryMode.insensitive,
},
}
label: {
contains: label,
mode: Prisma.QueryMode.insensitive,
},
}
: {}),
};

const orderByClause: Prisma.Enumerable<Prisma.ApplicationOrderByWithRelationInput> =
{
metadata: {
updatedAt: 'desc',
},
};
{
metadata: {
updatedAt: 'desc',
},
};

const skip = (page - 1) * limit;

Expand Down Expand Up @@ -126,6 +126,12 @@ export class ApplicationService {
return applicationDto;
}

public async getApplications() {
const applicationsList = await this.prisma.application.findMany();

return applicationsList;
}

private async createApplicationMetadata(ownerId: string) {
const applicationMetadata = await this.prisma.metadata.create({
data: {
Expand Down Expand Up @@ -162,21 +168,21 @@ export class ApplicationService {
plannedDecommissioningDate: createApplicationDto.lifecycle
.plannedDecommissioningDate
? new Date(
createApplicationDto.lifecycle.plannedDecommissioningDate,
)
createApplicationDto.lifecycle.plannedDecommissioningDate,
)
: undefined,
metadata: { connect: { id: applicationMetadataId } },
},
},
actors: {
create: Array.isArray(createApplicationDto.actors)
? createApplicationDto.actors.map((actorDto) => ({
role: actorDto.role,
user: { connect: { keycloakId: actorDto.userId } },
externalOrganization: actorDto.organizationId
? { connect: { id: actorDto.organizationId } }
: undefined,
}))
role: actorDto.role,
user: { connect: { keycloakId: actorDto.userId } },
externalOrganization: actorDto.organizationId
? { connect: { id: actorDto.organizationId } }
: undefined,
}))
: [],
},
compliances: {
Expand Down

0 comments on commit e4170ef

Please sign in to comment.