Skip to content
Snippets Groups Projects
Commit 003c1689 authored by Zoltan Runyo's avatar Zoltan Runyo
Browse files

ICSHWI-10972: Logs and command details

parent 48502bfe
No related branches found
No related tags found
2 merge requests!270Merging develop branch to master in order to create RC,!251Logs and command details ICSHWI-10972
...@@ -13,19 +13,9 @@ export default function AlertMessages({ alerts }) { ...@@ -13,19 +13,9 @@ export default function AlertMessages({ alerts }) {
const classes = useStyles(theme); const classes = useStyles(theme);
function determineSeverity(alarmType) { function determineSeverity(alarmType) {
if (alarmType === "ERROR") { return ["error", "warning", "success"].includes(alarmType?.toLowerCase())
return "error"; ? alarmType?.toLowerCase()
} : "info";
if (alarmType === "WARNING") {
return "warning";
}
if (alarmType === "SUCCESS") {
return "success";
}
return "info";
} }
function determineClassName(alarmType) { function determineClassName(alarmType) {
...@@ -47,10 +37,10 @@ export default function AlertMessages({ alerts }) { ...@@ -47,10 +37,10 @@ export default function AlertMessages({ alerts }) {
key={alert} key={alert}
> >
<Alert <Alert
className={determineClassName(alert.type)} className={determineClassName(alert?.type)}
severity={determineSeverity(alert.type)} severity={determineSeverity(alert?.type)}
action={ action={
alert.link && ( alert?.link && (
<Button <Button
target="_blank" target="_blank"
href={alert.link} href={alert.link}
...@@ -62,7 +52,7 @@ export default function AlertMessages({ alerts }) { ...@@ -62,7 +52,7 @@ export default function AlertMessages({ alerts }) {
) )
} }
> >
{alert.message} {alert?.message}
</Alert> </Alert>
</Grid> </Grid>
))} ))}
......
...@@ -41,7 +41,7 @@ export function IOCManage({ ...@@ -41,7 +41,7 @@ export function IOCManage({
}) { }) {
const { user } = useContext(userContext); const { user } = useContext(userContext);
const [state, setState] = useUrlState({ const [state, setState] = useUrlState({
log_open: "false" log_open: "true"
}); });
const [deployDialogOpen, setDeployDialogOpen] = useState(false); const [deployDialogOpen, setDeployDialogOpen] = useState(false);
......
...@@ -19,7 +19,6 @@ import GitRefLink from "../IOC/GitRefLink"; ...@@ -19,7 +19,6 @@ import GitRefLink from "../IOC/GitRefLink";
import AccessControl from "../auth/AccessControl"; import AccessControl from "../auth/AccessControl";
import { theme } from "../../style/Theme"; import { theme } from "../../style/Theme";
import { AWXJobDetails } from "../../api/DataTypes"; import { AWXJobDetails } from "../../api/DataTypes";
import { Alert } from "@material-ui/lab";
import AlertMessages from "../IOC/AlertMessages"; import AlertMessages from "../IOC/AlertMessages";
const useStyles = makeStyles((theme) => ({ const useStyles = makeStyles((theme) => ({
...@@ -28,20 +27,14 @@ const useStyles = makeStyles((theme) => ({ ...@@ -28,20 +27,14 @@ const useStyles = makeStyles((theme) => ({
} }
})); }));
function createAlert(operation, job, finishedSuccessfully) { function createAlert(operation, job) {
const jobDetails = new AWXJobDetails(operation.type, job); const jobDetails = new AWXJobDetails(operation.type, job);
const message = jobDetails.message(); const message = jobDetails.message();
const severity = jobDetails.severity(); const severity = jobDetails.severity();
return ( return {
!finishedSuccessfully && ( type: severity,
<Alert message: message
severity={severity} };
variant="standard"
>
{message}
</Alert>
)
);
} }
export function JobDetails({ operation, job }) { export function JobDetails({ operation, job }) {
...@@ -49,17 +42,12 @@ export function JobDetails({ operation, job }) { ...@@ -49,17 +42,12 @@ export function JobDetails({ operation, job }) {
let jobAlert = useMemo(() => operation.alerts ?? [], [operation]); let jobAlert = useMemo(() => operation.alerts ?? [], [operation]);
const successfulJob = useMemo( const finishedJob = useMemo(
() => () => operation && new AWXJobDetails(operation.type, job).isFinished(),
operation && [operation, job]
jobAlert?.length === 0 &&
job?.status.toLowerCase() === "successful",
[operation, jobAlert, job]
); );
const [alert, setAlert] = useState( const [alert, setAlert] = useState(createAlert(operation, job));
createAlert(operation, job, successfulJob)
);
const jobDetails = useMemo( const jobDetails = useMemo(
() => new AWXJobDetails(operation.type, job), () => new AWXJobDetails(operation.type, job),
...@@ -67,16 +55,8 @@ export function JobDetails({ operation, job }) { ...@@ -67,16 +55,8 @@ export function JobDetails({ operation, job }) {
); );
useEffect(() => { useEffect(() => {
setAlert(createAlert(operation, job, successfulJob)); setAlert(createAlert(operation, job, finishedJob));
}, [finishedJob, operation, job]);
// show SUCCESS message only to successful deployments (where no warnings came back from BE)
if (successfulJob) {
jobAlert.push({
type: "SUCCESS",
message: jobDetails.typeLabel() + " was successful!"
});
}
}, [successfulJob, jobAlert, operation, job, jobDetails]);
function calculateHostText() { function calculateHostText() {
// host is resolvable => show link for users // host is resolvable => show link for users
...@@ -139,12 +119,12 @@ export function JobDetails({ operation, job }) { ...@@ -139,12 +119,12 @@ export function JobDetails({ operation, job }) {
container container
spacing={1} spacing={1}
> >
{jobAlert && ( {finishedJob && (
<Grid <Grid
item item
xs={12} xs={12}
> >
<AlertMessages alerts={jobAlert} /> <AlertMessages alerts={[alert].concat(jobAlert)} />
</Grid> </Grid>
)} )}
<Grid <Grid
...@@ -186,12 +166,12 @@ export function JobDetails({ operation, job }) { ...@@ -186,12 +166,12 @@ export function JobDetails({ operation, job }) {
</CardContent> </CardContent>
</Card> </Card>
</Grid> </Grid>
{alert && ( {!finishedJob && alert && (
<Grid <Grid
item item
xs={12} xs={12}
> >
{alert} <AlertMessages alerts={[alert]} />
</Grid> </Grid>
)} )}
<AccessControl <AccessControl
......
...@@ -13,7 +13,6 @@ import { KeyValueTable } from "../common/KeyValueTable/KeyValueTable"; ...@@ -13,7 +13,6 @@ import { KeyValueTable } from "../common/KeyValueTable/KeyValueTable";
import { SimpleAccordion } from "../common/Accordion/SimpleAccordion"; import { SimpleAccordion } from "../common/Accordion/SimpleAccordion";
import { DeploymentBadge } from "./DeploymentBadge"; import { DeploymentBadge } from "./DeploymentBadge";
import { DeploymentJobOutput } from "./DeploymentJobOutput"; import { DeploymentJobOutput } from "./DeploymentJobOutput";
import { Alert } from "@material-ui/lab";
import { Link as ReactRouterLink } from "react-router-dom"; import { Link as ReactRouterLink } from "react-router-dom";
import { formatDate } from "../common/Helper"; import { formatDate } from "../common/Helper";
import GitRefLink from "../IOC/GitRefLink"; import GitRefLink from "../IOC/GitRefLink";
...@@ -22,20 +21,14 @@ import { AWXJobDetails, DeploymentStatus } from "../../api/DataTypes"; ...@@ -22,20 +21,14 @@ import { AWXJobDetails, DeploymentStatus } from "../../api/DataTypes";
import { theme } from "../../style/Theme"; import { theme } from "../../style/Theme";
import AlertMessages from "../IOC/AlertMessages"; import AlertMessages from "../IOC/AlertMessages";
function createAlert(deployment, deploymentJob, finishedSuccessfully) { function createAlert(deployment, deploymentJob) {
const deploymentStatus = new DeploymentStatus(deployment, deploymentJob); const deploymentStatus = new DeploymentStatus(deployment, deploymentJob);
const message = deploymentStatus.message(); const message = deploymentStatus.message();
const severity = deploymentStatus.severity(); const severity = deploymentStatus.severity();
return ( return {
!finishedSuccessfully && ( type: severity,
<Alert message: message
severity={severity} };
variant="standard"
>
{message}
</Alert>
)
);
} }
const useStyles = makeStyles((theme) => ({ const useStyles = makeStyles((theme) => ({
...@@ -49,16 +42,15 @@ export function DeploymentDetails({ deployment, deploymentJob }) { ...@@ -49,16 +42,15 @@ export function DeploymentDetails({ deployment, deploymentJob }) {
let deplAlert = deployment.alerts; let deplAlert = deployment.alerts;
const successfulJob = useMemo( const finishedJob = useMemo(
() => () =>
deployment && deployment &&
deplAlert?.length === 0 && new DeploymentStatus(deployment, deploymentJob).isFinished(),
deploymentJob?.status.toLowerCase() === "successful", [deployment, deploymentJob]
[deployment, deplAlert, deploymentJob]
); );
const [alert, setAlert] = useState( const [alert, setAlert] = useState(
createAlert(deployment, deploymentJob, successfulJob) createAlert(deployment, deploymentJob, finishedJob)
); );
const jobDetails = useMemo( const jobDetails = useMemo(
...@@ -71,16 +63,8 @@ export function DeploymentDetails({ deployment, deploymentJob }) { ...@@ -71,16 +63,8 @@ export function DeploymentDetails({ deployment, deploymentJob }) {
); );
useEffect(() => { useEffect(() => {
setAlert(createAlert(deployment, deploymentJob, successfulJob)); setAlert(createAlert(deployment, deploymentJob));
}, [deployment, deploymentJob]);
// show SUCCESS message only to successful deployments (where no warnings came back from BE)
if (successfulJob) {
deplAlert.push({
type: "SUCCESS",
message: jobDetails.typeLabel() + " was successful!"
});
}
}, [successfulJob, deplAlert, deployment, deploymentJob, jobDetails]);
function calculateHostText() { function calculateHostText() {
// host is resolvable => show link for users // host is resolvable => show link for users
...@@ -141,21 +125,17 @@ export function DeploymentDetails({ deployment, deploymentJob }) { ...@@ -141,21 +125,17 @@ export function DeploymentDetails({ deployment, deploymentJob }) {
: "-" : "-"
}; };
/* {alert && <Grid item xs={12}>
<AlertMessages alerts={liveIOC.alerts} />
</Grid>}*/
return ( return (
<Grid <Grid
container container
spacing={1} spacing={1}
> >
{deplAlert && ( {finishedJob && (
<Grid <Grid
item item
xs={12} xs={12}
> >
<AlertMessages alerts={deplAlert} /> <AlertMessages alerts={[alert].concat(deplAlert)} />
</Grid> </Grid>
)} )}
<Grid <Grid
...@@ -197,12 +177,12 @@ export function DeploymentDetails({ deployment, deploymentJob }) { ...@@ -197,12 +177,12 @@ export function DeploymentDetails({ deployment, deploymentJob }) {
</CardContent> </CardContent>
</Card> </Card>
</Grid> </Grid>
{alert && ( {!finishedJob && alert && (
<Grid <Grid
item item
xs={12} xs={12}
> >
{alert} <AlertMessages alerts={[alert]} />
</Grid> </Grid>
)} )}
<AccessControl <AccessControl
......
...@@ -71,12 +71,9 @@ export function IOCDetailsView({ ioc, getIOC, loading }) { ...@@ -71,12 +71,9 @@ export function IOCDetailsView({ ioc, getIOC, loading }) {
}; };
useEffect(() => { useEffect(() => {
if (ioc.activeDeployment) { let requestParams = initRequestParams(jobLazyParams());
let requestParams = initRequestParams(jobLazyParams()); requestParams.ioc_id = ioc.id;
requestParams.ioc_id = ioc.id; getOperations(requestParams);
// requestParams.deployment_id = ioc.activeDeployment.id;
getOperations(requestParams);
}
}, [getOperations, jobLazyParams, ioc]); }, [getOperations, jobLazyParams, ioc]);
const handleClick = () => { const handleClick = () => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment