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

Added job scheduling page #23

Open
wants to merge 7 commits into
base: main
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
31 changes: 15 additions & 16 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Nodes from "./pages/Nodes";
import Node from "./pages/Node";
import StatsNodesLock from "./pages/StatsNodesLock";
import StatsNodesJobs from "./pages/StatsNodesJobs";
import { ErrorBoundary } from "react-error-boundary";
import Schedule from "./pages/Schedule";

import "./App.css";
import ErrorFallback from "./components/ErrorFallback";
Expand All @@ -39,21 +39,20 @@ function App(props: AppProps) {
</header>
<Drawer drawerOpen={drawerOpen} setDrawerOpen={setDrawerOpen} />
<div className="App-body">
<ErrorBoundary FallbackComponent={ErrorFallback} >
<Routes>
<Route path="/" element={<Runs />} />
<Route path="/nodes" element={<Nodes />} />
<Route path="/nodes/:name" element={<Node />} />
<Route path="/stats/nodes/jobs" element={<StatsNodesJobs />} />
<Route path="/stats/nodes/lock" element={<StatsNodesLock />} />
<Route path="/runs" element={<Runs />} />
<Route path="/runs/:name" element={<Run />} />
<Route path="/runs/:name/jobs/:job_id" element={<Job />} />
<Route path="/queue" element={<Queue />} />
<Route path="/:name" element={<Run />} />
<Route path="/:name/:job_id" element={<Job />} />
</Routes>
</ErrorBoundary>
<Routes>
<Route path="/" element={<Runs />} />
<Route path="/nodes" element={<Nodes />} />
<Route path="/nodes/:name" element={<Node />} />
<Route path="/stats/nodes/jobs" element={<StatsNodesJobs />} />
<Route path="/stats/nodes/lock" element={<StatsNodesLock />} />
<Route path="/runs" element={<Runs />} />
<Route path="/runs/:name" element={<Run />} />
<Route path="/runs/:name/jobs/:job_id" element={<Job />} />
<Route path="/queue" element={<Queue />} />
<Route path="/schedule" element={<Schedule />} />
<Route path="/:name" element={<Run />} />
<Route path="/:name/:job_id" element={<Job />} />
</Routes>
</div>
</div>
);
Expand Down
5 changes: 3 additions & 2 deletions src/components/Drawer/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ export default function Drawer(props) {
<RouterLink to="/runs" className={classes.drawerLink}>
Runs
</RouterLink>
<Divider />
<RouterLink to="/nodes?machine_type=smithi" className={classes.drawerLink}>
Nodes
</RouterLink>
Expand All @@ -87,7 +86,9 @@ export default function Drawer(props) {
<RouterLink to="/stats/nodes/jobs" className={classes.drawerLink}>
Node Jobs Stats
</RouterLink>
<Divider />
<RouterLink to="/schedule" className={classes.drawerLink}>
Schedule
</RouterLink>
</StyledSwipeableDrawer>
);
}
31 changes: 25 additions & 6 deletions src/lib/teuthologyAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,46 @@ import { useQuery } from "@tanstack/react-query";
import { Cookies } from "react-cookie";
import type { UseQueryResult } from "@tanstack/react-query";

const TEUTHOLOGY_API_SERVER =
const TEUTHOLOGY_API_SERVER =
import.meta.env.VITE_TEUTHOLOGY_API || "";
const GH_USER_COOKIE = "GH_USER";

function getURL(relativeURL: URL|string): string {
if ( ! TEUTHOLOGY_API_SERVER ) return "";
function getURL(relativeURL: URL | string): string {
if (!TEUTHOLOGY_API_SERVER) return "";
return new URL(relativeURL, TEUTHOLOGY_API_SERVER).toString();
}

function doLogin() {
const url = getURL("/login/");
if ( url ) window.location.href = url;
if (url) window.location.href = url;
}

function doLogout() {
const cookies = new Cookies();
cookies.remove(GH_USER_COOKIE);

const url = getURL("/logout/");
window.location.href = url;
}

async function useSchedule(commandValue: any) {
const url = getURL("/suite?logs=true");
const username = useUserData().get("username");
if (username) {
commandValue['--owner'] = username;
}
return await axios.post(url, commandValue, {
VallariAg marked this conversation as resolved.
Show resolved Hide resolved
withCredentials: true,
headers: { "Content-Type": "application/json" },
}).then((resp) => {
console.log(resp);
return resp;
}, (error) => {
console.log(error);
throw error;
});
}

function useSession(): UseQueryResult {
const url = getURL("/");
const query = useQuery({
Expand Down Expand Up @@ -59,6 +77,7 @@ function useUserData(): Map<string, string> {
export {
doLogin,
doLogout,
useSchedule,
useSession,
useUserData
useUserData,
}
Loading
Loading