Skip to content

Commit

Permalink
Renamed CWA History page to CWA Stats, added Server Stats to Stats pa…
Browse files Browse the repository at this point in the history
…ge, fixed stat page css, starting to migrate CWA css to caliBlur_cwa.css as caliBlur.css is just way too big, repaired progress bar for EPUB Fixer
  • Loading branch information
crocodilestick committed Jan 6, 2025
1 parent 9ab6661 commit 86bd29c
Show file tree
Hide file tree
Showing 11 changed files with 276 additions and 230 deletions.
43 changes: 27 additions & 16 deletions root/app/calibre-web/cps/cwa_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
from datetime import datetime
import re

from .web import cwa_get_num_books_in_library

import sys
sys.path.insert(1, '/app/calibre-web-automated/scripts/')
from cwa_db import CWA_DB
Expand All @@ -27,7 +29,7 @@
library_refresh = Blueprint('library_refresh', __name__)
convert_library = Blueprint('convert_library', __name__)
epub_fixer = Blueprint('epub_fixer', __name__)
cwa_history = Blueprint('cwa_history', __name__)
cwa_stats = Blueprint('cwa_stats', __name__)
cwa_check_status = Blueprint('cwa_check_status', __name__)
cwa_settings = Blueprint('cwa_settings', __name__)

Expand Down Expand Up @@ -193,6 +195,14 @@ def set_cwa_settings():
## ##
##————————————————————————————————————————————————————————————————————————————##

def get_cwa_stats() -> dict[str,int]:
"""Returns CWA stat totals as a dict (keys are table names except for total_books)"""
cwa_db = CWA_DB()
totals = cwa_db.get_stat_totals()
totals["total_books"] = cwa_get_num_books_in_library() # from web.py

return totals

### TABLE HEADERS
headers = {
"enforcement":{
Expand All @@ -213,10 +223,10 @@ def set_cwa_settings():
"Timestamp", "Filename", "Original Format", "End Format", "Original Backed Up?"],
}

@cwa_history.route("/cwa-history-show", methods=["GET", "POST"])
@cwa_stats.route("/cwa-history-show", methods=["GET", "POST"])
@login_required_if_no_ano
@admin_required
def cwa_history_show():
def cwa_stats_show():
cwa_db = CWA_DB()
data_enforcement = cwa_db.enforce_show(paths=False, verbose=False, web_ui=True)
data_enforcement_with_paths = cwa_db.enforce_show(paths=True, verbose=False, web_ui=True)
Expand All @@ -225,66 +235,67 @@ def cwa_history_show():
data_epub_fixer = cwa_db.get_epub_fixer_history(fixes=False, verbose=False)
data_epub_fixer_with_fixes = cwa_db.get_epub_fixer_history(fixes=True, verbose=False)

