2020-02-08 13:43:14 -05:00
|
|
|
import React from 'react'
|
2020-02-08 00:11:15 -05:00
|
|
|
import { Admin, resolveBrowserLocale, Resource } from 'react-admin'
|
2020-01-20 09:54:29 -05:00
|
|
|
import dataProvider from './dataProvider'
|
|
|
|
|
import authProvider from './authProvider'
|
2020-02-07 09:40:52 -05:00
|
|
|
import polyglotI18nProvider from 'ra-i18n-polyglot'
|
|
|
|
|
import messages from './i18n'
|
2020-02-04 09:26:54 -05:00
|
|
|
import { DarkTheme, Layout, Login } from './layout'
|
2020-02-29 20:01:09 -05:00
|
|
|
import transcoding from './transcoding'
|
2020-03-12 09:38:07 -04:00
|
|
|
import player from './player'
|
2020-01-19 20:40:18 -05:00
|
|
|
import user from './user'
|
2020-01-22 10:19:13 -05:00
|
|
|
import song from './song'
|
2020-01-22 12:32:31 -05:00
|
|
|
import album from './album'
|
2020-01-22 13:02:19 -05:00
|
|
|
import artist from './artist'
|
2020-01-23 18:12:26 -05:00
|
|
|
import { createMuiTheme } from '@material-ui/core/styles'
|
2020-03-11 19:46:46 -04:00
|
|
|
import { Player, playQueueReducer } from './audioplayer'
|
2020-03-28 16:25:55 -04:00
|
|
|
import { albumViewReducer } from './album/albumState'
|
2020-01-23 18:12:26 -05:00
|
|
|
|
2020-01-23 22:51:52 -05:00
|
|
|
const theme = createMuiTheme(DarkTheme)
|
2020-01-13 22:53:23 -05:00
|
|
|
|
2020-02-07 09:40:52 -05:00
|
|
|
const i18nProvider = polyglotI18nProvider(
|
|
|
|
|
(locale) => (messages[locale] ? messages[locale] : messages.en),
|
|
|
|
|
resolveBrowserLocale()
|
|
|
|
|
)
|
|
|
|
|
|
2020-02-08 13:43:14 -05:00
|
|
|
const App = () => {
|
|
|
|
|
try {
|
|
|
|
|
const appConfig = JSON.parse(window.__APP_CONFIG__)
|
2020-02-08 00:11:15 -05:00
|
|
|
|
2020-02-08 13:43:14 -05: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 00:11:15 -05:00
|
|
|
|
2020-02-08 13:43:14 -05:00
|
|
|
return (
|
|
|
|
|
<Admin
|
|
|
|
|
theme={theme}
|
2020-03-28 16:25:55 -04:00
|
|
|
customReducers={{
|
|
|
|
|
queue: playQueueReducer,
|
|
|
|
|
albumView: albumViewReducer
|
|
|
|
|
}}
|
2020-02-08 13:43:14 -05:00
|
|
|
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 09:02:32 -05:00
|
|
|
<Resource name="albumSong" />,
|
2020-02-29 20:01:09 -05:00
|
|
|
permissions === 'admin' ? (
|
|
|
|
|
<Resource name="user" {...user} options={{ subMenu: 'settings' }} />
|
|
|
|
|
) : null,
|
2020-03-17 15:00:28 -04:00
|
|
|
<Resource
|
|
|
|
|
name="player"
|
|
|
|
|
{...player}
|
|
|
|
|
options={{ subMenu: 'settings' }}
|
|
|
|
|
/>,
|
2020-02-29 20:01:09 -05:00
|
|
|
permissions === 'admin' ? (
|
|
|
|
|
<Resource
|
|
|
|
|
name="transcoding"
|
|
|
|
|
{...transcoding}
|
|
|
|
|
options={{ subMenu: 'settings' }}
|
|
|
|
|
/>
|
2020-03-17 15:00:28 -04:00
|
|
|
) : (
|
|
|
|
|
<Resource name="transcoding" />
|
|
|
|
|
),
|
2020-02-08 13:43:14 -05:00
|
|
|
<Player />
|
|
|
|
|
]}
|
|
|
|
|
</Admin>
|
|
|
|
|
)
|
2020-02-08 00:11:15 -05:00
|
|
|
}
|
|
|
|
|
|
2020-02-08 13:43:14 -05:00
|
|
|
export default App
|