mirror of
https://github.com/plexguide/Huntarr.io.git
synced 2026-01-06 06:00:08 -06:00
Refactor stateful management reset and add new API endpoints for stateful operations
This commit is contained in:
@@ -1135,18 +1135,6 @@ const SettingsForms = {
|
||||
});
|
||||
}
|
||||
|
||||
// Add listener for reset stateful button
|
||||
const resetStatefulBtn = container.querySelector('#reset_stateful_btn');
|
||||
if (resetStatefulBtn) {
|
||||
resetStatefulBtn.addEventListener('click', function() {
|
||||
if (confirm('Are you sure you want to reset stateful management? This will clear all processed media IDs.')) {
|
||||
// Dispatch event for main.js to handle the reset
|
||||
const event = new CustomEvent('resetStateful', {});
|
||||
container.dispatchEvent(event);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Load stateful management info
|
||||
fetch('/api/stateful/info')
|
||||
.then(response => response.json())
|
||||
@@ -1170,6 +1158,20 @@ const SettingsForms = {
|
||||
}
|
||||
});
|
||||
|
||||
// Add listener for reset stateful button
|
||||
const resetStatefulBtn = container.querySelector('#reset_stateful_btn');
|
||||
if (resetStatefulBtn && typeof huntarrUI !== 'undefined' && typeof huntarrUI.resetStatefulManagement === 'function') {
|
||||
resetStatefulBtn.addEventListener('click', function() {
|
||||
if (confirm('Are you sure you want to reset stateful management? This will clear all processed media IDs.')) {
|
||||
huntarrUI.resetStatefulManagement();
|
||||
}
|
||||
});
|
||||
} else if (!resetStatefulBtn) {
|
||||
console.warn('Could not find #reset_stateful_btn to attach listener.');
|
||||
} else {
|
||||
console.warn('huntarrUI or huntarrUI.resetStatefulManagement is not available.');
|
||||
}
|
||||
|
||||
// Add confirmation dialog for local access bypass toggle
|
||||
const localAccessBypassCheckbox = container.querySelector('#local_access_bypass');
|
||||
if (localAccessBypassCheckbox) {
|
||||
|
||||
@@ -1,13 +1,38 @@
|
||||
from flask import Flask, render_template, request, redirect
|
||||
from flask import Flask, render_template, request, redirect, jsonify
|
||||
import os
|
||||
import json
|
||||
|
||||
# Import the necessary function
|
||||
from src.primary.stateful_manager import reset_stateful_management, get_stateful_management_info
|
||||
|
||||
# Configure Flask to use templates and static files from the frontend folder
|
||||
template_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'frontend', 'templates'))
|
||||
static_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'frontend', 'static'))
|
||||
|
||||
app = Flask(__name__, template_folder=template_dir, static_folder=static_dir)
|
||||
|
||||
# API Routes
|
||||
|
||||
@app.route('/api/stateful/reset', methods=['POST'])
|
||||
def api_reset_stateful():
|
||||
"""API endpoint to reset the stateful management system."""
|
||||
success = reset_stateful_management()
|
||||
if success:
|
||||
return jsonify({"success": True, "message": "Stateful management reset successfully."}), 200
|
||||
else:
|
||||
return jsonify({"success": False, "message": "Failed to reset stateful management."}), 500
|
||||
|
||||
@app.route('/api/stateful/info', methods=['GET'])
|
||||
def api_get_stateful_info():
|
||||
"""API endpoint to get stateful management info."""
|
||||
try:
|
||||
info = get_stateful_management_info()
|
||||
return jsonify(info), 200
|
||||
except Exception as e:
|
||||
# Log the exception details if possible
|
||||
app.logger.error(f"Error getting stateful info: {e}")
|
||||
return jsonify({"error": "Failed to retrieve stateful information."}), 500
|
||||
|
||||
def get_ui_preference():
|
||||
"""Determine which UI to use based on config and user preference"""
|
||||
# Check if ui_settings.json exists
|
||||
@@ -48,5 +73,10 @@ def user_page():
|
||||
else:
|
||||
return render_template('user.html')
|
||||
|
||||
@app.route('/user/new')
|
||||
def user_page_new():
|
||||
"""Serve the new user settings page"""
|
||||
return render_template('user-new.html')
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(debug=True)
|
||||
Reference in New Issue
Block a user