mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
migrate User Profile Page
This commit is contained in:
parent
d2df5830b5
commit
ab02f210ca
7 changed files with 41 additions and 31 deletions
|
@ -6,6 +6,7 @@ type PageProps = {
|
||||||
id: string, // id is required for libraryMenu
|
id: string, // id is required for libraryMenu
|
||||||
title?: string,
|
title?: string,
|
||||||
isBackButtonEnabled?: boolean,
|
isBackButtonEnabled?: boolean,
|
||||||
|
isMenuButtonEnabled?: boolean,
|
||||||
isNowPlayingBarEnabled?: boolean,
|
isNowPlayingBarEnabled?: boolean,
|
||||||
isThemeMediaSupported?: boolean
|
isThemeMediaSupported?: boolean
|
||||||
};
|
};
|
||||||
|
@ -20,6 +21,7 @@ const Page: FunctionComponent<PageProps & HTMLAttributes<HTMLDivElement>> = ({
|
||||||
className = '',
|
className = '',
|
||||||
title,
|
title,
|
||||||
isBackButtonEnabled = true,
|
isBackButtonEnabled = true,
|
||||||
|
isMenuButtonEnabled = false,
|
||||||
isNowPlayingBarEnabled = true,
|
isNowPlayingBarEnabled = true,
|
||||||
isThemeMediaSupported = false
|
isThemeMediaSupported = false
|
||||||
}) => {
|
}) => {
|
||||||
|
@ -60,6 +62,7 @@ const Page: FunctionComponent<PageProps & HTMLAttributes<HTMLDivElement>> = ({
|
||||||
className={`page ${className}`}
|
className={`page ${className}`}
|
||||||
data-title={title}
|
data-title={title}
|
||||||
data-backbutton={`${isBackButtonEnabled}`}
|
data-backbutton={`${isBackButtonEnabled}`}
|
||||||
|
data-menubutton={`${isMenuButtonEnabled}`}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -40,11 +40,11 @@ const UserPasswordForm: FunctionComponent<IProps> = ({userId}: IProps) => {
|
||||||
let showLocalAccessSection = false;
|
let showLocalAccessSection = false;
|
||||||
|
|
||||||
if (user.HasConfiguredPassword) {
|
if (user.HasConfiguredPassword) {
|
||||||
(page.querySelector('.btnResetPassword') as HTMLDivElement).classList.remove('hide');
|
(page.querySelector('#btnResetPassword') as HTMLDivElement).classList.remove('hide');
|
||||||
(page.querySelector('#fldCurrentPassword') as HTMLDivElement).classList.remove('hide');
|
(page.querySelector('#fldCurrentPassword') as HTMLDivElement).classList.remove('hide');
|
||||||
showLocalAccessSection = true;
|
showLocalAccessSection = true;
|
||||||
} else {
|
} else {
|
||||||
(page.querySelector('.btnResetPassword') as HTMLDivElement).classList.add('hide');
|
(page.querySelector('#btnResetPassword') as HTMLDivElement).classList.add('hide');
|
||||||
(page.querySelector('#fldCurrentPassword') as HTMLDivElement).classList.add('hide');
|
(page.querySelector('#fldCurrentPassword') as HTMLDivElement).classList.add('hide');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,11 +65,11 @@ const UserPasswordForm: FunctionComponent<IProps> = ({userId}: IProps) => {
|
||||||
|
|
||||||
if (user.HasConfiguredEasyPassword) {
|
if (user.HasConfiguredEasyPassword) {
|
||||||
txtEasyPassword.placeholder = '******';
|
txtEasyPassword.placeholder = '******';
|
||||||
(page.querySelector('.btnResetEasyPassword') as HTMLDivElement).classList.remove('hide');
|
(page.querySelector('#btnResetEasyPassword') as HTMLDivElement).classList.remove('hide');
|
||||||
} else {
|
} else {
|
||||||
txtEasyPassword.removeAttribute('placeholder');
|
txtEasyPassword.removeAttribute('placeholder');
|
||||||
txtEasyPassword.placeholder = '';
|
txtEasyPassword.placeholder = '';
|
||||||
(page.querySelector('.btnResetEasyPassword') as HTMLDivElement).classList.add('hide');
|
(page.querySelector('#btnResetEasyPassword') as HTMLDivElement).classList.add('hide');
|
||||||
}
|
}
|
||||||
|
|
||||||
const chkEnableLocalEasyPassword = page.querySelector('.chkEnableLocalEasyPassword') as HTMLInputElement;
|
const chkEnableLocalEasyPassword = page.querySelector('.chkEnableLocalEasyPassword') as HTMLInputElement;
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
<div id="userProfilePage" data-role="page" class="page libraryPage userPreferencesPage userPasswordPage noSecondaryNavPage" data-title="${Profile}" data-menubutton="false">
|
|
||||||
|
|
||||||
</div>
|
|
|
@ -4,17 +4,20 @@ import UserPasswordForm from '../components/dashboard/users/UserPasswordForm';
|
||||||
import { getParameterByName } from '../utils/url';
|
import { getParameterByName } from '../utils/url';
|
||||||
import SectionTitleContainer from '../components/dashboard/elements/SectionTitleContainer';
|
import SectionTitleContainer from '../components/dashboard/elements/SectionTitleContainer';
|
||||||
import Page from '../components/Page';
|
import Page from '../components/Page';
|
||||||
|
import loading from '../components/loading/loading';
|
||||||
|
|
||||||
const UserPasswordPage: FunctionComponent = () => {
|
const UserPasswordPage: FunctionComponent = () => {
|
||||||
const userId = getParameterByName('userId');
|
const userId = getParameterByName('userId');
|
||||||
const [ userName, setUserName ] = useState('');
|
const [ userName, setUserName ] = useState('');
|
||||||
|
|
||||||
const loadUser = useCallback(() => {
|
const loadUser = useCallback(() => {
|
||||||
|
loading.show();
|
||||||
window.ApiClient.getUser(userId).then(function (user) {
|
window.ApiClient.getUser(userId).then(function (user) {
|
||||||
if (!user.Name) {
|
if (!user.Name) {
|
||||||
throw new Error('Unexpected null user.Name');
|
throw new Error('Unexpected null user.Name');
|
||||||
}
|
}
|
||||||
setUserName(user.Name);
|
setUserName(user.Name);
|
||||||
|
loading.hide();
|
||||||
});
|
});
|
||||||
}, [userId]);
|
}, [userId]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
|
@ -1,21 +1,20 @@
|
||||||
import { ImageType, UserDto } from '@thornbill/jellyfin-sdk/dist/generated-client';
|
import { ImageType, UserDto } from '@thornbill/jellyfin-sdk/dist/generated-client';
|
||||||
import React, { FunctionComponent, useEffect, useState, useRef, useCallback } from 'react';
|
import React, { FunctionComponent, useEffect, useState, useRef, useCallback } from 'react';
|
||||||
|
|
||||||
import Dashboard from '../../utils/dashboard';
|
import Dashboard from '../utils/dashboard';
|
||||||
import globalize from '../../scripts/globalize';
|
import globalize from '../scripts/globalize';
|
||||||
import LibraryMenu from '../../scripts/libraryMenu';
|
import LibraryMenu from '../scripts/libraryMenu';
|
||||||
import { appHost } from '../apphost';
|
import { appHost } from '../components/apphost';
|
||||||
import confirm from '../confirm/confirm';
|
import confirm from '../components/confirm/confirm';
|
||||||
import ButtonElement from '../dashboard/elements/ButtonElement';
|
import ButtonElement from '../components/dashboard/elements/ButtonElement';
|
||||||
import UserPasswordForm from '../dashboard/users/UserPasswordForm';
|
import UserPasswordForm from '../components/dashboard/users/UserPasswordForm';
|
||||||
import loading from '../loading/loading';
|
import loading from '../components/loading/loading';
|
||||||
import toast from '../toast/toast';
|
import toast from '../components/toast/toast';
|
||||||
|
import { getParameterByName } from '../utils/url';
|
||||||
|
import Page from '../components/Page';
|
||||||
|
|
||||||
type IProps = {
|
const UserProfilePage: FunctionComponent = () => {
|
||||||
userId: string;
|
const userId = getParameterByName('userId');
|
||||||
}
|
|
||||||
|
|
||||||
const UserProfilePage: FunctionComponent<IProps> = ({userId}: IProps) => {
|
|
||||||
const [ userName, setUserName ] = useState('');
|
const [ userName, setUserName ] = useState('');
|
||||||
|
|
||||||
const element = useRef<HTMLDivElement>(null);
|
const element = useRef<HTMLDivElement>(null);
|
||||||
|
@ -145,13 +144,18 @@ const UserProfilePage: FunctionComponent<IProps> = ({userId}: IProps) => {
|
||||||
}, [reloadUser, userId]);
|
}, [reloadUser, userId]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div ref={element}>
|
<Page
|
||||||
<div className='padded-left padded-right padded-bottom-page'>
|
id='userProfilePage'
|
||||||
|
title={globalize.translate('Profile')}
|
||||||
|
className='mainAnimatedPage libraryPage userPreferencesPage userPasswordPage noSecondaryNavPage'
|
||||||
|
>
|
||||||
|
<div ref={element} className='padded-left padded-right padded-bottom-page'>
|
||||||
<div
|
<div
|
||||||
className='readOnlyContent'
|
className='readOnlyContent'
|
||||||
style={{margin: '0 auto', marginBottom: '1.8em', padding: '0 1em', display: 'flex', flexDirection: 'row', alignItems: 'center'}}
|
style={{margin: '0 auto', marginBottom: '1.8em', padding: '0 1em', display: 'flex', flexDirection: 'row', alignItems: 'center'}}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
|
className='imagePlaceHolder'
|
||||||
style={{position: 'relative', display: 'inline-block', maxWidth: 200 }}
|
style={{position: 'relative', display: 'inline-block', maxWidth: 200 }}
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
|
@ -188,7 +192,8 @@ const UserProfilePage: FunctionComponent<IProps> = ({userId}: IProps) => {
|
||||||
userId={userId}
|
userId={userId}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</Page>
|
||||||
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,6 +8,7 @@ import UserEditPage from './UserEditPage';
|
||||||
import UserLibraryAccessPage from './UserLibraryAccessPage';
|
import UserLibraryAccessPage from './UserLibraryAccessPage';
|
||||||
import UserParentalControl from './UserParentalControl';
|
import UserParentalControl from './UserParentalControl';
|
||||||
import UserPasswordPage from './UserPasswordPage';
|
import UserPasswordPage from './UserPasswordPage';
|
||||||
|
import UserProfilePage from './UserProfilePage';
|
||||||
import UserProfilesPage from './UserProfilesPage';
|
import UserProfilesPage from './UserProfilesPage';
|
||||||
|
|
||||||
const AppRoutes = () => (
|
const AppRoutes = () => (
|
||||||
|
@ -69,6 +70,14 @@ const AppRoutes = () => (
|
||||||
</ConnectionRequired>
|
</ConnectionRequired>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
<Route
|
||||||
|
path='myprofile.html'
|
||||||
|
element={
|
||||||
|
<ConnectionRequired>
|
||||||
|
<UserProfilePage />
|
||||||
|
</ConnectionRequired>
|
||||||
|
}
|
||||||
|
/>
|
||||||
{/* Suppress warnings for unhandled routes */}
|
{/* Suppress warnings for unhandled routes */}
|
||||||
<Route path='*' element={null} />
|
<Route path='*' element={null} />
|
||||||
</Route>
|
</Route>
|
||||||
|
|
|
@ -77,13 +77,6 @@ import { appRouter } from '../components/appRouter';
|
||||||
controller: 'user/menu/index'
|
controller: 'user/menu/index'
|
||||||
});
|
});
|
||||||
|
|
||||||
defineRoute({
|
|
||||||
alias: '/myprofile.html',
|
|
||||||
path: 'user/profile/index.html',
|
|
||||||
autoFocus: false,
|
|
||||||
pageComponent: 'UserProfilePage'
|
|
||||||
});
|
|
||||||
|
|
||||||
defineRoute({
|
defineRoute({
|
||||||
alias: '/mypreferencescontrols.html',
|
alias: '/mypreferencescontrols.html',
|
||||||
path: 'user/controls/index.html',
|
path: 'user/controls/index.html',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue