Skip to content

Commit

Permalink
Merge pull request #301 from d-rec/develop
Browse files Browse the repository at this point in the history
Stage Push on 21 June
  • Loading branch information
NamrataSweya authored Jun 27, 2024
2 parents ea3756d + 5d83e3d commit a921331
Show file tree
Hide file tree
Showing 54 changed files with 8,660 additions and 3,909 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/check-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: lts/gallium
node-version: lts/iron

- name: Run Prettier on Docs
working-directory: docs
Expand All @@ -32,7 +32,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: lts/gallium
node-version: lts/iron

- name: Install tooling
working-directory: docs
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: lts/gallium
node-version: lts/iron

- name: Install tooling
run: |
npm i -g @microsoft/rush
npm i -g pnpm@7
npm i -g pnpm@9
- name: Install drec-origin
run: |
Expand All @@ -42,12 +42,12 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: lts/gallium
node-version: lts/iron

- name: Install tooling
run: |
npm i -g @microsoft/rush
npm i -g pnpm@7
npm i -g pnpm@9
- name: Install drec-origin
run: |
Expand All @@ -71,12 +71,12 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: lts/gallium
node-version: lts/iron

- name: Install tooling
run: |
npm i -g @microsoft/rush
npm i -g pnpm@7
npm i -g pnpm@9
- name: Install drec-origin
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-gh-pages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: lts/gallium
node-version: lts/iron

- name: Install tooling
working-directory: docs
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ Repository for Origin DREC project

## Local environment setup of Ubuntu

Install `wsl`,`ubuntu-18.04` in command prompt running as administrator:
Install `wsl`,`ubuntu-20.04` in command prompt running as administrator:

```sh
wsl --install
wsl --install --distribution Ubuntu-18.04
wsl --install --distribution Ubuntu-20.04
```

Install `Influx-Client`:
Expand All @@ -52,7 +52,7 @@ Clone and Install `nvm`:

```sh
sudo wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
nvm install 14.19.1
nvm install 20.14.0
```

Install `rush`, `pnpm` if you don't have it:
Expand Down
4 changes: 2 additions & 2 deletions apps/drec-api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:16-alpine AS build
FROM node:20-alpine AS build

RUN apk --no-cache add bash

Expand All @@ -7,7 +7,7 @@ RUN npm cache clean --force
COPY . .

RUN npm i -g @microsoft/rush
RUN npm i -g pnpm@7
RUN npm i -g pnpm@9

WORKDIR /dist/src/app/apps/drec-api

Expand Down
2 changes: 1 addition & 1 deletion apps/drec-api/Dockerfile.bkp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:14-alpine
FROM node:20-alpine

RUN apk --no-cache add bash

Expand Down
2 changes: 1 addition & 1 deletion apps/drec-api/Dockerfile.migrations
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:14-alpine
FROM node:20-alpine

RUN apk --no-cache add bash

Expand Down
2 changes: 1 addition & 1 deletion apps/drec-api/buildspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ env:
phases:
install:
# runtime-versions:
# nodejs: 18
# nodejs: 20
# docker: 18
commands:
- nohup /usr/local/bin/dockerd --host=unix:///var/run/docker.sock --host=tcp://127.0.0.1:2375 --storage-driver=overlay2 &
Expand Down
17 changes: 9 additions & 8 deletions apps/drec-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@
"@ethersproject/bignumber": "5.3.0",
"@influxdata/influxdb-client": "1.9.0",
"@mapbox/timespace": "2.0.4",
"@nestjs-modules/mailer": "^1.6.0",
"@nestjs-modules/mailer": "2.0.2",
"@nestjs/axios": "~0.0.3",
"@nestjs/bull": "0.4.2",
"@nestjs/common": "8.1.1",
"@nestjs/config": "1.0.1",
"@nestjs/core": "8.1.1",
"@nestjs/core": "9.0.5",
"@nestjs/cqrs": "8.0.0",
"@nestjs/jwt": "8.0.0",
"@nestjs/jwt": "~10.2.0",
"@nestjs/passport": "8.0.1",
"@nestjs/platform-express": "8.1.1",
"@nestjs/schedule": "1.0.1",
Expand Down Expand Up @@ -99,9 +99,9 @@
"multer": "1.4.2",
"nanoid": "3.1.31",
"nodemailer": "6.9.9",
"passport": "0.4.0",
"passport": "0.6.0",
"passport-http-bearer": "1.0.1",
"passport-jwt": "4.0.0",
"passport-jwt": "~4.0.1",
"passport-local": "1.0.0",
"passport-oauth2-client-password": "0.1.2",
"passport-strategy": "1.x.x",
Expand All @@ -126,7 +126,7 @@
},
"devDependencies": {
"@compodoc/compodoc": "^1.1.22",
"@nestjs/cli": "7.5.4",
"@nestjs/cli": "~10.3.2",
"@nestjs/testing": "8.1.1",
"@types/bcryptjs": "2.4.2",
"@types/bull": "3.15.1",
Expand All @@ -153,7 +153,7 @@
"eslint-config-airbnb-base": "14.2.1",
"eslint-config-prettier": "7.0.0",
"jest": "26.6.0",
"mocha": "8.2.1",
"mocha": "~10.4.0",
"prettier": "~3.2.5",
"shx": "0.3.3",
"sinon": "^17.0.1",
Expand Down Expand Up @@ -182,5 +182,6 @@
],
"coverageDirectory": "../coverage",
"testEnvironment": "node"
}
},
"packageManager": "pnpm@9.4.0+sha512.f549b8a52c9d2b8536762f99c0722205efc5af913e77835dbccc3b0b0b2ca9e7dc8022b78062c17291c48e88749c70ce88eb5a74f1fa8c4bf5e18bb46c8bd83a"
}
3 changes: 2 additions & 1 deletion apps/drec-api/src/auth/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { ApiBearerAuth, ApiBody, ApiResponse, ApiTags } from '@nestjs/swagger';
import { AuthService } from './auth.service';
import { LoginReturnDataDTO } from './dto/login-return-data.dto';
import { LoginDataDTO } from './dto/login-data.dto';
import { WithoutAuthGuard } from '../guards';
@ApiTags('auth')
@ApiBearerAuth('access-token')
@Controller()
Expand All @@ -24,7 +25,7 @@ export class AuthController {

constructor(private readonly authService: AuthService) {}

@UseGuards(AuthGuard('local'))
@UseGuards(AuthGuard('local'), WithoutAuthGuard)
@Post('auth/login')
@HttpCode(HttpStatus.OK)
@ApiBody({ type: LoginDataDTO })
Expand Down
2 changes: 2 additions & 0 deletions apps/drec-api/src/guards/WithoutAuthGuard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ export class WithoutAuthGuard implements CanActivate {
role: Role.ApiUser,
api_user_id: request.params.api_user_id,
});
} else if (request.url.split('/')[3] === 'login') {
user = await this.userService.findByEmail(request.body.username);
}

