mirror of https://github.com/statping/statping
[statping-ui] : moved generateTooltipPosition to util
parent
87ee195de4
commit
ee3f8bcd63
|
@ -6,7 +6,11 @@ import API from "../config/API";
|
||||||
import ServiceLoader from "./ServiceLoader";
|
import ServiceLoader from "./ServiceLoader";
|
||||||
import ReactTooltip from "react-tooltip";
|
import ReactTooltip from "react-tooltip";
|
||||||
import { STATUS_CLASS } from "../utils/constants";
|
import { STATUS_CLASS } from "../utils/constants";
|
||||||
import { calcPer, isObjectEmpty } from "../utils/helper";
|
import {
|
||||||
|
calcPer,
|
||||||
|
generateTooltipPosition,
|
||||||
|
isObjectEmpty,
|
||||||
|
} from "../utils/helper";
|
||||||
import { errorToastConfig } from "../utils/toast";
|
import { errorToastConfig } from "../utils/toast";
|
||||||
|
|
||||||
const STATUS_TEXT = {
|
const STATUS_TEXT = {
|
||||||
|
@ -132,21 +136,6 @@ const GroupServiceFailures = ({ group = null, service, collapse }) => {
|
||||||
|
|
||||||
if (loaded) return <ServiceLoader text="Loading series.." />;
|
if (loaded) return <ServiceLoader text="Loading series.." />;
|
||||||
|
|
||||||
const generateTooltipPosition = (...args) => {
|
|
||||||
const position = args?.[0]; //tooltip default position
|
|
||||||
const place = args?.[4]; // tooltip placement
|
|
||||||
const offset = 6;
|
|
||||||
|
|
||||||
if (place === "left" || place === "right") {
|
|
||||||
return {
|
|
||||||
top: position.top,
|
|
||||||
left:
|
|
||||||
place === "left" ? position.left + offset : position.left - offset,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return position;
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div name="fade" style={{ display: collapse ? "none" : "block" }}>
|
<div name="fade" style={{ display: collapse ? "none" : "block" }}>
|
||||||
<div className="block-chart">
|
<div className="block-chart">
|
||||||
|
|
|
@ -90,3 +90,17 @@ export const generateUUID = (length) => {
|
||||||
Math.floor(Math.random() * 36).toString(36)
|
Math.floor(Math.random() * 36).toString(36)
|
||||||
).join("");
|
).join("");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const generateTooltipPosition = (...args) => {
|
||||||
|
const position = args?.[0]; //tooltip default position
|
||||||
|
const place = args?.[4]; // tooltip placement
|
||||||
|
const offset = 6;
|
||||||
|
|
||||||
|
if (place === "left" || place === "right") {
|
||||||
|
return {
|
||||||
|
top: position.top,
|
||||||
|
left: place === "left" ? position.left + offset : position.left - offset,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return position;
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in New Issue