pin auth should disable fields and show library

pull/342/head
elmerohueso 3 weeks ago
parent 6a27e7930c
commit d36f18f5d7

@ -7377,6 +7377,18 @@ def get_plex_pin_status():
return jsonify({"success": False, "error": str(e)}), 500
@app.route('/api/plex/clear-library', methods=['POST'])
def clear_plex_library_preference():
try:
from database.music_database import MusicDatabase
db = MusicDatabase()
db.set_preference('plex_music_library', '')
return jsonify({"success": True, "message": "Plex library preference cleared."})
except Exception as e:
logger.error(f"Error clearing Plex library preference: {e}")
return jsonify({"success": False, "error": str(e)}), 500
@app.route('/api/plex/music-libraries', methods=['GET'])
def get_plex_music_libraries():
"""Get list of all available music libraries from Plex"""

@ -6436,14 +6436,19 @@ function updateMediaServerFields() {
let _plexPinAuthRequestId = null;
let _plexPinAuthPollInterval = null;
function showPlexConfiguration() {
function showPlexConfiguration(disableFields = false) {
stopPlexPinAuthPolling();
const plexConfig = document.getElementById('plex-configuration');
const plexSetup = document.getElementById('plex-setup');
const plexPinAuthFlow = document.getElementById('plex-pin-auth-flow');
const plexUrl = document.getElementById('plex-url');
const plexToken = document.getElementById('plex-token');
if (plexConfig) plexConfig.style.display = '';
if (plexSetup) plexSetup.style.display = 'none';
if (plexPinAuthFlow) plexPinAuthFlow.style.display = 'none';
if (plexUrl) plexUrl.disabled = disableFields;
if (plexToken) plexToken.disabled = disableFields;
}
async function startPlexPinAuth() {
@ -6517,10 +6522,11 @@ async function pollPlexPinAuthStatus() {
document.getElementById('plex-url').value = result.found_url || '';
document.getElementById('plex-token').value = result.token || '';
if (typeof saveSettings === 'function') {
saveSettings(true);
await saveSettings(true);
}
showToast('Plex successfully linked', 'success');
showPlexConfiguration();
showPlexConfiguration(true);
await testConnection('plex');
return;
}
@ -6574,6 +6580,12 @@ function clearPlexConfiguration() {
if (plexLinkToPlexButton) plexLinkToPlexButton.style.display = '';
if (plexManualConfigButton) plexManualConfigButton.style.display = '';
try {
await fetch('/api/plex/clear-library', { method: 'POST' });
} catch (e) {
console.warn('Failed to clear Plex library preference:', e);
}
if (typeof saveSettings === 'function') {
saveSettings(true);
}

Loading…
Cancel
Save