Skip to content

Commit

Permalink
feat: allow user click badge cmd shortcut my model and update copy
Browse files Browse the repository at this point in the history
  • Loading branch information
urmauur committed Jan 8, 2024
1 parent 82ffcd0 commit e38e9c7
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 22 deletions.
23 changes: 19 additions & 4 deletions web/containers/Layout/BottomBar/SystemItem/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
import { ReactNode } from 'react'

import { twMerge } from 'tailwind-merge'

type Props = {
name?: string
value: string | ReactNode
titleBold?: boolean
}

export default function SystemItem({ name, value }: Props) {
export default function SystemItem({ name, value, titleBold }: Props) {
return (
<div className="flex items-center gap-x-1">
<p className="text-xs">{name}</p>
<span className="text-xs font-bold">{value}</span>
<div className="flex items-center gap-x-1 text-xs">
<p
className={twMerge(
titleBold ? 'font-semibold' : 'text-muted-foreground'
)}
>
{name}
</p>
<span
className={twMerge(
titleBold ? 'text-muted-foreground' : 'font-semibold'
)}
>
{value}
</span>
</div>
)
}
45 changes: 29 additions & 16 deletions web/containers/Layout/BottomBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@ import {
TooltipContent,
TooltipTrigger,
} from '@janhq/uikit'
import { useAtomValue } from 'jotai'
import { useAtomValue, useSetAtom } from 'jotai'

import { FaGithub, FaDiscord } from 'react-icons/fa'

import DownloadingState from '@/containers/Layout/BottomBar/DownloadingState'

import SystemItem from '@/containers/Layout/BottomBar/SystemItem'
import CommandListDownloadedModel from '@/containers/Layout/TopBar/CommandListDownloadedModel'
import ProgressBar from '@/containers/ProgressBar'

import { appDownloadProgress } from '@/containers/Providers/Jotai'

import { showSelectModelModalAtom } from '@/containers/Providers/KeyListener'
import ShortCut from '@/containers/Shortcut'

import { MainViewState } from '@/constants/screens'
Expand Down Expand Up @@ -48,6 +50,7 @@ const BottomBar = () => {
const { downloadedModels } = useGetDownloadedModels()
const { setMainViewState } = useMainViewState()
const { downloadStates } = useDownloadState()
const setShowSelectModelModal = useSetAtom(showSelectModelModalAtom)

return (
<div className="fixed bottom-0 left-16 z-20 flex h-12 w-[calc(100%-64px)] items-center justify-between border-t border-border bg-background/80 px-3">
Expand All @@ -58,25 +61,32 @@ const BottomBar = () => {
) : null}
</div>

<Badge
themes="secondary"
className="cursor-pointer rounded-md border-none font-medium"
onClick={() => setShowSelectModelModal((show) => !show)}
>
My Models&nbsp;
<ShortCut menu="E" />
</Badge>

{stateModel.state === 'start' && stateModel.loading && (
<SystemItem name="Starting:" value={stateModel.model || '-'} />
<SystemItem
titleBold
name="Starting"
value={stateModel.model || '-'}
/>
)}
{stateModel.state === 'stop' && stateModel.loading && (
<SystemItem name="Stopping:" value={stateModel.model || '-'} />
)}
{!stateModel.loading && downloadedModels.length !== 0 && (
<SystemItem
name={activeModel?.id ? 'Active model:' : ''}
value={
activeModel?.id || (
<Badge themes="outline" className="pl-1">
<ShortCut menu="E" />
&nbsp; to view models
</Badge>
)
}
titleBold
name="Stopping"
value={stateModel.model || '-'}
/>
)}
{!stateModel.loading && downloadedModels.length !== 0 && (
<SystemItem titleBold name={'Active model'} value={activeModel?.id} />
)}
{downloadedModels.length === 0 &&
!stateModel.loading &&
downloadStates.length === 0 && (
Expand All @@ -91,13 +101,15 @@ const BottomBar = () => {

<DownloadingState />
</div>
<div className="flex items-center gap-x-4">
<div className="flex items-center gap-x-3">
<div className="flex items-center gap-x-2">
<SystemItem name="CPU:" value={`${cpu}%`} />
<SystemItem name="Mem:" value={`${ram}%`} />
</div>
{/* VERSION is defined by webpack, please see next.config.js */}
<span className="text-xs">Jan v{VERSION ?? ''}</span>
<span className="text-xs text-muted-foreground">
Jan v{VERSION ?? ''}
</span>
<div className="mt-1 flex items-center gap-x-2">
{menuLinks
.filter((link) => !!link)
Expand All @@ -123,6 +135,7 @@ const BottomBar = () => {
))}
</div>
</div>
<CommandListDownloadedModel />
</div>
)
}
Expand Down
2 changes: 0 additions & 2 deletions web/containers/Layout/TopBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {

import { twMerge } from 'tailwind-merge'

import CommandListDownloadedModel from '@/containers/Layout/TopBar/CommandListDownloadedModel'
import CommandSearch from '@/containers/Layout/TopBar/CommandSearch'

import { MainViewState } from '@/constants/screens'
Expand Down Expand Up @@ -213,7 +212,6 @@ const TopBar = () => {
</div>
)}
<CommandSearch />
<CommandListDownloadedModel />
</div>
)
}
Expand Down

0 comments on commit e38e9c7

Please sign in to comment.