Skip to content

Commit

Permalink
Merge pull request #63 from r3yc0n1c/main
Browse files Browse the repository at this point in the history
api call for available machines
  • Loading branch information
zeitgeistxx authored Jun 29, 2024
2 parents 434a78a + acbdadb commit f3532a9
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 19 deletions.
13 changes: 10 additions & 3 deletions backend/src/routes/machine/machine.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,12 @@ const GetMachinesByUserId = async ({ params: { userId }, set, db, log }) => {
try {
const machines = await db.machine.findMany({
where: { userId },
include: {
user: true
}
});

set.status = 201;
set.status = 200;
return machines;
} catch (err) {
log.error(err);
Expand All @@ -61,9 +64,13 @@ const GetMachinesByUserId = async ({ params: { userId }, set, db, log }) => {

const GetAllMachines = async ({ set, db, log }) => {
try {
const allMachines = await db.machiune.findMany();
const allMachines = await db.machine.findMany({
include: {
user: true
}
})

set.status = 201;
set.status = 200;
return allMachines;
} catch (err) {
log.error(err);
Expand Down
1 change: 1 addition & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ yarn-error.log*

# local env files
.env*.local
.env

# vercel
.vercel
Expand Down
17 changes: 12 additions & 5 deletions frontend/components/search/SearchWrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
"use client"
import React from 'react'
import { Input } from '../ui/input'
import { Button } from '../ui/button'
import ComputeCard from './cards/ComputeCard'

export default function SearchWrapper() {
export default async function SearchWrapper() {
const machines = await (await fetch(`${process.env.NEXT_PUBLIC_API_URL}/machine/all`, {
next: {
revalidate: 3600
}
})).json()

return (
<div className='px-[5%]'>
<div className='w-full generalBorder offsetEffect bg-yellow-300'>
Expand All @@ -13,12 +18,14 @@ export default function SearchWrapper() {
</div>
<div className='py-4'>
<div className='flex items-center gap-4'>
<Input className='generalTabsBorder offsetEffect w-[40%]' placeholder='search for compute' /> <Button className='generalTabsBorder offsetstyle bg-orange-800'>Filter</Button>
<Input className='generalTabsBorder offsetEffect w-[40%]' placeholder='search for compute' />
<Button className='generalTabsBorder offsetstyle bg-orange-800'>Filter</Button>
</div>
</div>
<div className='grid grid-cols-4 gap-4'>
<ComputeCard props={{ activity: 4, cpu: "4/24GB", gpu: "1/15GB", id: "9iisjkjJHHH98j", name: "tappin.dip98", space: "0.003/24TB" }} />
<ComputeCard props={{ activity: 2, cpu: "20/32GB", gpu: "2/35GB", id: "9iisjkjJHHH98j", name: "tappin.amit78", space: "0.13/64TB" }} />
{machines.map((machine: any, idx: any) => (
<ComputeCard key={idx} props={{ id: machine.id, title: machine.title, cpu: machine.cpu, ram: machine.ram, storage: machine.size, address: machine.user.address }} />
))}
</div>
</div>
)
Expand Down
10 changes: 5 additions & 5 deletions frontend/components/search/cards/ComputeCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@ export default function ComputeCard({ props }: Props) {
<div className='grid grid-cols-2 gap-2'>
<div className='flex flex-col '>
<span className='text-xs text-gray-600'>Device name</span>
<h1 className='text-xl font-medium'>{props.name}</h1>
<h1 className='text-xl font-medium'>{props.title}</h1>
</div>
<div className='flex flex-col'>
<span className='text-xs text-gray-600'>Available CPU</span>
<h1 className='text-xl font-medium'>{props.cpu}</h1>
</div>
<div className='flex flex-col'>
<span className='text-xs text-gray-600'>Available GPU</span>
<h1 className='text-xl font-medium'>{props.gpu}</h1>
<span className='text-xs text-gray-600'>Available RAM</span>
<h1 className='text-xl font-medium'>{props.ram}GB</h1>
</div>
<div className='flex flex-col'>
<span className='text-xs text-gray-600'>Available space</span>
<h1 className='text-xl font-medium'>{props.space}</h1>
<h1 className='text-xl font-medium'>{props.storage}GB</h1>
</div>
<div className='flex flex-col'>
<span className='text-xs text-gray-600'>Instances</span>
<h1 className='text-xl font-medium'>{props.activity}</h1>
<h1 className='text-xl font-medium'>{props?.activity}</h1>
</div>
</div>
<div className='pt-2'>
Expand Down
13 changes: 7 additions & 6 deletions frontend/constants/images/models/specscard.model.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
export class SpecsCard {
declare id: string; //j82jjdjjjjHJHgshjkjj89981288j7shoxweeejua
declare name: string; //tappin.dip798
declare gpu: string; // 1/16GB
declare cpu: string; // 2/64GB
declare space: string; // 0.06/20TB
declare activity: number; // 3 (active leases)
declare id: string;
declare title: string;
declare cpu: string;
declare ram: string;
declare storage: string;
declare address: string;
declare activity?: number;
}

0 comments on commit f3532a9

Please sign in to comment.