Upload folder using huggingface_hub
Browse files- components/subscriptions.py +66 -91
components/subscriptions.py
CHANGED
|
@@ -61,7 +61,7 @@ def create_subscriptions_html(subscriptions):
|
|
| 61 |
connection_btn_html = ""
|
| 62 |
if is_active and access_token:
|
| 63 |
connection_btn_html = f'''
|
| 64 |
-
<button class="btn-connect" onclick="
|
| 65 |
Connect
|
| 66 |
</button>
|
| 67 |
'''
|
|
@@ -93,14 +93,14 @@ def create_subscriptions_html(subscriptions):
|
|
| 93 |
|
| 94 |
# Drawer HTML (slides in from right)
|
| 95 |
drawers_html += f'''
|
| 96 |
-
<div id="{drawer_id}" class="drawer-overlay" onclick="if(event.target===this)
|
| 97 |
<div class="drawer-panel">
|
| 98 |
<div class="drawer-header">
|
| 99 |
<div class="drawer-header-info">
|
| 100 |
<h3 class="drawer-title">{html.escape(dataset_id)}</h3>
|
| 101 |
<span class="drawer-status {status_class}">{status_text}</span>
|
| 102 |
</div>
|
| 103 |
-
<button class="drawer-close" onclick="
|
| 104 |
</div>
|
| 105 |
<div class="drawer-body">
|
| 106 |
<!-- MCP Config - expanded by default -->
|
|
@@ -114,7 +114,7 @@ def create_subscriptions_html(subscriptions):
|
|
| 114 |
<p class="config-desc">Add to your Claude Desktop config:</p>
|
| 115 |
<div class="code-wrapper">
|
| 116 |
<pre class="code-block">{mcp_config_escaped}</pre>
|
| 117 |
-
<button class="btn-copy" data-copy-id="{drawer_id}-mcp"
|
| 118 |
</div>
|
| 119 |
</div>
|
| 120 |
</details>
|
|
@@ -129,7 +129,7 @@ def create_subscriptions_html(subscriptions):
|
|
| 129 |
<div class="config-content">
|
| 130 |
<div class="code-wrapper">
|
| 131 |
<pre class="code-block prompt-block">{example_prompt_escaped}</pre>
|
| 132 |
-
<button class="btn-copy" data-copy-id="{drawer_id}-prompt"
|
| 133 |
</div>
|
| 134 |
</div>
|
| 135 |
</details>
|
|
@@ -144,7 +144,7 @@ def create_subscriptions_html(subscriptions):
|
|
| 144 |
<div class="config-content">
|
| 145 |
<div class="code-wrapper">
|
| 146 |
<code class="token-block">{html.escape(access_token)}</code>
|
| 147 |
-
<button class="btn-copy" data-copy-id="{drawer_id}-token"
|
| 148 |
</div>
|
| 149 |
</div>
|
| 150 |
</details>
|
|
@@ -188,98 +188,15 @@ def create_subscriptions_html(subscriptions):
|
|
| 188 |
# Convert copy_data to JSON for embedding in script
|
| 189 |
copy_data_json = json.dumps(copy_data)
|
| 190 |
|
|
|
|
| 191 |
result_html = f"""
|
| 192 |
-
<div class="subscriptions-container">
|
| 193 |
<div class="subscriptions-list">
|
| 194 |
{cards_html}
|
| 195 |
</div>
|
| 196 |
{drawers_html}
|
| 197 |
</div>
|
| 198 |
|
| 199 |
-
<script>
|
| 200 |
-
(function() {{
|
| 201 |
-
// Store copy data globally on window
|
| 202 |
-
window.datapassCopyData = window.datapassCopyData || {{}};
|
| 203 |
-
Object.assign(window.datapassCopyData, {copy_data_json});
|
| 204 |
-
|
| 205 |
-
// Define functions on window for global access
|
| 206 |
-
window.openDrawer = function(id) {{
|
| 207 |
-
var drawer = document.getElementById(id);
|
| 208 |
-
if (drawer) {{
|
| 209 |
-
drawer.classList.add('show');
|
| 210 |
-
document.body.style.overflow = 'hidden';
|
| 211 |
-
}}
|
| 212 |
-
}};
|
| 213 |
-
|
| 214 |
-
window.closeDrawer = function(id) {{
|
| 215 |
-
var drawer = document.getElementById(id);
|
| 216 |
-
if (drawer) {{
|
| 217 |
-
drawer.classList.remove('show');
|
| 218 |
-
document.body.style.overflow = '';
|
| 219 |
-
}}
|
| 220 |
-
}};
|
| 221 |
-
|
| 222 |
-
window.copyDatapassField = function(copyId) {{
|
| 223 |
-
if (!copyId || !window.datapassCopyData[copyId]) {{
|
| 224 |
-
console.error('Copy data not found for:', copyId);
|
| 225 |
-
return;
|
| 226 |
-
}}
|
| 227 |
-
// Decode base64
|
| 228 |
-
var text = atob(window.datapassCopyData[copyId]);
|
| 229 |
-
var btn = document.querySelector('[data-copy-id="' + copyId + '"]');
|
| 230 |
-
|
| 231 |
-
navigator.clipboard.writeText(text).then(function() {{
|
| 232 |
-
if (btn) {{
|
| 233 |
-
var originalText = btn.textContent;
|
| 234 |
-
btn.textContent = 'Copied!';
|
| 235 |
-
btn.classList.add('copied');
|
| 236 |
-
setTimeout(function() {{
|
| 237 |
-
btn.textContent = originalText;
|
| 238 |
-
btn.classList.remove('copied');
|
| 239 |
-
}}, 2000);
|
| 240 |
-
}}
|
| 241 |
-
}}).catch(function(err) {{
|
| 242 |
-
console.error('Failed to copy:', err);
|
| 243 |
-
// Fallback for older browsers or non-HTTPS
|
| 244 |
-
var textarea = document.createElement('textarea');
|
| 245 |
-
textarea.value = text;
|
| 246 |
-
textarea.style.position = 'fixed';
|
| 247 |
-
textarea.style.opacity = '0';
|
| 248 |
-
document.body.appendChild(textarea);
|
| 249 |
-
textarea.select();
|
| 250 |
-
try {{
|
| 251 |
-
document.execCommand('copy');
|
| 252 |
-
if (btn) {{
|
| 253 |
-
var originalText = btn.textContent;
|
| 254 |
-
btn.textContent = 'Copied!';
|
| 255 |
-
btn.classList.add('copied');
|
| 256 |
-
setTimeout(function() {{
|
| 257 |
-
btn.textContent = originalText;
|
| 258 |
-
btn.classList.remove('copied');
|
| 259 |
-
}}, 2000);
|
| 260 |
-
}}
|
| 261 |
-
}} catch (e) {{
|
| 262 |
-
console.error('Fallback copy failed:', e);
|
| 263 |
-
}}
|
| 264 |
-
document.body.removeChild(textarea);
|
| 265 |
-
}});
|
| 266 |
-
}};
|
| 267 |
-
|
| 268 |
-
// Listen for Escape key to close drawers
|
| 269 |
-
if (!window.datapassEscapeListenerAdded) {{
|
| 270 |
-
window.datapassEscapeListenerAdded = true;
|
| 271 |
-
document.addEventListener('keydown', function(e) {{
|
| 272 |
-
if (e.key === 'Escape') {{
|
| 273 |
-
document.querySelectorAll('.drawer-overlay.show').forEach(function(drawer) {{
|
| 274 |
-
drawer.classList.remove('show');
|
| 275 |
-
}});
|
| 276 |
-
document.body.style.overflow = '';
|
| 277 |
-
}}
|
| 278 |
-
}});
|
| 279 |
-
}}
|
| 280 |
-
}})();
|
| 281 |
-
</script>
|
| 282 |
-
|
| 283 |
<style>
|
| 284 |
.subscriptions-container {{
|
| 285 |
position: relative;
|
|
@@ -618,6 +535,64 @@ def create_subscriptions_html(subscriptions):
|
|
| 618 |
}}
|
| 619 |
}}
|
| 620 |
</style>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 621 |
"""
|
| 622 |
|
| 623 |
return result_html
|
|
|
|
| 61 |
connection_btn_html = ""
|
| 62 |
if is_active and access_token:
|
| 63 |
connection_btn_html = f'''
|
| 64 |
+
<button class="btn-connect" onclick="document.getElementById('{drawer_id}').classList.add('show'); document.body.style.overflow='hidden';">
|
| 65 |
Connect
|
| 66 |
</button>
|
| 67 |
'''
|
|
|
|
| 93 |
|
| 94 |
# Drawer HTML (slides in from right)
|
| 95 |
drawers_html += f'''
|
| 96 |
+
<div id="{drawer_id}" class="drawer-overlay" onclick="if(event.target===this){{this.classList.remove('show'); document.body.style.overflow='';}}">
|
| 97 |
<div class="drawer-panel">
|
| 98 |
<div class="drawer-header">
|
| 99 |
<div class="drawer-header-info">
|
| 100 |
<h3 class="drawer-title">{html.escape(dataset_id)}</h3>
|
| 101 |
<span class="drawer-status {status_class}">{status_text}</span>
|
| 102 |
</div>
|
| 103 |
+
<button class="drawer-close" onclick="document.getElementById('{drawer_id}').classList.remove('show'); document.body.style.overflow='';">×</button>
|
| 104 |
</div>
|
| 105 |
<div class="drawer-body">
|
| 106 |
<!-- MCP Config - expanded by default -->
|
|
|
|
| 114 |
<p class="config-desc">Add to your Claude Desktop config:</p>
|
| 115 |
<div class="code-wrapper">
|
| 116 |
<pre class="code-block">{mcp_config_escaped}</pre>
|
| 117 |
+
<button class="btn-copy" data-copy-id="{drawer_id}-mcp" data-copy-value="{copy_data[f"{drawer_id}-mcp"]}">Copy</button>
|
| 118 |
</div>
|
| 119 |
</div>
|
| 120 |
</details>
|
|
|
|
| 129 |
<div class="config-content">
|
| 130 |
<div class="code-wrapper">
|
| 131 |
<pre class="code-block prompt-block">{example_prompt_escaped}</pre>
|
| 132 |
+
<button class="btn-copy" data-copy-id="{drawer_id}-prompt" data-copy-value="{copy_data[f"{drawer_id}-prompt"]}">Copy</button>
|
| 133 |
</div>
|
| 134 |
</div>
|
| 135 |
</details>
|
|
|
|
| 144 |
<div class="config-content">
|
| 145 |
<div class="code-wrapper">
|
| 146 |
<code class="token-block">{html.escape(access_token)}</code>
|
| 147 |
+
<button class="btn-copy" data-copy-id="{drawer_id}-token" data-copy-value="{copy_data[f"{drawer_id}-token"]}">Copy</button>
|
| 148 |
</div>
|
| 149 |
</div>
|
| 150 |
</details>
|
|
|
|
| 188 |
# Convert copy_data to JSON for embedding in script
|
| 189 |
copy_data_json = json.dumps(copy_data)
|
| 190 |
|
| 191 |
+
# Build inline handlers that don't rely on global functions
|
| 192 |
result_html = f"""
|
| 193 |
+
<div class="subscriptions-container" id="datapass-subs-container" data-copy='{copy_data_json}'>
|
| 194 |
<div class="subscriptions-list">
|
| 195 |
{cards_html}
|
| 196 |
</div>
|
| 197 |
{drawers_html}
|
| 198 |
</div>
|
| 199 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 200 |
<style>
|
| 201 |
.subscriptions-container {{
|
| 202 |
position: relative;
|
|
|
|
| 535 |
}}
|
| 536 |
}}
|
| 537 |
</style>
|
| 538 |
+
|
| 539 |
+
<script>
|
| 540 |
+
// Use MutationObserver to attach handlers when elements are added
|
| 541 |
+
(function() {{
|
| 542 |
+
// Handle copy button clicks via event delegation on document
|
| 543 |
+
document.addEventListener('click', function(e) {{
|
| 544 |
+
var btn = e.target.closest('.btn-copy');
|
| 545 |
+
if (btn && btn.hasAttribute('data-copy-value')) {{
|
| 546 |
+
e.preventDefault();
|
| 547 |
+
e.stopPropagation();
|
| 548 |
+
var b64Value = btn.getAttribute('data-copy-value');
|
| 549 |
+
if (b64Value) {{
|
| 550 |
+
try {{
|
| 551 |
+
var text = atob(b64Value);
|
| 552 |
+
navigator.clipboard.writeText(text).then(function() {{
|
| 553 |
+
var originalText = btn.textContent;
|
| 554 |
+
btn.textContent = 'Copied!';
|
| 555 |
+
btn.classList.add('copied');
|
| 556 |
+
setTimeout(function() {{
|
| 557 |
+
btn.textContent = originalText;
|
| 558 |
+
btn.classList.remove('copied');
|
| 559 |
+
}}, 2000);
|
| 560 |
+
}}).catch(function() {{
|
| 561 |
+
// Fallback
|
| 562 |
+
var ta = document.createElement('textarea');
|
| 563 |
+
ta.value = text;
|
| 564 |
+
ta.style.cssText = 'position:fixed;opacity:0';
|
| 565 |
+
document.body.appendChild(ta);
|
| 566 |
+
ta.select();
|
| 567 |
+
document.execCommand('copy');
|
| 568 |
+
document.body.removeChild(ta);
|
| 569 |
+
var originalText = btn.textContent;
|
| 570 |
+
btn.textContent = 'Copied!';
|
| 571 |
+
btn.classList.add('copied');
|
| 572 |
+
setTimeout(function() {{
|
| 573 |
+
btn.textContent = originalText;
|
| 574 |
+
btn.classList.remove('copied');
|
| 575 |
+
}}, 2000);
|
| 576 |
+
}});
|
| 577 |
+
}} catch(err) {{
|
| 578 |
+
console.error('Copy failed:', err);
|
| 579 |
+
}}
|
| 580 |
+
}}
|
| 581 |
+
}}
|
| 582 |
+
}}, true);
|
| 583 |
+
|
| 584 |
+
// Handle Escape key to close drawers
|
| 585 |
+
document.addEventListener('keydown', function(e) {{
|
| 586 |
+
if (e.key === 'Escape') {{
|
| 587 |
+
var drawers = document.querySelectorAll('.drawer-overlay.show');
|
| 588 |
+
drawers.forEach(function(d) {{
|
| 589 |
+
d.classList.remove('show');
|
| 590 |
+
}});
|
| 591 |
+
document.body.style.overflow = '';
|
| 592 |
+
}}
|
| 593 |
+
}});
|
| 594 |
+
}})();
|
| 595 |
+
</script>
|
| 596 |
"""
|
| 597 |
|
| 598 |
return result_html
|