Skip to content

Commit

Permalink
feat: ability to start APO dynamic
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivo committed Apr 4, 2023
1 parent fee3c74 commit ba2a914
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 10 deletions.
18 changes: 15 additions & 3 deletions apps/client/src/components/Button/index.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
import { ButtonHTMLAttributes, FC } from "react";
import { LucideIcon } from "lucide-react";

type ButtonProps = ButtonHTMLAttributes<HTMLButtonElement>;
interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
LeftIcon?: LucideIcon;
RightIcon?: LucideIcon;
}

export const Button: FC<ButtonProps> = ({ children, className, ...rest }) => {
export const Button: FC<ButtonProps> = ({
children,
className,
LeftIcon,
RightIcon,
...rest
}) => {
return (
<button
className={`p-2 font-bold text-white font-inter items-center justify-center bg-primary-500 w-full flex hover:bg-primary-600 transition-all rounded-md outline-none focus:ring-2 focus:ring-primary-400 focus:ring-offset-2 focus:ring-offset-zinc-200 ${className}`}
className={`p-2 font-bold text-white font-inter items-center justify-center bg-primary-500 flex gap-x-2 hover:bg-primary-600 transition-all rounded-md outline-none focus:ring-2 focus:ring-primary-400 focus:ring-offset-2 focus:ring-offset-zinc-200 ${className}`}
{...rest}
>
{LeftIcon ? <LeftIcon /> : null}
{children}
{RightIcon ? <RightIcon /> : null}
</button>
);
};
26 changes: 26 additions & 0 deletions apps/client/src/pages/404.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { ArrowLeft } from "lucide-react";
import { useRouter } from "next/router";

import { Button } from "@app/components/Button";
import { PageLayout } from "@app/components/Layout/Page";

export default function Custom404() {
const router = useRouter();

return (
<PageLayout title="common:errors.404.title">
<div className="m-auto flex flex-col gap-y-2">
<h1 className="text-[8rem] font-bold font-grotesk text-center">404</h1>
<p className="text-xl font-medium font-grotesk text-center">
common:errors.404.description
</p>
<Button
LeftIcon={ArrowLeft}
onClick={() => router.replace("/")}
>
common:errors.404.back-to-home
</Button>
</div>
</PageLayout>
);
}
20 changes: 19 additions & 1 deletion apps/client/src/pages/dynamic/apo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,25 @@ export default function APODynamic() {
"Content-Type": "multipart/form-data"
}
})
.then(() => alert("Foi"))
.then(async ({ data }) => {
console.log(data);
if (data.status === "generated") {
await api
.post(
"/run",
{
folder_run: data.folder
},
{
headers: {
"Content-Type": "multipart/form-data"
}
}
)
.then(() => alert("running"))
.catch(() => alert("not running"));
}
})
.catch(() => alert("Não foi"));
};

Expand Down
7 changes: 3 additions & 4 deletions apps/client/src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { Input } from "@app/components/Input";
import { HeaderSEO } from "@app/components/Layout/HeaderSEO";
import { PageLayout } from "@app/components/Layout/Page";

export default function Home() {
return (
<section className="flex flex-col gap-y-4">
<HeaderSEO />
<PageLayout title="pages:home.title">
<Input
label="Label"
type="text"
/>
</section>
</PageLayout>
);
}
1 change: 0 additions & 1 deletion apps/server/server/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ class Config(object):
STATIC_FOLDER = os.path.join(basedir, "static")
MDP_LOCATION_FOLDER = os.path.join(STATIC_FOLDER, "mdp")
SOCK_SERVER_OPTIONS = {"ping_interval": 25}
SOURCE_COMMAND = "source /usr/local/gromacs/bin/GMXRC"
5 changes: 4 additions & 1 deletion apps/server/server/resources/generate_apo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ def post(self):
with open(os.path.join(dynamic_folder, "commands.txt"), "w") as f:
f.writelines(commands)

return {"status": "generated"}
return {
"status": "generated",
"folder": os.path.join(dynamic_folder, "run"),
}

return {"commands": commands}

0 comments on commit ba2a914

Please sign in to comment.