return render_title_template("cwa_history.html", title=_("Calibre-Web Automated Stats"), page="cwa-history",
return render_title_template("cwa_stats.html", title=_("Calibre-Web Automated Stats"), page="cwa-history",
cwa_stats=get_cwa_stats(),
data_enforcement=data_enforcement, headers_enforcement=headers["enforcement"]["no_paths"],
data_enforcement_with_paths=data_enforcement_with_paths,headers_enforcement_with_paths=headers["enforcement"]["with_paths"],
data_imports=data_imports, headers_import=headers["imports"],
data_conversions=data_conversions, headers_conversion=headers["conversions"],
data_epub_fixer=data_epub_fixer, headers_epub_fixer=headers["epub_fixer"]["no_fixes"],
data_epub_fixer_with_fixes=data_epub_fixer_with_fixes, headers_epub_fixer_with_fixes=headers["epub_fixer"]["with_fixes"])

@cwa_history.route("/cwa-history-show/full-enforcement", methods=["GET", "POST"])
@cwa_stats.route("/cwa-history-show/full-enforcement", methods=["GET", "POST"])
@login_required_if_no_ano
@admin_required
def show_full_enforcement():
cwa_db = CWA_DB()
data = cwa_db.enforce_show(paths=False, verbose=True, web_ui=True)
return render_title_template("cwa_history_full.html", title=_("Calibre-Web Automated - Full Enforcement History"), page="cwa-history-full",
return render_title_template("cwa_stats_full.html", title=_("Calibre-Web Automated - Full Enforcement History"), page="cwa-history-full",
table_headers=headers["enforcement"]["no_paths"], data=data)

@cwa_history.route("/cwa-history-show/full-enforcement-with-paths", methods=["GET", "POST"])
@cwa_stats.route("/cwa-history-show/full-enforcement-with-paths", methods=["GET", "POST"])
@login_required_if_no_ano
@admin_required
def show_full_enforcement_path():
cwa_db = CWA_DB()
data = cwa_db.enforce_show(paths=True, verbose=True, web_ui=True)
return render_title_template("cwa_history_full.html", title=_("Calibre-Web Automated - Full Enforcement History (w/ Paths)"), page="cwa-history-full",
return render_title_template("cwa_stats_full.html", title=_("Calibre-Web Automated - Full Enforcement History (w/ Paths)"), page="cwa-history-full",
table_headers=headers["enforcement"]["with_paths"], data=data)

@cwa_history.route("/cwa-history-show/full-imports", methods=["GET", "POST"])
@cwa_stats.route("/cwa-history-show/full-imports", methods=["GET", "POST"])
@login_required_if_no_ano
@admin_required
def show_full_imports():
cwa_db = CWA_DB()
data = cwa_db.get_import_history(verbose=True)
return render_title_template("cwa_history_full.html", title=_("Calibre-Web Automated - Full Import History"), page="cwa-history-full",
return render_title_template("cwa_stats_full.html", title=_("Calibre-Web Automated - Full Import History"), page="cwa-history-full",
table_headers=headers["imports"], data=data)

@cwa_history.route("/cwa-history-show/full-conversions", methods=["GET", "POST"])
@cwa_stats.route("/cwa-history-show/full-conversions", methods=["GET", "POST"])
@login_required_if_no_ano
@admin_required
def show_full_conversions():
cwa_db = CWA_DB()
data = cwa_db.get_conversion_history(verbose=True)
return render_title_template("cwa_history_full.html", title=_("Calibre-Web Automated - Full Conversion History"), page="cwa-history-full",
return render_title_template("cwa_stats_full.html", title=_("Calibre-Web Automated - Full Conversion History"), page="cwa-history-full",
table_headers=headers["conversions"], data=data)

@cwa_history.route("/cwa-history-show/full-epub-fixer", methods=["GET", "POST"])
@cwa_stats.route("/cwa-history-show/full-epub-fixer", methods=["GET", "POST"])
@login_required_if_no_ano
@admin_required
def show_full_epub_fixer():
cwa_db = CWA_DB()
data = cwa_db.get_epub_fixer_history(fixes=False, verbose=True)
return render_title_template("cwa_history_full.html", title=_("Calibre-Web Automated - Full EPUB Fixer History (w/out Paths & Fixes)"), page="cwa-history-full",
return render_title_template("cwa_stats_full.html", title=_("Calibre-Web Automated - Full EPUB Fixer History (w/out Paths & Fixes)"), page="cwa-history-full",
table_headers=headers["epub_fixer"]["no_fixes"], data=data)

@cwa_history.route("/cwa-history-show/full-epub-fixer-with-paths-fixes", methods=["GET", "POST"])
@cwa_stats.route("/cwa-history-show/full-epub-fixer-with-paths-fixes", methods=["GET", "POST"])
@login_required_if_no_ano
@admin_required
def show_full_epub_fixer_with_paths_fixes():
cwa_db = CWA_DB()
data = cwa_db.get_epub_fixer_history(fixes=True, verbose=True)
return render_title_template("cwa_history_full.html", title=_("Calibre-Web Automated - Full EPUB Fixer History (w/ Paths & Fixes)"), page="cwa-history-full",
return render_title_template("cwa_stats_full.html", title=_("Calibre-Web Automated - Full EPUB Fixer History (w/ Paths & Fixes)"), page="cwa-history-full",
table_headers=headers["epub_fixer"]["with_fixes"], data=data)

##————————————————————————————————————————————————————————————————————————————##
Expand Down
4 changes: 2 additions & 2 deletions root/app/calibre-web/cps/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def request_username():
def main():
app = create_app()

from .cwa_functions import switch_theme, library_refresh, convert_library, epub_fixer, cwa_history, cwa_check_status, cwa_settings
from .cwa_functions import switch_theme, library_refresh, convert_library, epub_fixer, cwa_stats, cwa_check_status, cwa_settings
from .web import web
from .opds import opds
from .admin import admi
Expand Down Expand Up @@ -67,7 +67,7 @@ def main():
app.register_blueprint(library_refresh)
app.register_blueprint(convert_library)
app.register_blueprint(epub_fixer)
app.register_blueprint(cwa_history)
app.register_blueprint(cwa_stats)
app.register_blueprint(cwa_check_status)
app.register_blueprint(cwa_settings)

Expand Down
68 changes: 1 addition & 67 deletions root/app/calibre-web/cps/static/css/caliBlur.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file.
2 changes: 1 addition & 1 deletion root/app/calibre-web/cps/templates/admin.html
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ <h2>{{_('Scheduled Tasks ⌛')}}</h2>
<div class="row form-group">
<h2>{{_('CWA Admin Functions⚡')}}</h2>
<a class="btn btn-default" id="cwa-settings" href="{{url_for('cwa_settings.set_cwa_settings')}}">{{_('CWA Settings')}}</a>
<a class="btn btn-default" id="cwa_history" href="{{url_for('cwa_history.cwa_history_show')}}">{{_('Show CWA Stats')}}</a>
<a class="btn btn-default" id="cwa_stats" href="{{url_for('cwa_stats.cwa_stats_show')}}">{{_('Show CWA Stats')}}</a>
<a class="btn btn-default" id="check_mon_srvs" href="{{url_for('cwa_check_status.cwa_flash_status')}}">{{_('Check CWA Status')}}</a>
</div>
<div class="row form-group">
Expand Down
4 changes: 3 additions & 1 deletion root/app/calibre-web/cps/templates/cwa_epub_fixer.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ <h3 style="color: whitesmoke;">CWA Send-to-Kindle EPUB Fixer</h3><br>
<a class="btn btn-default" href="{{ url_for('epub_fixer.start_epub_fixer') }}" style="vertical-align: top; float: right; width: 100px;">{{_('Start')}}</a>
</div>
</div>

<div class="progress-container" style="margin: 20px 0;">
<div id="progress-bar" style="width: 0%; height: 25px; background-color: green; text-align: center; color: white;"></div>
</div>
<div class="row">
<div class="logging_window" style="padding-left: 15px;
padding-right: 15px;
Expand Down
139 changes: 0 additions & 139 deletions root/app/calibre-web/cps/templates/cwa_history.html

This file was deleted.

Loading

0 comments on commit 86bd29c

Please sign in to comment.