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: first with boilerplate #1

Merged
merged 49 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
4e87458
feat: first with boilerplate
Feb 5, 2024
6df602d
feat: api boilerplate
Feb 5, 2024
9662148
feat: provider boilerplate
Feb 5, 2024
479af8e
feat: hooks boilerplate
Feb 5, 2024
01e51ff
chore: update readme to remove nextjs sample text
Feb 5, 2024
785916d
feat: components boilerplate
Feb 5, 2024
86f86cf
feat: base pages
Feb 5, 2024
41b7d3c
fix: linting prettier
Feb 5, 2024
a32983b
fix: lint your agents
Feb 5, 2024
0cb7594
feature: spawning page component boilerplate code
Feb 5, 2024
24bb530
feat: added swr and icons
Feb 5, 2024
77dc0ff
feature: added layout components i.e navbar
Feb 5, 2024
4809cb7
feature: add marketplace item component
Feb 5, 2024
1b42099
feat: add agents context and hooks
Feb 5, 2024
12329f7
chore: use enums for tabs
Feb 5, 2024
e8c95e5
fix: wrap app in layout
Feb 5, 2024
6a08a73
feat: add api boilerplate code
Feb 5, 2024
991bba0
Update eslint configuration and package.json scripts
truemiller Feb 5, 2024
a5cd27a
Add Jest and testing libraries to devDependencies
truemiller Feb 5, 2024
a6ec40a
Add child_process dependency to package.json
truemiller Feb 5, 2024
7f3731b
Add .env file to .gitignore
truemiller Feb 5, 2024
e0cdd08
Add Docker commands to run and stop agents
truemiller Feb 5, 2024
b3346e2
Add child_process package
truemiller Feb 5, 2024
7d3c4e7
Add frontend workflow and update ESLint configuration
truemiller Feb 5, 2024
f9ac35b
Refactor code and update tsconfig.json
truemiller Feb 5, 2024
8e791c0
Add working directory for frontend build
truemiller Feb 5, 2024
e6db20b
Update frontend workflow to trigger only on pull requests
truemiller Feb 5, 2024
947107e
Update eslint configuration and package dependencies
truemiller Feb 6, 2024
7155403
Update ESLint configuration and package dependencies
truemiller Feb 6, 2024
bf22e42
Fix missing semicolon in Layout.test.tsx
truemiller Feb 6, 2024
c2831c3
Delete unused components and add new components for spawning agents
truemiller Feb 6, 2024
991bfd9
Refactor useAgents and add testFlask to Home
truemiller Feb 6, 2024
7803ae3
fix: lift electron into root and resolve comments
truemiller Feb 6, 2024
40d9ff5
update github actions
truemiller Feb 6, 2024
ce1325a
Update .gitignore and package.json
Feb 6, 2024
1077ee7
Merge branch 'feature/frontend-boilerplate' of github.com:valory-xyz/…
Feb 6, 2024
e69b760
Refactor workflow and update SpawnHeader component
truemiller Feb 6, 2024
32160d4
Add .gitignore entries for Python files
truemiller Feb 6, 2024
ae3d175
updates
truemiller Feb 6, 2024
7645ff7
Add copyToClipboard helper function
truemiller Feb 6, 2024
1fdd205
Update Spawn flow
truemiller Feb 6, 2024
f30fd83
Add new enums for Tabs and URLs, remove unused code, and update depen…
truemiller Feb 6, 2024
1361d99
Add new files and components, update existing components
truemiller Feb 6, 2024
81252e7
Update URLs, enums, and components
truemiller Feb 6, 2024
ac63f53
Update window height and add title
truemiller Feb 6, 2024
7070ab3
Update loading.html and main.js, and remove transpilePackages in next…
truemiller Feb 6, 2024
f72d668
Update dev:python script in package.json
Feb 6, 2024
1e1a7b3
Add script pychache to .gitignore
Feb 6, 2024
b544d2c
Update API endpoint in useAgents hook
Feb 6, 2024
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
33 changes: 33 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"extends": [
"next/core-web-vitals",
"eslint:recommended",
"plugin:jest/recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"plugin:prettier/recommended"
],
"globals": {
"JSX": true,
"React": true
},
"plugins": [
"jest",
"prettier",
"react",
"react-hooks"
],
"rules": {
"no-console": "warn",
"no-unused-vars": "off",
"prettier/prettier": ["error", {
"endOfLine": "auto",
"semi": true
}],
"react/jsx-props-no-spreading": "off",
"react/no-array-index-key": "off",
"react/react-in-jsx-scope": "off",
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn"
}
}
37 changes: 37 additions & 0 deletions .github/workflows/main.yml.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# TBA
name: Frontend Workflow

on: [pull_request]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
# Node
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "20.11"
# Python
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
version: "1.7.1"
virtualenvs-create: true
virtualenvs-in-project: false
virtualenvs-path: ~/my-custom-path
installer-parallel: true
# Install dependencies
- name: Install dependencies
run: yarn
# Lint and test
- name: Lint
run: yarn lint
- name: Test
run: yarn test
44 changes: 42 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,42 @@
data/
__pycache__/
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts

# python
data
backend/__pycache__/
backend/scripts/__pycache__/
35 changes: 34 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,34 @@
# olas-operate-app
Frontend Electron + NextJS application for the Olas Operate App.

## Technologies Used
- NextJS
- Electron
- AntD
- TypeScript
- Python
- Flask
- Poetry


