Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Added static resources section in admin panel #6872

Merged
merged 22 commits into from
Sep 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
3bbfd0f
Added static resources section in admin panel
hanzlamateen Sep 6, 2022
e14ba93
Added search for static resources
hanzlamateen Sep 6, 2022
cff3952
Added static resource type value to db
hanzlamateen Sep 7, 2022
34d0b63
Merge branch 'dev' into admin-resources
hanzlamateen Sep 7, 2022
43d6977
fixed build errors
hanzlamateen Sep 7, 2022
a51d829
Fixed properties error
hanzlamateen Sep 7, 2022
d1e6bf5
Merge branch 'dev' into admin-resources
hanzlamateen Sep 7, 2022
492acd1
CRUD support for resources
hanzlamateen Sep 7, 2022
58bd97b
Merge branch 'dev' into admin-resources
hanzlamateen Sep 8, 2022
1b7a3ed
Added upload file/url in create/edit resource
hanzlamateen Sep 8, 2022
4de4ce4
Merge branch 'dev' into admin-resources
hanzlamateen Sep 8, 2022
2f8cc32
Merge branch 'dev' into admin-resources
hanzlamateen Sep 8, 2022
b759475
Fixed issue with dev-reinit
hanzlamateen Sep 8, 2022
ddd156d
Merge branch 'dev' into admin-resources
hanzlamateen Sep 8, 2022
484389e
Merge branch 'dev' into admin-resources
hanzlamateen Sep 9, 2022
a48ea76
Merge branch 'dev' into admin-resources
hanzlamateen Sep 9, 2022
1fb361b
Merge branch 'dev' into admin-resources
hanzlamateen Sep 10, 2022
da20de1
Added all static resource types to filter
hanzlamateen Sep 10, 2022
2531d25
Added all resource type for drawer
hanzlamateen Sep 10, 2022
a1e7e86
Removed ability to change mime type
hanzlamateen Sep 10, 2022
74a64f4
Added name for new resource and made key constant
hanzlamateen Sep 10, 2022
54a00a4
Merge branch 'dev' into admin-resources
hanzlamateen Sep 10, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions packages/client-core/i18n/en/admin.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"update": "Update",
"enter": "Enter",
"remove": "Remove",
"reset": "Reset",
"delete": "Delete",
"view": "View",
"yes": "Yes",
Expand Down Expand Up @@ -163,6 +164,26 @@
"instance": {
"confirmInstanceDelete": "Do you want to delete instance"
},
"resources": {
"resources": "resources",
"id": "Id",
"key": "Key",
"name": "Name",
"mimeType": "Mime Type",
"resourceType": "Resource Type",
"preview": "Preview",
"confirmResourceDelete": "Do you want to delete resource",
"nameCantEmpty": "Name can't be empty",
"resourceTypeCantEmpty": "Resource type can't be empty",
"resourceUrlCantEmpty": "Resource url can't be empty",
"resourceFileCantEmpty": "Resource file can't be empty",
"nameRequired": "Name is required",
"resourceTypeRequired": "Resource type is required",
"resourceUrlInvalid": "Resource url is not valid",
"resourceFileOversized": "Resource file size must be between {{minSize}} MB and {{maxSize}} MB",
"selectFile": "Select File",
"resourceUrl": "Resource Url"
},
"setting": {
"authentication": "Authentication",
"service": "Service",
Expand Down
4 changes: 4 additions & 0 deletions packages/client-core/i18n/en/user.json
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,14 @@
"content": "Content Packs",
"scenes": "Scenes",
"avatars": "Avatars",
"resources": "Resources",
"benchmarking": "Benchmarking",
"bots": "Bots",
"setting": "Settings"
},
"resource": {
"createResource": "Create Resource"
},
"avatar": {
"title": "Upload Avatar",
"titleSelectAvatar": "Select Avatar",
Expand Down
3 changes: 3 additions & 0 deletions packages/client-core/src/admin/adminRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const party = React.lazy(() => import('./components/Party'))
const botSetting = React.lazy(() => import('./components/Bots'))
const projects = React.lazy(() => import('./components/Project'))
const setting = React.lazy(() => import('./components/Setting'))
const resources = React.lazy(() => import('./components/Resources'))

const AdminSystemInjection = {
uuid: 'core.admin.AdminSystem',
Expand All @@ -45,6 +46,7 @@ const ProtectedRoutes = () => {
instance: false,
invite: false,
globalAvatars: false,
static_resource: false,
benchmarking: false,
routes: false,
projects: false,
Expand Down Expand Up @@ -105,6 +107,7 @@ const ProtectedRoutes = () => {
{allowedRoutes.bot && <PrivateRoute exact path="/admin/bots" component={botSetting} />}
{allowedRoutes.projects && <PrivateRoute exact path="/admin/projects" component={projects} />}
{allowedRoutes.settings && <PrivateRoute exact path="/admin/settings" component={setting} />}
{allowedRoutes.static_resource && <PrivateRoute exact path="/admin/resources" component={resources} />}
{allowedRoutes.user && <PrivateRoute exact Path="/admin/users" component={users} />}
</Switch>
)}
Expand Down
6 changes: 4 additions & 2 deletions packages/client-core/src/admin/common/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ import SearchIcon from '@mui/icons-material/Search'
import IconButton from '@mui/material/IconButton'
import InputBase from '@mui/material/InputBase'
import Paper from '@mui/material/Paper'
import { SxProps, Theme } from '@mui/material/styles'

import styles from '../styles/search.module.scss'

interface Props {
text: string
sx?: SxProps<Theme>
handleChange: (e) => void
}

const Search = ({ text, handleChange }: Props) => {
const Search = ({ text, sx, handleChange }: Props) => {
return (
<Paper component="div" className={styles.searchRoot}>
<Paper component="div" className={styles.searchRoot} sx={sx}>
<InputBase
className={styles.input}
placeholder={`Search for ${text}`}
Expand Down
32 changes: 32 additions & 0 deletions packages/client-core/src/admin/common/variables/resource.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import i18n from 'i18next'

import { StaticResourceInterface } from '@xrengine/common/src/interfaces/StaticResourceInterface'

export interface ResourceColumn {
id: 'id' | 'key' | 'mimeType' | 'staticResourceType' | 'thumbnail' | 'action'
label: string
minWidth?: number
align?: 'right'
}

export const resourceColumns: ResourceColumn[] = [
{ id: 'id', label: i18n.t('admin:components.resources.id'), minWidth: 65 },
{ id: 'key', label: i18n.t('admin:components.resources.key'), minWidth: 65 },
{ id: 'mimeType', label: i18n.t('admin:components.resources.mimeType'), minWidth: 65 },
{ id: 'staticResourceType', label: i18n.t('admin:components.resources.resourceType'), minWidth: 65 },
{
id: 'action',
label: 'Action',
minWidth: 65,
align: 'right'
}
]

export interface ResourceData {
el: StaticResourceInterface
id: string
key: string
mimeType: string
staticResourceType: string
action: JSX.Element
}
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,10 @@ const AvatarDrawerContent = ({ open, mode, selectedAvatar, onClose }: Props) =>
(state.source === 'url' && (tempErrors.avatarUrl || tempErrors.thumbnailUrl))
) {
NotificationService.dispatchNotify(t('admin:components.common.fixErrorFields'), { variant: 'error' })
return
} else if (tempErrors.name) {
NotificationService.dispatchNotify(t('admin:components.common.fillRequiredFields'), { variant: 'error' })
return
} else if (state.source === 'file' && state.avatarFile && state.thumbnailFile) {
avatarBlob = state.avatarFile
thumbnailBlob = state.thumbnailFile
Expand All @@ -309,8 +313,6 @@ const AvatarDrawerContent = ({ open, mode, selectedAvatar, onClose }: Props) =>

const thumbnailData = await fetch(state.thumbnailUrl)
thumbnailBlob = await thumbnailData.blob()
} else {
NotificationService.dispatchNotify(t('admin:components.common.fillRequiredFields'), { variant: 'error' })
}

if (avatarBlob && thumbnailBlob) {
Expand Down
Loading