Skip to content

Commit

Permalink
status visibility (platforms page)
Browse files Browse the repository at this point in the history
  • Loading branch information
adhiraj23zelthy committed Jan 29, 2025
1 parent ec49dde commit 5ec83e5
Showing 1 changed file with 33 additions and 22 deletions.
55 changes: 33 additions & 22 deletions frontend/src/components/Layout/NavSearchForm/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as Yup from 'yup';
import { ReactComponent as SearchIcon } from '../../../assets/images/svg/search-icon.svg';
import SelectField from './SelectField';
import useApi from '../../../hooks/useApi';

import {useLocation} from 'react-router-dom'
const AutoSave = ({ debounceMs }) => {
const formik = useFormikContext();
const [lastSaved, setLastSaved] = useState(null);
Expand All @@ -25,6 +25,10 @@ const AutoSave = ({ debounceMs }) => {
};

export default function NavSearchForm() {
const location = useLocation();
const isValidPath =
location.pathname === '/platform/apps' ||
location.pathname === '/platform/apps/';
const [isCeleryRunning, setIsCeleryRunning] = useState('Loading...');
const triggerApi = useApi();
let initialValues = {
Expand Down Expand Up @@ -53,12 +57,14 @@ export default function NavSearchForm() {
};

useEffect(() => {
fetchCeleryData();

const intervalId = setInterval(fetchCeleryData, 7500);
if(isValidPath){
fetchCeleryData();

return () => clearInterval(intervalId);
}, []);
const intervalId = setInterval(fetchCeleryData, 7500);

return () => clearInterval(intervalId);
}
}, [isValidPath]);

let onSubmit = (values) => {
makeApiCall();
Expand Down Expand Up @@ -124,23 +130,28 @@ export default function NavSearchForm() {
/>
</div>
</div>
<div
className={`flex font-semibold rounded-sm px-5 items-center justify-center text-xs ${
isCeleryRunning === 'Running'
? 'bg-green-200'
{
isValidPath && (
<div
className={`flex font-semibold rounded-sm px-5 items-center justify-center text-xs ${
isCeleryRunning === 'Running'
? 'bg-green-200'
: isCeleryRunning === 'Not Running'
? 'bg-red-200'
: 'bg-gray-100'
}`}
>
Celery Status: <span className={` ml-2 ${
isCeleryRunning === 'Running'
? 'text-green-700'
: isCeleryRunning === 'Not Running'
? 'bg-red-200'
: 'bg-gray-100'
}`}
>
Celery Status: <span className={` ml-2 ${
isCeleryRunning === 'Running'
? 'text-green-700'
: isCeleryRunning === 'Not Running'
? 'text-red-700'
: 'text-gray-700'
}`}>{isCeleryRunning}</span>
</div>{' '}
? 'text-red-700'
: 'text-gray-700'
}`}>{isCeleryRunning}</span>
</div>
)
}

</div>
</form>
);
Expand Down

0 comments on commit 5ec83e5

Please sign in to comment.