## Getting Started

### Install Yarn

```bash
npm install --global yarn
```

### Install dependencies

```bash
yarn
```

### Run the development app

```bash
yarn dev
```



12 changes: 12 additions & 0 deletions components/Layout/Layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { PropsWithChildren } from "react";
import { Navbar } from "./Navbar/Navbar";
import { Flex } from "antd";

export const Layout = ({ children }: PropsWithChildren) => {
return (
<Flex vertical>
<Navbar />
{children}
</Flex>
);
};
14 changes: 14 additions & 0 deletions components/Layout/Navbar/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { BellOutlined, SettingOutlined } from "@ant-design/icons";
import { Flex, Typography } from "antd";

export const Navbar = () => {
return (
<Flex vertical={false} justify="space-between" style={{ minWidth: "100%" }}>
<Typography.Text style={{ fontWeight: 700 }}>Operate</Typography.Text>
<Flex gap={4}>
<BellOutlined />
<SettingOutlined />
</Flex>
</Flex>
);
};
10 changes: 10 additions & 0 deletions components/Marketplace/Marketplace.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Flex } from "antd";
import { MarketplaceItem } from "./MarketplaceItem";

export const Marketplace = () => {
return (
<Flex vertical>
<MarketplaceItem />
</Flex>
);
};
26 changes: 26 additions & 0 deletions components/Marketplace/MarketplaceItem.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Row, Col, Button } from "antd";
import Image from "next/image";
export const MarketplaceItem = () => {
return (
<Row gutter={16}>
<Col span={8}>
<Image
src=""
alt="Image"
style={{
minWidth: "100%",
minHeight: "100%",
border: "1px solid black",
}}
/>
</Col>
<Col span={16}>
<h2>Agent Name</h2>
<p>Agent Description</p>
<Button href="/spawn/1" type="primary">
Run this agent
</Button>
</Col>
</Row>
);
};
11 changes: 11 additions & 0 deletions components/QRModal/QRModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Modal } from "antd";
import { Dispatch, SetStateAction } from "react";
type QRModalProps = {
open: boolean;
setOpen: Dispatch<SetStateAction<boolean>>;
address: string;
};

export const QRModal = ({ open, setOpen, address }: QRModalProps) => {
return <Modal open={open} onCancel={() => setOpen(false)} footer={null} />;
};
28 changes: 28 additions & 0 deletions components/Spawn/SpawnDone/SpawnDone.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { SpawnState } from "@/enums/SpawnState";
import { Tab } from "@/enums/Tabs";
import { useSpawn } from "@/hooks/useSpawn";
import { useTabs } from "@/hooks/useTabs";
import { Button, Flex } from "antd";
import { useRouter } from "next/router";

export const SpawnDone = () => {
const router = useRouter();

const { setSpawnState } = useSpawn();
const { setActiveTab } = useTabs();

const handleViewAgent = () => {
router.push("/").then(() => {
setActiveTab(Tab.YOUR_AGENTS);
setSpawnState(SpawnState.RPC);
});
};

return (
<Flex gap={8} vertical>
<Button type="primary" onClick={handleViewAgent}>
View agent
</Button>
</Flex>
);
};
56 changes: 56 additions & 0 deletions components/Spawn/SpawnFunds/SpawnFunds.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { SpawnState } from "@/enums/SpawnState";
import { copyToClipboard } from "@/helpers/copyToClipboard";
import { useSpawn } from "@/hooks/useSpawn";
import { Button, Flex, Timeline, Typography } from "antd";
import { useMemo } from "react";

const mockRequiresFunds = [
{ amount: 0.1, currency: "xDAI", to: "0xTest", recieved: true },
];

export const SpawnFunds = () => {
const { setSpawnState } = useSpawn();

const handleContinue = () => {
setSpawnState(SpawnState.DONE);
};

const items = useMemo(
() =>
mockRequiresFunds.map((mock) => ({
children: (
<Flex gap={8} vertical key={mock.to}>
<Typography.Text>
Send {mock.amount} {mock.currency} to: {mock.to}
</Typography.Text>
<Flex gap={8}>
<Button type="primary" onClick={() => copyToClipboard(mock.to)}>
Copy address
</Button>
<Button type="default">Show QR</Button>
</Flex>
</Flex>
),
})),
[],
);

const hasSentAllFunds = useMemo(
() => mockRequiresFunds.every((mock) => mock.recieved),
[],
);

return (
<Flex gap={8} vertical>
<Typography.Text>Your agent needs funds!</Typography.Text>
<Timeline items={items} />
<Button
type="default"
disabled={!hasSentAllFunds}
onClick={handleContinue}
>
Continue
</Button>
</Flex>
);
};
21 changes: 21 additions & 0 deletions components/Spawn/SpawnHeader/SpawnHeader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { useSpawn } from "@/hooks/useSpawn";
import { Progress, Typography } from "antd";
import Image from "next/image";
import { useMemo } from "react";

export const SpawnHeader = () => {
const { spawnPercentage } = useSpawn();

const title = useMemo(
() => (spawnPercentage === 100 ? "Agent Spawned" : "Spawn your Agent"),
[spawnPercentage],
);

return (
<>
<Image src="/robot-head.png" alt="robot head" width={200} height={200} />
<Typography.Title>{title}</Typography.Title>
<Progress percent={spawnPercentage} />
</>
);
};
Loading