if (
Expand Down
24 changes: 21 additions & 3 deletions apps/drec-api/src/pods/certificate-log/certificate-log.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -712,8 +712,16 @@ export class CertificateLogService {
); //going back 1 second in start and going forward 1 second in end
await Promise.all(
obj.deviceIds.map(async (deviceid: number) => {
const device = await this.deviceService.findOne(deviceid);

console.log(typeof deviceid);
// const device = await this.deviceService.findOne(deviceid);
let device: Device;
if (typeof deviceid === 'number') {
device = await this.deviceService.findOne(deviceid);
}
if (typeof deviceid === 'string') {
device = await this.deviceService.findReads(deviceid);
}
console.log(group);
let devicelog;
if (role === 'OrganizationAdmin') {
if (
Expand Down Expand Up @@ -874,7 +882,17 @@ export class CertificateLogService {
); //going back 1 second in start and going forward 1 second in end
await Promise.all(
obj.deviceIds.map(async (deviceid: number) => {
const device = await this.deviceService.findOne(deviceid);
// const device = await this.deviceService.findOne(deviceid);

// const device = await this.deviceService.findOne(deviceid);
let device: Device;
if (typeof deviceid === 'number') {
device = await this.deviceService.findOne(deviceid);
}
if (typeof deviceid === 'string') {
device = await this.deviceService.findReads(deviceid);
}

let devicelog;
if (role === 'OrganizationAdmin') {
if (
Expand Down
15 changes: 12 additions & 3 deletions apps/drec-api/src/pods/device-group/device-group.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,11 @@ export class DeviceGroupService {
}),
);
}

if (filterDto.name) {
const name = filterDto.name.toString();
const baseQuery = 'group.name ILIKE :name';
query.andWhere(baseQuery, { name: `%${name}%` });
}
if (filterDto.reservationActive) {
if (filterDto.reservationActive === 'Active') {
query.andWhere('group.reservationActive = :active', { active: true });
Expand Down Expand Up @@ -664,6 +668,11 @@ export class DeviceGroupService {
}),
);
}
if (groupfilterDto.name) {
const name = groupfilterDto.name.toString();
const baseQuery = 'dg.name ILIKE :name';
qb.andWhere(baseQuery, { name: `%${name}%` });
}
if (groupfilterDto.reservationActive) {
if (groupfilterDto.reservationActive === 'Active') {
qb.orWhere('dg.reservationActive = :active', { active: true });
Expand Down Expand Up @@ -2466,8 +2475,8 @@ export class DeviceGroupService {
SELECT 1
FROM jsonb_array_elements_text(CAST(crm.metadata AS jsonb)->'deviceIds') AS ids(deviceId)
WHERE
(deviceId ~ '^[0-9]+$' AND CAST(deviceId AS INTEGER) = d.id)
OR (deviceId !~ '^[0-9]+$' AND deviceId = d.id::TEXT)
(ids.deviceId ~* '^[0-9]+$' AND CAST(ids.deviceId AS INTEGER) = d.id) OR
(ids.deviceId !~* '^[0-9]+$' AND CAST(ids.deviceId AS TEXT) = d.externalId)
)`,
);
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ import {
import { countryCodesList } from '../../../models/country-code';
//import {SDGBenefits} from '../../../models/Sdgbenefit'
export class UnreservedDeviceGroupsFilterDTO {
@IsOptional()
@ApiPropertyOptional({
type: String,
description: 'string',
})
name: string;

@IsOptional()
@ApiPropertyOptional({
type: String,
Expand Down
2 changes: 1 addition & 1 deletion buildspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ phases:
install:
on-failure: ABORT
# runtime-versions:
# nodejs: 18
# nodejs: 20
# docker: 18
commands:
- nohup /usr/local/bin/dockerd --host=unix:///var/run/docker.sock --host=tcp://127.0.0.1:2375 --storage-driver=overlay2 &
Expand Down
Loading

0 comments on commit a921331

Please sign in to comment.