Skip to content

Commit

Permalink
Add name to monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
thongnguyen5 authored and thongnguyendev committed Apr 11, 2024
1 parent 4ad1b66 commit 175dfe6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
12 changes: 12 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 @@ -150,11 +150,16 @@ export class CreateMonitorDto {
@ApiProperty()
tags: string[];

@ApiProperty()
@IsNotEmpty()
name: string;

toMonitor(createdBy: string): Monitor {
return Builder<Monitor>()
.projectId(this.projectId)
.monitorId(generateMonitorId())
.network(this.network)
.name(this.name)
.condition(
Builder<MonitorCondition>()
.native(this.condition.native)
Expand Down Expand Up @@ -185,6 +190,9 @@ export class MonitorResponseDto {
@ApiResponseProperty()
network: MonitorNetwork;

@ApiResponseProperty()
name: string;

@ApiResponseProperty()
condition: MonitorCondition;

Expand All @@ -208,6 +216,7 @@ export class MonitorResponseDto {
.projectId(monitor.projectId)
.monitorId(monitor.monitorId)
.network(monitor.network)
.name(monitor.name)
.condition(monitor.condition)
.notification(monitor.notification)
.type(monitor.type)
Expand All @@ -232,6 +241,9 @@ export class DeleteMonitorResponseDto {
export class UpdateMonitorDto {
monitorId: string;

@ApiProperty()
name: string;

@ApiProperty({
example: {
native: true,
Expand Down
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 @@ -130,6 +130,9 @@ export class MonitorService {
throw new ServiceException('not authorized', 401);
}
const updateMonitor = new Map<string, any>();
if (request.name) {
updateMonitor['name'] = request.name;
}
if (request.condition) {
if (request.condition.native != undefined) {
updateMonitor['condition.native'] = request.condition.native;
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 @@ -74,6 +74,9 @@ export class Monitor {
@Prop({ required: true })
network: MonitorNetwork;

@Prop({ required: true })
name: string;

@Prop()
condition: MonitorCondition;

Expand Down

0 comments on commit 175dfe6

Please sign in to comment.