File size: 2,352 Bytes
ef78361
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
"""ChainShift Brand Risk Monitoring Dashboard v10.0.

Feature Plugin Architecture: ์ƒˆ ๊ธฐ๋Šฅ = features/ ๋””๋ ‰ํ† ๋ฆฌ ์ƒ์„ฑ โ†’ ์ž๋™ ๋“ฑ๋ก.
"""

import streamlit as st

from core.styles import DASHBOARD_CSS
from sidebar import render_sidebar
from registry import discover_features


# =============================================================================
# Page Config
# =============================================================================

st.set_page_config(
    page_title="ChainShift Dashboard",
    page_icon="โšก",
    layout="wide",
    initial_sidebar_state="expanded",
)

st.markdown(DASHBOARD_CSS, unsafe_allow_html=True)

st.title("ChainShift")
st.caption("AI ๊ฒ€์ƒ‰ ํ”Œ๋žซํผ์—์„œ ๋ธŒ๋žœ๋“œ๊ฐ€ ์–ด๋–ป๊ฒŒ ์–ธ๊ธ‰๋˜๊ณ  ์ธ์šฉ๋˜๋Š”์ง€ ๋ถ„์„ํ•ฉ๋‹ˆ๋‹ค")


# =============================================================================
# Sidebar (์ธ์ฆ + ์บ ํŽ˜์ธ ์„ ํƒ)
# =============================================================================

sidebar_result = render_sidebar()
if not sidebar_result:
    st.stop()

auth_info, selected_campaign_id, selected_campaign_display = sidebar_result


# =============================================================================
# Feature Discovery + Rendering
# =============================================================================

features = discover_features()

if not features:
    st.error("๋“ฑ๋ก๋œ Feature๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค. features/ ๋””๋ ‰ํ† ๋ฆฌ๋ฅผ ํ™•์ธํ•˜์„ธ์š”.")
    st.stop()

# Base context shared by all features
base_ctx = {
    "api_key": auth_info.get("api_key"),
    "access_token": auth_info.get("access_token"),
    "campaign_id": selected_campaign_id,
    "campaign_name": selected_campaign_display,
    "user_email": auth_info.get("email"),
}

# Create tabs from discovered features
tab_labels = [f"{f['config']['icon']} {f['config']['name']}" for f in features]
tabs = st.tabs(tab_labels)

for tab, feature in zip(tabs, features):
    with tab:
        try:
            feature["module"].render(base_ctx)
        except Exception as e:
            st.error(f"{feature['config']['name']} ๋กœ๋”ฉ ์‹คํŒจ: {e}")


# =============================================================================
# Footer
# =============================================================================

st.markdown("---")
st.caption("ChainShift v10.0")