Skip to content

Commit 3a01b03

Browse files
authored
Merge pull request #752 from bcgov/SRS-597
feat: SRS-597 - Manage People Search Page
2 parents b634fb9 + 24f4acc commit 3a01b03

File tree

161 files changed

+23355
-2639
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

161 files changed

+23355
-2639
lines changed

backend/applications/package-lock.json

Lines changed: 10119 additions & 56 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/users/package-lock.json

Lines changed: 1070 additions & 284 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/users/package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"typeorm:run-migrations": "npm run typeorm migration:run -- -d ./typeOrm.config.ts",
2424
"typeorm:generate-migration": "npm run typeorm -- -d ./typeOrm.config.ts migration:generate ./src/migrations/master-script",
2525
"typeorm:create-migration": "npm run typeorm -- migration:create ./src/migrations/master-script",
26-
"typeorm:revert-migration": "npm run typeorm -- -d ./typeOrm.config.ts migration:revert"
26+
"typeorm:revert-migration": "npm run typeorm -- -d ./typeOrm.config.ts migration:revert"
2727
},
2828
"dependencies": {
2929
"@apollo/federation": "^0.37.1",
@@ -35,15 +35,19 @@
3535
"@nestjs/platform-express": "^9.0.0",
3636
"@nestjs/typeorm": "^9.0.1",
3737
"apollo-server-express": "^3.10.2",
38+
"axios": "^1.7.9",
3839
"class-transformer": "^0.5.1",
40+
"cls-rtracer": "^2.6.3",
3941
"graphql": "^16.6.0",
4042
"keycloak-connect": "^18.0.2",
4143
"nest-keycloak-connect": "^1.9.0",
4244
"pg": "^8.8.0",
4345
"reflect-metadata": "^0.1.13",
4446
"rimraf": "^3.0.2",
4547
"rxjs": "^7.2.0",
46-
"typeorm": "^0.3.10"
48+
"typeorm": "^0.3.10",
49+
"winston": "^3.17.0",
50+
"winston-daily-rotate-file": "^5.0.0"
4751
},
4852
"devDependencies": {
4953
"@nestjs/cli": "^9.0.0",

backend/users/src/app.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { GraphQLModule } from '@nestjs/graphql';
77
import { TypeOrmModule } from '@nestjs/typeorm';
88
import { AppController } from './app.controller';
99
import { AppService } from './app.service';
10-
import { UsersModule } from './app/users.module';
10+
import { CatsModule } from './app/cats.module';
1111
import {
1212
AuthGuard,
1313
KeycloakConnectModule,
@@ -33,7 +33,7 @@ import { ConfigModule, ConfigService } from '@nestjs/config';
3333
}),
3434
// Secret key of the client taken from keycloak server
3535
}),
36-
UsersModule,
36+
CatsModule,
3737
TypeOrmModule.forRootAsync({
3838
inject: [ConfigService],
3939
useFactory: (config: ConfigService) => ({
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
import { Module } from '@nestjs/common';
2+
import { TypeOrmModule } from '@nestjs/typeorm';
3+
import { UserController } from './controllers/user.controller';
4+
import { KeycloakService } from './services/keycloak.service';
5+
import { LoggerService } from './logger/logger.service';
6+
import { Person } from './entities/person.entity';
7+
import { PersonResolver } from './resolvers/people.resolver';
8+
import { PersonService } from './services/people.service';
9+
import { Timesheet } from './entities/timesheet.entity';
10+
import { AppParticipant } from './entities/appParticipant.entity';
11+
import { Application } from './entities/application.entity';
12+
import { TimesheetWeek } from './entities/timesheetWeek.entity';
13+
import { TimesheetDetail } from './entities/timesheetDetail.entity';
14+
import { AppExpense } from './entities/appExpense.entity';
15+
import { AppLandUse } from './entities/appLandUse.entity';
16+
import { LandUse } from './entities/landUse.entity';
17+
import { AppNote } from './entities/appNote.entity';
18+
import { AppPriority } from './entities/appPriority.entity';
19+
import { Priority } from './entities/priority.entity';
20+
import { AppSedimentUse } from './entities/appSedimentUse.entity';
21+
import { SedimentUse } from './entities/sedimentUse.entity';
22+
import { AppService } from './entities/appService.entity';
23+
import { Service } from './entities/service.entity';
24+
import { AppTypeDefaultService } from './entities/appTypeDefaultService.entity';
25+
import { ServiceFeeSchedule } from './entities/serviceFeeSchedule.entity';
26+
import { AppType } from './entities/appType.entity';
27+
import { ServiceServiceCategory } from './entities/serviceServiceCategory.entity';
28+
import { ServiceCategory } from './entities/serviceCategory.entity';
29+
import { ServiceCategoryType } from './entities/serviceCategoryType.entity';
30+
import { AppStatus } from './entities/appStatus.entity';
31+
import { StatusType } from './entities/statusType.entity';
32+
import { AppVapourUse } from './entities/appVapourUse.entity';
33+
import { VapourUse } from './entities/vapourUse.entity';
34+
import { AppWaterUse } from './entities/appWaterUse.entity';
35+
import { WaterUse } from './entities/waterUse.entity';
36+
import { Media } from './entities/media.entity';
37+
import { Oceans } from './entities/oceans.entity';
38+
import { Outcome } from './entities/outcome.entity';
39+
import { ReviewProcess } from './entities/reviewProcess.entity';
40+
import { Risk } from './entities/risk.entity';
41+
import { Site } from './entities/site.entity';
42+
import { Region } from './entities/region.entity';
43+
import { SiteType } from './entities/siteType.entity';
44+
import { HousingApplicationXref } from './entities/housingApplicationXref.entity';
45+
import { HousingSiteXref } from './entities/housingSiteXref.entity';
46+
import { HousingType } from './entities/housingType.entity';
47+
import { Housing } from './entities/housing.entity';
48+
import { YesNoCode } from './entities/yesNoCode.entity';
49+
import { Invoice } from './entities/invoice.entity';
50+
import { Payment } from './entities/payment.entity';
51+
import { PaymentMethod } from './entities/paymentMethod.entity';
52+
import { Organization } from './entities/organization.entity';
53+
import { ParticipantRole } from './entities/participantRole.entity';
54+
/**
55+
* Module for wrapping all functionalities in user microserivce
56+
*/
57+
@Module({
58+
imports: [
59+
TypeOrmModule.forFeature([
60+
Person,
61+
Timesheet,
62+
AppParticipant,
63+
Application,
64+
TimesheetWeek,
65+
TimesheetDetail,
66+
AppExpense,
67+
AppLandUse,
68+
LandUse,
69+
AppNote,
70+
AppPriority,
71+
Priority,
72+
AppSedimentUse,
73+
SedimentUse,
74+
Service,
75+
AppTypeDefaultService,
76+
ServiceFeeSchedule,
77+
AppType,
78+
AppService,
79+
ServiceServiceCategory,
80+
ServiceCategory,
81+
ServiceCategoryType,
82+
AppStatus,
83+
StatusType,
84+
AppVapourUse,
85+
VapourUse,
86+
AppWaterUse,
87+
WaterUse,
88+
Media,
89+
Oceans,
90+
Outcome,
91+
ReviewProcess,
92+
Risk,
93+
Site,
94+
Region,
95+
SiteType,
96+
HousingApplicationXref,
97+
HousingSiteXref,
98+
HousingType,
99+
Housing,
100+
YesNoCode,
101+
Invoice,
102+
Payment,
103+
PaymentMethod,
104+
Organization,
105+
ParticipantRole,
106+
]),
107+
],
108+
providers: [PersonResolver, PersonService, KeycloakService, LoggerService],
109+
controllers: [UserController],
110+
})
111+
export class CatsModule { }

backend/users/src/app/controllers/user.controller.ts

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -11,74 +11,74 @@ import {
1111
Roles,
1212
Unprotected,
1313
} from 'nest-keycloak-connect';
14-
import { KeycloakService } from 'src/app/services/keycloak.service';
15-
import { AddUserToGroupDto } from 'src/app/dto/addUserToGroup';
14+
// import { KeycloakService } from 'src/app/services/keycloak.service';
15+
// import { AddUserToGroupDto } from 'src/app/dto/addUserToGroup';
1616

1717
@Controller('users')
1818
@Resource('user-service')
1919
export class UserController {
20-
constructor(private readonly keyCloakService: KeycloakService) {}
20+
constructor() {}
2121

2222
/**
2323
* Add user to a group in Keycloak.
2424
* @param addUserToGroupDto - Object containing userId.
2525
* @returns Object indicating success status and message.
2626
*/
27-
@Post('/addGroup')
28-
@Roles({ roles: ['user-admin'], mode: RoleMatchingMode.ANY })
29-
async addUserToGroup(
30-
@Body() addUserToGroupDto: AddUserToGroupDto,
31-
): Promise<any> {
32-
try {
33-
const { userId } = addUserToGroupDto;
27+
// @Post('/addGroup')
28+
// @Roles({ roles: ['user-admin'], mode: RoleMatchingMode.ANY })
29+
// async addUserToGroup(
30+
// @Body() addUserToGroupDto: AddUserToGroupDto,
31+
// ): Promise<any> {
32+
// try {
33+
// const { userId } = addUserToGroupDto;
3434

35-
// Get access token from Keycloak
36-
const accessToken = await this.keyCloakService.getToken();
37-
if (!accessToken) {
38-
throw new HttpException(
39-
'Failed to get access token',
40-
HttpStatus.INTERNAL_SERVER_ERROR,
41-
);
42-
}
35+
// // Get access token from Keycloak
36+
// const accessToken = await this.keyCloakService.getToken();
37+
// if (!accessToken) {
38+
// throw new HttpException(
39+
// 'Failed to get access token',
40+
// HttpStatus.INTERNAL_SERVER_ERROR,
41+
// );
42+
// }
4343

44-
// Find group ID by name
45-
const groupName = 'formsflow-client'; // Assuming 'formflow-client' is the group name
46-
const groupId = await this.keyCloakService.getGroupIdByName(
47-
groupName,
48-
accessToken,
49-
);
50-
if (!groupId) {
51-
throw new HttpException(
52-
`Group '${groupName}' not found`,
53-
HttpStatus.NOT_FOUND,
54-
);
55-
}
44+
// // Find group ID by name
45+
// const groupName = 'formsflow-client'; // Assuming 'formflow-client' is the group name
46+
// const groupId = await this.keyCloakService.getGroupIdByName(
47+
// groupName,
48+
// accessToken,
49+
// );
50+
// if (!groupId) {
51+
// throw new HttpException(
52+
// `Group '${groupName}' not found`,
53+
// HttpStatus.NOT_FOUND,
54+
// );
55+
// }
5656

57-
// Add user to group
58-
const result = await this.keyCloakService.addUserToGroup(
59-
userId,
60-
groupId,
61-
accessToken,
62-
);
63-
if (result.success) {
64-
return result;
65-
}
66-
} catch (error) {
67-
console.log('addUserToGroup error', error);
68-
// Handle errors
69-
if (error.response && error.response.data && error.response.data.error) {
70-
// If Keycloak returns an error message, throw a Bad Request exception with the error message
71-
throw new HttpException(
72-
error.response.data.error,
73-
HttpStatus.BAD_REQUEST,
74-
);
75-
} else {
76-
// If any other error occurs, throw an Internal Server Error exception
77-
throw new HttpException(
78-
'Internal server error',
79-
HttpStatus.INTERNAL_SERVER_ERROR,
80-
);
81-
}
82-
}
83-
}
57+
// // Add user to group
58+
// const result = await this.keyCloakService.addUserToGroup(
59+
// userId,
60+
// groupId,
61+
// accessToken,
62+
// );
63+
// if (result.success) {
64+
// return result;
65+
// }
66+
// } catch (error) {
67+
// console.log('addUserToGroup error', error);
68+
// // Handle errors
69+
// if (error.response && error.response.data && error.response.data.error) {
70+
// // If Keycloak returns an error message, throw a Bad Request exception with the error message
71+
// throw new HttpException(
72+
// error.response.data.error,
73+
// HttpStatus.BAD_REQUEST,
74+
// );
75+
// } else {
76+
// // If any other error occurs, throw an Internal Server Error exception
77+
// throw new HttpException(
78+
// 'Internal server error',
79+
// HttpStatus.INTERNAL_SERVER_ERROR,
80+
// );
81+
// }
82+
// }
83+
// }
8484
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import { Field, InputType } from '@nestjs/graphql';
2+
3+
@InputType('CreatePersonInput')
4+
export class CreatePersonInput {
5+
@Field(() => Number)
6+
id: number;
7+
8+
@Field(() => String)
9+
firstName: string;
10+
11+
@Field(() => String)
12+
middleName: string | null;
13+
14+
@Field(() => String)
15+
lastName: string;
16+
17+
@Field(() => Boolean)
18+
isTaxExempt: boolean;
19+
20+
@Field(() => Boolean)
21+
isEnvConsultant: boolean;
22+
23+
@Field(() => String)
24+
loginUserName: string | null;
25+
26+
@Field(() => String)
27+
address_1: string | null;
28+
29+
@Field(() => String)
30+
address_2: string | null;
31+
32+
@Field(() => String)
33+
city: string | null;
34+
35+
@Field(() => String)
36+
prov: string | null;
37+
38+
@Field(() => String)
39+
country: string | null;
40+
41+
@Field(() => String)
42+
postal: string | null;
43+
44+
@Field(() => String)
45+
phone: string | null;
46+
47+
@Field(() => String)
48+
mobile: string | null;
49+
50+
@Field(() => String)
51+
fax: string | null;
52+
53+
@Field(() => String)
54+
email: string | null;
55+
56+
@Field(() => Boolean)
57+
isActive: boolean;
58+
59+
@Field(() => Number)
60+
rowVersionCount: number;
61+
62+
@Field(() => String)
63+
createdBy: string;
64+
65+
@Field(() => Date)
66+
createdDatetime: Date;
67+
68+
@Field(() => String)
69+
updatedBy: string;
70+
71+
@Field(() => Date)
72+
updatedDatetime: Date;
73+
74+
@Field(() => Boolean, { nullable: true })
75+
isDeleted?: boolean;
76+
}
Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,27 @@
11
import { Field, Int, ObjectType } from '@nestjs/graphql';
2+
import { format } from 'date-fns';
23

34
/**
45
* Base class for returing response from graphql services
56
*/
67
@ObjectType()
78
export class BaseHttpResponse {
8-
@Field(() => Int)
9-
httpStatusCode: number;
9+
@Field(() => String, { nullable: true })
10+
message?: string;
11+
12+
@Field(() => Int, { nullable: true })
13+
httpStatusCode?: number;
14+
15+
@Field(() => Boolean, { nullable: true })
16+
success?: boolean;
17+
18+
@Field(() => String, { nullable: true })
19+
timestamp?: string;
20+
21+
constructor(message?: string, httpStatusCode?: number, success?: boolean) {
22+
this.message = message;
23+
this.httpStatusCode = httpStatusCode;
24+
this.success = success;
25+
this.timestamp = format(new Date(), 'MMMM do, yyyy');
26+
}
1027
}

0 commit comments

Comments
 (0)