Skip to content

Commit

Permalink
restructure monitor settings
Browse files Browse the repository at this point in the history
  • Loading branch information
naueramant committed Feb 4, 2024
1 parent 69ac2ee commit 62caa46
Show file tree
Hide file tree
Showing 39 changed files with 597 additions and 620 deletions.
5 changes: 3 additions & 2 deletions apps/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@mui/styled-engine-sc": "^5.14.12",
"@mui/x-data-grid": "^6.16.1",
"@ngneat/falso": "^7.1.1",
"@opsway/ui": "workspace:*",
"@tanstack/react-query": "^4.36.1",
"@testing-library/jest-dom": "^6.1.3",
"@testing-library/react": "^14.0.0",
Expand Down Expand Up @@ -55,8 +56,7 @@
"uuid": "^9.0.1",
"web-vitals": "^3.5.0",
"zustand": "^4.4.3",
"zxcvbn": "^4.4.2",
"@opsway/ui": "workspace:*"
"zxcvbn": "^4.4.2"
},
"scripts": {
"dev": "vite",
Expand All @@ -76,6 +76,7 @@
]
},
"devDependencies": {
"@hookform/devtools": "^4.3.1",
"@vitejs/plugin-react": "^4.1.0",
"axios-logger": "^2.7.0",
"axios-mock-adapter": "^1.22.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import client from "../client";
import { IGetUserResponse } from "./users";
import client from "../../client";
import { IGetUserResponse } from "../users";

export interface ILoginRequest {
email: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
import client from "../client";
import client from "../../client";

export interface IChangelog {
/*
Shared
*/

export interface Changelog {
id: number;
name: string;
createdAt: Date;
updatedAt: string;
}

export interface IChangelogsResponse {
changelogs: IChangelog[];
export interface GetChangelogsResponse {
changelogs: Changelog[];
totalCount: number;
}

/*
Get Changelogs
*/

export async function getChangelogs(
teamId: number,
offset?: number,
limit?: number,
query?: string,
): Promise<IChangelogsResponse> {
): Promise<GetChangelogsResponse> {
const response = await client.get(`/v1/teams/${teamId}/changelogs`, {
params: {
offset,
Expand All @@ -29,30 +37,42 @@ export async function getChangelogs(
return response?.data;
}

export interface IChangelogResponse extends IChangelog {}
/*
Get Changelog
*/

export interface GetChangelogResponse extends Changelog {}

export async function getChangelog(
teamId: number,
changelogId: number,
): Promise<IChangelogResponse> {
): Promise<GetChangelogResponse> {
const response = await client.get(
`/v1/teams/${teamId}/changelogs/${changelogId}`,
);

return response?.data;
}

export async function postChangelog(
/*
Create Changelog
*/

export async function createChangelog(
teamId: number,
name: string,
): Promise<IChangelogResponse> {
): Promise<GetChangelogResponse> {
const response = await client.post(`/v1/teams/${teamId}/changelogs`, {
name,
});

return response?.data;
}

/*
Delete Changelog
*/

export async function deleteChangelog(
teamId: number,
changelogId: number,
Expand Down
1 change: 1 addition & 0 deletions apps/dashboard/src/api/endpoints/changelogs/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./changelogs";
160 changes: 0 additions & 160 deletions apps/dashboard/src/api/endpoints/monitors.ts

This file was deleted.

73 changes: 73 additions & 0 deletions apps/dashboard/src/api/endpoints/monitors/checks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import client from "../../client";

/*
Shared
*/

export interface Check {
id: string;
statusCode: number;
timing: Timing;
tls: TLS;
createdAt: string;
}
export interface Timing {
dnsLookup: number;
tcpConnection: number;
tlsHandshake: number;
serverProcessing: number;
contentTransfer: number;
total: number;
}

export interface TLS {
version: string;
cipher: string;
issuer: string;
subject: string;
notBefore: Date;
notAfter: Date;
}

/*
Get Monitor Checks
*/

export interface GetMonitorChecksResponse {
checks: Check[];
}

export async function getMonitorChecks(
teamId: number,
monitorId: number,
offset?: number,
limit?: number,
): Promise<GetMonitorChecksResponse> {
const response = await client.get(
`/v1/teams/${teamId}/monitors/${monitorId}/checks`,
{
params: {
offset,
limit,
},
},
);

return response?.data;
}

/*
Get Monitor Check
*/

export async function getMonitorCheck(
teamId: number,
monitorId: number,
checkId: number,
): Promise<Check> {
const response = await client.get(
`/v1/teams/${teamId}/monitors/${monitorId}/checks/${checkId}`,
);

return response?.data;
}
3 changes: 3 additions & 0 deletions apps/dashboard/src/api/endpoints/monitors/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from "./checks";
export * from "./metrics";
export * from "./monitors";
33 changes: 33 additions & 0 deletions apps/dashboard/src/api/endpoints/monitors/metrics.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import client from "../../client";

/*
Shared
*/

export interface Metric {
name: string;
timing: MetricTiming[];
}

export interface MetricTiming {
timing: number;
start: string;
}

/*
Get monitor metrics
*/

export interface getMonitorMetricsResponse {
metrics: Metric[];
}

export async function getMonitorMetrics(
teamId: number,
monitorId: number,
): Promise<getMonitorMetricsResponse> {
const response = await client.get(
`/v1/teams/${teamId}/monitors/${monitorId}/metrics`,
);
return response?.data;
}
Loading

0 comments on commit 62caa46

Please sign in to comment.