Merge remote-tracking branch 'checkmate/develop' into fix/fe/profilepanel-ui
This commit is contained in:
commit
1d292b9553
137 files changed
+6910
-1994
No files matched your search
@@ -171,7 +171,6 @@ class NetworkService {
|
||||
async getMonitorsByTeamId(config) {
|
||||
const { authToken, teamId, limit, types, page, rowsPerPage, filter, field, order } =
|
||||
config;
|
||||
|
||||
const params = new URLSearchParams();
|
||||
|
||||
if (limit) params.append("limit", limit);
|
||||
@@ -862,6 +861,167 @@ class NetworkService {
|
||||
"https://api.github.com/repos/bluewave-labs/bluewave-uptime/releases/latest"
|
||||
);
|
||||
}
|
||||
|
||||
subscribeToDistributedUptimeMonitors(config) {
|
||||
const {
|
||||
authToken,
|
||||
teamId,
|
||||
onUpdate,
|
||||
onError,
|
||||
onOpen,
|
||||
limit,
|
||||
types,
|
||||
page,
|
||||
rowsPerPage,
|
||||
filter,
|
||||
field,
|
||||
order,
|
||||
} = config;
|
||||
|
||||
const params = new URLSearchParams();
|
||||
|
||||
if (limit) params.append("limit", limit);
|
||||
if (types) {
|
||||
types.forEach((type) => {
|
||||
params.append("type", type);
|
||||
});
|
||||
}
|
||||
if (page) params.append("page", page);
|
||||
if (rowsPerPage) params.append("rowsPerPage", rowsPerPage);
|
||||
if (filter) params.append("filter", filter);
|
||||
if (field) params.append("field", field);
|
||||
if (order) params.append("order", order);
|
||||
|
||||
if (this.eventSource) {
|
||||
this.eventSource.close();
|
||||
}
|
||||
|
||||
const url = `${this.axiosInstance.defaults.baseURL}/distributed-uptime/monitors/${teamId}?${params.toString()}`;
|
||||
this.eventSource = new EventSource(url, {
|
||||
headers: { Authorization: `Bearer ${authToken}` },
|
||||
});
|
||||
|
||||
this.eventSource.onopen = () => {
|
||||
onOpen?.();
|
||||
};
|
||||
|
||||
this.eventSource.addEventListener("open", (e) => {
|
||||
console.log("getDistributedUptimeMonitors connection opened:");
|
||||
});
|
||||
|
||||
this.eventSource.onmessage = (event) => {
|
||||
const data = JSON.parse(event.data);
|
||||
onUpdate(data);
|
||||
};
|
||||
|
||||
this.eventSource.onerror = (error) => {
|
||||
console.error("Monitor stream error:", error);
|
||||
onError?.();
|
||||
this.eventSource.close();
|
||||
};
|
||||
|
||||
// Returns a cleanup function
|
||||
return () => {
|
||||
if (this.eventSource) {
|
||||
this.eventSource.close();
|
||||
this.eventSource = null;
|
||||
}
|
||||
return () => {
|
||||
console.log("Nothing to cleanup");
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
subscribeToDistributedUptimeDetails(config) {
|
||||
const params = new URLSearchParams();
|
||||
const { authToken, monitorId, onUpdate, onOpen, onError, dateRange, normalize } =
|
||||
config;
|
||||
if (dateRange) params.append("dateRange", dateRange);
|
||||
if (normalize) params.append("normalize", normalize);
|
||||
|
||||
const url = `${this.axiosInstance.defaults.baseURL}/distributed-uptime/monitors/details/${monitorId}?${params.toString()}`;
|
||||
this.eventSource = new EventSource(url, {
|
||||
headers: { Authorization: `Bearer ${authToken}` },
|
||||
});
|
||||
|
||||
this.eventSource.onopen = (e) => {
|
||||
onOpen?.();
|
||||
};
|
||||
|
||||
this.eventSource.onmessage = (event) => {
|
||||
const data = JSON.parse(event.data);
|
||||
onUpdate(data);
|
||||
};
|
||||
|
||||
this.eventSource.onerror = (error) => {
|
||||
console.error("Monitor stream error:", error);
|
||||
onError?.();
|
||||
this.eventSource.close();
|
||||
};
|
||||
return () => {
|
||||
if (this.eventSource) {
|
||||
this.eventSource.close();
|
||||
this.eventSource = null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
async getStatusPage(config) {
|
||||
const { authToken } = config;
|
||||
return this.axiosInstance.get(`/status-page`, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${authToken}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async createStatusPage(config) {
|
||||
const { authToken, user, form, isCreate } = config;
|
||||
const fd = new FormData();
|
||||
fd.append("isPublished", form.isPublished);
|
||||
fd.append("companyName", form.companyName);
|
||||
fd.append("url", form.url);
|
||||
fd.append("timezone", form.timezone);
|
||||
fd.append("color", form.color);
|
||||
fd.append("showCharts", form.showCharts);
|
||||
fd.append("showUptimePercentage", form.showUptimePercentage);
|
||||
form.monitors.forEach((monitorId) => {
|
||||
fd.append("monitors[]", monitorId);
|
||||
});
|
||||
if (form?.logo?.src && form?.logo?.src !== "") {
|
||||
const imageResult = await axios.get(form.logo.src, {
|
||||
responseType: "blob",
|
||||
});
|
||||
fd.append("logo", imageResult.data);
|
||||
// Cleanup blob
|
||||
if (form.logo.src.startsWith("blob:")) {
|
||||
URL.revokeObjectURL(form.logo.src);
|
||||
}
|
||||
}
|
||||
if (isCreate) {
|
||||
return this.axiosInstance.post(`/status-page`, fd, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${authToken}`,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return this.axiosInstance.put(`/status-page`, fd, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${authToken}`,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async deleteStatusPage(config) {
|
||||
const { authToken } = config;
|
||||
return this.axiosInstance.delete(`/status-page`, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${authToken}`,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default NetworkService;
|
||||
|
||||
@@ -152,6 +152,11 @@ const newSemanticColors = {
|
||||
light: newColors.blueGray600,
|
||||
dark: newColors.gray200,
|
||||
},
|
||||
// CAIO_REVIEW, need a brighter color for dark bg
|
||||
contrastTextSecondaryDarkBg: {
|
||||
light: newColors.gray200,
|
||||
dark: newColors.gray200,
|
||||
},
|
||||
contrastTextTertiary: {
|
||||
light: newColors.blueGray500,
|
||||
dark: newColors.gray500,
|
||||
|
||||
@@ -21,6 +21,12 @@ const baseTheme = (palette) => ({
|
||||
color: palette.primary.contrastTextSecondary,
|
||||
fontWeight: 400,
|
||||
},
|
||||
// CAIO_REVIEW, need a brighter color for dark bg
|
||||
h2DarkBg: {
|
||||
fontSize: typographyLevels.l,
|
||||
color: palette.primary.contrastTextSecondaryDarkBg,
|
||||
fontWeight: 400,
|
||||
},
|
||||
body1: {
|
||||
fontSize: typographyLevels.m,
|
||||
color: palette.primary.contrastTextTertiary,
|
||||
@@ -53,6 +59,18 @@ const baseTheme = (palette) => ({
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
props: (props) => props.color === "error",
|
||||
style: {
|
||||
"&.Mui-disabled": {
|
||||
backgroundColor: theme.palette.error.lowContrast,
|
||||
},
|
||||
"& .MuiButton-loadingIndicator": {
|
||||
// styles for error variant loading indicator
|
||||
color: theme.palette.error.contrastText,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
props: (props) => props.variant === "group",
|
||||
style: {
|
||||
@@ -306,6 +324,44 @@ const baseTheme = (palette) => ({
|
||||
},
|
||||
},
|
||||
},
|
||||
MuiTab: {
|
||||
styleOverrides: {
|
||||
root: ({ theme }) => ({
|
||||
fontSize: 13,
|
||||
color: theme.palette.tertiary.contrastText,
|
||||
backgroundColor: theme.palette.tertiary.main,
|
||||
textTransform: "none",
|
||||
minWidth: "fit-content",
|
||||
paddingY: theme.spacing(6),
|
||||
fontWeight: 400,
|
||||
borderBottom: "2px solid transparent",
|
||||
borderRight: `1px solid ${theme.palette.primary.lowContrast}`,
|
||||
"&:first-of-type": { borderTopLeftRadius: "8px" },
|
||||
"&:last-child": { borderTopRightRadius: "8px", borderRight: 0 },
|
||||
"&:focus-visible": {
|
||||
color: theme.palette.primary.contrastText,
|
||||
borderColor: theme.palette.tertiary.contrastText,
|
||||
borderRightColor: theme.palette.primary.lowContrast,
|
||||
},
|
||||
"&.Mui-selected": {
|
||||
backgroundColor: theme.palette.secondary.main,
|
||||
color: theme.palette.secondary.contrastText,
|
||||
borderColor: theme.palette.secondary.contrastText,
|
||||
borderRightColor: theme.palette.primary.lowContrast,
|
||||
},
|
||||
"&:hover": {
|
||||
borderColor: theme.palette.primary.lowContrast,
|
||||
},
|
||||
}),
|
||||
},
|
||||
},
|
||||
MuiSvgIcon: {
|
||||
styleOverrides: {
|
||||
root: ({ theme }) => ({
|
||||
color: theme.palette.primary.contrastTextTertiary,
|
||||
}),
|
||||
},
|
||||
},
|
||||
},
|
||||
shape: {
|
||||
borderRadius: 2,
|
||||
|
||||
@@ -15,3 +15,22 @@ export const capitalizeFirstLetter = (str) => {
|
||||
}
|
||||
return str.charAt(0).toUpperCase() + str.slice(1);
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper function to get first letter as a lower case string
|
||||
* @param {string} str String whose first letter is to be lower cased
|
||||
* @returns A string with first letter lower cased
|
||||
*/
|
||||
|
||||
export const toLowerCaseFirstLetter = (str) => {
|
||||
if (str === null || str === undefined) {
|
||||
return "";
|
||||
}
|
||||
if (typeof str !== "string") {
|
||||
throw new TypeError("Input must be a string");
|
||||
}
|
||||
if (str.length === 0) {
|
||||
return "";
|
||||
}
|
||||
return str.charAt(0).toLowerCase() + str.slice(1);
|
||||
};
|
||||
Reference in new issue
Block a user