Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const approveJob = async () => {
const body = {"status":"approved"};
const data = await requestDelete.put(`${currentJob.cluster}/jobs/${currentJob.jobId}/status/`,body);
return data;
}
const pauseJob = async () => {
const body = {"status":"pausing"};
const data = await requestDelete.put(`${currentJob.cluster}/jobs/${currentJob.jobId}/status/`,body);
return data;
}
const resumeJob = async () => {
const body = {"status":"queued"};
const data = await requestDelete.put(`${currentJob.cluster}/jobs/${currentJob.jobId}/status/`,body);
return data;
}
const { put: setPriority } = usePut('/api');
const [currentCluster, setCurrentCluster] = useState(props.match.params.cluster ? props.match.params.cluster : Array.isArray(_.map(clusters,'id') )?_.map(clusters,'id')[0] : '');
const [jobs, error] = useJobs();
const [allJobs, err] = useJobsAll();
const[isAdmin, setIsAdmin] = useState(clusters.filter((cluster) => cluster.id === currentCluster)[0].admin);
const filterJobsByCluster = (jobs: any, clusterName: string) => {
console.log(isAdmin);
if (clusterName == '-1' || clusterName === '') {
return Jobs;
} else {
return jobs.filter((job: any)=>job['cluster'] === clusterName)
}
}
const filterFinishedJobs = (jobs: any) => {
const filteredJobs = filterJobsByCluster(jobs, currentCluster);
return filteredJobs.filter((job: any) => job['jobStatus'] !== 'running' &&
job['jobStatus'] !== 'queued' && job['jobStatus'] !== 'unapproved' && job['jobStatus'] !== 'scheduling' &&job['jobStatus'] !== 'pausing' && job['jobStatus'] !== 'paused' )