|
|
|
@@ -8,7 +8,7 @@ import { |
|
|
|
testM18ImportMasterData, |
|
|
|
testM18ImportDo, |
|
|
|
} from "@/app/api/settings/m18ImportTesting/actions"; |
|
|
|
import { Card, CardContent, Grid, Stack, Typography } from "@mui/material"; |
|
|
|
import { Card, CardContent, Grid, Stack, Typography, Button } from "@mui/material"; |
|
|
|
import React, { |
|
|
|
BaseSyntheticEvent, |
|
|
|
FormEvent, |
|
|
|
@@ -22,6 +22,8 @@ import M18ImportPq from "./M18ImportPq"; |
|
|
|
import { dateTimeStringToDayjs } from "@/app/utils/formatUtil"; |
|
|
|
import M18ImportMasterData from "./M18ImportMasterData"; |
|
|
|
import M18ImportDo from "./M18ImportDo"; |
|
|
|
import { PlayArrow, Refresh as RefreshIcon } from "@mui/icons-material"; |
|
|
|
import { triggerScheduler, refreshCronSchedules } from "@/app/api/settings/m18ImportTesting/actions"; |
|
|
|
|
|
|
|
interface Props {} |
|
|
|
|
|
|
|
@@ -166,9 +168,80 @@ const M18ImportTesting: React.FC<Props> = ({}) => { |
|
|
|
// [], |
|
|
|
// ); |
|
|
|
|
|
|
|
const handleManualTrigger = async (type: any) => { |
|
|
|
setIsLoading(true); |
|
|
|
setLoadingType(`Manual ${type}`); |
|
|
|
try { |
|
|
|
const result = await triggerScheduler(type); |
|
|
|
if (result) alert(result); |
|
|
|
} catch (error) { |
|
|
|
console.error(error); |
|
|
|
alert("Trigger failed. Check server logs."); |
|
|
|
} finally { |
|
|
|
setIsLoading(false); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
const handleRefreshSchedules = async () => { |
|
|
|
// Re-use the manual trigger logic which we know works |
|
|
|
await handleManualTrigger('refresh-cron'); |
|
|
|
}; |
|
|
|
|
|
|
|
return ( |
|
|
|
<Card> |
|
|
|
<CardContent sx={{ display: "flex", flexDirection: "column", gap: 1 }}> |
|
|
|
<Typography variant="h6">{t("Manual Scheduler Triggers")}</Typography> |
|
|
|
<Stack direction="row" spacing={1} flexWrap="wrap" useFlexGap> |
|
|
|
<Button |
|
|
|
variant="outlined" |
|
|
|
startIcon={<PlayArrow />} |
|
|
|
onClick={() => handleManualTrigger('po')} |
|
|
|
disabled={isLoading} |
|
|
|
> |
|
|
|
Trigger PO |
|
|
|
</Button> |
|
|
|
<Button |
|
|
|
variant="outlined" |
|
|
|
startIcon={<PlayArrow />} |
|
|
|
onClick={() => handleManualTrigger('do1')} |
|
|
|
disabled={isLoading} |
|
|
|
> |
|
|
|
Trigger DO1 |
|
|
|
</Button> |
|
|
|
<Button |
|
|
|
variant="outlined" |
|
|
|
startIcon={<PlayArrow />} |
|
|
|
onClick={() => handleManualTrigger('do2')} |
|
|
|
disabled={isLoading} |
|
|
|
> |
|
|
|
Trigger DO2 |
|
|
|
</Button> |
|
|
|
<Button |
|
|
|
variant="outlined" |
|
|
|
startIcon={<PlayArrow />} |
|
|
|
onClick={() => handleManualTrigger('master-data')} |
|
|
|
disabled={isLoading} |
|
|
|
> |
|
|
|
Trigger Master |
|
|
|
</Button> |
|
|
|
<Button |
|
|
|
variant="contained" |
|
|
|
color="secondary" |
|
|
|
startIcon={<RefreshIcon />} |
|
|
|
onClick={handleRefreshSchedules} // This now uses the logic that works |
|
|
|
disabled={isLoading} |
|
|
|
> |
|
|
|
Reload Cron Settings |
|
|
|
</Button> |
|
|
|
</Stack> |
|
|
|
|
|
|
|
<hr style={{ opacity: 0.2 }} /> |
|
|
|
|
|
|
|
<Typography variant="overline"> |
|
|
|
{t("Status: ")} |
|
|
|
{isLoading ? t(`Processing ${loadingType}...`) : t("Ready")} |
|
|
|
</Typography> |
|
|
|
|
|
|
|
<Typography variant="overline"> |
|
|
|
{t("Status: ")} |
|
|
|
{isLoading ? t(`Importing ${loadingType}...`) : t("Ready to import")} |
|
|
|
|