mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-01-16 23:00:51 +00:00
chore: Update probeKey type to string in CustomProbeDocumentation and ProbeView components
This commit updates the probeKey prop type from ObjectID to string in the CustomProbeDocumentation and ProbeView components. The probeKey is used to identify the probe and was previously defined as ObjectID, but it should be a string. This change ensures that the probeKey is correctly passed and used throughout the components, improving the accuracy and reliability of the application.
This commit is contained in:
parent
34888e9b7f
commit
56d3e7e1f2
8 changed files with 66 additions and 33 deletions
|
|
@ -62,16 +62,8 @@ RunCron(
|
|||
connectionStatus = ProbeConnectionStatus.Disconnected;
|
||||
}
|
||||
|
||||
let shouldNotifyProbeOwner: boolean = false;
|
||||
let shouldUpdateConnectionStatus: boolean = false;
|
||||
|
||||
if (
|
||||
probe.connectionStatus &&
|
||||
probe.connectionStatus !== connectionStatus
|
||||
) {
|
||||
shouldNotifyProbeOwner = true;
|
||||
}
|
||||
|
||||
if (probe.connectionStatus !== connectionStatus) {
|
||||
shouldUpdateConnectionStatus = true;
|
||||
}
|
||||
|
|
@ -93,17 +85,6 @@ RunCron(
|
|||
isRoot: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!probe.projectId) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (shouldNotifyProbeOwner) {
|
||||
await ProbeService.notifyOwnersOnStatusChange({
|
||||
probeId: probe.id,
|
||||
connectionStatus: connectionStatus,
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
logger.error(error);
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
import User from "Model/Models/User";
|
||||
import PostgresDatabase from "../Infrastructure/PostgresDatabase";
|
||||
import CreateBy from "../Types/Database/CreateBy";
|
||||
import { OnCreate } from "../Types/Database/Hooks";
|
||||
import { OnCreate, OnUpdate } from "../Types/Database/Hooks";
|
||||
import DatabaseService from "./DatabaseService";
|
||||
import ObjectID from "Common/Types/ObjectID";
|
||||
import Version from "Common/Types/Version";
|
||||
import Model, { ProbeConnectionStatus } from "Model/Models/Probe";
|
||||
import ProbeOwnerUser from "Model/Models/ProbeOwnerUser";
|
||||
import ProbeOwnerUserService from "./ProbeOwnerUserService";
|
||||
import { LIMIT_PER_PROJECT } from "Common/Types/Database/LimitMax";
|
||||
import LIMIT_MAX, { LIMIT_PER_PROJECT } from "Common/Types/Database/LimitMax";
|
||||
import ProbeOwnerTeam from "Model/Models/ProbeOwnerTeam";
|
||||
import ProbeOwnerTeamService from "./ProbeOwnerTeamService";
|
||||
import TeamMemberService from "./TeamMemberService";
|
||||
|
|
@ -25,6 +25,7 @@ import { EmailEnvelope } from "Common/Types/Email/EmailMessage";
|
|||
import EmailTemplateType from "Common/Types/Email/EmailTemplateType";
|
||||
import DatabaseConfig from "../DatabaseConfig";
|
||||
import URL from "Common/Types/API/URL";
|
||||
import UpdateBy from "../Types/Database/UpdateBy";
|
||||
|
||||
export class Service extends DatabaseService<Model> {
|
||||
public constructor(postgresDatabase?: PostgresDatabase) {
|
||||
|
|
@ -35,7 +36,7 @@ export class Service extends DatabaseService<Model> {
|
|||
createBy: CreateBy<Model>,
|
||||
): Promise<OnCreate<Model>> {
|
||||
if (!createBy.data.key) {
|
||||
createBy.data.key = ObjectID.generate();
|
||||
createBy.data.key = ObjectID.generate().toString();
|
||||
}
|
||||
|
||||
if (!createBy.data.probeVersion) {
|
||||
|
|
@ -118,6 +119,58 @@ export class Service extends DatabaseService<Model> {
|
|||
return users;
|
||||
}
|
||||
|
||||
protected override async onBeforeUpdate(
|
||||
updateBy: UpdateBy<Model>,
|
||||
): Promise<OnUpdate<Model>> {
|
||||
const carryForward: any = {
|
||||
probesToNotifyOwners: [],
|
||||
};
|
||||
|
||||
if (updateBy.data.connectionStatus && updateBy.query.id) {
|
||||
const probes: Array<Model> = await this.findBy({
|
||||
query: updateBy.query,
|
||||
props: {
|
||||
isRoot: true,
|
||||
},
|
||||
select: {
|
||||
_id: true,
|
||||
connectionStatus: true,
|
||||
},
|
||||
skip: 0,
|
||||
limit: LIMIT_MAX,
|
||||
});
|
||||
|
||||
const probesToNotifyOwners: Array<Model> = probes.filter(
|
||||
(probe: Model) => {
|
||||
return (
|
||||
probe.connectionStatus &&
|
||||
probe.connectionStatus !== updateBy.data.connectionStatus
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
carryForward.probesToNotifyOwners = probesToNotifyOwners;
|
||||
}
|
||||
|
||||
return { updateBy: updateBy, carryForward };
|
||||
}
|
||||
|
||||
protected override async onUpdateSuccess(
|
||||
onUpdate: OnUpdate<Model>,
|
||||
_updatedItemIds: Array<ObjectID>,
|
||||
): Promise<OnUpdate<Model>> {
|
||||
if (onUpdate.carryForward.probesToNotifyOwners.length > 0) {
|
||||
for (const probe of onUpdate.carryForward.probesToNotifyOwners) {
|
||||
await this.notifyOwnersOnStatusChange({
|
||||
probeId: probe.id!,
|
||||
connectionStatus: probe.connectionStatus!,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return Promise.resolve(onUpdate);
|
||||
}
|
||||
|
||||
public async notifyOwnersOnStatusChange(data: {
|
||||
probeId: ObjectID;
|
||||
connectionStatus: ProbeConnectionStatus;
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ const ResetObjectID: <TBaseModel extends BaseModel>(
|
|||
modelType: props.modelType,
|
||||
id: props.modelId,
|
||||
data: {
|
||||
[props.fieldName]: resetIdTo,
|
||||
[props.fieldName]: resetIdTo.toString(),
|
||||
},
|
||||
});
|
||||
setNewId(resetIdTo);
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import { HOST, HTTP_PROTOCOL } from "CommonUI/src/Config";
|
|||
import React, { FunctionComponent, ReactElement } from "react";
|
||||
|
||||
export interface ComponentProps {
|
||||
probeKey: ObjectID;
|
||||
probeKey: string;
|
||||
probeId: ObjectID;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ const TeamView: FunctionComponent<PageComponentProps> = (
|
|||
): ReactElement => {
|
||||
const [modelId] = useState<ObjectID>(Navigation.getLastParamAsObjectID());
|
||||
|
||||
const [probeKey, setProbeKey] = useState<ObjectID | null>(null);
|
||||
const [probeKey, setProbeKey] = useState<string | null>(null);
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import OneUptimeDate from "Common/Types/Date";
|
||||
import BadDataException from "Common/Types/Exception/BadDataException";
|
||||
import { JSONObject } from "Common/Types/JSON";
|
||||
import ObjectID from "Common/Types/ObjectID";
|
||||
import ClusterKeyAuthorization from "CommonServer/Middleware/ClusterKeyAuthorization";
|
||||
import ProbeService from "CommonServer/Services/ProbeService";
|
||||
import Express, {
|
||||
|
|
@ -39,7 +38,7 @@ router.post(
|
|||
|
||||
const probe: Probe | null = await ProbeService.findOneBy({
|
||||
query: {
|
||||
key: new ObjectID(probeKey),
|
||||
key: probeKey,
|
||||
isGlobalProbe: true,
|
||||
},
|
||||
select: {
|
||||
|
|
@ -72,7 +71,7 @@ router.post(
|
|||
|
||||
let newProbe: Probe = new Probe();
|
||||
newProbe.isGlobalProbe = true;
|
||||
newProbe.key = new ObjectID(probeKey);
|
||||
newProbe.key = probeKey;
|
||||
newProbe.name = data["probeName"] as string;
|
||||
newProbe.description = data["probeDescription"] as string;
|
||||
newProbe.lastAlive = OneUptimeDate.getCurrentDate();
|
||||
|
|
|
|||
|
|
@ -98,15 +98,14 @@ export default class Probe extends BaseModel {
|
|||
@TableColumn({
|
||||
required: true,
|
||||
unique: true,
|
||||
type: TableColumnType.ObjectID,
|
||||
type: TableColumnType.ShortText,
|
||||
})
|
||||
@Column({
|
||||
type: ColumnType.ObjectID,
|
||||
type: ColumnType.ShortText,
|
||||
nullable: false,
|
||||
unique: true,
|
||||
transformer: ObjectID.getDatabaseTransformer(),
|
||||
})
|
||||
public key?: ObjectID = undefined;
|
||||
public key?: string = undefined;
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [
|
||||
|
|
@ -510,6 +509,7 @@ export default class Probe extends BaseModel {
|
|||
title: "Connection Status",
|
||||
description: "Connection Status of the Probe",
|
||||
type: TableColumnType.ShortText,
|
||||
canReadOnRelationQuery: true,
|
||||
})
|
||||
@Column({
|
||||
type: ColumnType.ShortText,
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ export default class Register {
|
|||
if (!pingMonitoringCheck && websiteMonitoringCheck) {
|
||||
// probe is online but ping monitoring is blocked by the cloud provider. Fallback to port monitoring.
|
||||
logger.warn(
|
||||
"Ping monitoring is on this machine. Fallback to port monitoring",
|
||||
"Ping monitoring is disabled on this machine. Fallback to port monitoring",
|
||||
);
|
||||
LocalCache.setString("PROBE", "PING_MONITORING", "PORT");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue