Skip to content
Snippets Groups Projects
Commit f726b0c1 authored by Max Frederiksen's avatar Max Frederiksen
Browse files

Merge branch 'CE-3136-remove-isdeployed-prop' into 'develop'

CE-3136: Remove isDeployed from LokiPanel, Remove unused LokiContainer, Refactoring

See merge request !541
parents fd990eb1 6ccb3d84
No related branches found
No related tags found
2 merge requests!612Release 5.0.0,!541CE-3136: Remove isDeployed from LokiPanel, Remove unused LokiContainer, Refactoring
Pipeline #197709 passed
...@@ -33,7 +33,6 @@ const defaultSubset = ({ ...@@ -33,7 +33,6 @@ const defaultSubset = ({
}) => ({ name, description, host, active, status, git, version }); }) => ({ name, description, host, active, status, git, version });
export function IOCDetails({ ioc, getSubset = defaultSubset, buttons }) { export function IOCDetails({ ioc, getSubset = defaultSubset, buttons }) {
ioc = { ...ioc };
const subset = getSubset(ioc); const subset = getSubset(ioc);
const client = useContext(apiContext); const client = useContext(apiContext);
...@@ -109,7 +108,7 @@ export function IOCDetails({ ioc, getSubset = defaultSubset, buttons }) { ...@@ -109,7 +108,7 @@ export function IOCDetails({ ioc, getSubset = defaultSubset, buttons }) {
component="p" component="p"
color="textPrimary" color="textPrimary"
> >
{ioc.namingName ?? ioc.name} {ioc.namingName}
</Typography> </Typography>
<Typography <Typography
noWrap noWrap
......
...@@ -24,10 +24,8 @@ export function IOCLiveStatus({ ioc }) { ...@@ -24,10 +24,8 @@ export function IOCLiveStatus({ ioc }) {
{ navigateMode: "replace" } { navigateMode: "replace" }
); );
const liveIOC = { ...ioc }; const hostName = ioc.activeDeployment?.host?.hostName;
liveIOC.name = ioc.namingName; const externalIdValid = ioc.activeDeployment?.host?.externalIdValid;
const hostName = liveIOC.activeDeployment?.host?.hostName;
const getSubset = useCallback((ioc) => { const getSubset = useCallback((ioc) => {
const iocHasDeployment = new IocActiveDeployment( const iocHasDeployment = new IocActiveDeployment(
...@@ -67,14 +65,10 @@ export function IOCLiveStatus({ ioc }) { ...@@ -67,14 +65,10 @@ export function IOCLiveStatus({ ioc }) {
return subset; return subset;
}, []); }, []);
function isIocDeployed(ioc) {
return Boolean(ioc.activeDeployment);
}
return ( return (
<> <>
<IOCDetails <IOCDetails
ioc={liveIOC} ioc={ioc}
getSubset={getSubset} getSubset={getSubset}
/> />
...@@ -82,7 +76,7 @@ export function IOCLiveStatus({ ioc }) { ...@@ -82,7 +76,7 @@ export function IOCLiveStatus({ ioc }) {
allowedRoles={["DeploymentToolAdmin", "DeploymentToolIntegrator"]} allowedRoles={["DeploymentToolAdmin", "DeploymentToolIntegrator"]}
renderNoAccess={() => <></>} renderNoAccess={() => <></>}
> >
{liveIOC.activeDeployment?.host?.externalIdValid && ( {externalIdValid && (
<SimpleAccordion <SimpleAccordion
summary={ summary={
<Typography <Typography
...@@ -101,7 +95,6 @@ export function IOCLiveStatus({ ioc }) { ...@@ -101,7 +95,6 @@ export function IOCLiveStatus({ ioc }) {
<LokiPanel <LokiPanel
hostName={hostName} hostName={hostName}
iocName={ioc.namingName} iocName={ioc.namingName}
isDeployed={isIocDeployed(ioc)}
/> />
)} )}
</SimpleAccordion> </SimpleAccordion>
......
import { Box } from "@mui/material";
import { LokiPanel } from "./LokiPanel";
export function LokiContainer({ hostName, iocName, isDeployed }) {
return (
<>
{hostName && (
<Box sx={{ pt: 2 }}>
<LokiPanel
hostName={hostName}
isSyslog={false}
iocName={iocName}
isDeployed={isDeployed}
/>
</Box>
)}
</>
);
}
...@@ -30,11 +30,10 @@ const TIME_RANGE_VALUES = [ ...@@ -30,11 +30,10 @@ const TIME_RANGE_VALUES = [
* hostName: name of the host (mandatory) which will be the qery parameter for backend call * hostName: name of the host (mandatory) which will be the qery parameter for backend call
* iocName: name of ioc (optional). Used when querying procServ log * iocName: name of ioc (optional). Used when querying procServ log
* isSyslog: boolean, if true -> SysLog will be queried, if false -> procServLog will be queried * isSyslog: boolean, if true -> SysLog will be queried, if false -> procServLog will be queried
* isDeployed: boolean, if true -> periodic update (backend query) will be enabled, if false -> periodic update will be disabled
*/ */
const LOG_POLL_INTERVAL = 5000; const LOG_POLL_INTERVAL = 5000;
export function LokiPanel({ hostName, iocName, isSyslog, isDeployed }) { export function LokiPanel({ hostName, iocName, isSyslog }) {
const showWarning = useCustomSnackbar(); const showWarning = useCustomSnackbar();
const client = useContext(apiContext); const client = useContext(apiContext);
...@@ -54,7 +53,11 @@ export function LokiPanel({ hostName, iocName, isSyslog, isDeployed }) { ...@@ -54,7 +53,11 @@ export function LokiPanel({ hostName, iocName, isSyslog, isDeployed }) {
const [html, setHtml] = useState(""); const [html, setHtml] = useState("");
const preprocessLog = useCallback( const preprocessLog = useCallback(
(logData, isDeployed, showWarning, timeRange, alertIds, setAlertIds) => { (logData, showWarning, timeRange, alertIds, setAlertIds) => {
if (!logData) {
return "";
}
if (logData?.warning && alertIds?.length === 0) { if (logData?.warning && alertIds?.length === 0) {
const warningId = showWarning(logData.warning, "warning"); const warningId = showWarning(logData.warning, "warning");
setAlertIds((alertIds) => [...alertIds, warningId]); setAlertIds((alertIds) => [...alertIds, warningId]);
...@@ -71,10 +74,6 @@ export function LokiPanel({ hostName, iocName, isSyslog, isDeployed }) { ...@@ -71,10 +74,6 @@ export function LokiPanel({ hostName, iocName, isSyslog, isDeployed }) {
<pre>${logHtml.join("")}</pre> <pre>${logHtml.join("")}</pre>
</body> </body>
</html>`; </html>`;
} else {
if (!(isDeployed === true)) {
return "<html><body><pre> NOT DEPLOYED YET! </pre></body></html>";
}
} }
return `<html><body><pre> - No messages found for ${TIME_RANGE_VALUES.find((range) => range.value === timeRange).text} period - </pre></body></html>`; return `<html><body><pre> - No messages found for ${TIME_RANGE_VALUES.find((range) => range.value === timeRange).text} period - </pre></body></html>`;
...@@ -87,7 +86,6 @@ export function LokiPanel({ hostName, iocName, isSyslog, isDeployed }) { ...@@ -87,7 +86,6 @@ export function LokiPanel({ hostName, iocName, isSyslog, isDeployed }) {
isSysLog, isSysLog,
logData, logData,
procServLog, procServLog,
isDeployed,
showWarning, showWarning,
timeRange, timeRange,
alertIds, alertIds,
...@@ -96,7 +94,6 @@ export function LokiPanel({ hostName, iocName, isSyslog, isDeployed }) { ...@@ -96,7 +94,6 @@ export function LokiPanel({ hostName, iocName, isSyslog, isDeployed }) {
if (isSysLog === true) { if (isSysLog === true) {
return preprocessLog( return preprocessLog(
logData, logData,
true,
showWarning, showWarning,
timeRange, timeRange,
alertIds, alertIds,
...@@ -106,7 +103,6 @@ export function LokiPanel({ hostName, iocName, isSyslog, isDeployed }) { ...@@ -106,7 +103,6 @@ export function LokiPanel({ hostName, iocName, isSyslog, isDeployed }) {
return preprocessLog( return preprocessLog(
procServLog, procServLog,
isDeployed,
showWarning, showWarning,
timeRange, timeRange,
alertIds, alertIds,
...@@ -182,19 +178,9 @@ export function LokiPanel({ hostName, iocName, isSyslog, isDeployed }) { ...@@ -182,19 +178,9 @@ export function LokiPanel({ hostName, iocName, isSyslog, isDeployed }) {
if (isSyslog === true) { if (isSyslog === true) {
getSysLogData(hostName, timeRange); getSysLogData(hostName, timeRange);
} else { } else {
if (isDeployed === true) { getProcServLog(hostName, iocName, timeRange);
getProcServLog(hostName, iocName, timeRange);
}
} }
}, [ }, [getSysLogData, getProcServLog, hostName, iocName, isSyslog, timeRange]);
getSysLogData,
getProcServLog,
hostName,
iocName,
isDeployed,
isSyslog,
timeRange
]);
const hasLogError = !!sysLogError || !!procServLogError; const hasLogError = !!sysLogError || !!procServLogError;
const hasLogData = !!sysLogData || !!procServLog; const hasLogData = !!sysLogData || !!procServLog;
...@@ -215,7 +201,6 @@ export function LokiPanel({ hostName, iocName, isSyslog, isDeployed }) { ...@@ -215,7 +201,6 @@ export function LokiPanel({ hostName, iocName, isSyslog, isDeployed }) {
isSyslog, isSyslog,
sysLogData, sysLogData,
procServLog, procServLog,
isDeployed,
showWarning, showWarning,
timeRange, timeRange,
alertIds, alertIds,
...@@ -225,7 +210,6 @@ export function LokiPanel({ hostName, iocName, isSyslog, isDeployed }) { ...@@ -225,7 +210,6 @@ export function LokiPanel({ hostName, iocName, isSyslog, isDeployed }) {
}, [ }, [
setHtml, setHtml,
alertIds, alertIds,
isDeployed,
isSyslog, isSyslog,
logsToPreprocess, logsToPreprocess,
procServLog, procServLog,
......
import { LokiContainer } from "./LokiContainer";
import { LokiPanel } from "./LokiPanel"; import { LokiPanel } from "./LokiPanel";
export { LokiContainer, LokiPanel }; export { LokiPanel };
...@@ -148,7 +148,6 @@ export function HostDetailsView({ hostId, host, alert }) { ...@@ -148,7 +148,6 @@ export function HostDetailsView({ hostId, host, alert }) {
<LokiPanel <LokiPanel
hostName={host.name} hostName={host.name}
isSyslog isSyslog
isDeployed
/> />
</SimpleAccordion> </SimpleAccordion>
</AccessControl> </AccessControl>
......
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