Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI & Feature update - July 2024 #141

Open
wants to merge 40 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
f507bda
Add font and save languages between sessions (#137)
ericboucher Jul 2, 2024
942330a
Update login page UI (#138)
ericboucher Jul 3, 2024
300652f
Update search filters and forms table (#140)
ericboucher Jul 10, 2024
5e9a69e
Update navbar style (#144)
echaidemenos Jul 11, 2024
0ee4f7b
Add missing geodata and a utility script (#148)
ericboucher Jul 12, 2024
a8c1634
Update Home UI (#146)
echaidemenos Jul 12, 2024
7ce7a31
build(deps): bump next from 13.4.2 to 14.1.1 in /apps/frontend (#145)
dependabot[bot] Jul 12, 2024
c318598
Update email placeholder
ericboucher Jul 14, 2024
d2983bd
Make filters use MultiSelect (#149)
echaidemenos Jul 15, 2024
d181edb
Update Dockerfile
ericboucher Jul 16, 2024
03fb030
Update node:hydrogen-alpine3.20
ericboucher Jul 15, 2024
f202ddd
Add flood number column and batch edit (#150)
ericboucher Jul 18, 2024
b7fca34
Update the Report tables' styles (#152)
echaidemenos Jul 23, 2024
190b471
Update app.module.ts
ericboucher Jul 23, 2024
d6e96ea
New UI for Forms Validation (#157)
echaidemenos Aug 1, 2024
591dd4c
Only authorize patching endpoints from dmp.ovio.org (#163)
ericboucher Aug 30, 2024
830980e
Add charts (#164)
ericboucher Aug 30, 2024
a7a7830
empty
ericboucher Sep 4, 2024
2a08d01
Update amplify.yml
ericboucher Sep 4, 2024
468cc3b
Update amplify.yml
ericboucher Sep 4, 2024
62558b4
Update amplify.yml
ericboucher Sep 5, 2024
fb063ab
empty
ericboucher Sep 5, 2024
76f4577
Fix Report print functionality (#161)
echaidemenos Sep 16, 2024
c7a76bd
build(deps-dev): bump webpack from 5.74.0 to 5.94.0 in /apps/backend …
dependabot[bot] Sep 16, 2024
3f42368
Better telegram instructions (#168)
ericboucher Sep 16, 2024
b75055b
Fix usePrintContext and edit page
ericboucher Sep 17, 2024
6f6cd31
Make kobo webhook handlers more flexible (#172)
ericboucher Sep 20, 2024
1b9df6c
Add village and other fields based on kobo form changes (#171)
wadhwamatic Sep 23, 2024
73d3e48
build(deps): bump express from 4.18.1 to 4.20.0 in /apps/backend (#167)
dependabot[bot] Sep 23, 2024
a156078
Update en.json
ericboucher Sep 23, 2024
07bfc84
Add khmer translation for families
ericboucher Sep 24, 2024
313c95d
Upgrade rollup
ericboucher Sep 24, 2024
ef90150
Add villages
ericboucher Oct 4, 2024
a063c66
Use FactoryAff and FactoryDam key
ericboucher Oct 4, 2024
3c199cd
Update incident.ts
ericboucher Oct 4, 2024
51613eb
Add number of villages reported to summary tables
ericboucher Oct 8, 2024
69068af
Fix border issue for last column (#175)
K-Markopoulos Oct 10, 2024
aa613c4
Display village names directly (#174)
ericboucher Oct 11, 2024
273852f
Fix table printing extra space (#176)
K-Markopoulos Oct 14, 2024
5d43761
Add total row in report tables (#179)
K-Markopoulos Oct 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = {
'import/prefer-default-export': 0,
'import/no-duplicates': 'error',
complexity: ['error', 8],
'max-lines': ['error', 200],
'max-lines': ['error', 250],
'max-depth': ['error', 3],
'max-params': ['error', 4],
eqeqeq: ['error', 'smart'],
Expand Down
28 changes: 19 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- name: Install pnpm
uses: pnpm/action-setup@v2.2.4
uses: pnpm/action-setup@v4
with:
version: 7.14.1
version: 9.4.0
- name: Setup Node
uses: actions/setup-node@v3
with:
Expand All @@ -61,9 +61,9 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- name: Install pnpm
uses: pnpm/action-setup@v2.2.4
uses: pnpm/action-setup@v4
with:
version: 7.14.1
version: 9.4.0
- name: Setup Node
uses: actions/setup-node@v3
with:
Expand All @@ -72,7 +72,7 @@ jobs:
- name: Install dependencies
run: pnpm install
- name: Check for vulnerable dependencies
run: pnpm run security
run: pnpm run security --level 2

frontend_build_and_deploy:
needs: test
Expand All @@ -82,31 +82,41 @@ jobs:
surge_url: wfp-dmp-${{ github.event.pull_request.number }}.surge.sh
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2.2.3
- uses: pnpm/action-setup@v4.0.0
- name: Setup Node.js
id: setup-node
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'pnpm'
- name: Log pnpm version
run: pnpm --version
- name: Check lockfile version
run: |
if grep -q '"lockfileVersion":' ../../pnpm-lock.yaml; then
echo "Lockfile version: $(grep '"lockfileVersion":' ../../pnpm-lock.yaml)";
else
echo "Lockfile version not found";
fi
- name: Install frontend dependencies
run: pnpm install --frozen-lockfile
- name: Clean build folder
run: rm -rf apps/frontend/out
- name: Build Interfaces & Frontend
run: pnpm turbo build
env:
NEXT_PUBLIC_API_BASE_URL: https://staging-api-dmp.ovio.org
NEXT_PUBLIC_API_BASE_URL: https://api-dmp.ovio.org
- name: Export to static HTML
run: |
cd apps/frontend
./gen_env.sh staging
pnpm next export
cd out
cp index.html 200.html
- name: Deploy on surge
uses: dswistowski/surge-sh-action@v1
with:
domain: ${{ env.surge_url }}
project: "apps/frontend/out/."
project: 'apps/frontend/out/.'
login: ${{ secrets.surge_login }}
token: ${{ secrets.surge_token }}
- name: Get current date
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/merge-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2.2.3
- uses: pnpm/action-setup@v4.0.0
- name: Setup Node.js
id: setup-node
uses: actions/setup-node@v3
Expand All @@ -33,7 +33,7 @@ jobs:
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Configure AWS Credentials (Authentication)
uses: aws-actions/configure-aws-credentials@v1
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ vars.AWS_REGION }}
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/merge-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2.2.3
- uses: pnpm/action-setup@v4.0.0
- name: Setup Node.js
id: setup-node
uses: actions/setup-node@v3
Expand All @@ -33,7 +33,7 @@ jobs:
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Configure AWS Credentials (Authentication)
uses: aws-actions/configure-aws-credentials@v1
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ vars.AWS_REGION }}
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
Expand All @@ -50,7 +50,7 @@ jobs:
surge_url: staging-wfp-dmp.surge.sh
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2.2.3
- uses: pnpm/action-setup@v4.0.0
- name: Setup Node.js
id: setup-node
uses: actions/setup-node@v3
Expand All @@ -67,11 +67,10 @@ jobs:
run: |
cd apps/frontend
./gen_env.sh staging
pnpm next export
- name: Deploy on surge
uses: dswistowski/surge-sh-action@v1
with:
domain: ${{ env.surge_url }}
project: "apps/frontend/out/."
project: 'apps/frontend/out/.'
login: ${{ secrets.surge_login }}
token: ${{ secrets.surge_token }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ npm-debug.log*
pnpm-debug.log*
pnpm-error.log*
lerna-debug.log*
.vscode
4 changes: 0 additions & 4 deletions .husky/commit-msg

This file was deleted.

4 changes: 0 additions & 4 deletions .husky/pre-commit

This file was deleted.

3 changes: 1 addition & 2 deletions amplify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ applications:
preBuild:
commands:
- nvm use 18
- npm install -g pnpm@^7
- npm install -g pnpm@^9
- cd ../..
- pnpm install --virtual-store-dir apps/frontend/node_modules/.pnpm
build:
Expand All @@ -14,7 +14,6 @@ applications:
- cd apps/frontend
- env | grep -e NEXT_PUBLIC_ > .env.production
- ./gen_env.sh production
- pnpm next export # export static files
- cd out
- cp index.html 200.html
- cd ..
Expand Down
8 changes: 5 additions & 3 deletions apps/backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM node:hydrogen-alpine3.16 AS pnpm-installed
FROM node:hydrogen-alpine3.20 AS pnpm-installed
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
ENV PNPM_HOME=/usr/local/.pnpm
ENV PATH="$PATH:/usr/local/.pnpm"
RUN corepack enable && corepack prepare pnpm@7.14.2 --activate
RUN corepack enable && corepack prepare pnpm@9.4.0 --activate

FROM pnpm-installed AS turbo-installed
RUN apk add --no-cache libc6-compat
Expand All @@ -29,7 +29,9 @@ COPY --from=builder /app/out/pnpm-lock.yaml ./pnpm-lock.yaml
COPY --from=builder /app/out/full/ .

RUN HUSKY=0 pnpm install && \
pnpm build --scope='@wfp-dmp/backend' && \
cd packages/interfaces && pnpm build && \
cd ../../apps/backend && pnpm build && \
cd ../.. && \
rm -rf **/src **/.turbo node_modules **/node_modules && \
pnpm install --production

Expand Down
33 changes: 19 additions & 14 deletions apps/backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,7 @@ pnpm migration:run

## Telegram notifications

To setup the Telegram notifications when a new form is available:

Check first that the telegram secrets `/wfp/dmp/telegram/telegramNcdmChatId`, `/wfp/dmp/telegram/telegramPcdmChatId` and `/wfp/dmp/telegram/telegramBotToken` have been setup in the AWS Secret Manager.

- In Kobo, for each form:
- Go to `SETTINGS`
- Click on `REST Services` and then on `REGISTER A NEW SERVICE`
- Add:
- A name
- An endpoint URL: `<Environment backend URL>/webhook/<FLOOD or DROUGHT or INCIDENT>`
- A custom http Headers `authorization` : `Bearer <dmpWebhookToken from the AWS SecretManager>`
- Click on `CREATE`

# Create a bot
### Create a Telegram bot

- To create a bot follow this [tutorial](https://core.telegram.org/bots/tutorial).
Keep in a safe place its associated token.
Expand All @@ -104,3 +91,21 @@ curl https://api.telegram.org/bot<BOT_TOKEN>/getUpdates
If you cannot see the chat ids, remove the bot from the channels and add it again in the chats and run the command again

You can now fill out `/wfp/dmp/telegram/telegramNcdmChatId`, `/wfp/dmp/telegram/telegramPcdmChatId` and `/wfp/dmp/telegram/telegramBotToken` in the AWS Secret Manager.

### Kobo Webhook settings

To setup the Telegram notifications when a new form is available:

Check first that the telegram secrets `/wfp/dmp/telegram/telegramNcdmChatId`, `/wfp/dmp/telegram/telegramPcdmChatId` and `/wfp/dmp/telegram/telegramBotToken` have been setup in the AWS Secret Manager.

- In Kobo, for each form:
- Go to `SETTINGS`
- Click on `REST Services` and then on `REGISTER A NEW SERVICE`
- Add:
- A name
- An endpoint URL: `<Environment backend URL>/webhook/<FLOOD or DROUGHT or INCIDENT>`
- A custom http Headers `authorization` : `Bearer <dmpWebhookToken from the AWS SecretManager>`
- Click on `CREATE`

![](images/kobo_rest_services.png)
![](images/kobo_rest_services_webhook.png)
Binary file added apps/backend/images/kobo_rest_services.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions apps/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"schema:drop": ". ./.env.rc && typeorm -d datasource.js schema:drop",
"start:debug": "pnpm start --debug",
"start:prod": "node dist/main.js",
"test": ". ./.env.test.rc && jest * --maxWorkers=2",
"test": "TZ=UTC . ./.env.test.rc && jest * --maxWorkers=2",
"test:circular": "depcruise --validate .dependency-cruiser.js src",
"test:coverage": "docker compose up -d db-test && pnpm test -- --coverage",
"test:debug": "NODE_OPTIONS='--inspect-brk' pnpm test",
Expand Down Expand Up @@ -54,7 +54,7 @@
"cli-color": "2.0.3",
"connect-typeorm": "^2.0.0",
"cookie-parser": "1.4.6",
"express": "4.18.1",
"express": "4.20.0",
"express-formidable": "1.2.0",
"express-session": "1.17.3",
"jsonwebtoken": "9.0.0",
Expand Down Expand Up @@ -97,7 +97,7 @@
"ts-loader": "9.3.1",
"tsconfig": "workspace:*",
"typescript": "4.7.4",
"webpack": "5.74.0"
"webpack": "5.94.0"
},
"engines": {
"node": "^18.12.1"
Expand Down
9 changes: 9 additions & 0 deletions apps/backend/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ const authenticate = async (email: string, password: string) => {
companyName: 'Disaster Monitoring Platform',
withMadeWithLove: false,
favicon: 'https://dmp.ovio.org/favicon.ico',
theme: {
colors: {
primary100: '#63B2BD', // Example color for primary buttons
primary80: '#fff', // Example color for primary buttons on hover
primary60: '#fff', // Example color for primary buttons on active
primary40: '#fff', // Example color for primary buttons on focus
primary20: '#fff', // Example color for primary buttons on disabled
},
},
},
locale: {
language: 'en',
Expand Down
7 changes: 7 additions & 0 deletions apps/backend/src/modules/kobo/kobo.controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { UseProvince } from '@auth/user.decorator';
import { Get } from '@decorators/httpDecorators';
import { Body, Controller, HttpException, HttpStatus, Param, Patch, Query } from '@nestjs/common';
import { OriginGuard } from '@utils/originGuard';
import {
DisasterDtoType,
DROUGHT,
Expand All @@ -17,6 +18,8 @@ import {

import { KoboService } from './kobo.service';

const AuthorizedPatchOrigin = /^https:\/\/dmp\.ovio\.org(\/.*)?$/;

@Controller('kobo')
export class KoboController {
constructor(private readonly koboService: KoboService) {}
Expand Down Expand Up @@ -72,6 +75,7 @@ export class KoboController {
}

@Patch('form/validationStatus')
@OriginGuard(AuthorizedPatchOrigin)
async patchValidationStatus(
@Body() body: PatchValidationStatusDto,
): Promise<ValidationStatusDto> {
Expand All @@ -86,6 +90,7 @@ export class KoboController {
}

@Patch(`form/${FLOOD}/:id`)
@OriginGuard(AuthorizedPatchOrigin)
async patchFloodForm(
@Param('id') id: string,
@Body() body: PatchFloodFormDto,
Expand All @@ -96,6 +101,7 @@ export class KoboController {
}

@Patch(`form/${DROUGHT}/:id`)
@OriginGuard(AuthorizedPatchOrigin)
async patchDroughtForm(
@Param('id') id: string,
@Body() body: PatchDroughtFormDto,
Expand All @@ -106,6 +112,7 @@ export class KoboController {
}

@Patch(`form/${INCIDENT}/:id`)
@OriginGuard(AuthorizedPatchOrigin)
async patchIncidentForm(
@Param('id') id: string,
@Body() body: PatchIncidentFormDto,
Expand Down
16 changes: 10 additions & 6 deletions apps/backend/src/modules/kobo/kobo.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ export class KoboService {
endDate,
}: {
disTyps: string[];
province: string | undefined;
district?: string;
commune?: string;
province?: string | string[];
district?: string | string[];
commune?: string | string[];
startDate?: string;
endDate?: string;
}): Promise<QueryResponse<T>> {
Expand All @@ -85,9 +85,13 @@ export class KoboService {
{
params: {
query: {
[koboKeys[disasterType].province]: province,
[koboKeys[disasterType].district]: district,
[koboKeys[disasterType].commune]: commune,
[koboKeys[disasterType].province]: Array.isArray(province)
? { $in: province }
: province,
[koboKeys[disasterType].district]: Array.isArray(district)
? { $in: district }
: district,
[koboKeys[disasterType].commune]: Array.isArray(commune) ? { $in: commune } : commune,
[koboKeys[disasterType].entryDate]: { $gte: startDate, $lte: endDate },
[koboKeys[disasterType].disTyp]: { $in: disTyps },
},
Expand Down
6 changes: 3 additions & 3 deletions apps/backend/src/modules/kobo/tests/__mocks__/getForms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ export const getFormsMock = ({
endDate,
}: {
disTyps: string[];
province?: string;
district?: string;
commune?: string;
province?: string | string[];
district?: string | string[];
commune?: string | string[];
startDate?: string;
endDate?: string;
}) => {
Expand Down
Loading
Loading