Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [SIG-582]: added planned maintenance create dialog #4863

Merged
merged 21 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
13734e2
feat: [SIG-582]: added planned maintenance create dialog
SagarRajput-7 Apr 14, 2024
89870ce
feat: [SIG-582]: added planned maintenance - listing
SagarRajput-7 Apr 17, 2024
e573455
feat: [SIG-582]: added alert rule select
SagarRajput-7 Apr 25, 2024
bd2f122
feat: [SIG-582]: added - planned maintenance list and createform ui f…
SagarRajput-7 Apr 26, 2024
1ded9ed
feat: [SIG-582]: added - alert-rule tag styles
SagarRajput-7 Apr 26, 2024
492c82b
feat: [SIG-582]: added - style changes
SagarRajput-7 Apr 26, 2024
036f4a3
feat: [SIG-582]: added - crud API integration and delete modal
SagarRajput-7 May 6, 2024
0bbea9f
feat: [SIG-582]: added - reccurrence form details
SagarRajput-7 May 15, 2024
0abeed7
feat: [SIG-582]: added - duration and timezone
SagarRajput-7 May 16, 2024
98b6b3e
feat: [SIG-582]: removed console logs
SagarRajput-7 May 16, 2024
bd8f88b
feat: [SIG-582]: added - form validation for duration and endTime
SagarRajput-7 May 16, 2024
a9e56b3
feat: [SIG-582]: code refactor
SagarRajput-7 May 16, 2024
fd7b5e5
feat: [SIG-582]: code refactor
SagarRajput-7 May 16, 2024
3f0dc7e
feat: [SIG-582]: code refactor
SagarRajput-7 May 16, 2024
9b035ac
feat: [SIG-582]: code refactor
SagarRajput-7 May 16, 2024
9c30dca
feat: [SIG-582]: light mode styles
SagarRajput-7 May 19, 2024
92413c3
feat: [SIG-582]: code refactor
SagarRajput-7 May 19, 2024
0333e58
feat: [SIG-582]: code refactor and comment resolve
SagarRajput-7 May 22, 2024
8867d0b
feat: [SIG-582]: code refactor and removed filters
SagarRajput-7 May 22, 2024
e46fb04
feat: [SIG-582]: changed coming up on to start time
SagarRajput-7 May 22, 2024
9dce166
feat: [SIG-582]: added planned downtime behind FF - PLANNED_MAINTENANCE
SagarRajput-7 May 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions frontend/src/api/plannedDowntime/createDowntimeSchedule.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import axios from 'api';
import { ErrorResponseHandler } from 'api/ErrorResponseHandler';
import { AxiosError } from 'axios';
import { ErrorResponse, SuccessResponse } from 'types/api';

import { Recurrence } from './getAllDowntimeSchedules';

export interface DowntimeSchedulePayload {
name: string;
description?: string;
alertIds: string[];
schedule: {
timezone?: string;
startTime?: string;
endTime?: string;
recurrence?: Recurrence;
};
}

export interface PayloadProps {
status: string;
data: string;
}

const createDowntimeSchedule = async (
props: DowntimeSchedulePayload,
): Promise<SuccessResponse<PayloadProps> | ErrorResponse> => {
try {
const response = await axios.post('/downtime_schedules', {
...props,
});

return {
statusCode: 200,
error: null,
message: response.data.status,
payload: response.data.data,
};
} catch (error) {
return ErrorResponseHandler(error as AxiosError);
vikrantgupta25 marked this conversation as resolved.
Show resolved Hide resolved
}
};

export default createDowntimeSchedule;
19 changes: 19 additions & 0 deletions frontend/src/api/plannedDowntime/deleteDowntimeSchedule.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import axios from 'api';
import { useMutation, UseMutationResult } from 'react-query';

export interface DeleteDowntimeScheduleProps {
id?: number;
}

export interface DeleteSchedulePayloadProps {
status: string;
data: string;
}

export const useDeleteDowntimeSchedule = (
props: DeleteDowntimeScheduleProps,
): UseMutationResult<DeleteSchedulePayloadProps, Error, number> =>
useMutation({
mutationKey: [props.id],
mutationFn: () => axios.delete(`/downtime_schedules/${props.id}`),
});
50 changes: 50 additions & 0 deletions frontend/src/api/plannedDowntime/getAllDowntimeSchedules.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import axios from 'api';
import { AxiosError, AxiosResponse } from 'axios';
import { Option } from 'container/PlannedDowntime/DropdownWithSubMenu/DropdownWithSubMenu';
import { useQuery, UseQueryResult } from 'react-query';

export type Recurrence = {
startTime?: string | null;
endTime?: string | null;
duration?: number | string | null;
repeatType?: string | Option | null;
repeatOn?: string[] | null;
};

type Schedule = {
timezone: string | null;
startTime: string | null;
endTime: string | null;
recurrence: Recurrence | null;
};

