save settings correctly to db and parse response from insertion
This commit is contained in:
		@@ -22,5 +22,24 @@ if (isset($_POST['action'])) {
 | 
			
		||||
            }
 | 
			
		||||
            echo json_encode($r);
 | 
			
		||||
            break;
 | 
			
		||||
        case "saveGeneralSettings":
 | 
			
		||||
            $mediacentername = $_POST['mediacentername'];
 | 
			
		||||
            $password = $_POST['password'];
 | 
			
		||||
            $videopath = $_POST['videopath'];
 | 
			
		||||
            $tvshowpath = $_POST['tvshowpath'];
 | 
			
		||||
 | 
			
		||||
            $query = "UPDATE settings SET 
 | 
			
		||||
                        video_path='$videopath',
 | 
			
		||||
                        episode_path='$tvshowpath',
 | 
			
		||||
                        password='$password',
 | 
			
		||||
                        mediacenter_name='$mediacentername'
 | 
			
		||||
                    WHERE 1";
 | 
			
		||||
 | 
			
		||||
            if ($conn->query($query) === true) {
 | 
			
		||||
                echo '{"success": true}';
 | 
			
		||||
            } else {
 | 
			
		||||
                echo '{"success": true}';
 | 
			
		||||
            }
 | 
			
		||||
            break;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -93,10 +93,19 @@ class GeneralSettings extends React.Component {
 | 
			
		||||
        const updateRequest = new FormData();
 | 
			
		||||
        updateRequest.append('action', 'saveGeneralSettings');
 | 
			
		||||
 | 
			
		||||
        fetch('/api/settings.php', {method: 'POST', body: updateRequest})
 | 
			
		||||
        updateRequest.append('password', this.state.passwordsupport ? this.state.password : "-1");
 | 
			
		||||
        updateRequest.append('videopath', this.state.videopath);
 | 
			
		||||
        updateRequest.append('tvshowpath', this.state.tvshowpath);
 | 
			
		||||
        updateRequest.append('mediacentername', this.state.mediacentername);
 | 
			
		||||
 | 
			
		||||
        fetch('/api/Settings.php', {method: 'POST', body: updateRequest})
 | 
			
		||||
            .then((response) => response.json()
 | 
			
		||||
                .then((result) => {
 | 
			
		||||
                    // todo 2020-07-4: settings result here
 | 
			
		||||
                    if (result.success) {
 | 
			
		||||
                        // todo 2020-07-10: popup success
 | 
			
		||||
                    } else {
 | 
			
		||||
                        // todo 2020-07-10: popup error
 | 
			
		||||
                    }
 | 
			
		||||
                }));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user