-
Klaas Kliffen authoredKlaas Kliffen authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
Batch.js 12.13 KiB
import axios from "axios";
import React, { useContext, useEffect, useState } from "react";
import { Button, Container, Form } from "react-bootstrap";
import { Link } from 'react-router-dom';
import "../../assets/Interactive.css";
import { BATCHContext } from "../../contexts/BATCHContext";
import { GlobalContext } from "../../contexts/GlobalContext";
export default function Batch() {
const { batchSystemURL, setBatchSystemURL, workflowURL, setWorkflowURL, list_of_workflows, setList_of_workflows, list_of_batchSystems, setList_of_batchSystems, list_job_results, setList_job_results } = useContext(BATCHContext);
const { api_host, accessToken } = useContext(GlobalContext);
const [defaultWorkflow] = "https://github.com/ESAP-WP5/binder-empty";
const [state, setState] = useState({
showDeploy: false,
showNext: false,
showMonitor: false,
showSubmit: false,
showJobStatus: false,
showMoreButton: true,
numberOfitemsShown: 3,
loading: true
});
/* Cannot be included in the above for some reason - breaks */
const [searchTerm, setSearchTerm] = useState("");
const [showFacilities, setShowFacilities] = useState(false);
// Fetch Notebooks
useEffect(() => {
axios
.get(api_host + "batch/workflows/search")
.then((response) => {
setList_of_workflows(response.data.results);
setWorkflowURL(defaultWorkflow);
setState(prev => ({ ...prev, loading: true }));
});
}, [api_host, setList_of_workflows, setWorkflowURL]);
// Fetch JHubs
useEffect(() => {
axios
.get(api_host + "batch/facilities/search")
.then((response) => {
setList_of_batchSystems(response.data.results);
setBatchSystemURL(response.data.results[0].url);
});
}, [api_host, setList_of_batchSystems, setBatchSystemURL]);
/* Main Monitor Job Button */
const onClickMonitorJob = e => {
e.preventDefault();
setState(prev => ({ ...prev, showSubmit: false, showMonitor: true, showDeloy: false }));
setShowFacilities(false);
}
/* Main Submit Job Button */
const onClickSubmitJob = e => {
e.preventDefault();
setState(prev => ({ ...prev, showNext: false, showSubmit: true, showMonitor: false }));
}