Skip to content

Commit

Permalink
Merge pull request #283 from DavitBakhutashvili/feat/add-api-key
Browse files Browse the repository at this point in the history
Feat/add api key
  • Loading branch information
Chkhikvadze authored Nov 7, 2023
2 parents 416eb5c + 2c3c8ce commit 084a74e
Show file tree
Hide file tree
Showing 31 changed files with 727 additions and 641 deletions.
1 change: 1 addition & 0 deletions apps/ui/.env.develop
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ REACT_APP_TERMS_LINK=https://github.com/l3vels/L3AGI/blob/main/docs/terms.md
REACT_APP_PRIVACY=https://github.com/l3vels/L3AGI/blob/main/docs/privacy.md
REACT_APP_BASICS_LINK=https://github.com/l3vels/L3AGI/blob/main/docs/basic.md
REACT_APP_AGENTS_LINK=https://github.com/l3vels/L3AGI/blob/main/docs/agent.md
REACT_APP_API_KEYS_LINK=https://github.com/l3vels/L3AGI/blob/main/docs/apiKeys.md
REACT_APP_DATASOURCES_LINK=https://github.com/l3vels/L3AGI/blob/main/docs/datasource.md
REACT_APP_TOOLS_LINK=https://github.com/l3vels/L3AGI/blob/main/docs/toolkit.md

Expand Down
1 change: 1 addition & 0 deletions apps/ui/.env.local
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ REACT_APP_YOUTUBE_VIDEO_ID=i84RodECglM
REACT_APP_TERMS_LINK=https://github.com/l3vels/L3AGI/blob/main/docs/terms.md
REACT_APP_PRIVACY=https://github.com/l3vels/L3AGI/blob/main/docs/privacy.md
REACT_APP_BASICS_LINK=https://github.com/l3vels/L3AGI/blob/main/docs/basic.md
REACT_APP_API_KEYS_LINK=https://github.com/l3vels/L3AGI/blob/main/docs/apiKeys.md
REACT_APP_AGENTS_LINK=https://github.com/l3vels/L3AGI/blob/main/docs/agent.md
REACT_APP_DATASOURCES_LINK=https://github.com/l3vels/L3AGI/blob/main/docs/datasource.md
REACT_APP_TOOLS_LINK=https://github.com/l3vels/L3AGI/blob/main/docs/toolkit.md
Expand Down
1 change: 1 addition & 0 deletions apps/ui/.env.production
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ REACT_APP_TERMS_LINK=https://github.com/l3vels/L3AGI/blob/main/docs/terms.md
REACT_APP_PRIVACY=https://github.com/l3vels/L3AGI/blob/main/docs/privacy.md
REACT_APP_BASICS_LINK=https://github.com/l3vels/L3AGI/blob/main/docs/basic.md
REACT_APP_AGENTS_LINK=https://github.com/l3vels/L3AGI/blob/main/docs/agent.md
REACT_APP_API_KEYS_LINK=https://github.com/l3vels/L3AGI/blob/main/docs/apiKeys.md
REACT_APP_DATASOURCES_LINK=https://github.com/l3vels/L3AGI/blob/main/docs/datasource.md
REACT_APP_TOOLS_LINK=https://github.com/l3vels/L3AGI/blob/main/docs/toolkit.md

