Skip to content

Commit

Permalink
Ajout de la page Synthèse (#579)
Browse files Browse the repository at this point in the history
* add overview page with different states and route from step 1

* add charts on audit card

* split page in sub components

* fix donut theme prop ts check

* add conditions to dispay some data

* add breadcrumb link, back link on audit page and meta component

* update buttons label and remove account page breadcrumb

* redesign copy block and update nav items

* add meta desc

* remove step four page and redirect links to overview instead

* add redirect from /partage to /synthese

* add new props to progress bar and delete sticky indicators component

* move title above sticky header + remove validate button

* add toast when audit is done and set publicationDate

* make main action in audit row to take full width

* update audit creation email content

* only send audit creation email when not connected

* fix condition to show auditor infos when creating audit

* add back links on pages

* get audit edit id in report route and show back link on report page

* improve responsiveness of header

* remove back link on report page + make sure report link are in new tab

* add notes button + modal

* remove notes tab

* fix markdown button type + textarea height

* remove edit id in report fetch data

* fix accessibility labels

* remove markdown button in notes modal

* add correct toast wording when updating audit notes

* align badge width step title

* remove settings link in header dropdown

* move audit alert banners from step three to overview page

* rename breadcrumb first item when connected

* add back link to audit page when not connected

* add utility class to remove external icon + fix icon in overview steps buttons

* add close button to copy block success message

* publish audit when using dev button

* update audit finished toast wording for other audit types

* update audit creation email content

* update icon + highlight first nav link + update copy success message
  • Loading branch information
bellangerq authored Dec 14, 2023
1 parent b641355 commit efddcef
Show file tree
Hide file tree
Showing 43 changed files with 1,321 additions and 914 deletions.
9 changes: 7 additions & 2 deletions confiture-rest-api/src/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Module } from '@nestjs/common';
import { MiddlewareConsumer, Module, NestModule } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { FeedbackModule } from './feedback/feedback.module';
import { AuditsModule } from './audits/audits.module';
Expand All @@ -7,6 +7,7 @@ import { configValidationSchema } from './config-validation-schema';
import { MailModule } from './mail/mail.module';
import { AuthModule } from './auth/auth.module';
import { ProfileModule } from './profile/profile.module';
import { UserMiddleware } from './auth/user.middleware';

@Module({
imports: [
Expand All @@ -22,4 +23,8 @@ import { ProfileModule } from './profile/profile.module';
],
controllers: [HealthCheckController],
})
export class AppModule {}
export class AppModule implements NestModule{
configure(consumer: MiddlewareConsumer) {
consumer.apply(UserMiddleware).forRoutes('*')
}
}
13 changes: 8 additions & 5 deletions confiture-rest-api/src/audits/audits.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,16 @@ export class AuditsController {
description: 'The audit has been successfully created.',
type: Audit,
})
async createAudit(@Body() body: CreateAuditDto) {
async createAudit(@Body() body: CreateAuditDto, @User() user: AuthenticationJwtPayload) {
const audit = await this.auditService.createAudit(body);

this.mailer.sendAuditCreatedMail(audit).catch((err) => {
console.error(`Failed to send email for audit ${audit.editUniqueId}`);
console.error(err);
});

if (!user) {
this.mailer.sendAuditCreatedMail(audit).catch((err) => {
console.error(`Failed to send email for audit ${audit.editUniqueId}`);
console.error(err);
});
}

return audit;
}
Expand Down
29 changes: 5 additions & 24 deletions confiture-rest-api/src/auth/auth.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,14 @@ import { JwtService } from '@nestjs/jwt';
import type { Request } from 'express';
import { AuthenticationJwtPayload } from './jwt-payloads';

/**
* Verify that the request is authenticated.
* This guard requires the `UserMiddleware` to be run on the request.
*/
@Injectable()
export class AuthGuard implements CanActivate {
constructor(private readonly jwt: JwtService) {}

async canActivate(context: ExecutionContext) {
const request = context.switchToHttp().getRequest();
const token = this.extractTokenFromHeader(request);
if (!token) {
throw new UnauthorizedException();
}

try {
const payload = (await this.jwt.verifyAsync(
token,
)) as AuthenticationJwtPayload;
// 💡 We're assigning the payload to the request object here
// so that we can access it in our route handlers
request['user'] = payload;
} catch {
throw new UnauthorizedException();
}

return true;
}

private extractTokenFromHeader(request: Request): string | undefined {
const [type, token] = request.headers.authorization?.split(' ') ?? [];
return type === 'Bearer' ? token : undefined;
return !!request.user
}
}
36 changes: 36 additions & 0 deletions confiture-rest-api/src/auth/user.middleware.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Injectable, NestMiddleware } from "@nestjs/common";
import { JwtService } from "@nestjs/jwt";
import type { Request } from 'express';
import { AuthenticationJwtPayload } from "./jwt-payloads";

