Skip to content

Commit

Permalink
fix(frontend): remove useless package
Browse files Browse the repository at this point in the history
  • Loading branch information
pYassine committed Aug 21, 2024
1 parent 57c2432 commit b2bd87a
Show file tree
Hide file tree
Showing 58 changed files with 2,386 additions and 85 deletions.
14 changes: 11 additions & 3 deletions .talismanrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ fileignoreconfig:
- filename: .kontinuous/env/prod/templates/backend.sealed-secret.yaml
checksum: a066a32a383b37f3e2195d41a309628e64d66e70611aa8ee05159205c0fdcd7c
- filename: _scripts/db/dumps/domifa_test.postgres.restore-data-only.sql
checksum: d61470228208094ecc7a14b8ccb30aa49c363009104aaa4d983fe54baba10c08
checksum: 87cc842ce287cb7f38c7ce74317e760923eb1be9e6f38b25b041596be401e54d
- filename: _scripts/db/dumps/domifa_test.postgres.truncate-data.sql
checksum: 0a9b780387e8c40344bd52f033a201da019c8b3e9e5d501ee6cb85040b6e168c
- filename: _scripts/db/dumps/domifa_test.postgres.truncate-restore-data-only.sql
checksum: 82670bbe12e21c9cf5af9a3e75f1c06c4a97d1bf5a8825cfab2553bc075e171e
checksum: e4d8eec59790779184081d5ec593ed69f4426395338743a44f4af23555f96d3e
- filename: packages/backend/.env.backend.dev.example.env
checksum: d52c7fbfae21884e63f84a7aa0759c5296f0ecb483e71866541b2b44d7880758
- filename: packages/backend/.env.backend.test.local.example.env
Expand Down Expand Up @@ -43,6 +43,8 @@ fileignoreconfig:
checksum: 4c1f4f912bebc23465a8ed8bf0729091774483f2c15025b60f7cbe7a4cbd0d12
- filename: packages/backend/src/_migrations/1722521444554-auto-migration.ts
checksum: 4a28aeadfff8f388ef4a0ea9709fbb471f9ec931215ffcf28e71a95fc3171e73
- filename: packages/backend/src/_migrations/1723547616571-create-structure-information-migration.ts
checksum: 3d2e687ba83156be0cc3efbcfef99c6b668b9845e06233b2f381c2f737f7c4f6
- filename: packages/backend/src/_migrations/_init-db/1603812391580-pr-env-create-database.ts
checksum: 9c4984cbb8b435b626b2b26fd1cba740542aed18aa568bd03af517651de1aacd
- filename: packages/backend/src/modules/portail-usagers/controllers/portail-usagers-manager/portail-usagers-manager.controller.ts
Expand All @@ -55,12 +57,18 @@ fileignoreconfig:
checksum: 7d123141536acb8ec5b0bee34c0c8e2690e31743c4a8842f1e6a4bdc5dd6464e
- filename: packages/backend/src/usagers/services/xlsx-structure-usagers-renderer/tests/FIRST_SHEET_USAGERS.mock.ts
checksum: 80fb82d1004aba92a2c611267df10ee10a488d934a5f45ea10eee63064cb8295
- filename: packages/backend/src/users/controllers/users.public.controller.spec.ts
checksum: ecf53f692193dc5a61793cb820793f1af209da870f2391eed42c30f591bb9d80
- filename: packages/backend/src/users/dto/user.dto.ts
checksum: fab1dab2ad003174730bbdc703d59af49e65db3297415c0a1ac98a95e9f64280
- filename: packages/backend/src/util/expressResponseExcelRenderer.service.ts
checksum: 74fc4a9067af6f823ddcbbed150444cc1db78402ae265082a2114e64c0f459cb
- filename: packages/frontend/src/app/modules/admin-portail-usagers/components/admin-portail-usagers-menu/admin-portail-usagers-menu.component.html
checksum: 6c8166fdecdf0d9ab56fb12390ca2ed5bd98c8ba91b6c6bc976cdf659dde9263
- filename: packages/frontend/src/app/modules/admin-portail-usagers/components/manage-structure-information-form/manage-structure-information-form.component.ts
checksum: e828dd23fc4ba4ac16e586edb960c07ff58436d8165eb0b1c796d33ef1470ba9
- filename: packages/frontend/src/app/modules/admin-portail-usagers/components/manage-structure-information/manage-structure-information.component.html
checksum: 4548c095070e35ca663d7ae675e8f0edccff093be26d10da7425c7a1427b3f22
- filename: packages/frontend/src/app/modules/admin-portail-usagers/components/manage-temp-messages/manage-temp-messages.component.html
checksum: f5bc2bd3820b5f982b8d3c36360ed20764e408b4f59d65f470e503e66d1b3282
- filename: packages/frontend/src/app/modules/general/components/static-pages/cgu-responsable/cgu-responsable.component.html
Expand All @@ -86,5 +94,5 @@ fileignoreconfig:
- filename: packages/portail-admins/src/environments/environment.ts
checksum: 65d0b914b6baa33b2e8ec95786ef0c9d9960787295f1f02450d0262f71fd3d0e
- filename: yarn.lock
checksum: dce41db10fe65e26fb8b1ca281e9a4672e65131e94a881a5ad6fadbfbcfd9058
checksum: 43def94fbef38b83cc4ad7473a21e15c856c8bb5410c6d5fe0f65e021329ead6
version: "1.0"
Binary file modified _scripts/db/dumps/domifa_test.postgres.custom.gz
Binary file not shown.
16 changes: 16 additions & 0 deletions _scripts/db/dumps/domifa_test.postgres.restore-data-only.sql
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,14 @@ COPY public.structure_doc (uuid, "createdAt", "updatedAt", version, id, label, "
\.
--
-- Data for Name: structure_information; Type: TABLE DATA; Schema: public; Owner: -
--
COPY public.structure_information (uuid, "createdAt", "updatedAt", version, title, description, "startDate", "endDate", type, "createdBy", "structureId") FROM stdin;
\.
--
-- Data for Name: structure_stats_reporting; Type: TABLE DATA; Schema: public; Owner: -
--
Expand Down Expand Up @@ -225,6 +233,14 @@ d887dd71-6b09-4eef-bfc8-3a3d28cd9ab4 2024-05-28 21:03:55.09392+02 2024-05-28 21:
\.
--
-- Data for Name: typeorm_metadata; Type: TABLE DATA; Schema: public; Owner: -
--
COPY public.typeorm_metadata (type, database, schema, "table", name, value) FROM stdin;
\.
--
-- Data for Name: usager_docs; Type: TABLE DATA; Schema: public; Owner: -
--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,14 @@ COPY public.structure_doc (uuid, "createdAt", "updatedAt", version, id, label, "
\.
--
-- Data for Name: structure_information; Type: TABLE DATA; Schema: public; Owner: -
--
COPY public.structure_information (uuid, "createdAt", "updatedAt", version, title, description, "startDate", "endDate", type, "createdBy", "structureId") FROM stdin;
\.
--
-- Data for Name: structure_stats_reporting; Type: TABLE DATA; Schema: public; Owner: -
--
Expand Down Expand Up @@ -265,6 +273,14 @@ d887dd71-6b09-4eef-bfc8-3a3d28cd9ab4 2024-05-28 21:03:55.09392+02 2024-05-28 21:
\.
--
-- Data for Name: typeorm_metadata; Type: TABLE DATA; Schema: public; Owner: -
--
COPY public.typeorm_metadata (type, database, schema, "table", name, value) FROM stdin;
\.
--
-- Data for Name: usager_docs; Type: TABLE DATA; Schema: public; Owner: -
--
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { MigrationInterface, QueryRunner } from "typeorm";
import { domifaConfig } from "../config";

export class CreateStructureInformationMigration1723547616571
implements MigrationInterface
{
name = "CreateStructureInformationMigration1723547616571";

public async up(queryRunner: QueryRunner): Promise<void> {
if (
domifaConfig().envId === "prod" ||
domifaConfig().envId === "preprod" ||
domifaConfig().envId === "local"
) {
await queryRunner.query(
`CREATE TABLE "structure_information" ("uuid" uuid NOT NULL DEFAULT uuid_generate_v4(), "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "version" integer NOT NULL, "title" character varying NOT NULL, "description" character varying, "startDate" TIMESTAMP NOT NULL, "endDate" TIMESTAMP, "type" character varying NOT NULL, "createdBy" jsonb, "structureId" integer NOT NULL, CONSTRAINT "PK_b51c75b37769abf1fdf28fc89ef" PRIMARY KEY ("uuid"))`
);
await queryRunner.query(
`CREATE INDEX "IDX_17cd35c9fdcd9ab82015a46b22" ON "structure_information" ("structureId") `
);
await queryRunner.query(
`ALTER TABLE "structure_information" ADD CONSTRAINT "FK_17cd35c9fdcd9ab82015a46b22c" FOREIGN KEY ("structureId") REFERENCES "structure"("id") ON DELETE CASCADE ON UPDATE NO ACTION`
);
}
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "structure_information" DROP CONSTRAINT "FK_17cd35c9fdcd9ab82015a46b22c"`
);

await queryRunner.query(`DROP TABLE "structure_information"`);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import {
} from "../../../_common/model";
import { AdminStructuresService } from "../services";
import { CurrentUser } from "../../../auth/decorators/current-user.decorator";
import { UsersController } from "../../../users/users.controller";
import { RegisterUserAdminDto } from "../../../users/dto";
import { format } from "date-fns";
import { structureCreatorService } from "../../../structures/services";
Expand All @@ -51,6 +50,7 @@ import { domifaConfig } from "../../../config";
import jwt from "jsonwebtoken";
import { FindOptionsWhere } from "typeorm";
import { AppLogsService } from "../../../modules/app-logs/app-logs.service";
import { UsersController } from "../../../users/users.controller";

@UseGuards(AuthGuard("jwt"), AppUserGuard)
@Controller("admin/structures")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function allowSuperAdminDomifaOnly(
validExpectedResponseStatus = HttpStatus.OK,
}: { validExpectedResponseStatus?: HttpStatus } = {}
): HttpStatus {
console.log("validExpectedResponseStatus");
return !user
? HttpStatus.UNAUTHORIZED
: user?.profile === "super-admin-domifa"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { createParamDecorator, ExecutionContext } from "@nestjs/common";
import { UserStructureAuthenticated } from "../../_common/model";

export const CurrentStructureInformation = createParamDecorator(
(_data: unknown, ctx: ExecutionContext) => {
const request = ctx.switchToHttp().getRequest();
return request.structureInformation as UserStructureAuthenticated;
}
);
1 change: 1 addition & 0 deletions packages/backend/src/auth/decorators/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export * from "./AllowUserProfiles.decorator";
export * from "./AllowUserStructureRoles.decorator";
export * from "./current-chosen-user-structure.decorator";
export * from "./current-interaction.decorator";
export * from "./current-structure-information.decorator";
export * from "./current-usager-note.decorator";
export * from "./current-usager.decorator";
export * from "./current-user.decorator";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { userStructureRepository } from "../../database";
export class CanGetUserStructureGuard implements CanActivate {
public async canActivate(context: ExecutionContext) {
const r = context.switchToHttp().getRequest();

const userUuid = r.params.userUuid;
const structureId = r.user.structureId;

Expand Down
1 change: 1 addition & 0 deletions packages/backend/src/auth/guards/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
export * from "./AppUserGuard.guard";
export * from "./CanGetUserStructure.guard";
export * from "./interactions.guard";
export * from "./structure-information-access.guard";
export * from "./usager-access.guard";
export * from "./usager-note-access.guard";
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import {
CanActivate,
ExecutionContext,
HttpException,
HttpStatus,
Injectable,
} from "@nestjs/common";

import { appLogger } from "../../util";
import { structureInformationRepository } from "../../database";

@Injectable()
export class StructureInformationAccessGuard implements CanActivate {
public async canActivate(context: ExecutionContext) {
const r = context.switchToHttp().getRequest();

if (
typeof r.params.uuid === "undefined" ||
typeof r.user.structureId === "undefined"
) {
appLogger.error(
`[StructureInformationAccessGuard] invalid uuid or structureId`,
{
sentry: true,
context: {
usagerRef: r?.params?.uui,
structureId: r?.user?.structureId,
user: r?.user?._id,
},
}
);
throw new HttpException(
"STRUCTURE_INFORMATION_NOT_FOUND",
HttpStatus.BAD_REQUEST
);
}

const uuid = r.params.uuid;
const structureId = parseInt(r.user.structureId, 10);

try {
const structureInformation =
await structureInformationRepository.findOneOrFail({
where: {
structureId,
uuid,
},
});
r.structureInformation = structureInformation;
return r;
} catch (e) {
appLogger.error(`[UsagerAccessGuard] structureInformation not found`, {
sentry: true,
context: {
uuid,
structureId,
user: r?.user?._id,
role: r?.user?.role,
},
});
throw new HttpException("USAGER_NOT_FOUND", HttpStatus.BAD_REQUEST);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import {
StructureInformation,
StructureInformationType,
UserStructureResume,
} from "@domifa/common";
import { Entity, Column, Index, JoinColumn, ManyToOne } from "typeorm";
import { AppTypeormTable } from "../_core";
import { StructureTable } from "./StructureTable.typeorm";

@Entity({ name: "structure_information" })
export class StructureInformationTable
extends AppTypeormTable<StructureInformationTable>
implements StructureInformation
{
@Column({ type: "varchar" })
title: string;

@Column({ nullable: true })
description: string;

@Column({ type: "timestamp" })
startDate: Date;

@Column({ type: "timestamp", nullable: true })
endDate: Date | null;

@Column({ type: "varchar" })
type: StructureInformationType;

@Column({ type: "jsonb", nullable: true })
createdBy: UserStructureResume;

@Index()
@ManyToOne(() => StructureTable, (structure) => structure.id, {
onDelete: "CASCADE",
})
@Column({ type: "integer", nullable: false })
@JoinColumn({ name: "structureId", referencedColumnName: "id" })
public structureId: number;
}
1 change: 1 addition & 0 deletions packages/backend/src/database/entities/structure/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @index('./*', f => `export * from '${f.path}'`)
export * from "./StructureInformationTable.typeorm";
export * from "./StructureStatsReportingQuestionsTable.typeorm";
export * from "./StructureTable.typeorm";
3 changes: 2 additions & 1 deletion packages/backend/src/database/services/structure/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @index('./*', f => `export * from '${f.path}'`)
// @index('./*.service.ts', f => `export * from '${f.path}'`)
export * from "./structureInformationRepository.service";
export * from "./structureRepository.service";
export * from "./structureStatsReportingQuestionsRepository.service";
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { StructureInformation } from "@domifa/common";
import { myDataSource } from "../_postgres";
import { StructureInformationTable } from "../../entities/structure/StructureInformationTable.typeorm";

export const structureInformationRepository =
myDataSource.getRepository<StructureInformation>(StructureInformationTable);
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { myDataSource } from "..";
import { UsagerTable } from "../../entities";
import { joinSelectFields, pgRepository } from "../_postgres";
import { getDateForMonthInterval } from "../../../stats/services";
import { USER_USAGER_ATTRIBUTES } from "../../../modules/portail-usagers/const";
import { USER_USAGER_ATTRIBUTES } from "../../../modules/portail-usagers/constants";

const baseRepository = pgRepository.get<UsagerTable, Usager>(UsagerTable);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Test, TestingModule } from "@nestjs/testing";
import { StructureInformationController } from "./structure-information.controller";

describe("StructureInformationController", () => {
let controller: StructureInformationController;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [StructureInformationController],
}).compile();

controller = module.get<StructureInformationController>(
StructureInformationController
);
});

it("should be defined", () => {
expect(controller).toBeDefined();
});
});
Loading

0 comments on commit b2bd87a

Please sign in to comment.