2020-02-08 19:43:14 +01:00
|
|
|
import React from 'react'
|
2020-02-08 06:11:15 +01:00
|
|
|
import { Admin, resolveBrowserLocale, Resource } from 'react-admin'
|
2020-01-20 15:54:29 +01:00
|
|
|
import dataProvider from './dataProvider'
|
|
|
|
import authProvider from './authProvider'
|
2020-02-07 15:40:52 +01:00
|
|
|
import polyglotI18nProvider from 'ra-i18n-polyglot'
|
|
|
|
import messages from './i18n'
|
2020-02-04 15:26:54 +01:00
|
|
|
import { DarkTheme, Layout, Login } from './layout'
|
2020-03-01 02:01:09 +01:00
|
|
|
import transcoding from './transcoding'
|
2020-01-20 02:40:18 +01:00
|
|
|
import user from './user'
|
2020-01-22 16:19:13 +01:00
|
|
|
import song from './song'
|
2020-01-22 18:32:31 +01:00
|
|
|
import album from './album'
|
2020-01-22 19:02:19 +01:00
|
|
|
import artist from './artist'
|
2020-01-24 00:12:26 +01:00
|
|
|
import { createMuiTheme } from '@material-ui/core/styles'
|
2020-03-12 00:46:46 +01:00
|
|
|
import { Player, playQueueReducer } from './audioplayer'
|
2020-01-24 00:12:26 +01:00
|
|
|
|
2020-01-24 04:51:52 +01:00
|
|
|
const theme = createMuiTheme(DarkTheme)
|
2020-01-14 04:53:23 +01:00
|
|
|
|
2020-02-07 15:40:52 +01:00
|
|
|
const i18nProvider = polyglotI18nProvider(
|
|
|
|
(locale) => (messages[locale] ? messages[locale] : messages.en),
|
|
|
|
resolveBrowserLocale()
|
|
|
|
)
|
|
|
|
|
2020-02-08 19:43:14 +01:00
|
|
|
const App = () => {
|
|
|
|
try {
|
|
|
|
const appConfig = JSON.parse(window.__APP_CONFIG__)
|
2020-02-08 06:11:15 +01:00
|
|
|
|
2020-02-08 19:43:14 +01:00
|
|
|
// This flags to the login process that it should create the first account instead
|
|
|
|
if (appConfig.firstTime) {
|
|
|
|
localStorage.setItem('initialAccountCreation', 'true')
|
|
|
|
}
|
|
|
|
} catch (e) {}
|
2020-02-08 06:11:15 +01:00
|
|
|
|
2020-02-08 19:43:14 +01:00
|
|
|
return (
|
|
|
|
<Admin
|
|
|
|
theme={theme}
|
|
|
|
customReducers={{ queue: playQueueReducer }}
|
|
|
|
dataProvider={dataProvider}
|
|
|
|
authProvider={authProvider}
|
|
|
|
i18nProvider={i18nProvider}
|
|
|
|
layout={Layout}
|
|
|
|
loginPage={Login}
|
|
|
|
>
|
|
|
|
{(permissions) => [
|
|
|
|
<Resource name="artist" {...artist} options={{ subMenu: 'library' }} />,
|
|
|
|
<Resource name="album" {...album} options={{ subMenu: 'library' }} />,
|
|
|
|
<Resource name="song" {...song} options={{ subMenu: 'library' }} />,
|
2020-02-14 15:02:32 +01:00
|
|
|
<Resource name="albumSong" />,
|
2020-03-01 02:01:09 +01:00
|
|
|
permissions === 'admin' ? (
|
|
|
|
<Resource name="user" {...user} options={{ subMenu: 'settings' }} />
|
|
|
|
) : null,
|
|
|
|
permissions === 'admin' ? (
|
|
|
|
<Resource
|
|
|
|
name="transcoding"
|
|
|
|
{...transcoding}
|
|
|
|
options={{ subMenu: 'settings' }}
|
|
|
|
/>
|
|
|
|
) : null,
|
2020-02-08 19:43:14 +01:00
|
|
|
<Player />
|
|
|
|
]}
|
|
|
|
</Admin>
|
|
|
|
)
|
2020-02-08 06:11:15 +01:00
|
|
|
}
|
|
|
|
|
2020-02-08 19:43:14 +01:00
|
|
|
export default App
|