implement full load of videos and startdata
modify api where necessary
This commit is contained in:
@ -80,48 +80,48 @@ describe('<GeneralSettings/>', function () {
|
||||
it('test videopath change event', function () {
|
||||
const wrapper = shallow(<GeneralSettings/>);
|
||||
|
||||
expect(wrapper.state().videopath).not.toBe('test');
|
||||
expect(wrapper.state().generalSettings.VideoPath).not.toBe('test');
|
||||
|
||||
const event = {target: {name: 'pollName', value: 'test'}};
|
||||
wrapper.find('[data-testid=\'videpathform\']').find('FormControl').simulate('change', event);
|
||||
expect(wrapper.state().videopath).toBe('test');
|
||||
expect(wrapper.state().generalSettings.VideoPath).toBe('test');
|
||||
});
|
||||
|
||||
it('test tvshowpath change event', function () {
|
||||
const wrapper = shallow(<GeneralSettings/>);
|
||||
|
||||
const event = {target: {name: 'pollName', value: 'test'}};
|
||||
expect(wrapper.state().tvshowpath).not.toBe('test');
|
||||
expect(wrapper.state().generalSettings.EpisodePath).not.toBe('test');
|
||||
wrapper.find('[data-testid=\'tvshowpath\']').find('FormControl').simulate('change', event);
|
||||
expect(wrapper.state().tvshowpath).toBe('test');
|
||||
expect(wrapper.state().generalSettings.EpisodePath).toBe('test');
|
||||
});
|
||||
|
||||
it('test mediacentername-form change event', function () {
|
||||
const wrapper = shallow(<GeneralSettings/>);
|
||||
|
||||
const event = {target: {name: 'pollName', value: 'test'}};
|
||||
expect(wrapper.state().mediacentername).not.toBe('test');
|
||||
expect(wrapper.state().generalSettings.MediacenterName).not.toBe('test');
|
||||
wrapper.find('[data-testid=\'nameform\']').find('FormControl').simulate('change', event);
|
||||
expect(wrapper.state().mediacentername).toBe('test');
|
||||
expect(wrapper.state().generalSettings.MediacenterName).toBe('test');
|
||||
});
|
||||
|
||||
it('test password-form change event', function () {
|
||||
const wrapper = shallow(<GeneralSettings/>);
|
||||
wrapper.setState({passwordsupport: true});
|
||||
wrapper.setState({generalSettings : {PasswordEnabled: true}});
|
||||
|
||||
const event = {target: {name: 'pollName', value: 'test'}};
|
||||
expect(wrapper.state().password).not.toBe('test');
|
||||
expect(wrapper.state().generalSettings.Password).not.toBe('test');
|
||||
wrapper.find('[data-testid=\'passwordfield\']').find('FormControl').simulate('change', event);
|
||||
expect(wrapper.state().password).toBe('test');
|
||||
expect(wrapper.state().generalSettings.Password).toBe('test');
|
||||
});
|
||||
|
||||
it('test tmdbsupport change event', function () {
|
||||
const wrapper = shallow(<GeneralSettings/>);
|
||||
wrapper.setState({tmdbsupport: true});
|
||||
wrapper.setState({generalSettings : {TMDBGrabbing: true}});
|
||||
|
||||
expect(wrapper.state().tmdbsupport).toBe(true);
|
||||
expect(wrapper.state().generalSettings.TMDBGrabbing).toBe(true);
|
||||
wrapper.find('[data-testid=\'tmdb-switch\']').simulate('change');
|
||||
expect(wrapper.state().tmdbsupport).toBe(false);
|
||||
expect(wrapper.state().generalSettings.TMDBGrabbing).toBe(false);
|
||||
});
|
||||
|
||||
it('test insertion of 4 infoheaderitems', function () {
|
||||
|
@ -11,23 +11,13 @@ import {SettingsTypes} from '../../types/ApiTypes';
|
||||
import {GeneralSuccess} from '../../types/GeneralTypes';
|
||||
|
||||
interface state {
|
||||
passwordsupport: boolean,
|
||||
tmdbsupport: boolean,
|
||||
customapi: boolean,
|
||||
|
||||
videopath: string,
|
||||
tvshowpath: string,
|
||||
mediacentername: string,
|
||||
password: string,
|
||||
apipath: string,
|
||||
|
||||
videonr: number,
|
||||
dbsize: number,
|
||||
difftagnr: number,
|
||||
tagsadded: number
|
||||
customapi: boolean
|
||||
apipath: string
|
||||
generalSettings: SettingsTypes.loadGeneralSettingsType
|
||||
}
|
||||
|
||||
interface props {}
|
||||
interface props {
|
||||
}
|
||||
|
||||
/**
|
||||
* Component for Generalsettings tag on Settingspage
|
||||
@ -38,20 +28,21 @@ class GeneralSettings extends React.Component<props, state> {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
passwordsupport: false,
|
||||
tmdbsupport: false,
|
||||
customapi: false,
|
||||
|
||||
videopath: '',
|
||||
tvshowpath: '',
|
||||
mediacentername: '',
|
||||
password: '',
|
||||
apipath: '',
|
||||
|
||||
videonr: 0,
|
||||
dbsize: 0,
|
||||
difftagnr: 0,
|
||||
tagsadded: 0
|
||||
generalSettings: {
|
||||
DarkMode: true,
|
||||
DBSize: 0,
|
||||
DifferentTags: 0,
|
||||
EpisodePath: "",
|
||||
MediacenterName: "",
|
||||
Password: "",
|
||||
PasswordEnabled: false,
|
||||
TagsAdded: 0,
|
||||
TMDBGrabbing: false,
|
||||
VideoNr: 0,
|
||||
VideoPath: ""
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -65,19 +56,19 @@ class GeneralSettings extends React.Component<props, state> {
|
||||
<>
|
||||
<div className={style.infoheader}>
|
||||
<InfoHeaderItem backColor='lightblue'
|
||||
text={this.state.videonr}
|
||||
text={this.state.generalSettings.VideoNr}
|
||||
subtext='Videos in Gravity'
|
||||
icon={faArchive}/>
|
||||
<InfoHeaderItem backColor='yellow'
|
||||
text={this.state.dbsize !== undefined ? this.state.dbsize + ' MB' : ''}
|
||||
text={this.state.generalSettings.DBSize + ' MB'}
|
||||
subtext='Database size'
|
||||
icon={faRulerVertical}/>
|
||||
<InfoHeaderItem backColor='green'
|
||||
text={this.state.difftagnr}
|
||||
text={this.state.generalSettings.DifferentTags}
|
||||
subtext='different Tags'
|
||||
icon={faAddressCard}/>
|
||||
<InfoHeaderItem backColor='orange'
|
||||
text={this.state.tagsadded}
|
||||
text={this.state.generalSettings.TagsAdded}
|
||||
subtext='tags added'
|
||||
icon={faBalanceScaleLeft}/>
|
||||
</div>
|
||||
@ -89,15 +80,26 @@ class GeneralSettings extends React.Component<props, state> {
|
||||
<Form.Row>
|
||||
<Form.Group as={Col} data-testid='videpathform'>
|
||||
<Form.Label>Video Path</Form.Label>
|
||||
<Form.Control type='text' placeholder='/var/www/html/video' value={this.state.videopath}
|
||||
onChange={(ee): void => this.setState({videopath: ee.target.value})}/>
|
||||
<Form.Control type='text' placeholder='/var/www/html/video'
|
||||
value={this.state.generalSettings.VideoPath}
|
||||
onChange={(ee): void => this.setState({
|
||||
generalSettings: {
|
||||
...this.state.generalSettings,
|
||||
VideoPath: ee.target.value
|
||||
}
|
||||
})}/>
|
||||
</Form.Group>
|
||||
|
||||
<Form.Group as={Col} data-testid='tvshowpath'>
|
||||
<Form.Label>TV Show Path</Form.Label>
|
||||
<Form.Control type='text' placeholder='/var/www/html/tvshow'
|
||||
value={this.state.tvshowpath}
|
||||
onChange={(e): void => this.setState({tvshowpath: e.target.value})}/>
|
||||
value={this.state.generalSettings.EpisodePath}
|
||||
onChange={(e): void => this.setState({
|
||||
generalSettings: {
|
||||
...this.state.generalSettings,
|
||||
EpisodePath: e.target.value
|
||||
}
|
||||
})}/>
|
||||
</Form.Group>
|
||||
</Form.Row>
|
||||
|
||||
@ -131,17 +133,28 @@ class GeneralSettings extends React.Component<props, state> {
|
||||
id='custom-switch'
|
||||
data-testid='passwordswitch'
|
||||
label='Enable Password support'
|
||||
checked={this.state.passwordsupport}
|
||||
checked={this.state.generalSettings.PasswordEnabled}
|
||||
onChange={(): void => {
|
||||
this.setState({passwordsupport: !this.state.passwordsupport});
|
||||
this.setState({
|
||||
generalSettings: {
|
||||
...this.state.generalSettings,
|
||||
PasswordEnabled: !this.state.generalSettings.PasswordEnabled
|
||||
}
|
||||
});
|
||||
}}
|
||||
/>
|
||||
|
||||
{this.state.passwordsupport ?
|
||||
{this.state.generalSettings.PasswordEnabled ?
|
||||
<Form.Group data-testid='passwordfield'>
|
||||
<Form.Label>Password</Form.Label>
|
||||
<Form.Control type='password' placeholder='**********' value={this.state.password}
|
||||
onChange={(e): void => this.setState({password: e.target.value})}/>
|
||||
<Form.Control type='password' placeholder='**********'
|
||||
value={this.state.generalSettings.Password}
|
||||
onChange={(e): void => this.setState({
|
||||
generalSettings: {
|
||||
...this.state.generalSettings,
|
||||
Password: e.target.value
|
||||
}
|
||||
})}/>
|
||||
</Form.Group> : null
|
||||
}
|
||||
|
||||
@ -150,9 +163,14 @@ class GeneralSettings extends React.Component<props, state> {
|
||||
id='custom-switch-2'
|
||||
data-testid='tmdb-switch'
|
||||
label='Enable TMDB video grabbing support'
|
||||
checked={this.state.tmdbsupport}
|
||||
checked={this.state.generalSettings.TMDBGrabbing}
|
||||
onChange={(): void => {
|
||||
this.setState({tmdbsupport: !this.state.tmdbsupport});
|
||||
this.setState({
|
||||
generalSettings: {
|
||||
...this.state.generalSettings,
|
||||
TMDBGrabbing: !this.state.generalSettings.TMDBGrabbing
|
||||
}
|
||||
});
|
||||
}}
|
||||
/>
|
||||
|
||||
@ -171,8 +189,14 @@ class GeneralSettings extends React.Component<props, state> {
|
||||
|
||||
<Form.Group className={style.mediacenternameform} data-testid='nameform'>
|
||||
<Form.Label>The name of the Mediacenter</Form.Label>
|
||||
<Form.Control type='text' placeholder='Mediacentername' value={this.state.mediacentername}
|
||||
onChange={(e): void => this.setState({mediacentername: e.target.value})}/>
|
||||
<Form.Control type='text' placeholder='Mediacentername'
|
||||
value={this.state.generalSettings.MediacenterName}
|
||||
onChange={(e): void => this.setState({
|
||||
generalSettings: {
|
||||
...this.state.generalSettings,
|
||||
MediacenterName: e.target.value
|
||||
}
|
||||
})}/>
|
||||
</Form.Group>
|
||||
|
||||
<Button variant='primary' type='submit'>
|
||||
@ -192,19 +216,7 @@ class GeneralSettings extends React.Component<props, state> {
|
||||
*/
|
||||
loadSettings(): void {
|
||||
callAPI(APINode.Settings, {action: 'loadGeneralSettings'}, (result: SettingsTypes.loadGeneralSettingsType) => {
|
||||
this.setState({
|
||||
videopath: result.video_path,
|
||||
tvshowpath: result.episode_path,
|
||||
mediacentername: result.mediacenter_name,
|
||||
password: result.password,
|
||||
passwordsupport: result.passwordEnabled,
|
||||
tmdbsupport: result.TMDB_grabbing,
|
||||
|
||||
videonr: result.videonr,
|
||||
dbsize: result.dbsize,
|
||||
difftagnr: result.difftagnr,
|
||||
tagsadded: result.tagsadded
|
||||
});
|
||||
this.setState({generalSettings: result});
|
||||
});
|
||||
}
|
||||
|
||||
@ -212,14 +224,15 @@ class GeneralSettings extends React.Component<props, state> {
|
||||
* save the selected and typed settings to the backend
|
||||
*/
|
||||
saveSettings(): void {
|
||||
let settings = this.state.generalSettings;
|
||||
if(!this.state.generalSettings.PasswordEnabled){
|
||||
settings.Password = '-1';
|
||||
}
|
||||
settings.DarkMode = GlobalInfos.isDarkTheme()
|
||||
|
||||
callAPI(APINode.Settings, {
|
||||
action: 'saveGeneralSettings',
|
||||
password: this.state.passwordsupport ? this.state.password : '-1',
|
||||
videopath: this.state.videopath,
|
||||
tvshowpath: this.state.tvshowpath,
|
||||
mediacentername: this.state.mediacentername,
|
||||
tmdbsupport: this.state.tmdbsupport,
|
||||
darkmodeenabled: GlobalInfos.isDarkTheme().toString()
|
||||
Settings: settings
|
||||
}, (result: GeneralSuccess) => {
|
||||
if (result.result) {
|
||||
console.log('successfully saved settings');
|
||||
|
@ -52,10 +52,9 @@ describe('<MovieSettings/>', function () {
|
||||
|
||||
it('content available received and in state', () => {
|
||||
const wrapper = shallow(<MovieSettings/>);
|
||||
|
||||
callAPIMock({
|
||||
contentAvailable: true,
|
||||
message: 'firstline\nsecondline'
|
||||
ContentAvailable: true,
|
||||
Messages: ['firstline', 'secondline']
|
||||
})
|
||||
|
||||
wrapper.instance().updateStatus();
|
||||
@ -70,7 +69,8 @@ describe('<MovieSettings/>', function () {
|
||||
|
||||
it('test reindex with no content available', () => {
|
||||
callAPIMock({
|
||||
contentAvailable: false
|
||||
Messages: [],
|
||||
ContentAvailable: false
|
||||
})
|
||||
|
||||
global.clearInterval = jest.fn();
|
||||
@ -99,12 +99,12 @@ describe('<MovieSettings/>', function () {
|
||||
expect(wrapper.instance().setState).toBeCalledTimes(1);
|
||||
});
|
||||
|
||||
it('test no textDiv insertion if string is empty', function () {
|
||||
it('expect insertion before existing ones', function () {
|
||||
const wrapper = shallow(<MovieSettings/>);
|
||||
|
||||
callAPIMock({
|
||||
contentAvailable: true,
|
||||
message: 'test'
|
||||
ContentAvailable: true,
|
||||
Messages: ['test']
|
||||
})
|
||||
|
||||
wrapper.instance().updateStatus();
|
||||
@ -115,14 +115,14 @@ describe('<MovieSettings/>', function () {
|
||||
|
||||
// expect an untouched state if we try to add an empty string...
|
||||
callAPIMock({
|
||||
contentAvailable: true,
|
||||
message: ''
|
||||
ContentAvailable: true,
|
||||
Messages: ['']
|
||||
})
|
||||
|
||||
wrapper.instance().updateStatus();
|
||||
|
||||
expect(wrapper.state()).toMatchObject({
|
||||
text: ['test']
|
||||
text: ['', 'test']
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -58,11 +58,7 @@ class MovieSettings extends React.Component<props, state> {
|
||||
*/
|
||||
startReindex(): void {
|
||||
// clear output text before start
|
||||
this.setState({text: []});
|
||||
|
||||
this.setState({startbtnDisabled: true});
|
||||
|
||||
console.log('starting');
|
||||
this.setState({text: [], startbtnDisabled: true});
|
||||
|
||||
callAPI(APINode.Settings, {action: 'startReindex'}, (result: GeneralSuccess): void => {
|
||||
console.log(result);
|
||||
@ -85,18 +81,12 @@ class MovieSettings extends React.Component<props, state> {
|
||||
*/
|
||||
updateStatus = (): void => {
|
||||
callAPI(APINode.Settings, {action: 'getStatusMessage'}, (result: SettingsTypes.getStatusMessageType) => {
|
||||
if (result.contentAvailable) {
|
||||
// ignore if message is empty
|
||||
console.log(result);
|
||||
if(result.message === '') return;
|
||||
|
||||
// todo 2020-07-4: scroll to bottom of div here
|
||||
this.setState({
|
||||
// insert a string for each line
|
||||
text: [...result.message.split('\n'),
|
||||
...this.state.text]
|
||||
});
|
||||
} else {
|
||||
this.setState({
|
||||
// insert a string for each line
|
||||
text: [...result.Messages, ...this.state.text]
|
||||
});
|
||||
// todo 2020-07-4: scroll to bottom of div here
|
||||
if (!result.ContentAvailable) {
|
||||
// clear refresh interval if no content available
|
||||
clearInterval(this.myinterval);
|
||||
|
||||
|
Reference in New Issue
Block a user