Expand Down
1 change: 1 addition & 0 deletions apps/ui/src/@types/vite-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ interface ImportMetaEnv {
readonly REACT_APP_TERMS_LINK: string
readonly REACT_APP_PRIVACY: string
readonly REACT_APP_BASICS_LINK: string
readonly REACT_APP_API_KEYS_LINK: string
readonly REACT_APP_AGENTS_LINK: string
readonly REACT_APP_DATASOURCES_LINK: string
readonly REACT_APP_TOOLS_LINK: string
Expand Down
15 changes: 15 additions & 0 deletions apps/ui/src/Route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ import ScheduleRunModal from 'modals/ScheduleRunModal'
import RunLogsModal from 'modals/RunLogsModal/RunLogsModal'
import CreateFineTuningForm from 'pages/Models/FineTuning/FineTuningForm/CreateFineTuningForm'
import EditFineTuningForm from 'pages/Models/FineTuning/FineTuningForm/EditFineTuningForm'
import CreateApiKeyForm from 'pages/ApiKeys/CreateApiKey/CreateApikeysForm'
import EditApiKeyForm from 'pages/ApiKeys/EditApiKey/EditApiKeysForm'
import Integrations from 'pages/Integrations'
import VoiceView from 'plugins/contact/pages/Voice/VoiceView'
import VoiceModal from 'modals/VoiceModal'
Expand Down Expand Up @@ -305,6 +307,19 @@ const Route = () => {
/>
</Router>

<Router path='api-key' element={<MainRouteLayout />} key={document.location.href}>
<Router index element={<ApiKeys />} key={document.location.href} />
<Router
path={'create-api-key'}
element={<CreateApiKeyForm />}
key={document.location.href}
/>
<Router
path={':apiKeyId/edit-api-key'}
element={<EditApiKeyForm />}
key={document.location.href}
/>
</Router>
{/* <Router path={'groups'} element={<MainRouteLayout />} key={document.location.href}>
<Router index element={<Group />} key={document.location.href} />
</Router> */}
Expand Down
23 changes: 22 additions & 1 deletion apps/ui/src/components/AvatarDropDown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
} from '@radix-ui/react-dropdown-menu'

import Avatar from '@l3-lib/ui-core/dist/Avatar'
import API from '@l3-lib/ui-core/dist/icons/API'
import Typography from '@l3-lib/ui-core/dist/Typography'
import styled, { css, keyframes } from 'styled-components'

Expand Down Expand Up @@ -101,9 +102,23 @@ const AvatarDropDown = () => {
style={{ fontSize: '12px', fontStyle: 'normal', fontWeight: '500', lineHeight: '16px' }}
/>
</StyledDropDownMenuItem>
<StyledDropDownMenuItem onClick={() => navigate('api-key')}>
<StyledAPIIcon size={20} />

<TypographyPrimary
value='API Keys'
type={Typography.types.P}
size={Typography.sizes.xss}
style={{
fontSize: '12px',
fontStyle: 'normal',
fontWeight: '500',
lineHeight: '16px',
}}
/>
</StyledDropDownMenuItem>
<StyledDropDownMenuItem onClick={handleLogout}>
<StyledLogOutIcon size={20} />

<TypographyPrimary
value={t('logout')}
type={Typography.types.P}
Expand Down Expand Up @@ -331,3 +346,9 @@ const StyledSettingsIcon = styled(Settings)`
stroke: ${({ theme }) => theme.body.iconColor};
}
`

const StyledAPIIcon = styled(API)`
path {
fill: ${({ theme }) => theme.body.iconColor};
}
`
15 changes: 10 additions & 5 deletions apps/ui/src/gql/apiKey/apiKeyById.gql
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
query apiKeyById($id: ID!) @api(name: game) {
apiKeyById(id: $id) {
query apiKeyById($id: id!) @api(name: "ai") {
apiKeyById(id: $id)
@rest(type: "ApiKeys", path: "/api-key/{args.id}", method: "GET", endpoint: "ai") {
id
name
token
note
expiration
games
description
is_deleted
account_id
created_on
created_by
modified_by
}
}
24 changes: 11 additions & 13 deletions apps/ui/src/gql/apiKey/apiKeys.gql
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
query apiKeys($filter: ListFilterQuery) @api(name: game) {
apiKeys(filter: $filter) {
items {
id
name
token
note
expiration
games
created_on
last_used
}
total_count
query getApiKeys @api(name: "ai") {
getApiKeys @rest(type: "ApiKeys", path: "/api-key", method: "GET", endpoint: "ai") {
id
name
token
description
is_deleted
account_id
created_on
created_by
modified_by
}
}
22 changes: 12 additions & 10 deletions apps/ui/src/gql/apiKey/createApiKey.gql
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
mutation createApiKey($input: ApiKeyInput!) @api(name: game) {
createApiKey(input: $input) {
success
apiKey {
name
token
note
expiration
games
}
mutation createApiKey($input: input!) @api(name: ai) {
createApiKey(input: $input)
@rest(type: "ApiKeys", path: "/api-key", method: "POST", bodyKey: "input", endpoint: "ai") {
id
name
token
description
is_deleted
account_id
created_on
created_by
modified_by
}
}
20 changes: 10 additions & 10 deletions apps/ui/src/gql/apiKey/deleteApikeyById.gql
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
mutation deleteApiKey($id: ID!) @api(name: game) {
deleteApiKey(id: $id) {
id
name
token
note
expiration
games
created_on
last_used
mutation deleteApiKey($id: id!) @api(name: ai) {
deleteApiKey(id: $id)
@rest(
type: "ApiKeys"
path: "/api-key/{args.id}"
method: "DELETE"
bodyKey: "input"
endpoint: "ai"
) {
agent
}
}
14 changes: 8 additions & 6 deletions apps/ui/src/gql/apiKey/updateApiKey.gql
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
mutation updateApiKey($id: ID!, $input: ApiKeyInput!) @api(name: game) {
updateApiKey(id: $id, input: $input) {
mutation updateApiKey($id: id!, $input: input!) @api(name: "ai") {
updateApiKey(id: $id, input: $input)
@rest(type: "ApiKeys", path: "/api-key/{args.id}", method: "PUT", endpoint: "ai") {
success
apiKey {
id
name
token
note
expiration
games
description
is_deleted
account_id
created_on
last_used
created_by
modified_by
}
}
}
1 change: 1 addition & 0 deletions apps/ui/src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
"create-asset": "Create Asset",
"create-session": "Create Session",
"create-secret-key": "Create secret key",
"create-api-key": "Create Api key",
"create-new-secret-key": "Create a new secret key",
"createAgent": "Create Agent",
"custom-fields": "Custom Fields",
Expand Down
Loading

0 comments on commit 084a74e

Please sign in to comment.