79 lines
3.0 KiB
Python
79 lines
3.0 KiB
Python
from __future__ import annotations
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import streamlit as st
|
|
from jarca_ledger_mcp.adapters.streamlit import overview_gateway
|
|
|
|
# Streamlit executes this file as a script, so ensure absolute dashboard imports
|
|
# resolve identically to package imports used by tests.
|
|
if __package__ in (None, ""):
|
|
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
|
|
|
st.set_page_config(page_title="Jarca Ledger", page_icon="💰", layout="wide")
|
|
|
|
from dashboard.common import (
|
|
clear_cache,
|
|
get_db_path,
|
|
get_transfer_review_items, # noqa: F401
|
|
inject_app_css,
|
|
render_dashboard_body,
|
|
render_sidebar_nav,
|
|
validate_dashboard_page,
|
|
) # noqa: F401
|
|
from dashboard.authentication import require_dashboard_authentication
|
|
from dashboard.page_views.accounts import page_accounts
|
|
from dashboard.page_views.assets import page_assets
|
|
from dashboard.page_views.categories import page_categories
|
|
from dashboard.page_views.cross_transfer_review import page_cross_transfer_review
|
|
from dashboard.page_views.imports import page_imports
|
|
from dashboard.page_views.monthly_settlement import page_monthly_settlement
|
|
from dashboard.page_views.overview import page_overview
|
|
from dashboard.page_views.rules import page_rules
|
|
from dashboard.page_views.transactions import page_transactions
|
|
from dashboard.page_views.uncategorized import page_uncategorized
|
|
|
|
def main() -> None:
|
|
if not require_dashboard_authentication():
|
|
return
|
|
|
|
db_path = get_db_path()
|
|
db_status = overview_gateway.get_ledger_db_status(db_path=db_path, include_hash=False, include_integrity=False)
|
|
inject_app_css()
|
|
if not db_status.get("success"):
|
|
st.error("Ledger DB를 사용할 수 없습니다: " + db_status.get("error", "ledger database is unavailable"))
|
|
return
|
|
pages = ["월정산", "요약", "자산/마감", "거래내역", "확인필요 큐", "미분류", "분류 규칙", "카테고리", "계좌", "Import"]
|
|
query_page = st.query_params.get("page")
|
|
if query_page == "monthly_settlement":
|
|
query_page = "월정산"
|
|
page = validate_dashboard_page(query_page, pages)
|
|
st.session_state["dashboard_page"] = page
|
|
|
|
with st.sidebar:
|
|
st.markdown("## 💰 Jarca Ledger")
|
|
st.caption("가계부 · 분류 · Import 운영 콘솔")
|
|
st.markdown('<div class="jarca-nav-title">메뉴</div>', unsafe_allow_html=True)
|
|
page = render_sidebar_nav(pages, page)
|
|
if st.button("새로고침", key="refresh_button", use_container_width=True):
|
|
clear_cache()
|
|
st.rerun()
|
|
dispatch = {
|
|
"월정산": page_monthly_settlement,
|
|
"요약": page_overview,
|
|
"자산/마감": page_assets,
|
|
"거래내역": page_transactions,
|
|
"확인필요 큐": page_cross_transfer_review,
|
|
"미분류": page_uncategorized,
|
|
"분류 규칙": page_rules,
|
|
"카테고리": page_categories,
|
|
"계좌": page_accounts,
|
|
"Import": page_imports,
|
|
}
|
|
render_dashboard_body(page, lambda: dispatch[page](db_path))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|