Skip to content

Commit

Permalink
Refactor MonitorTest table to remove "lastMonitoringLog" column and a…
Browse files Browse the repository at this point in the history
…dd "monitorStepProbeResponse" and "isInQueue" columns
  • Loading branch information
simlarsen committed Oct 29, 2024
1 parent c2bb44f commit d99111b
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
import { MigrationInterface, QueryRunner } from "typeorm";

export class MigrationName1730223198692 implements MigrationInterface {
public name = 'MigrationName1730223198692'
public name = "MigrationName1730223198692";

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "MonitorTest" DROP COLUMN "lastMonitoringLog"`);
await queryRunner.query(`ALTER TABLE "MonitorTest" ADD "monitorStepProbeResponse" jsonb`);
await queryRunner.query(`ALTER TABLE "MonitorTest" ADD "isInQueue" boolean DEFAULT true`);

}

public async down(queryRunner: QueryRunner): Promise<void> {

await queryRunner.query(`ALTER TABLE "MonitorTest" DROP COLUMN "isInQueue"`);
await queryRunner.query(`ALTER TABLE "MonitorTest" DROP COLUMN "monitorStepProbeResponse"`);
await queryRunner.query(`ALTER TABLE "MonitorTest" ADD "lastMonitoringLog" jsonb`);
}
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "MonitorTest" DROP COLUMN "lastMonitoringLog"`,
);
await queryRunner.query(
`ALTER TABLE "MonitorTest" ADD "monitorStepProbeResponse" jsonb`,
);
await queryRunner.query(
`ALTER TABLE "MonitorTest" ADD "isInQueue" boolean DEFAULT true`,
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "MonitorTest" DROP COLUMN "isInQueue"`,
);
await queryRunner.query(
`ALTER TABLE "MonitorTest" DROP COLUMN "monitorStepProbeResponse"`,
);
await queryRunner.query(
`ALTER TABLE "MonitorTest" ADD "lastMonitoringLog" jsonb`,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -159,5 +159,5 @@ export default [
MigrationName1729682875503,
MigrationName1730117995642,
MigrationName1730209089495,
MigrationName1730223198692
MigrationName1730223198692,
];
6 changes: 4 additions & 2 deletions Common/UI/Components/Loader/Loader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,20 @@ export interface ComponentProps {
size?: undefined | number;
color?: undefined | Color;
loaderType?: undefined | LoaderType;
className?: string;
}

const Loader: FunctionComponent<ComponentProps> = ({
size = 50,
color = VeryLightGray,
loaderType = LoaderType.Bar,
className = "",
}: ComponentProps) => {
if (loaderType === LoaderType.Bar) {
return (
<div
role="bar-loader mt-1"
className="justify-center"
role={`bar-loader mt-1 ${className}`}
className="flex justify-center"
data-testid="loader"
>
<BarLoader height={4} width={size} color={color.toString()} />
Expand Down
2 changes: 1 addition & 1 deletion Dashboard/src/Components/Form/Monitor/MonitorSteps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const MonitorStepsElement: FunctionComponent<ComponentProps> = (
const [onCallPolicyDropdownOptions, setOnCallPolicyDropdownOptions] =
React.useState<Array<DropdownOption>>([]);

const [probes, setProbes] = React.useState<Array<Probe>>([]);
const [probes, setProbes] = React.useState<Array<Probe>>([]);

const [isLoading, setIsLoading] = React.useState<boolean>(false);
const [error, setError] = React.useState<string>();
Expand Down
25 changes: 14 additions & 11 deletions Dashboard/src/Components/Form/Monitor/MonitorTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const MonitorTestForm: FunctionComponent<ComponentProps> = (

attempts++;

if (attempts > 10) {
if (attempts > 10 && !result?.monitorStepProbeResponse) {
clearInterval(interval);
setIsLoading(false);
setError(
Expand All @@ -119,13 +119,10 @@ const MonitorTestForm: FunctionComponent<ComponentProps> = (
}
};



return (
<div>
<div className="-ml-3">
<Button

buttonStyle={ButtonStyleType.NORMAL}
buttonSize={ButtonSize.Small}
title="Test Monitor"
Expand Down Expand Up @@ -191,15 +188,21 @@ const MonitorTestForm: FunctionComponent<ComponentProps> = (
>
<div>
{error && <ErrorMessage error={error} />}
{isLoading && <div className="w-full text-center min-h-24 flex justify-center">
<Loader loaderType={LoaderType.Bar} size={200} />
{isLoading && (
<div className="w-full text-center mt-5 mb-5">
<Loader
className="m-auto"
loaderType={LoaderType.Bar}
size={200}
/>

<div className="text-xs text-gray-500 text-center mt-3">
Running Monitor Test. This usually takes a minute or two to
complete.
<div className="text-xs text-gray-500 text-center mt-3">
Running monitor test on a probe. This usually takes a minute
or two to complete because we need to notify the probe to run
the test.
</div>
</div>

</div>}
)}
{monitorStepProbeResponse && (
<div className="mt-3">
<SummaryInfo
Expand Down

0 comments on commit d99111b

Please sign in to comment.