export interface DowntimeSchedules {
id: number;
name: string | null;
description: string | null;
schedule: Schedule | null;
alertIds: string[] | null;
createdAt: string | null;
createdBy: string | null;
updatedAt: string | null;
updatedBy: string | null;
}
export type PayloadProps = { data: DowntimeSchedules[] };

export const getAllDowntimeSchedules = async (
props?: GetAllDowntimeSchedulesPayloadProps,
): Promise<AxiosResponse<PayloadProps>> =>
axios.get('/downtime_schedules', { params: props });

export interface GetAllDowntimeSchedulesPayloadProps {
active?: boolean;
recurrence?: boolean;
}

export const useGetAllDowntimeSchedules = (
props?: GetAllDowntimeSchedulesPayloadProps,
): UseQueryResult<AxiosResponse<PayloadProps>, AxiosError> =>
useQuery<AxiosResponse<PayloadProps>, AxiosError>({
queryKey: ['getAllDowntimeSchedules', props],
queryFn: () => getAllDowntimeSchedules(props),
});
37 changes: 37 additions & 0 deletions frontend/src/api/plannedDowntime/updateDowntimeSchedule.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import axios from 'api';
import { ErrorResponseHandler } from 'api/ErrorResponseHandler';
import { AxiosError } from 'axios';
import { ErrorResponse, SuccessResponse } from 'types/api';

import { DowntimeSchedulePayload } from './createDowntimeSchedule';

export interface DowntimeScheduleUpdatePayload {
data: DowntimeSchedulePayload;
id?: number;
}

export interface PayloadProps {
status: string;
data: string;
}

const updateDowntimeSchedule = async (
props: DowntimeScheduleUpdatePayload,
): Promise<SuccessResponse<PayloadProps> | ErrorResponse> => {
try {
const response = await axios.put(`/downtime_schedules/${props.id}`, {
...props.data,
});

return {
statusCode: 200,
error: null,
message: response.data.status,
payload: response.data.data,
};
} catch (error) {
return ErrorResponseHandler(error as AxiosError);
vikrantgupta25 marked this conversation as resolved.
Show resolved Hide resolved
}
};

export default updateDowntimeSchedule;
1 change: 1 addition & 0 deletions frontend/src/constants/features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ export enum FeatureKeys {
OSS = 'OSS',
ONBOARDING = 'ONBOARDING',
CHAT_SUPPORT = 'CHAT_SUPPORT',
PLANNED_MAINTENANCE = 'PLANNED_MAINTENANCE',
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
.options {
width: 100%;
}

.option {
padding: 8px 10px;
cursor: pointer;
overflow: auto;
}

.option:hover {
background-color: var(--bg-slate-200);
}

.submenu-container {
position: absolute;
top: 0;
right: 50%;
z-index: 1;
background-color: var(--bg-ink-400);
border: 1px solid var(--bg-slate-500);
max-height: 300px;
overflow-y: auto;
width: 160px;
display: flex;
flex-direction: column;
gap: 6px;
padding: 12px;
border-radius: 4px;

.submenu-checkbox {
padding: 0px;
}
}

.dropdown-submenu {
.dropdown-input {
box-sizing: border-box;
margin: 0;
padding: 4.5px 11px;
color: rgba(255, 255, 255, 0.85);
font-size: 13px;
line-height: 1.6153846153846154;
list-style: none;
font-family: Inter;
position: relative;
display: inline-block;
min-width: 0;
transition: all 0.2s;
}

.ant-popover-inner {
padding: 0px;
}
}

.options-container {
position: relative;
--arrow-x: 175px;
--arrow-y: 266px;
width: 350px;
box-sizing: border-box;
margin: 0;
padding: 4px;
color: var(--bg-vanilla-400);
font-size: 12px;
line-height: 1.6153846153846154;
list-style: none;
font-family: Inter;
z-index: 1050;
overflow: hidden;
font-variant: initial;
background-color: var(--bg-ink-400);
border-radius: 2px;
outline: none;
box-shadow: 4px 10px 16px 2px rgba(0, 0, 0, 0.3);
}

.submenu-popover {
.ant-popover-inner {
padding: 0px;
}
}

.save-option-btn {
height: 24px;
padding: 0;
display: flex;
align-items: center;
justify-content: center;
align-self: flex-end;
width: 60px;
}

.submenu-header {
color: var(--bg-vanilla-200);
font-family: Inter;
font-size: 12px;
font-style: normal;
font-weight: 400;
padding-bottom: 8px;
text-transform: uppercase;
}

.lightMode {
.option:hover {
background-color: var(--bg-vanilla-200);
}

.submenu-container {
background-color: var(--bg-vanilla-100);
border: 1px solid var(--bg-vanilla-300);
}

.dropdown-submenu {
.dropdown-input {
color: var(--bg-slate-100);
}
}
.options-container {
color: var(--bg-slate-100);
background-color: var(--bg-vanilla-100);
}
.submenu-header {
color: var(--bg-slate-200);
}
}
Loading
Loading