Skip to content

Commit

Permalink
Add monitor status
Browse files Browse the repository at this point in the history
  • Loading branch information
thongnguyen5 authored and thongnguyendev committed Apr 11, 2024
1 parent effe2f5 commit 81db12d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/apps/onebox/src/modules/monitor/dto/monitor.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ export class CreateMonitorDto {
.tags(this.tags)
.createdBy(createdBy)
.dateCreated(new Date())
.disabled(false)
.build();
}
}
Expand Down Expand Up @@ -211,6 +212,9 @@ export class MonitorResponseDto {
@ApiResponseProperty()
dateCreated: Date;

@ApiResponseProperty()
disabled: boolean;

static from(monitor: Monitor) {
return Builder<MonitorResponseDto>()
.projectId(monitor.projectId)
Expand All @@ -223,6 +227,7 @@ export class MonitorResponseDto {
.note(monitor.note)
.tags(monitor.tags)
.dateCreated(monitor.dateCreated)
.disabled(monitor.disabled || false)
.build();
}
}
Expand Down Expand Up @@ -300,4 +305,7 @@ export class UpdateMonitorDto {

@ApiProperty()
tags: string[];

@ApiProperty()
disabled: boolean;
}
3 changes: 3 additions & 0 deletions app/apps/onebox/src/modules/monitor/monitor.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ export class MonitorService {
if (request.tags) {
updateMonitor['tags'] = request.tags;
}
if (request.disabled != undefined) {
updateMonitor['disabled'] = request.disabled;
}
return this.monitorRepository
.updateMonitor(monitor.monitorId, updateMonitor)
.then((monitor) => MonitorResponseDto.from(monitor));
Expand Down
3 changes: 3 additions & 0 deletions app/libs/shared_modules/src/monitor/schemas/monitor.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ export class Monitor {

@Prop()
webhookId: string;

@Prop()
disabled: boolean;
}
export type MonitorDocument = HydratedDocument<Monitor>;
export const MonitorSchema = SchemaFactory.createForClass(Monitor);
Expand Down

0 comments on commit 81db12d

Please sign in to comment.