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
|
||||
}
|
||||
}
|
||||
});
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user