- Update to add status page subdomain as env variable
- Adjust Server lists and Add new layout etc - Adjust Save button
This commit is contained in:
1 parent
8b72f8447d
commit
5226f3c9b1
8 files changed
+149
-138
No files matched your search
@@ -1 +1,2 @@
|
|||||||
VITE_APP_API_BASE_URL=UPTIME_APP_API_BASE_URL
|
VITE_APP_API_BASE_URL=UPTIME_APP_API_BASE_URL
|
||||||
|
VITE_STATUS_PAGE_SUBDOMAIN_PREFIX=UPTIME_STATUS_PAGE_SUBDOMAIN_PREFIX
|
||||||
@@ -150,7 +150,7 @@ const ContentPanel = () => {
|
|||||||
>
|
>
|
||||||
<Stack
|
<Stack
|
||||||
direction="row"
|
direction="row"
|
||||||
justifyContent="space-around"
|
justifyContent="space-between"
|
||||||
>
|
>
|
||||||
<Typography
|
<Typography
|
||||||
component="p"
|
component="p"
|
||||||
@@ -163,7 +163,7 @@ const ContentPanel = () => {
|
|||||||
onClick={handleAddNew}
|
onClick={handleAddNew}
|
||||||
disabled={monitors.length === 0 || monitors.length <= cards.length}
|
disabled={monitors.length === 0 || monitors.length <= cards.length}
|
||||||
>
|
>
|
||||||
Add New
|
Add new
|
||||||
</Button>
|
</Button>
|
||||||
</Stack>
|
</Stack>
|
||||||
{cards.length > 0 && (
|
{cards.length > 0 && (
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ const GeneralSettingsPanel = () => {
|
|||||||
|
|
||||||
const [progress, setProgress] = useState({ value: 0, isLoading: false });
|
const [progress, setProgress] = useState({ value: 0, isLoading: false });
|
||||||
const intervalRef = useRef(null);
|
const intervalRef = useRef(null);
|
||||||
|
const SUBDOAMIN_PREFIX =
|
||||||
|
import.meta.env.VITE_STATUS_PAGE_SUBDOMAIN_PREFIX ?? "http://localhost/";
|
||||||
|
|
||||||
// Clears specific error from errors state
|
// Clears specific error from errors state
|
||||||
const clearError = (err) => {
|
const clearError = (err) => {
|
||||||
@@ -178,7 +180,7 @@ const GeneralSettingsPanel = () => {
|
|||||||
value={form.url}
|
value={form.url}
|
||||||
startAdornment={
|
startAdornment={
|
||||||
<HttpAdornment
|
<HttpAdornment
|
||||||
prefix={"http://uptimegenie.com/"}
|
prefix={SUBDOAMIN_PREFIX}
|
||||||
https={false}
|
https={false}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,150 +20,154 @@ import { networkService } from "../../../main";
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
const CreateStatus = ({ initForm }) => {
|
const CreateStatus = ({ initForm }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const mode = useSelector((state) => state.ui.mode);
|
const mode = useSelector((state) => state.ui.mode);
|
||||||
const { authToken } = useSelector((state) => state.auth);
|
const { authToken } = useSelector((state) => state.auth);
|
||||||
const {apiBaseUrl} = useSelector((state) => state.settings);
|
const [tabIdx, setTabIdx] = useState(0);
|
||||||
const [tabIdx, setTabIdx] = useState(0);
|
const [errors, setErrors] = useState({});
|
||||||
const [errors, setErrors] = useState({});
|
const error_tab_maping = [
|
||||||
const error_tab_maping = [["companyName","url","timezone","color","publish","logo"],["monitors",
|
["companyName", "url", "timezone", "color", "publish", "logo"],
|
||||||
"showUptimePercentage", "showBarcode"]]
|
["monitors", "showUptimePercentage", "showBarcode"],
|
||||||
const tabList = ["General Settings", "Contents"];
|
];
|
||||||
const hasInitForm = initForm && Object.keys(initForm).length > 0;
|
const tabList = ["General Settings", "Contents"];
|
||||||
const [form, setForm] = useState(
|
const hasInitForm = initForm && Object.keys(initForm).length > 0;
|
||||||
hasInitForm
|
const [form, setForm] = useState(
|
||||||
? initForm
|
hasInitForm
|
||||||
: {
|
? initForm
|
||||||
companyName: "",
|
: {
|
||||||
url: "",
|
companyName: "",
|
||||||
timezone: "America/Toronto",
|
url: "",
|
||||||
color: "#4169E1",
|
timezone: "America/Toronto",
|
||||||
//which fields matching below?
|
color: "#4169E1",
|
||||||
//publish: false,
|
//which fields matching below?
|
||||||
logo: null,
|
//publish: false,
|
||||||
monitors: [],
|
logo: null,
|
||||||
// showUptimePercentage: false,
|
monitors: [],
|
||||||
// showBarcode: false,
|
// showUptimePercentage: false,
|
||||||
}
|
// showBarcode: false,
|
||||||
);
|
}
|
||||||
const setActiveTabOnErrors = () => {
|
);
|
||||||
let newIdx = -1;
|
const setActiveTabOnErrors = () => {
|
||||||
Object.keys(errors).map((id) => {
|
let newIdx = -1;
|
||||||
if (newIdx !== -1) return;
|
Object.keys(errors).map((id) => {
|
||||||
error_tab_maping.map((val, idx) => {
|
if (newIdx !== -1) return;
|
||||||
let anyMatch = val.some((vl) => vl == id);
|
error_tab_maping.map((val, idx) => {
|
||||||
if (anyMatch) {
|
let anyMatch = val.some((vl) => vl == id);
|
||||||
newIdx = idx;
|
if (anyMatch) {
|
||||||
return;
|
newIdx = idx;
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
if (newIdx !== -1) setTabIdx(newIdx);
|
||||||
if (newIdx !== -1) setTabIdx(newIdx);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleTabChange = (_, newTab) => {
|
|
||||||
setTabIdx(tabList.indexOf(newTab));
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleSubmit = async (e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
let localData = {
|
|
||||||
...form,
|
|
||||||
monitors:
|
|
||||||
form.monitors[0] && Object.keys(form.monitors[0]).includes("_id")
|
|
||||||
? form.monitors.map((m) => m._id)
|
|
||||||
: form.monitors,
|
|
||||||
theme: mode,
|
|
||||||
logo: { type: form.logo?.type ?? "", size: form.logo?.size ?? "" },
|
|
||||||
};
|
};
|
||||||
//delete localData.logo
|
|
||||||
if (hasValidationErrors(localData, publicPageGeneralSettingsValidation, setErrors)) {
|
|
||||||
setActiveTabOnErrors();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//form.logo = { ...logo, size: formatBytes(logo?.size) };
|
const handleTabChange = (_, newTab) => {
|
||||||
let config = { authToken: authToken, url: "status-page", data: localData };
|
setTabIdx(tabList.indexOf(newTab));
|
||||||
try {
|
};
|
||||||
const res = await networkService.createStatusPage(config);
|
|
||||||
if (!res.status === 200) {
|
const handleSubmit = async (e) => {
|
||||||
throw new Error("Failed to create status page");
|
e.preventDefault();
|
||||||
|
let localData = {
|
||||||
|
...form,
|
||||||
|
monitors:
|
||||||
|
form.monitors[0] && Object.keys(form.monitors[0]).includes("_id")
|
||||||
|
? form.monitors.map((m) => m._id)
|
||||||
|
: form.monitors,
|
||||||
|
theme: mode,
|
||||||
|
logo: { type: form.logo?.type ?? "", size: form.logo?.size ?? "" },
|
||||||
|
};
|
||||||
|
//delete localData.logo
|
||||||
|
if (
|
||||||
|
hasValidationErrors(localData, publicPageGeneralSettingsValidation, setErrors)
|
||||||
|
) {
|
||||||
|
setActiveTabOnErrors();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
createToast({ body: "Status page created successfully!" });
|
|
||||||
} catch (e) {
|
|
||||||
createToast({ body: e.message || "Error creating status page" });
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
//form.logo = { ...logo, size: formatBytes(logo?.size) };
|
||||||
<Box
|
let config = { authToken: authToken, url: "status-page", data: localData };
|
||||||
className="status"
|
try {
|
||||||
px={theme.spacing(20)}
|
const res = await networkService.createStatusPage(config);
|
||||||
py={theme.spacing(12)}
|
if (!res.status === 200) {
|
||||||
border={1}
|
throw new Error("Failed to create status page");
|
||||||
borderColor={theme.palette.border.light}
|
}
|
||||||
borderRadius={theme.shape.borderRadius}
|
createToast({ body: "Status page created successfully!" });
|
||||||
backgroundColor={theme.palette.background.main}
|
} catch (e) {
|
||||||
>
|
createToast({ body: e.message || "Error creating status page" });
|
||||||
<TabContext value={tabList[tabIdx]}>
|
}
|
||||||
<Box
|
};
|
||||||
sx={{
|
|
||||||
borderBottom: 1,
|
return (
|
||||||
borderColor: theme.palette.border.light,
|
|
||||||
"& .MuiTabs-root": { height: "fit-content", minHeight: "0" },
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<TabList
|
|
||||||
onChange={handleTabChange}
|
|
||||||
aria-label="status tabs"
|
|
||||||
>
|
|
||||||
{tabList.map((label, index) => (
|
|
||||||
<Tab
|
|
||||||
label={label}
|
|
||||||
key={index}
|
|
||||||
value={label}
|
|
||||||
sx={{
|
|
||||||
fontSize: 13,
|
|
||||||
color: theme.palette.text.tertiary,
|
|
||||||
textTransform: "none",
|
|
||||||
minWidth: "fit-content",
|
|
||||||
minHeight: 0,
|
|
||||||
paddingLeft: 0,
|
|
||||||
paddingY: theme.spacing(4),
|
|
||||||
fontWeight: 400,
|
|
||||||
marginRight: theme.spacing(8),
|
|
||||||
"&:focus": {
|
|
||||||
outline: "none",
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</TabList>
|
|
||||||
</Box>
|
|
||||||
<StatusFormProvider
|
|
||||||
form={form}
|
|
||||||
setForm={setForm}
|
|
||||||
errors={errors}
|
|
||||||
setErrors={setErrors}
|
|
||||||
>
|
|
||||||
{tabIdx == 0 ? <GeneralSettingsPanel /> : <ContentPanel />}
|
|
||||||
</StatusFormProvider>
|
|
||||||
</TabContext>
|
|
||||||
<Stack
|
<Stack
|
||||||
direction="row"
|
className="status"
|
||||||
justifyContent="flex-end"
|
px={theme.spacing(20)}
|
||||||
|
py={theme.spacing(12)}
|
||||||
|
gap={theme.spacing(12)}
|
||||||
|
border={1}
|
||||||
|
borderColor={theme.palette.border.light}
|
||||||
|
borderRadius={theme.shape.borderRadius}
|
||||||
|
backgroundColor={theme.palette.background.main}
|
||||||
>
|
>
|
||||||
<Button
|
<TabContext value={tabList[tabIdx]}>
|
||||||
variant="contained"
|
<Box
|
||||||
color="primary"
|
sx={{
|
||||||
onClick={handleSubmit}
|
borderBottom: 1,
|
||||||
|
borderColor: theme.palette.border.light,
|
||||||
|
"& .MuiTabs-root": { height: "fit-content", minHeight: "0" },
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<TabList
|
||||||
|
onChange={handleTabChange}
|
||||||
|
aria-label="status tabs"
|
||||||
|
>
|
||||||
|
{tabList.map((label, index) => (
|
||||||
|
<Tab
|
||||||
|
label={label}
|
||||||
|
key={index}
|
||||||
|
value={label}
|
||||||
|
sx={{
|
||||||
|
fontSize: 13,
|
||||||
|
color: theme.palette.text.tertiary,
|
||||||
|
textTransform: "none",
|
||||||
|
minWidth: "fit-content",
|
||||||
|
minHeight: 0,
|
||||||
|
paddingLeft: 0,
|
||||||
|
paddingY: theme.spacing(4),
|
||||||
|
fontWeight: 400,
|
||||||
|
marginRight: theme.spacing(8),
|
||||||
|
"&:focus": {
|
||||||
|
outline: "none",
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</TabList>
|
||||||
|
</Box>
|
||||||
|
<StatusFormProvider
|
||||||
|
form={form}
|
||||||
|
setForm={setForm}
|
||||||
|
errors={errors}
|
||||||
|
setErrors={setErrors}
|
||||||
|
>
|
||||||
|
{tabIdx == 0 ? <GeneralSettingsPanel /> : <ContentPanel />}
|
||||||
|
</StatusFormProvider>
|
||||||
|
</TabContext>
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
justifyContent="flex-end"
|
||||||
>
|
>
|
||||||
Save
|
<Button
|
||||||
</Button>
|
variant="contained"
|
||||||
|
color="primary"
|
||||||
|
onClick={handleSubmit}
|
||||||
|
>
|
||||||
|
Save
|
||||||
|
</Button>
|
||||||
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Box>
|
);
|
||||||
);
|
};
|
||||||
};
|
|
||||||
|
|
||||||
CreateStatus.propTypes = {
|
CreateStatus.propTypes = {
|
||||||
initForm: PropTypes.object
|
initForm: PropTypes.object
|
||||||
|
|||||||
Vendored
+1
@@ -4,6 +4,7 @@ services:
|
|||||||
restart: always
|
restart: always
|
||||||
environment:
|
environment:
|
||||||
UPTIME_APP_API_BASE_URL: "http://localhost:5000/api/v1"
|
UPTIME_APP_API_BASE_URL: "http://localhost:5000/api/v1"
|
||||||
|
UPTIME_STATUS_PAGE_SUBDOMAIN_PREFIX: "http://uptimegenie.com/"
|
||||||
ports:
|
ports:
|
||||||
- "80:80"
|
- "80:80"
|
||||||
- "443:443"
|
- "443:443"
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ services:
|
|||||||
restart: always
|
restart: always
|
||||||
environment:
|
environment:
|
||||||
UPTIME_APP_API_BASE_URL: "https://checkmate-demo.bluewavelabs.ca/api/v1"
|
UPTIME_APP_API_BASE_URL: "https://checkmate-demo.bluewavelabs.ca/api/v1"
|
||||||
|
UPTIME_STATUS_PAGE_SUBDOMAIN_PREFIX: "http://uptimegenie.com/"
|
||||||
ports:
|
ports:
|
||||||
- "80:80"
|
- "80:80"
|
||||||
- "443:443"
|
- "443:443"
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ services:
|
|||||||
restart: always
|
restart: always
|
||||||
environment:
|
environment:
|
||||||
UPTIME_APP_API_BASE_URL: "https://checkmate-test.bluewavelabs.ca/api/v1"
|
UPTIME_APP_API_BASE_URL: "https://checkmate-test.bluewavelabs.ca/api/v1"
|
||||||
|
UPTIME_STATUS_PAGE_SUBDOMAIN_PREFIX: "http://uptimegenie.com/"
|
||||||
ports:
|
ports:
|
||||||
- "80:80"
|
- "80:80"
|
||||||
- "443:443"
|
- "443:443"
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ services:
|
|||||||
image: uptime_client:latest
|
image: uptime_client:latest
|
||||||
environment:
|
environment:
|
||||||
UPTIME_APP_API_BASE_URL: "https://checkmate-demo.bluewavelabs.ca/api/v1"
|
UPTIME_APP_API_BASE_URL: "https://checkmate-demo.bluewavelabs.ca/api/v1"
|
||||||
|
UPTIME_STATUS_PAGE_SUBDOMAIN_PREFIX: "http://uptimegenie.com/"
|
||||||
ports:
|
ports:
|
||||||
- "80:80"
|
- "80:80"
|
||||||
- "443:443"
|
- "443:443"
|
||||||
|
|||||||
Reference in new issue
Block a user