use eslint to lint project
drop code quality job
This commit is contained in:
		@@ -11,20 +11,19 @@ import {SettingsTypes} from '../../types/ApiTypes';
 | 
			
		||||
import {GeneralSuccess} from '../../types/GeneralTypes';
 | 
			
		||||
 | 
			
		||||
interface state {
 | 
			
		||||
    customapi: boolean
 | 
			
		||||
    apipath: string
 | 
			
		||||
    generalSettings: SettingsTypes.loadGeneralSettingsType
 | 
			
		||||
    customapi: boolean;
 | 
			
		||||
    apipath: string;
 | 
			
		||||
    generalSettings: SettingsTypes.loadGeneralSettingsType;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
interface props {
 | 
			
		||||
}
 | 
			
		||||
interface Props {}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Component for Generalsettings tag on Settingspage
 | 
			
		||||
 * handles general settings of mediacenter which concerns to all pages
 | 
			
		||||
 */
 | 
			
		||||
class GeneralSettings extends React.Component<props, state> {
 | 
			
		||||
    constructor(props: props) {
 | 
			
		||||
class GeneralSettings extends React.Component<Props, state> {
 | 
			
		||||
    constructor(props: Props) {
 | 
			
		||||
        super(props);
 | 
			
		||||
 | 
			
		||||
        this.state = {
 | 
			
		||||
@@ -34,14 +33,14 @@ class GeneralSettings extends React.Component<props, state> {
 | 
			
		||||
                DarkMode: true,
 | 
			
		||||
                DBSize: 0,
 | 
			
		||||
                DifferentTags: 0,
 | 
			
		||||
                EpisodePath: "",
 | 
			
		||||
                MediacenterName: "",
 | 
			
		||||
                Password: "",
 | 
			
		||||
                EpisodePath: '',
 | 
			
		||||
                MediacenterName: '',
 | 
			
		||||
                Password: '',
 | 
			
		||||
                PasswordEnabled: false,
 | 
			
		||||
                TagsAdded: 0,
 | 
			
		||||
                TMDBGrabbing: false,
 | 
			
		||||
                VideoNr: 0,
 | 
			
		||||
                VideoPath: ""
 | 
			
		||||
                VideoPath: ''
 | 
			
		||||
            }
 | 
			
		||||
        };
 | 
			
		||||
    }
 | 
			
		||||
@@ -55,51 +54,71 @@ class GeneralSettings extends React.Component<props, state> {
 | 
			
		||||
        return (
 | 
			
		||||
            <>
 | 
			
		||||
                <div className={style.infoheader}>
 | 
			
		||||
                    <InfoHeaderItem backColor='lightblue'
 | 
			
		||||
                                    text={this.state.generalSettings.VideoNr}
 | 
			
		||||
                                    subtext='Videos in Gravity'
 | 
			
		||||
                                    icon={faArchive}/>
 | 
			
		||||
                    <InfoHeaderItem backColor='yellow'
 | 
			
		||||
                                    text={this.state.generalSettings.DBSize + ' MB'}
 | 
			
		||||
                                    subtext='Database size'
 | 
			
		||||
                                    icon={faRulerVertical}/>
 | 
			
		||||
                    <InfoHeaderItem backColor='green'
 | 
			
		||||
                                    text={this.state.generalSettings.DifferentTags}
 | 
			
		||||
                                    subtext='different Tags'
 | 
			
		||||
                                    icon={faAddressCard}/>
 | 
			
		||||
                    <InfoHeaderItem backColor='orange'
 | 
			
		||||
                                    text={this.state.generalSettings.TagsAdded}
 | 
			
		||||
                                    subtext='tags added'
 | 
			
		||||
                                    icon={faBalanceScaleLeft}/>
 | 
			
		||||
                    <InfoHeaderItem
 | 
			
		||||
                        backColor='lightblue'
 | 
			
		||||
                        text={this.state.generalSettings.VideoNr}
 | 
			
		||||
                        subtext='Videos in Gravity'
 | 
			
		||||
                        icon={faArchive}
 | 
			
		||||
                    />
 | 
			
		||||
                    <InfoHeaderItem
 | 
			
		||||
                        backColor='yellow'
 | 
			
		||||
                        text={this.state.generalSettings.DBSize + ' MB'}
 | 
			
		||||
                        subtext='Database size'
 | 
			
		||||
                        icon={faRulerVertical}
 | 
			
		||||
                    />
 | 
			
		||||
                    <InfoHeaderItem
 | 
			
		||||
                        backColor='green'
 | 
			
		||||
                        text={this.state.generalSettings.DifferentTags}
 | 
			
		||||
                        subtext='different Tags'
 | 
			
		||||
                        icon={faAddressCard}
 | 
			
		||||
                    />
 | 
			
		||||
                    <InfoHeaderItem
 | 
			
		||||
                        backColor='orange'
 | 
			
		||||
                        text={this.state.generalSettings.TagsAdded}
 | 
			
		||||
                        subtext='tags added'
 | 
			
		||||
                        icon={faBalanceScaleLeft}
 | 
			
		||||
                    />
 | 
			
		||||
                </div>
 | 
			
		||||
                <div className={style.GeneralForm + ' ' + themeStyle.subtextcolor}>
 | 
			
		||||
                    <Form data-testid='mainformsettings' onSubmit={(e): void => {
 | 
			
		||||
                        e.preventDefault();
 | 
			
		||||
                        this.saveSettings();
 | 
			
		||||
                    }}>
 | 
			
		||||
                    <Form
 | 
			
		||||
                        data-testid='mainformsettings'
 | 
			
		||||
                        onSubmit={(e): void => {
 | 
			
		||||
                            e.preventDefault();
 | 
			
		||||
                            this.saveSettings();
 | 
			
		||||
                        }}>
 | 
			
		||||
                        <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.generalSettings.VideoPath}
 | 
			
		||||
                                              onChange={(ee): void => this.setState({
 | 
			
		||||
                                                  generalSettings: {
 | 
			
		||||
                                                      ...this.state.generalSettings,
 | 
			
		||||
                                                      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.generalSettings.EpisodePath}
 | 
			
		||||
                                              onChange={(e): void => this.setState({
 | 
			
		||||
                                                  generalSettings: {
 | 
			
		||||
                                                      ...this.state.generalSettings,
 | 
			
		||||
                                                      EpisodePath: e.target.value
 | 
			
		||||
                                                  }
 | 
			
		||||
                                              })}/>
 | 
			
		||||
                                <Form.Control
 | 
			
		||||
                                    type='text'
 | 
			
		||||
                                    placeholder='/var/www/html/tvshow'
 | 
			
		||||
                                    value={this.state.generalSettings.EpisodePath}
 | 
			
		||||
                                    onChange={(e): void =>
 | 
			
		||||
                                        this.setState({
 | 
			
		||||
                                            generalSettings: {
 | 
			
		||||
                                                ...this.state.generalSettings,
 | 
			
		||||
                                                EpisodePath: e.target.value
 | 
			
		||||
                                            }
 | 
			
		||||
                                        })
 | 
			
		||||
                                    }
 | 
			
		||||
                                />
 | 
			
		||||
                            </Form.Group>
 | 
			
		||||
                        </Form.Row>
 | 
			
		||||
 | 
			
		||||
@@ -116,17 +135,20 @@ class GeneralSettings extends React.Component<props, state> {
 | 
			
		||||
                                this.setState({customapi: !this.state.customapi});
 | 
			
		||||
                            }}
 | 
			
		||||
                        />
 | 
			
		||||
                        {this.state.customapi ?
 | 
			
		||||
                        {this.state.customapi ? (
 | 
			
		||||
                            <Form.Group className={style.customapiform} data-testid='apipath'>
 | 
			
		||||
                                <Form.Label>API Backend url</Form.Label>
 | 
			
		||||
                                <Form.Control type='text' placeholder='https://127.0.0.1'
 | 
			
		||||
                                              value={this.state.apipath}
 | 
			
		||||
                                              onChange={(e): void => {
 | 
			
		||||
                                                  this.setState({apipath: e.target.value});
 | 
			
		||||
                                                  setCustomBackendDomain(e.target.value);
 | 
			
		||||
                                              }}/>
 | 
			
		||||
                            </Form.Group> : null}
 | 
			
		||||
 | 
			
		||||
                                <Form.Control
 | 
			
		||||
                                    type='text'
 | 
			
		||||
                                    placeholder='https://127.0.0.1'
 | 
			
		||||
                                    value={this.state.apipath}
 | 
			
		||||
                                    onChange={(e): void => {
 | 
			
		||||
                                        this.setState({apipath: e.target.value});
 | 
			
		||||
                                        setCustomBackendDomain(e.target.value);
 | 
			
		||||
                                    }}
 | 
			
		||||
                                />
 | 
			
		||||
                            </Form.Group>
 | 
			
		||||
                        ) : null}
 | 
			
		||||
 | 
			
		||||
                        <Form.Check
 | 
			
		||||
                            type='switch'
 | 
			
		||||
@@ -144,19 +166,24 @@ class GeneralSettings extends React.Component<props, state> {
 | 
			
		||||
                            }}
 | 
			
		||||
                        />
 | 
			
		||||
 | 
			
		||||
                        {this.state.generalSettings.PasswordEnabled ?
 | 
			
		||||
                        {this.state.generalSettings.PasswordEnabled ? (
 | 
			
		||||
                            <Form.Group data-testid='passwordfield'>
 | 
			
		||||
                                <Form.Label>Password</Form.Label>
 | 
			
		||||
                                <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
 | 
			
		||||
                        }
 | 
			
		||||
                                <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}
 | 
			
		||||
 | 
			
		||||
                        <Form.Check
 | 
			
		||||
                            type='switch'
 | 
			
		||||
@@ -189,14 +216,19 @@ 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.generalSettings.MediacenterName}
 | 
			
		||||
                                          onChange={(e): void => this.setState({
 | 
			
		||||
                                              generalSettings: {
 | 
			
		||||
                                                  ...this.state.generalSettings,
 | 
			
		||||
                                                  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'>
 | 
			
		||||
@@ -204,9 +236,7 @@ class GeneralSettings extends React.Component<props, state> {
 | 
			
		||||
                        </Button>
 | 
			
		||||
                    </Form>
 | 
			
		||||
                </div>
 | 
			
		||||
                <div className={style.footer}>
 | 
			
		||||
                    Version: {version}
 | 
			
		||||
                </div>
 | 
			
		||||
                <div className={style.footer}>Version: {version}</div>
 | 
			
		||||
            </>
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
@@ -225,23 +255,27 @@ class GeneralSettings extends React.Component<props, state> {
 | 
			
		||||
     */
 | 
			
		||||
    saveSettings(): void {
 | 
			
		||||
        let settings = this.state.generalSettings;
 | 
			
		||||
        if(!this.state.generalSettings.PasswordEnabled){
 | 
			
		||||
        if (!this.state.generalSettings.PasswordEnabled) {
 | 
			
		||||
            settings.Password = '-1';
 | 
			
		||||
        }
 | 
			
		||||
        settings.DarkMode = GlobalInfos.isDarkTheme()
 | 
			
		||||
        settings.DarkMode = GlobalInfos.isDarkTheme();
 | 
			
		||||
 | 
			
		||||
        callAPI(APINode.Settings, {
 | 
			
		||||
            action: 'saveGeneralSettings',
 | 
			
		||||
            Settings: settings
 | 
			
		||||
        }, (result: GeneralSuccess) => {
 | 
			
		||||
            if (result.result) {
 | 
			
		||||
                console.log('successfully saved settings');
 | 
			
		||||
                // todo 2020-07-10: popup success
 | 
			
		||||
            } else {
 | 
			
		||||
                console.log('failed to save settings');
 | 
			
		||||
                // todo 2020-07-10: popup error
 | 
			
		||||
        callAPI(
 | 
			
		||||
            APINode.Settings,
 | 
			
		||||
            {
 | 
			
		||||
                action: 'saveGeneralSettings',
 | 
			
		||||
                Settings: settings
 | 
			
		||||
            },
 | 
			
		||||
            (result: GeneralSuccess) => {
 | 
			
		||||
                if (result.result) {
 | 
			
		||||
                    console.log('successfully saved settings');
 | 
			
		||||
                    // todo 2020-07-10: popup success
 | 
			
		||||
                } else {
 | 
			
		||||
                    console.log('failed to save settings');
 | 
			
		||||
                    // todo 2020-07-10: popup error
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -5,20 +5,20 @@ import {GeneralSuccess} from '../../types/GeneralTypes';
 | 
			
		||||
import {SettingsTypes} from '../../types/ApiTypes';
 | 
			
		||||
 | 
			
		||||
interface state {
 | 
			
		||||
    text: string[]
 | 
			
		||||
    startbtnDisabled: boolean
 | 
			
		||||
    text: string[];
 | 
			
		||||
    startbtnDisabled: boolean;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
interface props {}
 | 
			
		||||
interface Props {}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Component for MovieSettings on Settingspage
 | 
			
		||||
 * handles settings concerning to movies in general
 | 
			
		||||
 */
 | 
			
		||||
class MovieSettings extends React.Component<props, state> {
 | 
			
		||||
class MovieSettings extends React.Component<Props, state> {
 | 
			
		||||
    myinterval: number = -1;
 | 
			
		||||
 | 
			
		||||
    constructor(props: props) {
 | 
			
		||||
    constructor(props: Props) {
 | 
			
		||||
        super(props);
 | 
			
		||||
 | 
			
		||||
        this.state = {
 | 
			
		||||
@@ -32,23 +32,36 @@ class MovieSettings extends React.Component<props, state> {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    componentWillUnmount(): void {
 | 
			
		||||
        if (this.myinterval !== -1)
 | 
			
		||||
        if (this.myinterval !== -1) {
 | 
			
		||||
            clearInterval(this.myinterval);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    render(): JSX.Element {
 | 
			
		||||
        return (
 | 
			
		||||
            <>
 | 
			
		||||
                <button disabled={this.state.startbtnDisabled}
 | 
			
		||||
                        className='btn btn-success'
 | 
			
		||||
                        onClick={(): void => {this.startReindex();}}>Reindex Movie
 | 
			
		||||
                <button
 | 
			
		||||
                    disabled={this.state.startbtnDisabled}
 | 
			
		||||
                    className='btn btn-success'
 | 
			
		||||
                    onClick={(): void => {
 | 
			
		||||
                        this.startReindex();
 | 
			
		||||
                    }}>
 | 
			
		||||
                    Reindex Movie
 | 
			
		||||
                </button>
 | 
			
		||||
                <button className='btn btn-warning'
 | 
			
		||||
                        onClick={(): void => {this.cleanupGravity();}}>Cleanup Gravity
 | 
			
		||||
                <button
 | 
			
		||||
                    className='btn btn-warning'
 | 
			
		||||
                    onClick={(): void => {
 | 
			
		||||
                        this.cleanupGravity();
 | 
			
		||||
                    }}>
 | 
			
		||||
                    Cleanup Gravity
 | 
			
		||||
                </button>
 | 
			
		||||
                <div className={style.indextextarea}>{this.state.text.map(m => (
 | 
			
		||||
                    <div key={m} className='textarea-element'>{m}</div>
 | 
			
		||||
                ))}</div>
 | 
			
		||||
                <div className={style.indextextarea}>
 | 
			
		||||
                    {this.state.text.map((m) => (
 | 
			
		||||
                        <div key={m} className='textarea-element'>
 | 
			
		||||
                            {m}
 | 
			
		||||
                        </div>
 | 
			
		||||
                    ))}
 | 
			
		||||
                </div>
 | 
			
		||||
            </>
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
@@ -99,7 +112,7 @@ class MovieSettings extends React.Component<props, state> {
 | 
			
		||||
     * send request to cleanup db gravity
 | 
			
		||||
     */
 | 
			
		||||
    cleanupGravity(): void {
 | 
			
		||||
        callAPI(APINode.Settings, {action: 'cleanupGravity'}, (result) => {
 | 
			
		||||
        callAPI(APINode.Settings, {action: 'cleanupGravity'}, () => {
 | 
			
		||||
            this.setState({
 | 
			
		||||
                text: ['successfully cleaned up gravity!']
 | 
			
		||||
            });
 | 
			
		||||
 
 | 
			
		||||
@@ -28,17 +28,17 @@ class SettingsPage extends React.Component {
 | 
			
		||||
                </div>
 | 
			
		||||
                <div className={style.SettingsContent}>
 | 
			
		||||
                    <Switch>
 | 
			
		||||
                        <Route path="/settings/general">
 | 
			
		||||
                            <GeneralSettings/>
 | 
			
		||||
                        <Route path='/settings/general'>
 | 
			
		||||
                            <GeneralSettings />
 | 
			
		||||
                        </Route>
 | 
			
		||||
                        <Route path="/settings/movies">
 | 
			
		||||
                            <MovieSettings/>
 | 
			
		||||
                        <Route path='/settings/movies'>
 | 
			
		||||
                            <MovieSettings />
 | 
			
		||||
                        </Route>
 | 
			
		||||
                        <Route path="/settings/tv">
 | 
			
		||||
                            <span/>
 | 
			
		||||
                        <Route path='/settings/tv'>
 | 
			
		||||
                            <span />
 | 
			
		||||
                        </Route>
 | 
			
		||||
                        <Route path="/settings">
 | 
			
		||||
                            <Redirect to='/settings/general'/>
 | 
			
		||||
                        <Route path='/settings'>
 | 
			
		||||
                            <Redirect to='/settings/general' />
 | 
			
		||||
                        </Route>
 | 
			
		||||
                    </Switch>
 | 
			
		||||
                </div>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user