/**
* Extract the authentication token and verifies it.
* No error is thrown if there is no token or if the token is invalid. Use the
* AuthRequired decorator if you want a route to only accept authenticated requests.
*/
@Injectable()
export class UserMiddleware implements NestMiddleware {
constructor(private readonly jwt: JwtService) {}

use(req: Request, res: any, next: (error?: any) => void) {
const token = this.extractTokenFromHeader(req);

if (!token) {
next()
return
}

this.jwt.verifyAsync(token)
.then(payload => {
req['user'] = payload;
next()
})
.catch(next)
}

private extractTokenFromHeader(request: Request): string | undefined {
const [type, token] = request.headers.authorization?.split(' ') ?? [];
return type === 'Bearer' ? token : undefined;
}

}
12 changes: 5 additions & 7 deletions confiture-rest-api/src/mail/audit-creation-email.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { renderMailTemplate } from './render-mjml-template';

export interface AuditCreationEmailData {
auditorName: string;
procedureName: string;
auditUrl: string;
overviewUrl: string;
reportUrl: string;
}

Expand All @@ -17,13 +16,12 @@ export function html(data: AuditCreationEmailData): string {

export function plain(data: AuditCreationEmailData): string {
return `
Bonjour ${data.auditorName}, vous venez de créer l’audit "${data.procedureName}".
Bonjour, vous venez de créer l’audit "${data.procedureName}".
Vous trouverez ci-dessous le lien administrateur de l’audit. Pensez bien à le conserver, c’est le seul moyen de reprendre l’édition de l’audit.
${data.auditUrl}
Voici le lien de la synthèse d’audit (privé) permettant d’accéder aux documents suivants : l’audit, le rapport d’audit et la déclaration d’accessibilité (dans le cas d’un audit 106 critères). Pensez-bien à conserver ce lien, c’est le seul moyen d’accéder à vos documents.
${data.overviewUrl}
Vous trouverez ci-dessous le lien public du rapport d’audit. Il vous permet de consulter et vérifier le rapport d’audit. Vous devrez le partager une fois que l’audit sera terminé.
${data.reportUrl}
Voici le lien du rapport d’audit (public) : ${data.reportUrl}
Vous avez une question ? Vous pouvez nous contacter en utilisant l’adresse e-mail [email protected].
`;
Expand Down
14 changes: 7 additions & 7 deletions confiture-rest-api/src/mail/mail.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import * as updateEmailVerificationEmail from './update-email-verification-email
import * as updateEmailConfirmationEmail from './update-email-confirmation-email';
import * as requestPasswordResetEmail from './request-password-reset-email';
import { EmailConfig } from './email-config.interface';
import { AuditCreationEmailData } from './audit-creation-email'

const EMAILS: Record<EmailType, EmailConfig> = {
[EmailType.AUDIT_CREATION]: auditCreationEmail,
Expand Down Expand Up @@ -81,19 +82,18 @@ export class MailService {
}

sendAuditCreatedMail(audit: Audit) {
const auditUrl = `${this.config.get('FRONT_BASE_URL')}/audits/${
const overviewUrl = `${this.config.get('FRONT_BASE_URL')}/audits/${
audit.editUniqueId
}/generation`;
}/synthese`;

const reportUrl = `${this.config.get('FRONT_BASE_URL')}/rapports/${
audit.consultUniqueId
}/resultats`;
}`;

const data = {
auditorName: audit.auditorName,
const data: AuditCreationEmailData = {
procedureName: audit.procedureName,
auditUrl,
reportUrl,
overviewUrl,
reportUrl
};

return this.sendMail(audit.auditorEmail, EmailType.AUDIT_CREATION, data);
Expand Down
6 changes: 0 additions & 6 deletions confiture-rest-api/templates/account-confirmation.mjml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@
</mj-column>
</mj-section>

<mj-section>
<mj-column>
<mj-spacer height="32px"></mj-spacer>
</mj-column>
</mj-section>

<!-- FOOTER -->
<mj-include path="./footer.mjml" />
</mj-body>
Expand Down
6 changes: 0 additions & 6 deletions confiture-rest-api/templates/account-verification.mjml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@
</mj-column>
</mj-section>

<mj-section>
<mj-column>
<mj-spacer height="32px"></mj-spacer>
</mj-column>
</mj-section>

<!-- FOOTER -->
<mj-include path="./footer.mjml" />
</mj-body>
Expand Down
49 changes: 17 additions & 32 deletions confiture-rest-api/templates/audit-creation.mjml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<mjml>
<mj-head>
<mj-title>Création d’un nouvel audit : {{ audit.name }}</mj-title>
<mj-title>Création d’un nouvel audit : {{ procedureName }}</mj-title>
<mj-attributes>
<mj-preview>Création d’un nouvel audit : {{ audit.name }}</mj-preview>
<mj-preview>Création d’un nouvel audit : {{ procedureName }}</mj-preview>
<mj-include path="./styles.mjml" />
</mj-attributes>
</mj-head>
Expand All @@ -13,60 +13,45 @@
<!-- BODY -->
<mj-section>
<mj-column>
<mj-text font-size="20px" font-weight="700" padding-bottom="8px">Bonjour {{ auditorName }}</mj-text>
<mj-text padding-bottom="16px">Vous venez de créer l'audit
<strong>{{ procedureName }}</strong>.
</mj-text>
<mj-text padding-bottom="12px">Vous trouverez ci-dessous le lien administrateur de l’audit.
Pensez-bien à le conserver, c’est le seul moyen de reprendre l’édition
de l’audit.</mj-text>
</mj-column>
</mj-section>

<mj-section mj-class="blue-section">
<mj-column>
<mj-text font-size="20px" font-weight="700" padding-bottom="10px">Lien vers l'audit - Ne pas partager</mj-text>
<mj-text mj-class="blue-link">
<a href="{{auditUrl}}" style="color: inherit;">{{auditUrl}}</a>
</mj-text>
<mj-text font-size="20px" font-weight="700" padding-bottom="16px">Audit créé avec succès</mj-text>
<mj-text>Vous trouverez ci-dessous le lien permettant d’accéder aux documents suivants :</mj-text>
<mj-text>- Audit {{ procedureName }}</mj-text>
<mj-text>- Rapport d’audit (généré automatiquement)</mj-text>
<mj-text padding-bottom="12px">- Déclaration d’accessibilité (dans le cas d’un audit 106 critères).</mj-text>
<mj-text padding-bottom="32px" font-weight="700">Pensez-bien à conserver ces liens, c’est le seul moyen d’accéder à vos documents.</mj-text>
</mj-column>
</mj-section>

<mj-section>
<mj-column>
<mj-spacer height="24px"></mj-spacer>
<mj-text font-size="20px" font-weight="700" padding-bottom="8px">Lien de la synthèse d’audit (privé)</mj-text>
<mj-text padding-bottom="12px">⚠️ Ne pas partagez pas ce lien, il permet de modifier ou supprimer votre audit.</mj-text>
</mj-column>
</mj-section>

<mj-section>
<mj-section mj-class="blue-section">
<mj-column>
<mj-text>Vous trouverez ci-dessous le lien public du rapport d’audit. Il vous
permet de consulter et vérifier le rapport d’audit. Vous devrez le
partager une fois que l’audit sera terminé.</mj-text>
<mj-text mj-class="blue-link">
<a href="{{ overviewUrl }}" style="color: inherit;">{{ overviewUrl }}</a>
</mj-text>
</mj-column>
</mj-section>

<mj-section>
<mj-column>
<mj-spacer height="12px"></mj-spacer>
<mj-text font-size="20px" font-weight="700" padding-top="24px" padding-bottom="8px">Lien du rapport d’audit (public)</mj-text>
<mj-text padding-bottom="12px">Vous pouvez partager ce lien à tout moment.</mj-text>
</mj-column>
</mj-section>

<mj-section mj-class="blue-section">
<mj-column>
<mj-text font-size="20px" font-weight="700" padding-bottom="10px">Lien vers le rapport - À partager au client</mj-text>
<mj-text mj-class="blue-link">
<a href="{{reportUrl}}" style="color: inherit;">{{reportUrl}}</a>
<a href="{{ reportUrl }}" style="color: inherit;">{{ reportUrl }}</a>
</mj-text>
</mj-column>
</mj-section>

<mj-section>
<mj-column>
<mj-spacer height="32px"></mj-spacer>
</mj-column>
</mj-section>

<!-- FOOTER -->
<mj-include path="./footer.mjml" />
</mj-body>
Expand Down
6 changes: 0 additions & 6 deletions confiture-rest-api/templates/email-update-confirmation.mjml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@
</mj-column>
</mj-section>

<mj-section>
<mj-column>
<mj-spacer height="32px"></mj-spacer>
</mj-column>
</mj-section>

<!-- FOOTER -->
<mj-include path="./footer.mjml" />
</mj-body>
Expand Down
6 changes: 0 additions & 6 deletions confiture-rest-api/templates/email-update-verification.mjml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@
</mj-column>
</mj-section>

<mj-section>
<mj-column>
<mj-spacer height="32px"></mj-spacer>
</mj-column>
</mj-section>

<!-- FOOTER -->
<mj-include path="./footer.mjml" />
</mj-body>
Expand Down
6 changes: 6 additions & 0 deletions confiture-rest-api/templates/footer.mjml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<mj-section>
<mj-column>
<mj-spacer height="32px"></mj-spacer>
</mj-column>
</mj-section>

<mj-section padding-bottom="32px">
<mj-column>
<mj-text font-size="18px" padding-bottom="8px">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<mj-text font-size="20px" font-weight="700" padding-bottom="8px">
Mot de passe mis à jour avec succès
</mj-text>
<mj-text padding-bottom="24px">
<mj-text>
Le mot de passe de votre compte Ara a bien été modifié.
</mj-text>
</mj-column>
Expand Down
6 changes: 0 additions & 6 deletions confiture-rest-api/templates/request-password-reset.mjml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@
</mj-column>
</mj-section>

<mj-section>
<mj-column>
<mj-spacer height="32px"></mj-spacer>
</mj-column>
</mj-section>

<!-- FOOTER -->
<mj-include path="./footer.mjml" />
</mj-body>
Expand Down
10 changes: 10 additions & 0 deletions confiture-web-app/src/assets/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

Tous les changements notables de Ara sont documentés ici avec leur date, leur catégorie (nouvelle fonctionnalité, correction de bug ou autre changement) et leur pull request (PR) associée.

## 14/12/2023

### Nouvelles fonctionnalités 🚀

- Ajout d’une page synthèse pour faciliter l’accès aux documents liés à l’audit ([#579](https://github.com/DISIC/Ara/pull/579))

### Autres changements ⚙️

- Déplacement des notes dans l’en-tête de la page de génération de l’audit ([#579](https://github.com/DISIC/Ara/pull/579))

## 11/12/2023

### Corrections 🐛
Expand Down
Loading

0 comments on commit efddcef

Please sign in to comment.