-
Notifications
You must be signed in to change notification settings - Fork 0
digit-recognition frontend #3
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
Merged
Merged
Changes from 33 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
7205723
init digit-recognition frontend
vraja-nayaka 948c725
remove tailwind styles
vraja-nayaka 89a9a65
remove tailwind config
vraja-nayaka 44e15ea
init digit-recognition frontend
vraja-nayaka e701ff7
remove tailwind styles
vraja-nayaka 372a873
remove tailwind config
vraja-nayaka a9d5431
upd Dockerfile
kvs96 dc2f631
Merge branch 'vt-digit-recognition-frontend' of github.com:gear-found…
vraja-nayaka 9238252
Merge remote-tracking branch 'origin/master' into vt-digit-recognitio…
vraja-nayaka df43068
fix envs
vraja-nayaka 7608cba
fix build
vraja-nayaka 1fc3b3d
Merge remote-tracking branch 'origin/master' into vt-digit-recognitio…
vraja-nayaka e83e47d
add contract api
vraja-nayaka e50afcf
debug envs
vraja-nayaka c371cc0
Update Dockerfile
sergeyfilyanin 0eaf81e
Update Dockerfile
sergeyfilyanin 3033344
Update Dockerfile
sergeyfilyanin a266a88
Update consts.ts
sergeyfilyanin 2897cc8
Update consts.ts
sergeyfilyanin bbce1d1
Update CI-CD_digit-recognition-frontend.yaml
sergeyfilyanin 08bef76
debug event subscription
vraja-nayaka b89b864
fix event subscription
vraja-nayaka 0cc7368
Merge branch 'vt-digit-recognition-frontend' of github.com:gear-found…
vraja-nayaka ddff3cd
fix read state
vraja-nayaka 578f724
bebug envs
vraja-nayaka 4bb9048
fix ci cd
vraja-nayaka 7d9476f
remove envs debugger
vraja-nayaka 8cad172
remove unused abi
vraja-nayaka 1fcea35
Update CI-CD-Distributed-Computation-fe.yml
sergeyfilyanin d7a44a2
fix digit recorgnition
vraja-nayaka 28f8ec5
remove unused deps
vraja-nayaka 580096d
Merge branch 'vt-digit-recognition-frontend' of github.com:gear-found…
vraja-nayaka dfb8869
remove unused deps
vraja-nayaka 0678856
Merge remote-tracking branch 'origin/master' into vt-digit-recognitio…
vraja-nayaka 8970124
fix review
vraja-nayaka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,66 +1,121 @@ | ||
| name: Deploy Frontend Distributed Computation | ||
| name: Build and Deploy mandelbrot-set/frontend | ||
|
|
||
| on: | ||
| push: | ||
| branches: ['master'] | ||
| paths: frontend | ||
| workflow_dispatch: | ||
| push: | ||
| branches: ["*"] | ||
| paths: | ||
| - "mandelbrot-set/frontend/**" | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| env: | ||
| REGISTRY: ghcr.io | ||
| IMAGE_NAME: ${{ github.repository }} | ||
| ENVIRONMENT: ${{ (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main') && 'prod' || 'stg' }} | ||
| REGISTRY: ghcr.io/$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]') | ||
| AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
| AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
| AWS_REGION: ${{ secrets.AWS_REGION }} | ||
| KUBECTL_VERSION: ${{ secrets.KUBECTL_VERSION }} | ||
| KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_DATA }} | ||
| KUBE_NAMESPACE: gear-exe-dapps | ||
| KUBE_DEPLOY_PREFIX: mandelbrot-set-frontend | ||
| KUBE_DEPLOY_TYPE: deployment # (statefulset or deployment) | ||
|
|
||
| jobs: | ||
| build-frontend-image: | ||
| prepair: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| image_name: ${{ steps.image.outputs.image_name }} | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Get branch | ||
| id: branch | ||
| run: | | ||
| branch_name=${GITHUB_REF#refs/heads/} | ||
| echo "branch_name=$branch_name" >> $GITHUB_ENV | ||
|
|
||
| - name: Get short SHA | ||
| id: sha | ||
| run: | | ||
| sha_short=$(git rev-parse --short HEAD) | ||
| echo "sha_short=$sha_short" >> $GITHUB_ENV | ||
|
|
||
| - name: Set IMAGE_NAME | ||
| id: image | ||
| run: | | ||
| image_name=${{ env.REGISTRY }}-${{ env.KUBE_DEPLOY_PREFIX }}:${{ env.branch_name }}-${{ env.sha_short }} | ||
| echo "image_name=$image_name" >> $GITHUB_OUTPUT | ||
|
|
||
| build-and-push-image: | ||
| needs: [prepair] | ||
| runs-on: ubuntu-latest | ||
| environment: ${{ (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main') && 'prod' || 'stg' }} | ||
| permissions: | ||
| contents: read | ||
| packages: write | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v2 | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Log in to the github container registry | ||
| uses: docker/login-action@master | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| registry: ${{ env.REGISTRY }} | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Build and push Frontend Docker image | ||
| uses: docker/build-push-action@master | ||
| - name: Build and push image | ||
| uses: docker/build-push-action@v6 | ||
| with: | ||
| context: mandelbrot-set/frontend | ||
| context: mandelbrot-set/frontend/ | ||
| push: true | ||
| tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-mandelbrot-set-fe:prod | ||
| build-args: | | ||
| VITE_WALLET_CONNECT_PROJECT_ID=${{ secrets.VITE_WALLET_CONNECT_PROJECT_ID_MONDELBROT }} | ||
| VITE_GEAR_API_NODE=${{ secrets.VITE_GEAR_API_NODE }} | ||
| VITE_CONTRACT_ADDRESS=${{ secrets.VITE_CONTRACT_ADDRESS_MONDELBROT }} | ||
| VITE_ETH_NODE_ADDRESS=${{ secrets.VITE_ETH_NODE_ADDRESS }} | ||
| tags: ${{ needs.prepair.outputs.image_name }} | ||
|
|
||
| deploy-k8s: | ||
| needs: build-frontend-image | ||
| deploy-to-k8s: | ||
| needs: [prepair, build-and-push-image] | ||
| runs-on: ubuntu-latest | ||
|
|
||
| environment: ${{ (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main') && 'prod' || 'stg' }} | ||
| steps: | ||
| - name: Setup kubectl | ||
| run: | | ||
| curl -LO "https://dl.k8s.io/release/${{ env.KUBECTL_VERSION }}/bin/linux/amd64/kubectl" | ||
| chmod +x kubectl | ||
| sudo mv kubectl /usr/local/bin/ | ||
| mkdir -p $HOME/.kube/ | ||
| echo "${{ env.KUBE_CONFIG_DATA }}" | base64 -d > $HOME/.kube/config | ||
|
|
||
| - name: Configure AWS credentials | ||
| uses: aws-actions/configure-aws-credentials@v1 | ||
| uses: aws-actions/configure-aws-credentials@v4 | ||
| with: | ||
| aws-access-key-id: ${{ env.AWS_ACCESS_KEY_ID }} | ||
| aws-secret-access-key: ${{ env.AWS_SECRET_ACCESS_KEY }} | ||
| aws-region: ${{ env.AWS_REGION }} | ||
|
|
||
| - name: Deploy to k8s | ||
| uses: sergeyfilyanin/kubectl-aws-eks@master | ||
| with: | ||
| args: rollout restart deployment distributed-computation -n gear-dapps | ||
| - name: Get containes | ||
| id: containers | ||
| run: | | ||
| containers=$(kubectl get ${{ env.KUBE_DEPLOY_TYPE }}/${{ env.KUBE_DEPLOY_PREFIX }}-${{ env.ENVIRONMENT }} -n ${{ env.KUBE_NAMESPACE }} -o jsonpath="{.spec.template.spec.containers[*].name}") | ||
| echo "CONTAINERS=$containers" >> $GITHUB_ENV | ||
|
|
||
| - name: Update deployment image | ||
| run: | | ||
| for container in ${{ env.CONTAINERS }}; do | ||
| kubectl set image ${{ env.KUBE_DEPLOY_TYPE }}/${{ env.KUBE_DEPLOY_PREFIX }}-${{ env.ENVIRONMENT }} $container=${{ needs.prepair.outputs.image_name }} -n ${{ env.KUBE_NAMESPACE }}; | ||
| done | ||
|
|
||
| - name: Restart deployment | ||
| run: | | ||
| kubectl rollout restart ${{ env.KUBE_DEPLOY_TYPE }}/${{ env.KUBE_DEPLOY_PREFIX }}-${{ env.ENVIRONMENT }} -n ${{ env.KUBE_NAMESPACE }} | ||
|
|
||
| - name: Check deployment | ||
| run: | | ||
| kubectl rollout status ${{ env.KUBE_DEPLOY_TYPE }}/${{ env.KUBE_DEPLOY_PREFIX }}-${{ env.ENVIRONMENT }} --timeout=300s -n ${{ env.KUBE_NAMESPACE }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| VITE_WALLET_CONNECT_PROJECT_ID= | ||
| VITE_GEAR_API_NODE= | ||
| VITE_ETH_NODE_ADDRESS= | ||
| VITE_CONTRACT_ADDRESS_DIGIT_RECOGNITION= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| # Logs | ||
| logs | ||
| *.log | ||
| npm-debug.log* | ||
| yarn-debug.log* | ||
| yarn-error.log* | ||
| pnpm-debug.log* | ||
| lerna-debug.log* | ||
|
|
||
| node_modules | ||
| dist | ||
| dist-ssr | ||
| *.local | ||
| .env | ||
|
|
||
| # Editor directories and files | ||
| .vscode/* | ||
| !.vscode/extensions.json | ||
| .idea | ||
| .DS_Store | ||
| *.suo | ||
| *.ntvs* | ||
| *.njsproj | ||
| *.sln | ||
| *.sw? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| FROM node:18-alpine | ||
|
|
||
| WORKDIR /opt | ||
|
|
||
| RUN apk add --no-cache xsel | ||
|
|
||
| COPY package.json yarn.lock ./ | ||
|
|
||
| RUN yarn install --frozen-lockfile | ||
|
|
||
| COPY . . | ||
|
|
||
| ARG VITE_WALLET_CONNECT_PROJECT_ID \ | ||
| VITE_GEAR_API_NODE \ | ||
| VITE_ETH_NODE_ADDRESS \ | ||
| VITE_CONTRACT_ADDRESS_DIGIT_RECOGNITION | ||
|
|
||
| ENV VITE_WALLET_CONNECT_PROJECT_ID=${VITE_WALLET_CONNECT_PROJECT_ID} \ | ||
| VITE_CONTRACT_ADDRESS_DIGIT_RECOGNITION=${VITE_CONTRACT_ADDRESS_DIGIT_RECOGNITION} \ | ||
| VITE_GEAR_API_NODE=${VITE_GEAR_API_NODE} \ | ||
| VITE_ETH_NODE_ADDRESS=${VITE_ETH_NODE_ADDRESS} \ | ||
| DISABLE_ESLINT_PLUGIN=true | ||
|
|
||
| RUN yarn build | ||
|
|
||
| RUN npm install --global serve | ||
|
|
||
| EXPOSE 4173 | ||
|
|
||
| CMD ["serve", "-s", "/opt/dist"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # AI Image Recognition | ||
|
|
||
| ## Description | ||
|
|
||
| React application of AI Image Recognition. | ||
|
|
||
| ## Getting started | ||
|
|
||
| ### Install packages: | ||
|
|
||
| ```sh | ||
| yarn install | ||
| ``` | ||
|
|
||
| ### Declare environment variables: | ||
|
|
||
| Create `.env` file, `.env.example` will let you know what variables are expected. | ||
|
|
||
| ### Run the app: | ||
|
|
||
| ```sh | ||
| yarn start | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import js from '@eslint/js' | ||
| import globals from 'globals' | ||
| import reactHooks from 'eslint-plugin-react-hooks' | ||
| import reactRefresh from 'eslint-plugin-react-refresh' | ||
| import tseslint from 'typescript-eslint' | ||
|
|
||
| export default tseslint.config( | ||
| { ignores: ['dist'] }, | ||
| { | ||
| extends: [js.configs.recommended, ...tseslint.configs.recommended], | ||
| files: ['**/*.{ts,tsx}'], | ||
| languageOptions: { | ||
| ecmaVersion: 2020, | ||
| globals: globals.browser, | ||
| }, | ||
| plugins: { | ||
| 'react-hooks': reactHooks, | ||
| 'react-refresh': reactRefresh, | ||
| }, | ||
| rules: { | ||
| ...reactHooks.configs.recommended.rules, | ||
| 'react-refresh/only-export-components': [ | ||
| 'warn', | ||
| { allowConstantExport: true }, | ||
| ], | ||
| }, | ||
| }, | ||
| ) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| <!doctype html> | ||
| <html lang="en" class="dark"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <link rel="icon" type="image/png" href="/favicon.png" sizes="any" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <title>AI Image Recognition</title> | ||
| </head> | ||
| <body> | ||
| <div id="root"></div> | ||
| <script type="module" src="/src/main.tsx"></script> | ||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| { | ||
| "name": "distributed-computation", | ||
| "private": true, | ||
| "version": "0.0.0", | ||
| "type": "module", | ||
| "scripts": { | ||
| "dev": "vite", | ||
| "build": "tsc -b && vite build", | ||
| "lint": "eslint .", | ||
| "preview": "vite preview" | ||
| }, | ||
| "dependencies": { | ||
| "@polkadot/types": "14.3.1", | ||
| "@radix-ui/react-slot": "1.1.0", | ||
| "@reown/appkit": "^1.6.0", | ||
| "@reown/appkit-adapter-wagmi": "^1.6.0", | ||
| "@tanstack/react-query": "^5.59.20", | ||
| "class-variance-authority": "^0.7.1", | ||
| "react": "^18.3.1", | ||
| "react-dom": "^18.3.1", | ||
| "wagmi": "^2.12.29" | ||
| }, | ||
| "devDependencies": { | ||
| "@eslint/js": "^9.13.0", | ||
| "@types/react": "^18.3.12", | ||
| "@types/react-dom": "^18.3.1", | ||
| "@vitejs/plugin-react": "^4.3.3", | ||
| "eslint": "^9.13.0", | ||
| "eslint-plugin-react-hooks": "^5.0.0", | ||
| "eslint-plugin-react-refresh": "^0.4.14", | ||
| "globals": "^15.11.0", | ||
| "typescript": "~5.6.2", | ||
| "typescript-eslint": "^8.11.0", | ||
| "vite": "^5.4.10", | ||
| "vite-plugin-svgr": "^4.3.0", | ||
| "sass": "1.62.0" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| .connectionWrapper { | ||
| display: flex; | ||
| flex-direction: column; | ||
| justify-content: center; | ||
| align-items: center; | ||
| gap: 48px; | ||
| padding-top: 0; | ||
| min-height: calc(100vh - 78px); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import "./index.css"; | ||
| import { useAccount } from "wagmi"; | ||
|
|
||
| import { WalletButton, Header, Layout } from "@/components"; | ||
| import { Recognition } from "./components/recognition/Recognition"; | ||
| import styles from "./App.module.scss"; | ||
|
|
||
| function App() { | ||
| const ethAccount = useAccount(); | ||
| const isConnected = Boolean(ethAccount.chain); | ||
|
|
||
| return ( | ||
| <> | ||
| <Header /> | ||
| {!isConnected && ( | ||
| <Layout className={styles.connectionWrapper}> | ||
| <h1>AI Image Recognition</h1> | ||
|
|
||
| <WalletButton /> | ||
| </Layout> | ||
| )} | ||
| {isConnected && <Recognition />} | ||
| </> | ||
| ); | ||
| } | ||
|
|
||
| export default App; | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions
5
digit-recognition/frontend/src/assets/icons/document-copy.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.