Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: integrate wes #36

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified cypress/videos/spec.cy.js.mp4
Binary file not shown.
12 changes: 11 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"version": "1.0.0",
"private": true,
"dependencies": {
"@elixir-cloud/tes": "0.1.1",
"@elixir-cloud/tes": "^0.1.1",
"@elixir-cloud/wes": "^0.1.1",
"@szhsin/react-menu": "^3.0.1",
"@testing-library/cypress": "^8.0.3",
"@testing-library/jest-dom": "^5.16.4",
Expand Down
179 changes: 3 additions & 176 deletions src/components/ManageWorkflows.js
Original file line number Diff line number Diff line change
@@ -1,192 +1,19 @@
import axios from 'axios';
import React, { useEffect } from 'react';
import { useNavigate } from 'react-router-dom';
import { host_uri_wes } from '../config';
import ECCClientGa4ghWesRuns from '@elixir-cloud/wes/dist/react/runs';

const ManageWorkflows = ({ isLoggedIn, showToast }) => {
const navigate = useNavigate();
const [workflows, setWorkflows] = React.useState(null);
const [query, setQuery] = React.useState('');
// const [nextToken, setNextToken] = React.useState(null);
// const [loading, setLoading] = React.useState(false);
// var token = localStorage.getItem("params");
// token = JSON.parse(token);
// token = token ? token.access_token : null;

useEffect(() => {
if (isLoggedIn === 'false') {
return navigate('/');
}
}, [isLoggedIn]);

useEffect(() => {
(async function fetchWorkflows() {
try {
const res = await axios.get(`${host_uri_wes}/runs`);
setWorkflows(res.data);
// setNextToken(res.data.next_page_token);
} catch (e) {
console.log(e);
showToast('error', 'Server error!');
}
// setInterval(handleRefresh, 5000);
})();
}, []);

// const handleRefresh = async () => {
// if (workflows === null) return;
// try {
// const res = await axios.get(`${host_uri_wes}/runs`, {
// headers: {
// Authorization: `Bearer ${token}`,
// },
// });
// let tempWorkflows = workflows;
// console.log(workflows, tempWorkflows, res.data);
// // if (tempWorkflows[0].run_id !== res.data.runs[0].run_id) {
// // tempWorkflows.unshift(res.data.runs[0]);
// // }
// // setWorkflows(tempWorkflows);
// } catch (e) {
// showToast("error", "Server error!");
// }
// };

// const loadMore = async () => {
// setLoading(true);
// try {
// const res = await axios.get(`${host_uri_wes}/runs?${nextToken !== "" ? "page_token=" + nextToken : ""}`, {
// headers: {
// Authorization: `Bearer ${token}`,
// },
// });
// setWorkflows([...workflows, ...res.data.runs]);
// setNextToken(res.data.next_page_token);
// } catch (error) {
// showToast("error", "Server error!");
// }
// setLoading(false);
// };
// console.log(workflows);

// const fetchWorkflow = async (id) => {
// try {
// const res = await axios.get(`${host_uri_wes}/runs/${id}`, {
// headers: {
// Authorization: `Bearer ${token}`,
// },
// });
// let tempworkflows = workflows;
// let index = tempworkflows.findIndex((workflow) => workflow.id === id);
// tempworkflows[index]. =
// return res.data;
// } catch (error) {
// showToast("error", "Server error!");
// }
// };

const renderRuns = () => {
console.log(workflows);
if (workflows === null || workflows === undefined) {
return <div></div>;
} else if (workflows.length === 0) {
return <div></div>;
} else {
return (
<tbody>
{workflows.map((workflow, i) =>
query === '' || workflow.run_id.includes(query) ? (
<tr
key={workflow.run_id}
className="bg-white border-t transition duration-100 ease-in-out hover:bg-gray-100 cursor-pointer"
onClick={() => navigate(`/manage/${workflow.run_id}`)}
>
<td className="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900 sm:hidden">
{i + 1}
</td>
<td className="text-sm text-gray-900 px-6 py-4 whitespace-nowrap">
{workflow.run_id}
</td>
<td className="text-sm text-gray-900 px-6 py-4 whitespace-nowrap">
{workflow.run_status}
</td>
</tr>
) : (
<></>
)
)}
</tbody>
);
}
};

return (
<div
className="pt-36 md:px-32 px-10 font-open"
style={{ transition: 'all 0.5s' }}
>
<div className="border rounded-lg px-5 pt-3">
<input
type="search"
className="border w-full rounded-lg text-sm py-1 px-3 outline-none"
placeholder="Search by run id.."
value={query}
onChange={(e) => setQuery(e.target.value)}
></input>
<div className="overflow-x-auto">
<table className="table-auto min-w-full">
<thead className="bg-white">
<tr>
<th
scope="col"
className="text-sm font-medium text-gray-900 px-6 py-4 text-left sm:hidden"
>
#
</th>
<th
scope="col"
className="text-sm font-medium text-gray-900 px-6 py-4 text-left"
>
Run ID
</th>
<th
scope="col"
className="text-sm font-medium text-gray-900 px-6 py-4 text-left"
>
Run Status
</th>
</tr>
</thead>
{renderRuns()}
</table>
</div>
{workflows === null ? (
<div className="flex w-full items-center justify-center bg-white rounded-xl py-3">
<svg
role="status"
className="w-7 h-7 mr-2 text-gray-200 animate-spin fill-color3"
viewBox="0 0 100 101"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
fill="currentColor"
/>
<path
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
fill="currentFill"
/>
</svg>
</div>
) : workflows.length === 0 ? (
<p className="flex w-full items-center justify-center bg-white rounded-xl py-3 text-gray-900 font-open">
No workflows found
</p>
) : (
<div></div>
)}
</div>
<div className="tesContainer mt-28 p-1">
<ECCClientGa4ghWesRuns />
</div>
);
};
Expand Down
Loading
Loading