Skip to content

Commit

Permalink
Merge pull request #457 from l3vels/feat/subnets-page
Browse files Browse the repository at this point in the history
feat: subnets page
  • Loading branch information
Chkhikvadze authored May 31, 2024
2 parents 5fdd525 + 4c3c316 commit ff43c2f
Show file tree
Hide file tree
Showing 9 changed files with 681 additions and 3 deletions.
4 changes: 4 additions & 0 deletions apps/ui/src/Route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ import VoiceOptionsModal from 'modals/VoiceOptionsModal'
import LlmSettingsModal from 'modals/LlmSettingsModal'
import { InviteUsers, CreateUserAccess } from 'pages/InviteUsers'
import { Pods, PodsContent } from 'pages/Pods'
import Subnets from 'pages/Subnets'


const Route = () => {
const { loading } = useContext(AuthContext)
Expand Down Expand Up @@ -294,6 +296,8 @@ const Route = () => {
<Router path={'voice/:slug'} element={<VoiceView />} key={document.location.href} />
</Router>

<Router path={'subnets'} element={<Subnets />} key={document.location.href}></Router>

{/* <Router path={'toolkits'} element={<MainRouteLayout />} key={document.location.href}>
<Router index element={<Toolkit />} key={document.location.href} />
<Router path={':slug'} element={<ToolView />} key={document.location.href} />
Expand Down
29 changes: 27 additions & 2 deletions apps/ui/src/pages/Navigation/MainNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ import FineTuning from 'share-ui/components/Icon/Icons/components/FineTuning'
import Book from 'share-ui/components/Icon/Icons/components/Book'

const MainNavigation = ({ user }: { user: any }) => {
const domainEnv = import.meta.env
const isDatura = domainEnv.REACT_APP_ENV === 'datura'

const { getDomainConfig } = useDomainConfig()
const domainLogo = getDomainConfig('logo')

Expand Down Expand Up @@ -98,7 +101,7 @@ const MainNavigation = ({ user }: { user: any }) => {
</Tooltip>
)}

{isChat && (
{!isDatura && isChat && (
<Tooltip content={t('chat')} position={Tooltip.positions.LEFT}>
<StyledLi isActive={includes(active, 'chat')} onClick={() => onHandleClick('/chat')}>
<Chats size={40} />
Expand Down Expand Up @@ -147,7 +150,7 @@ const MainNavigation = ({ user }: { user: any }) => {
</Tooltip>
)} */}

{isDatasource && (
{!isDatura && isDatasource && (
<Tooltip content={t('datasource')} position={Tooltip.positions.LEFT}>
<StyledLi
isActive={includes(active, 'datasources')}
Expand Down Expand Up @@ -195,6 +198,21 @@ const MainNavigation = ({ user }: { user: any }) => {
</StyledLi>
</Tooltip>

{isDatura && (
<Tooltip content={t('Subnets')} position={Tooltip.positions.LEFT}>
<StyledLi
isActive={includes(active, 'subnets')}
onClick={() => onHandleClick('/subnets')}
>
<StyledImg
src='https://icons.veryicon.com/png/o/application/cloud-supervision-platform-vr10/subnets.png'
picked={includes(active, 'subnets')}
/>
{includes(active, 'subnets') && <StyledCorner />}
</StyledLi>
</Tooltip>
)}

{/* {isDiscover && (
<Tooltip content={t('discover')} position={Tooltip.positions.LEFT}>
<StyledLi
Expand Down Expand Up @@ -369,6 +387,13 @@ const StyledLogo = styled.img`
width: 40px;
height: 40px;
`
const StyledImg = styled.img<{ picked: boolean }>`
width: 22px;
height: 22px;
filter: ${({ picked }) => (picked ? 'brightness(0) invert(1)' : 'none')};
`

const StyledCorner = styled.div`
width: 0;
height: 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { useEditSchedule } from '../useEditSchedule'
import ScheduleForm from './ScheduleForm'
import { StyledFormWrapper } from 'styles/formStyles.css'

const EditScheduleForm = ({ scheduleId }: { scheduleId: string }) => {
const EditScheduleForm = ({ scheduleId }: { scheduleId?: string }) => {
const { formik, isLoading } = useEditSchedule({ incomingScheduleId: scheduleId })

return (
Expand Down
159 changes: 159 additions & 0 deletions apps/ui/src/pages/Subnets/ApiCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
import styled from 'styled-components'

import Typography from 'share-ui/components/typography/Typography'

import AvatarGenerator from 'components/AvatarGenerator/AvatarGenerator'

import TypographySecondary from 'components/Typography/Secondary'
import TypographyPrimary from 'components/Typography/Primary'

import { textSlicer } from 'utils/textSlicer'
import Switcher from './Switcher'

type ApiCardProps = {
name: string
description: string
headerText?: string
headerTag?: string
avatar?: string
icon?: string
}

const ApiCard = ({ name, description, headerTag, avatar, icon }: ApiCardProps) => {
const { shortText: shortName } = textSlicer(name, 25)

let shortHeaderTag
if (headerTag) {
const { shortText } = textSlicer(headerTag, 40)
shortHeaderTag = shortText
}

return (
<StyledApiCard>
<StyledCardHeader>
<StyledAvatarWrapper>
{icon ? <StyledIcon>{icon}</StyledIcon> : <StyledImg src={avatar} />}
</StyledAvatarWrapper>

<StyledTitleWrapper>
<TypographyPrimary
value={shortName}
type={Typography.types.P}
size={Typography.sizes.sm}
/>
</StyledTitleWrapper>

<StyledSwitcherWrapper>
<Switcher />
</StyledSwitcherWrapper>
</StyledCardHeader>
<StyledCardBody>
<StyledBodyTextWrapper>
<TypographySecondary
value={description}
type={Typography.types.P}
size={Typography.sizes.sm}
/>
</StyledBodyTextWrapper>
</StyledCardBody>
</StyledApiCard>
)
}

export default ApiCard

export const StyledApiCard = styled.div`
position: relative;
width: 300px;
min-width: 300px;
height: 170px;
min-height: 170px;
padding: 15px;
padding-bottom: 10px;
padding-top: 20px;
border-radius: 22px;
/* background: rgba(0, 0, 0, 0.5); */
background: ${({ theme }) => theme.body.cardBgColor};
/* border: ${({ theme }) => theme.body.border}; */
box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.1);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
:hover {
.cardFooter {
opacity: 1;
}
}
.components-IconButton-IconButton-module__iconButtonContainer--ttuRB {
&:hover {
background: ${({ theme }) => theme.body.humanMessageBgColor};
border-radius: 50%;
}
}
`
const StyledCardHeader = styled.div`
width: 100%;
padding-bottom: 12px;
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 5px;
min-height: 20px;
`

const StyledCardBody = styled.div`
width: 100%;
height: 100%;
margin-top: auto;
display: flex;
gap: 15px;
overflow: hidden;
`

const StyledBodyTextWrapper = styled.div`
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 3;
overflow: hidden;
text-overflow: ellipsis;
max-height: 70px;
`
const StyledAvatarWrapper = styled.div`
text-align: center;
height: fit-content;
`
const StyledIcon = styled.span`
font-size: 30px;
`

const StyledTitleWrapper = styled.div`
display: flex;
justify-content: space-between;
font-weight: 500;
`
const StyledImg = styled.img`
width: 34px;
height: 34px;
object-fit: contain;
border-radius: 8px;
`
const StyledSwitcherWrapper = styled.div`
margin-left: auto;
`
Loading

0 comments on commit ff43c2f

Please sign in to comment.