Skip to content

Commit

Permalink
[#noissue] fix: opentelmetric intl
Browse files Browse the repository at this point in the history
  • Loading branch information
BillionaireDY authored and binDongKim committed Sep 4, 2024
1 parent 253029d commit beca3d3
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"SUBMIT_SUCCESS": "Successfully submitted.",
"SUBMIT_FAIL": "Failed to submit.",
"REMOVE_SUCCESS": "Successfully removed.",
"TARGET_REMOVE_SUCCESS": "\"{{target}}\" has been deleted.",
"REMOVE_FAIL": "Failed to remove."
},
"APP_SELECT": {
Expand Down Expand Up @@ -62,7 +63,9 @@
"METRIC": "Metric",
"CREATE_METRIC_BUTTON": "Create a new metric",
"CREATE_METRIC_DESC": "Create a new metric",
"SAVE_DASHBOARD": "Save Dashboard"
"SAVE_DASHBOARD": "Save Dashboard",
"SAVE_DASHBOARD_SUCCESS": "The current dashboard status has been saved.",
"SAVE_DASHBOARD_FAIL": "Saving the current dashboard status failed."
},
"CONFIGURATION": {
"GENERAL": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"SUBMIT_SUCCESS": "등록되었습니다.",
"SUBMIT_FAIL": "등록에 실패하였습니다.",
"REMOVE_SUCCESS": "삭제되었습니다.",
"TARGET_REMOVE_SUCCESS": "\"{{target}}\"이(가) 삭제되었습니다.",
"REMOVE_FAIL": "삭제에 실패하였습니다."
},
"APP_SELECT": {
Expand Down Expand Up @@ -62,7 +63,9 @@
"METRIC": "메트릭",
"CREATE_METRIC_BUTTON": "새 메트릭 생성",
"CREATE_METRIC_DESC": "새로운 메트릭을 생성합니다.",
"SAVE_DASHBOARD": "대시보드 저장"
"SAVE_DASHBOARD": "대시보드 저장",
"SAVE_DASHBOARD_SUCCESS": "현재 대시보드 상태를 저장했습니다.",
"SAVE_DASHBOARD_FAIL": "현재 대시보드 상태 저장에 실패했습니다."
},
"CONFIGURATION": {
"GENERAL": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export const Widget = ({ title, children, onClickEdit, onClickDelete }: WidgetPr
<h3 className="flex-1 pl-1 text-sm truncate">{title}</h3>
<DropdownMenu>
<DropdownMenuTrigger className="@md:hidden">
{/* <button */}
<Button variant="ghost" className="px-2 py-1 rounded-sm h-7">
<RxDotsVertical />
</Button>
Expand All @@ -63,7 +62,7 @@ export const Widget = ({ title, children, onClickEdit, onClickDelete }: WidgetPr
</Button>
</div>
</div>
{children && <div className="h-[calc(100%-2rem)]">{children}</div>}
{children && <div className="h-[calc(100%-2rem)] px-2 py-1">{children}</div>}
</div>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ export const OpenTelemetryDashboardFetcher = () => {
refetch();
setCurrentDeletingTarget(undefined);
setCurrentEditingTarget(undefined);
toast.success('success');
} else {
toast.error('fail');
}
},
});
Expand All @@ -63,6 +60,26 @@ export const OpenTelemetryDashboardFetcher = () => {
layouts: { sm: [] },
});

const updateMetricsWithToastMessage = (
props: Parameters<typeof updateMetrics>[0],
{
successMessage,
errorMessage,
}: {
successMessage: string;
errorMessage: string;
},
) => {
updateMetrics(props, {
onSuccess: () => {
toast.success(successMessage);
},
onError: () => {
toast.error(errorMessage);
},
});
};

// grid-layout 변경 시 사용
const onLayoutChange = (layouts: ReactGridLayout.Layout[], layout: ReactGridLayout.Layouts) => {
console.log('layouts', layouts, layout);
Expand Down Expand Up @@ -107,10 +124,16 @@ export const OpenTelemetryDashboardFetcher = () => {
},
};
});
updateMetrics({
applicationName: applicationName,
appMetricDefinitionList: newMetics as OtlpMetricDefUserDefined.Metric[],
});
updateMetricsWithToastMessage(
{
applicationName: applicationName,
appMetricDefinitionList: newMetics as OtlpMetricDefUserDefined.Metric[],
},
{
successMessage: t('OPEN_TELEMETRY.SAVE_DASHBOARD_SUCCESS'),
errorMessage: t('SAVE_DASHBOARD_FAIL.SAVE_DASHBOARD_FAIL'),
},
);
}
};

Expand Down Expand Up @@ -213,11 +236,18 @@ export const OpenTelemetryDashboardFetcher = () => {
const targetExceptedMetrics = metrics.filter(
(m) => m.id !== currentDeletingTarget.id,
);
updateMetrics({
// TODO
applicationName,
appMetricDefinitionList: targetExceptedMetrics,
});
updateMetricsWithToastMessage(
{
applicationName,
appMetricDefinitionList: targetExceptedMetrics,
},
{
successMessage: t('COMMON.TARGET_REMOVE_SUCCESS', {
target: `${currentDeletingTarget.title}`,
}),
errorMessage: t('COMMON.REMOVE_FAIL'),
},
);
}
}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,11 @@ export const MetricDefinitionFormFetcher = ({
const { mutate: updateMetrics } = usePatchOtlpMetricDefUserDefined({
onSuccess: (res) => {
if (res.result === 'SUCCESS') {
toast.success(
`${metricDefinitionForm.getValues().title}을(를) ${metric?.id ? '수정했습니다.' : '생성했습니다.'}`,
);
toast.success(`${metric?.id ? t('COMMON.UPDATE_SUCCESS') : t('COMMON.CREATE_SUCCESS')}`);
refetch();
onComplete?.();
} else {
toast.error('fail');
toast.error(`${metric?.id ? t('COMMON.UPDATE_FAIL') : t('COMMON.CREATE_FAILED')}`);
}
},
});
Expand Down Expand Up @@ -229,7 +227,7 @@ export const MetricDefinitionFormFetcher = ({
className="relative flex-1 overflow-y-auto"
onSubmit={metricDefinitionForm.handleSubmit(handleSubmit)}
>
<div className="p-4 space-y-4 md:space-y-6 md:p-6">
<div className="p-4 space-y-4 md:p-6">
<h3 className="py-3 font-medium">1. Data configuration</h3>
<FormField
name="metricGroupName"
Expand Down Expand Up @@ -473,7 +471,7 @@ export const MetricDefinitionFormFetcher = ({
/>
</div>
<Separator className="mt-3" />
<div className="p-4 space-y-4 md:space-y-6 md:p-6">
<div className="p-4 space-y-4 md:p-6">
<h3 className="py-3 font-medium">2. Graph configuration</h3>
<FormField
name="chartType"
Expand Down

0 comments on commit beca3d3

Please sign in to comment.