Spaces:
Runtime error
Runtime error
Commit
Β·
006fe0b
1
Parent(s):
c0c93be
Add application files
Browse files
app.py
CHANGED
|
@@ -559,6 +559,11 @@ footer { display: none !important; }
|
|
| 559 |
display: none !important;
|
| 560 |
}
|
| 561 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 562 |
.setup-required {
|
| 563 |
background: var(--warning-light);
|
| 564 |
border: 2px solid var(--warning-orange);
|
|
@@ -2713,6 +2718,87 @@ def create_app():
|
|
| 2713 |
if (overlay) overlay.style.display = 'none';
|
| 2714 |
}};
|
| 2715 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2716 |
// Initialize on load
|
| 2717 |
document.addEventListener('DOMContentLoaded', function() {{
|
| 2718 |
// Handle overlay click to close sidebar
|
|
@@ -2720,6 +2806,12 @@ def create_app():
|
|
| 2720 |
if (overlay) {{
|
| 2721 |
overlay.addEventListener('click', window.closeMobileSidebar);
|
| 2722 |
}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2723 |
}});
|
| 2724 |
</script>
|
| 2725 |
"""
|
|
@@ -2868,7 +2960,7 @@ def create_app():
|
|
| 2868 |
setup_output = gr.Markdown("*Enter your credentials and company name to begin.*")
|
| 2869 |
|
| 2870 |
# ===== DASHBOARD PAGE =====
|
| 2871 |
-
with gr.Column(visible=
|
| 2872 |
gr.HTML("""<div class="page-header"><div>
|
| 2873 |
<h1 class="page-title">π Dashboard</h1>
|
| 2874 |
<p class="page-subtitle">Overview of your sales pipeline</p>
|
|
@@ -2897,7 +2989,7 @@ def create_app():
|
|
| 2897 |
refresh_btn = gr.Button("π Refresh Dashboard", variant="secondary")
|
| 2898 |
|
| 2899 |
# ===== DISCOVERY PAGE =====
|
| 2900 |
-
with gr.Column(visible=
|
| 2901 |
gr.HTML("""<div class="page-header"><div>
|
| 2902 |
<h1 class="page-title">π Discovery</h1>
|
| 2903 |
<p class="page-subtitle">AI-powered prospect discovery</p>
|
|
@@ -2934,7 +3026,7 @@ def create_app():
|
|
| 2934 |
discovery_output = gr.Markdown("*Click 'Find Prospects' after completing Setup.*")
|
| 2935 |
|
| 2936 |
# ===== PROSPECTS PAGE =====
|
| 2937 |
-
with gr.Column(visible=
|
| 2938 |
gr.HTML("""<div class="page-header"><div>
|
| 2939 |
<h1 class="page-title">π― Prospects</h1>
|
| 2940 |
<p class="page-subtitle">Companies discovered by AI</p>
|
|
@@ -2954,7 +3046,7 @@ def create_app():
|
|
| 2954 |
prospects_list = gr.HTML(get_prospects_html())
|
| 2955 |
|
| 2956 |
# ===== CONTACTS PAGE =====
|
| 2957 |
-
with gr.Column(visible=
|
| 2958 |
gr.HTML("""<div class="page-header"><div>
|
| 2959 |
<h1 class="page-title">π₯ Contacts</h1>
|
| 2960 |
<p class="page-subtitle">Decision makers found by AI</p>
|
|
@@ -2974,7 +3066,7 @@ def create_app():
|
|
| 2974 |
contacts_list = gr.HTML(get_contacts_html())
|
| 2975 |
|
| 2976 |
# ===== EMAILS PAGE =====
|
| 2977 |
-
with gr.Column(visible=
|
| 2978 |
gr.HTML("""<div class="page-header"><div>
|
| 2979 |
<h1 class="page-title">βοΈ Emails</h1>
|
| 2980 |
<p class="page-subtitle">AI-drafted outreach emails</p>
|
|
@@ -2994,7 +3086,7 @@ def create_app():
|
|
| 2994 |
emails_list = gr.HTML(get_emails_html())
|
| 2995 |
|
| 2996 |
# ===== AI CHAT PAGE =====
|
| 2997 |
-
with gr.Column(visible=
|
| 2998 |
gr.HTML("""<div class="page-header"><div>
|
| 2999 |
<h1 class="page-title">π¬ AI Chat</h1>
|
| 3000 |
<p class="page-subtitle">AI-powered communication hub</p>
|
|
@@ -3090,7 +3182,7 @@ def create_app():
|
|
| 3090 |
handoff_output = gr.Markdown(visible=False, elem_classes="handoff-packet")
|
| 3091 |
|
| 3092 |
# ===== ABOUT US PAGE =====
|
| 3093 |
-
with gr.Column(visible=
|
| 3094 |
gr.HTML("""<div class="page-header"><div>
|
| 3095 |
<h1 class="page-title">βΉοΈ About Us</h1>
|
| 3096 |
<p class="page-subtitle">Learn more about CX AI Agent</p>
|
|
@@ -3279,40 +3371,7 @@ This project is open source and available under the MIT License.
|
|
| 3279 |
btn_chat.click(fn=lambda: show_page("chat"), outputs=all_pages)
|
| 3280 |
btn_about.click(fn=lambda: show_page("about"), outputs=all_pages)
|
| 3281 |
|
| 3282 |
-
# JavaScript
|
| 3283 |
-
gr.HTML("""
|
| 3284 |
-
<script>
|
| 3285 |
-
window._pageIds = ['setup', 'dashboard', 'discovery', 'prospects', 'contacts', 'emails', 'chat', 'about'];
|
| 3286 |
-
|
| 3287 |
-
window.selectPage = function(pageName) {
|
| 3288 |
-
// Close mobile sidebar immediately
|
| 3289 |
-
if (window.closeMobileSidebar) {
|
| 3290 |
-
window.closeMobileSidebar();
|
| 3291 |
-
}
|
| 3292 |
-
|
| 3293 |
-
// Update active nav item in sidebar (instant visual feedback)
|
| 3294 |
-
document.querySelectorAll('.nav-item').forEach(item => {
|
| 3295 |
-
item.classList.toggle('active', item.dataset.page === pageName);
|
| 3296 |
-
});
|
| 3297 |
-
|
| 3298 |
-
// Directly show/hide page containers
|
| 3299 |
-
window._pageIds.forEach(function(pageId) {
|
| 3300 |
-
const pageEl = document.getElementById('page-' + pageId);
|
| 3301 |
-
if (pageEl) {
|
| 3302 |
-
if (pageId === pageName) {
|
| 3303 |
-
pageEl.style.display = 'flex';
|
| 3304 |
-
pageEl.classList.remove('hidden');
|
| 3305 |
-
} else {
|
| 3306 |
-
pageEl.style.display = 'none';
|
| 3307 |
-
pageEl.classList.add('hidden');
|
| 3308 |
-
}
|
| 3309 |
-
}
|
| 3310 |
-
});
|
| 3311 |
-
|
| 3312 |
-
console.log('Switched to page:', pageName);
|
| 3313 |
-
};
|
| 3314 |
-
</script>
|
| 3315 |
-
""")
|
| 3316 |
|
| 3317 |
# ===== EVENT HANDLERS =====
|
| 3318 |
|
|
|
|
| 559 |
display: none !important;
|
| 560 |
}
|
| 561 |
|
| 562 |
+
/* Hide pages by default using CSS class */
|
| 563 |
+
.page-hidden {
|
| 564 |
+
display: none !important;
|
| 565 |
+
}
|
| 566 |
+
|
| 567 |
.setup-required {
|
| 568 |
background: var(--warning-light);
|
| 569 |
border: 2px solid var(--warning-orange);
|
|
|
|
| 2718 |
if (overlay) overlay.style.display = 'none';
|
| 2719 |
}};
|
| 2720 |
|
| 2721 |
+
// Page navigation using CSS classes
|
| 2722 |
+
window._pageIds = ['setup', 'dashboard', 'discovery', 'prospects', 'contacts', 'emails', 'chat', 'about'];
|
| 2723 |
+
window._pageElementsCache = {{}};
|
| 2724 |
+
|
| 2725 |
+
// Find page element - tries multiple approaches
|
| 2726 |
+
function findPageElement(pageId) {{
|
| 2727 |
+
// Check cache first
|
| 2728 |
+
if (window._pageElementsCache[pageId]) {{
|
| 2729 |
+
return window._pageElementsCache[pageId];
|
| 2730 |
+
}}
|
| 2731 |
+
|
| 2732 |
+
let el = null;
|
| 2733 |
+
|
| 2734 |
+
// Try direct ID
|
| 2735 |
+
el = document.getElementById('page-' + pageId);
|
| 2736 |
+
|
| 2737 |
+
// Try querySelector with partial match
|
| 2738 |
+
if (!el) {{
|
| 2739 |
+
el = document.querySelector('[id*="page-' + pageId + '"]');
|
| 2740 |
+
}}
|
| 2741 |
+
|
| 2742 |
+
// Try finding by data attribute
|
| 2743 |
+
if (!el) {{
|
| 2744 |
+
el = document.querySelector('[data-page="' + pageId + '"]');
|
| 2745 |
+
}}
|
| 2746 |
+
|
| 2747 |
+
// Cache if found
|
| 2748 |
+
if (el) {{
|
| 2749 |
+
window._pageElementsCache[pageId] = el;
|
| 2750 |
+
console.log('Cached page element:', pageId, '->', el.id || el.className);
|
| 2751 |
+
}}
|
| 2752 |
+
|
| 2753 |
+
return el;
|
| 2754 |
+
}}
|
| 2755 |
+
|
| 2756 |
+
window.selectPage = function(pageName) {{
|
| 2757 |
+
console.log('selectPage called:', pageName);
|
| 2758 |
+
|
| 2759 |
+
// Close mobile sidebar
|
| 2760 |
+
if (window.closeMobileSidebar) {{
|
| 2761 |
+
window.closeMobileSidebar();
|
| 2762 |
+
}}
|
| 2763 |
+
|
| 2764 |
+
// Update active nav item
|
| 2765 |
+
document.querySelectorAll('.nav-item').forEach(function(item) {{
|
| 2766 |
+
item.classList.toggle('active', item.dataset.page === pageName);
|
| 2767 |
+
}});
|
| 2768 |
+
|
| 2769 |
+
// Show/hide pages using class-based approach
|
| 2770 |
+
let foundCount = 0;
|
| 2771 |
+
window._pageIds.forEach(function(id) {{
|
| 2772 |
+
const el = findPageElement(id);
|
| 2773 |
+
if (el) {{
|
| 2774 |
+
foundCount++;
|
| 2775 |
+
if (id === pageName) {{
|
| 2776 |
+
el.classList.remove('page-hidden');
|
| 2777 |
+
el.style.display = 'flex';
|
| 2778 |
+
console.log('SHOWING page:', id);
|
| 2779 |
+
}} else {{
|
| 2780 |
+
el.classList.add('page-hidden');
|
| 2781 |
+
el.style.display = 'none';
|
| 2782 |
+
}}
|
| 2783 |
+
}}
|
| 2784 |
+
}});
|
| 2785 |
+
|
| 2786 |
+
if (foundCount === 0) {{
|
| 2787 |
+
console.error('No page elements found! Dumping DOM structure...');
|
| 2788 |
+
const mainWrapper = document.querySelector('.main-wrapper');
|
| 2789 |
+
if (mainWrapper) {{
|
| 2790 |
+
console.log('main-wrapper children:', mainWrapper.children.length);
|
| 2791 |
+
Array.from(mainWrapper.children).forEach(function(child, i) {{
|
| 2792 |
+
console.log(i + ':', child.tagName, child.id, child.className.substring(0, 50));
|
| 2793 |
+
}});
|
| 2794 |
+
}} else {{
|
| 2795 |
+
console.log('main-wrapper not found!');
|
| 2796 |
+
}}
|
| 2797 |
+
}} else {{
|
| 2798 |
+
console.log('Found', foundCount, 'page elements');
|
| 2799 |
+
}}
|
| 2800 |
+
}};
|
| 2801 |
+
|
| 2802 |
// Initialize on load
|
| 2803 |
document.addEventListener('DOMContentLoaded', function() {{
|
| 2804 |
// Handle overlay click to close sidebar
|
|
|
|
| 2806 |
if (overlay) {{
|
| 2807 |
overlay.addEventListener('click', window.closeMobileSidebar);
|
| 2808 |
}}
|
| 2809 |
+
|
| 2810 |
+
// Initial page element discovery after Gradio loads
|
| 2811 |
+
setTimeout(function() {{
|
| 2812 |
+
console.log('Running initial page discovery...');
|
| 2813 |
+
window.selectPage('setup');
|
| 2814 |
+
}}, 1000);
|
| 2815 |
}});
|
| 2816 |
</script>
|
| 2817 |
"""
|
|
|
|
| 2960 |
setup_output = gr.Markdown("*Enter your credentials and company name to begin.*")
|
| 2961 |
|
| 2962 |
# ===== DASHBOARD PAGE =====
|
| 2963 |
+
with gr.Column(visible=True, elem_id="page-dashboard", elem_classes="page-hidden") as dashboard_page:
|
| 2964 |
gr.HTML("""<div class="page-header"><div>
|
| 2965 |
<h1 class="page-title">π Dashboard</h1>
|
| 2966 |
<p class="page-subtitle">Overview of your sales pipeline</p>
|
|
|
|
| 2989 |
refresh_btn = gr.Button("π Refresh Dashboard", variant="secondary")
|
| 2990 |
|
| 2991 |
# ===== DISCOVERY PAGE =====
|
| 2992 |
+
with gr.Column(visible=True, elem_id="page-discovery", elem_classes="page-hidden") as discovery_page:
|
| 2993 |
gr.HTML("""<div class="page-header"><div>
|
| 2994 |
<h1 class="page-title">π Discovery</h1>
|
| 2995 |
<p class="page-subtitle">AI-powered prospect discovery</p>
|
|
|
|
| 3026 |
discovery_output = gr.Markdown("*Click 'Find Prospects' after completing Setup.*")
|
| 3027 |
|
| 3028 |
# ===== PROSPECTS PAGE =====
|
| 3029 |
+
with gr.Column(visible=True, elem_id="page-prospects", elem_classes="page-hidden") as prospects_page:
|
| 3030 |
gr.HTML("""<div class="page-header"><div>
|
| 3031 |
<h1 class="page-title">π― Prospects</h1>
|
| 3032 |
<p class="page-subtitle">Companies discovered by AI</p>
|
|
|
|
| 3046 |
prospects_list = gr.HTML(get_prospects_html())
|
| 3047 |
|
| 3048 |
# ===== CONTACTS PAGE =====
|
| 3049 |
+
with gr.Column(visible=True, elem_id="page-contacts", elem_classes="page-hidden") as contacts_page:
|
| 3050 |
gr.HTML("""<div class="page-header"><div>
|
| 3051 |
<h1 class="page-title">π₯ Contacts</h1>
|
| 3052 |
<p class="page-subtitle">Decision makers found by AI</p>
|
|
|
|
| 3066 |
contacts_list = gr.HTML(get_contacts_html())
|
| 3067 |
|
| 3068 |
# ===== EMAILS PAGE =====
|
| 3069 |
+
with gr.Column(visible=True, elem_id="page-emails", elem_classes="page-hidden") as emails_page:
|
| 3070 |
gr.HTML("""<div class="page-header"><div>
|
| 3071 |
<h1 class="page-title">βοΈ Emails</h1>
|
| 3072 |
<p class="page-subtitle">AI-drafted outreach emails</p>
|
|
|
|
| 3086 |
emails_list = gr.HTML(get_emails_html())
|
| 3087 |
|
| 3088 |
# ===== AI CHAT PAGE =====
|
| 3089 |
+
with gr.Column(visible=True, elem_id="page-chat", elem_classes="page-hidden") as chat_page:
|
| 3090 |
gr.HTML("""<div class="page-header"><div>
|
| 3091 |
<h1 class="page-title">π¬ AI Chat</h1>
|
| 3092 |
<p class="page-subtitle">AI-powered communication hub</p>
|
|
|
|
| 3182 |
handoff_output = gr.Markdown(visible=False, elem_classes="handoff-packet")
|
| 3183 |
|
| 3184 |
# ===== ABOUT US PAGE =====
|
| 3185 |
+
with gr.Column(visible=True, elem_id="page-about", elem_classes="page-hidden") as about_page:
|
| 3186 |
gr.HTML("""<div class="page-header"><div>
|
| 3187 |
<h1 class="page-title">βΉοΈ About Us</h1>
|
| 3188 |
<p class="page-subtitle">Learn more about CX AI Agent</p>
|
|
|
|
| 3371 |
btn_chat.click(fn=lambda: show_page("chat"), outputs=all_pages)
|
| 3372 |
btn_about.click(fn=lambda: show_page("about"), outputs=all_pages)
|
| 3373 |
|
| 3374 |
+
# Navigation JavaScript is now in head_html for earlier loading
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3375 |
|
| 3376 |
# ===== EVENT HANDLERS =====
|
| 3377 |
|