sovereign 1.0.0b126__py3-none-any.whl → 1.0.0b127.post6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of sovereign might be problematic. Click here for more details.

@@ -5,267 +5,9 @@
5
5
  <link rel="preconnect" href="https://fonts.googleapis.com">
6
6
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
7
7
  <link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet">
8
- <script>
9
- // Only store resource metadata (names/identifiers), not full content
10
- const resourceNames = [
11
- {% for resource in resources %}
12
- "{{ resource.name or resource.cluster_name or 'Unknown' }}"{% if not loop.last %},{% endif %}
13
- {% endfor %}
14
- ];
15
- const resources = resourceNames.map((name, index) => ({ name: name, index: index }));
16
- let filteredResources = [...resources];
17
-
18
- // Function to set envoy_version cookie and reload page
19
- function setEnvoyVersion(version) {
20
- document.cookie = `envoy_version=${version}; path=/ui/resources/; max-age=31536000`;
21
- window.location.reload();
22
- }
23
- </script>
24
- <style>
25
- #filterInput {
26
- font-family: monospace;
27
- }
28
- .filtered {
29
- display: none;
30
- }
31
- .tooltip {
32
- position: relative;
33
- display: inline-block;
34
- cursor: help;
35
- }
36
- .tooltip .tooltip-text {
37
- visibility: hidden;
38
- width: 220px;
39
- background-color: #363636;
40
- color: #fff;
41
- text-align: left;
42
- padding: 0.5rem;
43
- border-radius: 6px;
44
- position: absolute;
45
- z-index: 1;
46
- top: 125%;
47
- left: 50%;
48
- margin-left: -110px;
49
- opacity: 0;
50
- transition: opacity 0.3s;
51
- font-size: 0.875rem;
52
- }
53
- .tooltip:hover .tooltip-text {
54
- visibility: visible;
55
- opacity: 1;
56
- }
57
-
58
- /* Side panel styles - using Bulma-compatible approach */
59
- .side-panel {
60
- position: fixed;
61
- top: 0;
62
- right: -100%;
63
- width: 95%;
64
- max-width: 1200px;
65
- min-width: 400px;
66
- height: 100vh;
67
- z-index: 1000;
68
- transition: right 0.3s ease-in-out;
69
- overflow-y: auto;
70
- }
71
-
72
- .side-panel.is-active {
73
- right: 0;
74
- }
75
-
76
- /* Responsive side panel sizing */
77
- @media (min-width: 768px) {
78
- .side-panel { width: 75%; right: -75%; }
79
- }
80
-
81
- @media (min-width: 1024px) {
82
- .side-panel { width: 65%; right: -65%; }
83
- }
84
-
85
- @media (min-width: 1400px) {
86
- .side-panel { width: 55%; right: -55%; }
87
- }
88
-
89
- @media (min-width: 1600px) {
90
- .side-panel { width: 50%; right: -50%; }
91
- }
92
-
93
- @media (max-width: 480px) {
94
- .side-panel { width: 95%; min-width: 300px; right: -95%; }
95
- }
96
-
97
- .json-container {
98
- position: relative;
99
- }
100
-
101
- .json-header {
102
- padding: 1rem;
103
- border-bottom: 1px solid #555;
104
- background-color: #2d2d2d;
105
- display: flex;
106
- justify-content: space-between;
107
- align-items: center;
108
- }
109
-
110
-
111
- .json-content {
112
- background-color: #1e1e1e;
113
- border: none;
114
- border-radius: 0;
115
- padding: 1rem;
116
- font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Source Code Pro', 'Menlo', 'Consolas', monospace;
117
- font-size: 0.875rem;
118
- line-height: 1.5;
119
- white-space: pre-wrap;
120
- word-wrap: break-word;
121
- max-height: calc(100vh - 250px);
122
- overflow-y: auto;
123
- color: #d4d4d4;
124
- margin: 0;
125
- }
126
-
127
- /* JSON Syntax Highlighting - VS Code Dark+ theme colors */
128
- .json-key {
129
- color: #9cdcfe;
130
- font-weight: 400;
131
- }
132
-
133
- .json-string {
134
- color: #ce9178;
135
- }
136
-
137
- .json-number {
138
- color: #b5cea8;
139
- }
140
-
141
- .json-boolean {
142
- color: #569cd6;
143
- font-weight: 500;
144
- }
145
-
146
- .json-null {
147
- color: #569cd6;
148
- font-weight: 500;
149
- font-style: italic;
150
- }
151
-
152
- .json-punctuation {
153
- color: #d4d4d4;
154
- }
155
-
156
- /* Improve readability */
157
- .json-content::-webkit-scrollbar {
158
- width: 8px;
159
- }
160
-
161
- .json-content::-webkit-scrollbar-track {
162
- background: #2d2d2d;
163
- }
164
-
165
- .json-content::-webkit-scrollbar-thumb {
166
- background: #555;
167
- border-radius: 4px;
168
- }
169
-
170
- .json-content::-webkit-scrollbar-thumb:hover {
171
- background: #666;
172
- }
173
-
174
- /* Collapsible JSON */
175
- .json-toggle {
176
- cursor: pointer;
177
- user-select: none;
178
- color: #808080;
179
- margin-right: 0.25rem;
180
- font-family: monospace;
181
- font-size: 0.875rem;
182
- }
183
-
184
- .json-toggle:hover {
185
- color: #fff;
186
- }
187
-
188
- .json-collapsible {
189
- margin-left: 1rem;
190
- }
191
-
192
- .json-collapsed {
193
- display: none;
194
- }
195
-
196
- .loading-spinner {
197
- display: inline-block;
198
- width: 20px;
199
- height: 20px;
200
- border: 3px solid #f3f3f3;
201
- border-top: 3px solid #433fca;
202
- border-radius: 50%;
203
- animation: spin 1s linear infinite;
204
- }
205
-
206
- @keyframes spin {
207
- 0% { transform: rotate(0deg); }
208
- 100% { transform: rotate(360deg); }
209
- }
210
-
211
- /* Prevent body scroll when side panel is open */
212
- body.side-panel-open {
213
- overflow: hidden;
214
- }
215
-
216
- /* Backdrop overlay for side panel */
217
- .side-panel-backdrop {
218
- position: fixed;
219
- top: 0;
220
- left: 0;
221
- width: 100%;
222
- height: 100%;
223
- background-color: rgba(0, 0, 0, 0.5);
224
- z-index: 999;
225
- opacity: 0;
226
- visibility: hidden;
227
- transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
228
- }
229
-
230
- .side-panel-backdrop.is-active {
231
- opacity: 1;
232
- visibility: visible;
233
- }
234
-
235
- /* Show backdrop on smaller screens */
236
- @media (max-width: 1024px) {
237
- .side-panel-backdrop.is-active {
238
- opacity: 1;
239
- visibility: visible;
240
- }
241
- }
242
-
243
- /* Minimal custom styles - using Bulma classes for most styling */
244
- .json-chunk-controls {
245
- background-color: #2d2d2d;
246
- border-bottom: 1px solid #555;
247
- }
248
-
249
- /* Preferences details styling */
250
- details summary {
251
- list-style: none;
252
- }
253
-
254
- details summary::-webkit-details-marker {
255
- display: none;
256
- }
257
-
258
- details summary::before {
259
- content: "▶";
260
- margin-right: 0.5rem;
261
- transition: transform 0.2s;
262
- }
263
-
264
- details[open] summary::before {
265
- transform: rotate(90deg);
266
- }
267
- </style>
268
-
8
+ <link rel="stylesheet" href="/static/resources.css">
9
+ <script src="/static/resources.js"></script>
10
+ <script src="/static/panel.js"></script>
269
11
  {% endblock %}
270
12
 
271
13
 
@@ -284,7 +26,7 @@
284
26
  <div class="column is-narrow">
285
27
  <div class="dropdown is-hoverable">
286
28
  <div class="dropdown-trigger">
287
- <button class="button is-dark" aria-haspopup="true" aria-controls="dropdown-menu">
29
+ <button class="button is-primary" aria-haspopup="true" aria-controls="dropdown-menu">
288
30
  <span>Template Version</span>
289
31
  <span class="icon is-small">
290
32
  <i class="fas fa-angle-down" aria-hidden="false"></i>
@@ -309,9 +51,9 @@
309
51
  <!-- node expression box -->
310
52
  <div class="column">
311
53
  <form id="filterForm">
312
- <input id="filterInput" class="input is-dark" type="text" placeholder="Node filter expression"/>
54
+ <input id="filterInput" class="input" type="text" placeholder="Node filter expression"/>
313
55
  </form>
314
- <p id="filterMessage" class="help is-danger"></p>
56
+ <p id="filterMessage" class="help"></p>
315
57
  </div>
316
58
  <div class="column is-narrow">
317
59
  <div class="tooltip">
@@ -334,7 +76,7 @@
334
76
 
335
77
  {% set count = resources|length %}
336
78
  {% if count > 0 %}
337
- <nav class="panel is-dark" id="resources">
79
+ <nav class="panel is-primary" id="resources">
338
80
  <p class="panel-heading">
339
81
  {{ resource_type|capitalize }}
340
82
  </p>
@@ -371,14 +113,19 @@
371
113
  </p>
372
114
  </div>
373
115
  </nav>
116
+ {% if count < 10 %}
117
+ {% set hidden = "display: none;" %}
118
+ {% endif %}
119
+ <div style="{{ hidden }}">
374
120
  <nav class="pagination is-right is-small" role="navigation" aria-label="pagination">
375
121
  <a id="prev-btn" class="pagination-previous">Previous</a>
376
122
  <a id="next-btn" class="pagination-next">Next</a>
377
123
  <ul id="page-numbers" class="pagination-list"></ul>
378
124
  </nav>
125
+ </div>
379
126
 
380
127
  {% if resource_type == 'routes' %}
381
- <nav class="panel">
128
+ <nav class="panel is-primary">
382
129
  <p class="panel-heading">Virtual Hosts</p>
383
130
  <div class="panel-block">
384
131
  <p class="control has-icons-left">
@@ -403,6 +150,9 @@
403
150
  data-category="{{ resource['name'] }}"
404
151
  href="#"
405
152
  onclick="loadVirtualHostInSidePanel('{{ resource['name'] }}', '{{ virtualhost['name'] }}'); return false;">
153
+ <p class="tag is-small is-primary">
154
+ {{ resource['name'] }}
155
+ </p>
406
156
  <span class="panel-icon">
407
157
  <i class="fas fa-arrow-right" aria-hidden="true"></i>
408
158
  </span>
@@ -416,7 +166,7 @@
416
166
  <div class="notification is-danger">
417
167
  No resources found
418
168
  <script>
419
- setTimeout(() => location.reload(), 2000);
169
+ setTimeout(() => location.reload(), 6000);
420
170
  </script>
421
171
  </div>
422
172
  {% endif %}
@@ -490,576 +240,21 @@
490
240
  {% block footer %}
491
241
  <div class="content has-text-centered is-small">
492
242
  <script src="/static/node_expression.js"></script>
493
- <script src="/static/panel.js"></script>
494
243
  <script>
495
- // Side panel functionality
496
- function openSidePanel() {
497
- document.getElementById('sidePanel').classList.add('is-active');
498
- document.getElementById('sidePanelBackdrop').classList.add('is-active');
499
- document.body.classList.add('side-panel-open');
500
- }
501
-
502
- function closeSidePanel() {
503
- document.getElementById('sidePanel').classList.remove('is-active');
504
- document.getElementById('sidePanelBackdrop').classList.remove('is-active');
505
- document.body.classList.remove('side-panel-open');
506
- }
507
-
508
- function showLoading() {
509
- document.getElementById('sidePanelContent').innerHTML = `
510
- <div style="text-align: center; padding: 2rem;">
511
- <div class="loading-spinner"></div>
512
- <p style="margin-top: 1rem;">Loading resource data...</p>
513
- </div>
514
- `;
515
- }
516
-
517
- function showError(message) {
518
- document.getElementById('sidePanelContent').innerHTML = `
519
- <div class="notification is-danger">
520
- <strong>Error:</strong> ${message}
521
- </div>
522
- `;
523
- }
524
-
525
- function escapeHtml(text) {
526
- const div = document.createElement('div');
527
- div.textContent = text;
528
- return div.innerHTML;
529
- }
530
-
531
- function syntaxHighlight(json) {
532
- if (typeof json !== 'string') {
533
- json = JSON.stringify(json, null, 2);
534
- }
535
-
536
- // Escape HTML first
537
- json = escapeHtml(json);
538
-
539
- // Apply syntax highlighting
540
- json = json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) {
541
- let cls = 'json-number';
542
- if (/^"/.test(match)) {
543
- if (/:$/.test(match)) {
544
- cls = 'json-key';
545
- // Remove the colon from the match for styling, we'll add it back
546
- match = match.slice(0, -1);
547
- return '<span class="' + cls + '">' + match + '</span><span class="json-punctuation">:</span>';
548
- } else {
549
- cls = 'json-string';
550
- }
551
- } else if (/true|false/.test(match)) {
552
- cls = 'json-boolean';
553
- } else if (/null/.test(match)) {
554
- cls = 'json-null';
555
- }
556
- return '<span class="' + cls + '">' + match + '</span>';
557
- });
558
-
559
- // Highlight punctuation (brackets, braces, commas)
560
- json = json.replace(/([{}[\],])/g, '<span class="json-punctuation">$1</span>');
561
-
562
- return json;
563
- }
564
-
565
- function makeJsonCollapsible(element) {
566
- // This function would add collapsible functionality
567
- // For now, we'll keep it simple and just return the element
568
- // Future enhancement: add click handlers for { } and [ ] to collapse/expand
569
- return element;
570
- }
571
-
572
- function copyToClipboard(text) {
573
- if (navigator.clipboard && window.isSecureContext) {
574
- // Use the modern clipboard API
575
- navigator.clipboard.writeText(text).then(() => {
576
- showCopySuccess();
577
- }).catch(err => {
578
- console.error('Failed to copy: ', err);
579
- fallbackCopyTextToClipboard(text);
580
- });
581
- } else {
582
- // Fallback for older browsers
583
- fallbackCopyTextToClipboard(text);
584
- }
585
- }
586
-
587
- function fallbackCopyTextToClipboard(text) {
588
- const textArea = document.createElement("textarea");
589
- textArea.value = text;
590
- textArea.style.top = "0";
591
- textArea.style.left = "0";
592
- textArea.style.position = "fixed";
593
- document.body.appendChild(textArea);
594
- textArea.focus();
595
- textArea.select();
596
-
597
- try {
598
- const successful = document.execCommand('copy');
599
- if (successful) {
600
- showCopySuccess();
601
- }
602
- } catch (err) {
603
- console.error('Fallback: Oops, unable to copy', err);
604
- }
605
-
606
- document.body.removeChild(textArea);
607
- }
608
-
609
- function showCopySuccess() {
610
- const copyBtn = document.querySelector('.copy-button');
611
- if (copyBtn) {
612
- const originalText = copyBtn.textContent;
613
- copyBtn.textContent = 'Copied!';
614
- copyBtn.style.backgroundColor = '#48c774';
615
- setTimeout(() => {
616
- copyBtn.textContent = originalText;
617
- copyBtn.style.backgroundColor = '#433fca';
618
- }, 2000);
619
- }
620
- }
621
-
622
- // Global variables for chunked loading
623
- let currentResourceData = null;
624
- let currentChunkSize = 1000; // lines
625
- let currentChunkIndex = 0;
626
- let totalChunks = 0;
627
-
628
- // Helper function to generate preferences section HTML
629
- function getPreferencesHtml() {
630
- const currentThreshold = localStorage.getItem('jsonSizeThreshold') || 0.5;
631
- const autoChunk = localStorage.getItem('autoChunkLargeJson') === 'true';
632
-
633
- return `
634
- <details class="has-background-grey-darker">
635
- <summary class="has-background-grey-dark has-text-white-ter p-3 is-clickable" style="cursor: pointer;">
636
- <span class="is-size-7">Display Preferences</span>
637
- </summary>
638
- <div class="box has-background-grey-dark has-text-white-ter m-0" style="border-radius: 0;">
639
- <div class="content is-small">
640
- <div class="field">
641
- <label class="checkbox has-text-white-ter">
642
- <input type="checkbox" id="autoChunkPreference" ${autoChunk ? 'checked' : ''}
643
- onchange="event.stopPropagation(); updateAutoChunkPreference(this.checked)"
644
- class="mr-2">
645
- Always use chunked view for large files
646
- </label>
647
- </div>
648
- <div class="field is-grouped">
649
- <div class="control">
650
- <label class="label is-small has-text-white-ter">Size threshold:</label>
651
- </div>
652
- <div class="control">
653
- <div class="select is-dark is-small">
654
- <select id="thresholdSelector" value="${currentThreshold}"
655
- onchange="event.stopPropagation(); updateThresholdPreference(this.value)">
656
- <option value="0.25" ${currentThreshold == 0.25 ? 'selected' : ''}>250 KB</option>
657
- <option value="0.5" ${currentThreshold == 0.5 ? 'selected' : ''}>500 KB</option>
658
- <option value="1" ${currentThreshold == 1 ? 'selected' : ''}>1 MB</option>
659
- <option value="2" ${currentThreshold == 2 ? 'selected' : ''}>2 MB</option>
660
- <option value="5" ${currentThreshold == 5 ? 'selected' : ''}>5 MB</option>
661
- </select>
662
- </div>
663
- </div>
664
- </div>
665
- <div class="field is-grouped">
666
- <div class="control">
667
- <button class="button is-link is-small" onclick="event.stopPropagation(); showChunkedJson()">
668
- Switch to Chunked View
669
- </button>
670
- </div>
671
- <div class="control">
672
- <button class="button is-success is-small" onclick="event.stopPropagation(); showFullJson()">
673
- Switch to Full View
674
- </button>
675
- </div>
676
- </div>
677
- </div>
678
- </div>
679
- </details>
680
- `;
681
- }
682
-
683
- // Helper functions to update preferences
684
- function updateAutoChunkPreference(checked) {
685
- localStorage.setItem('autoChunkLargeJson', checked.toString());
686
- }
687
-
688
- function updateThresholdPreference(threshold) {
689
- localStorage.setItem('jsonSizeThreshold', threshold);
690
- }
691
-
692
- async function loadResourceInSidePanel(resourceType, resourceName) {
693
- document.getElementById('sidePanelTitle').textContent = `${resourceType}: ${resourceName}`;
694
- openSidePanel();
695
- showLoading();
696
-
697
- try {
698
- // Get current URL parameters to maintain context
699
- const urlParams = new URLSearchParams(window.location.search);
700
- const region = urlParams.get('region') || '';
701
- const apiVersion = urlParams.get('api_version') || 'v2';
702
-
703
- // Build the fetch URL with current parameters
704
- let fetchUrl = `/ui/resources/${resourceType}/${encodeURIComponent(resourceName)}`;
705
- const params = new URLSearchParams();
706
- if (region) params.append('region', region);
707
- params.append('api_version', apiVersion);
708
-
709
- if (params.toString()) {
710
- fetchUrl += '?' + params.toString();
711
- }
712
-
713
- const response = await fetch(fetchUrl, {
714
- credentials: 'same-origin' // Include cookies in the request
715
- });
716
-
717
- if (!response.ok) {
718
- throw new Error(`HTTP ${response.status}: ${response.statusText}`);
719
- }
720
-
721
- const data = await response.json();
722
- const jsonString = JSON.stringify(data, null, 2);
723
- const sizeKB = (new Blob([jsonString]).size / 1024).toFixed(1);
724
- const sizeMB = sizeKB / 1024;
725
-
726
- // Store the data globally
727
- currentResourceData = {
728
- data: data,
729
- jsonString: jsonString,
730
- sizeKB: sizeKB,
731
- sizeMB: sizeMB
732
- };
733
-
734
- // Check if the JSON is large and show warning/chunked view
735
- // Use a lower threshold (500KB) to be more conservative about browser performance
736
- const threshold = localStorage.getItem('jsonSizeThreshold') || 0.5; // MB
737
- if (sizeMB > threshold) {
738
- // Check user preference for auto-chunking
739
- const autoChunk = localStorage.getItem('autoChunkLargeJson') === 'true';
740
- if (autoChunk) {
741
- showChunkedJson();
742
- } else {
743
- showLargeJsonWarning(resourceType, resourceName);
744
- }
745
- } else {
746
- showFullJson();
747
- }
748
- } catch (error) {
749
- console.error('Error loading resource:', error);
750
- showError(error.message);
751
- }
752
- }
753
-
754
- function showLargeJsonWarning(resourceType, resourceName) {
755
- const sizeKB = currentResourceData.sizeKB;
756
- const sizeMB = currentResourceData.sizeMB;
757
-
758
- document.getElementById('sidePanelContent').innerHTML = `
759
- <div class="notification is-warning">
760
- <p>
761
- <strong>Large JSON detected (${sizeKB} KB / ${sizeMB.toFixed(1)} MB)</strong><br>
762
- Loading this much data may slow down your browser. <br>
763
- </p>
764
-
765
- Choose an option:
766
- <button class="button is-dark is-small" onclick="event.stopPropagation(); showChunkedJson()">
767
- View in Chunks
768
- </button>
769
- <button class="button is-dark is-small" onclick="event.stopPropagation(); showFullJson()">
770
- Load Full JSON
771
- </button>
772
- </div>
773
- `;
774
- }
775
-
776
- function showChunkedJson() {
777
- const lines = currentResourceData.jsonString.split('\n');
778
- totalChunks = Math.ceil(lines.length / currentChunkSize);
779
- currentChunkIndex = 0;
780
-
781
- renderChunkedJson();
782
- }
783
-
784
- function showFullJson() {
785
- // Store the JSON string globally for copying
786
- window.currentJsonData = currentResourceData.jsonString;
787
-
788
- document.getElementById('sidePanelContent').innerHTML = `
789
- <div class="json-container">
790
- <div class="json-header">
791
- <span style="color: #d4d4d4; font-size: 0.875rem;">JSON Response (${currentResourceData.sizeKB} KB) - Full View</span>
792
- <button class="button is-primary is-small" onclick="event.stopPropagation(); copyToClipboard(window.currentJsonData)">
793
- Copy JSON
794
- </button>
795
- </div>
796
- ${getPreferencesHtml()}
797
- <div class="json-content">${syntaxHighlight(currentResourceData.data)}</div>
798
- </div>
799
- `;
800
- }
801
-
802
- function renderChunkedJson() {
803
- const lines = currentResourceData.jsonString.split('\n');
804
- const startLine = currentChunkIndex * currentChunkSize;
805
- const endLine = Math.min(startLine + currentChunkSize, lines.length);
806
- const chunkLines = lines.slice(startLine, endLine);
807
- const chunkText = chunkLines.join('\n');
808
-
809
- // Store current chunk for copying
810
- window.currentJsonData = currentResourceData.jsonString; // Always allow copying full JSON
811
- window.currentChunkData = chunkText;
812
-
813
- document.getElementById('sidePanelContent').innerHTML = `
814
- <div class="json-container">
815
- <div class="json-header">
816
- <span style="color: #d4d4d4; font-size: 0.875rem;">JSON Response (${currentResourceData.sizeKB} KB) - Chunked View</span>
817
- <button class="button is-primary is-small" onclick="event.stopPropagation(); copyToClipboard(window.currentJsonData)">
818
- Copy Full JSON
819
- </button>
820
- </div>
821
- ${getPreferencesHtml()}
822
- <div class="json-chunk-controls p-4">
823
- <div class="field is-grouped is-grouped-multiline">
824
- <div class="control">
825
- <label class="label is-small has-text-white">Lines per chunk:</label>
826
- <div class="select is-dark is-small">
827
- <select onchange="event.stopPropagation(); changeChunkSize(this.value)">
828
- <option value="50" ${currentChunkSize === 50 ? 'selected' : ''}>50</option>
829
- <option value="100" ${currentChunkSize === 100 ? 'selected' : ''}>100</option>
830
- <option value="250" ${currentChunkSize === 250 ? 'selected' : ''}>250</option>
831
- <option value="500" ${currentChunkSize === 500 ? 'selected' : ''}>500</option>
832
- <option value="1000" ${currentChunkSize === 1000 ? 'selected' : ''}>1000</option>
833
- <option value="2000" ${currentChunkSize === 2000 ? 'selected' : ''}>2000</option>
834
- <option value="5000" ${currentChunkSize === 5000 ? 'selected' : ''}>5000</option>
835
- </select>
836
- </div>
837
- </div>
838
- <div class="control">
839
- <div class="buttons">
840
- <button class="button is-primary is-small" onclick="event.stopPropagation(); previousChunk()" ${currentChunkIndex === 0 ? 'disabled' : ''}>
841
- ← Previous
842
- </button>
843
- <button class="button is-primary is-small" onclick="event.stopPropagation(); nextChunk()" ${currentChunkIndex >= totalChunks - 1 ? 'disabled' : ''}>
844
- Next →
845
- </button>
846
- <button class="button is-info is-small" onclick="event.stopPropagation(); copyToClipboard(window.currentChunkData)">
847
- Copy Chunk
848
- </button>
849
- </div>
850
- </div>
851
- </div>
852
- </div>
853
- <progress class="progress is-primary is-small" value="${endLine}" max="${lines.length}">
854
- Chunk ${currentChunkIndex + 1} of ${totalChunks}
855
- </progress>
856
- <div class="json-content">${syntaxHighlight(chunkText)}</div>
857
- </div>
858
- `;
859
- }
860
-
861
- function changeChunkSize(newSize) {
862
- currentChunkSize = parseInt(newSize);
863
- const lines = currentResourceData.jsonString.split('\n');
864
- totalChunks = Math.ceil(lines.length / currentChunkSize);
865
-
866
- // Adjust current chunk index to stay roughly in the same area
867
- const currentLine = currentChunkIndex * currentChunkSize;
868
- currentChunkIndex = Math.floor(currentLine / currentChunkSize);
869
- currentChunkIndex = Math.min(currentChunkIndex, totalChunks - 1);
870
-
871
- renderChunkedJson();
872
- }
873
-
874
- function previousChunk() {
875
- if (currentChunkIndex > 0) {
876
- currentChunkIndex--;
877
- renderChunkedJson();
878
- }
879
- }
880
-
881
- function nextChunk() {
882
- if (currentChunkIndex < totalChunks - 1) {
883
- currentChunkIndex++;
884
- renderChunkedJson();
885
- }
886
- }
887
-
888
-
889
- async function loadVirtualHostInSidePanel(routeConfiguration, virtualHost) {
890
- document.getElementById('sidePanelTitle').textContent = `Virtual Host: ${virtualHost}`;
891
- openSidePanel();
892
- showLoading();
893
-
894
- try {
895
- // Get current URL parameters to maintain context
896
- const urlParams = new URLSearchParams(window.location.search);
897
- const region = urlParams.get('region') || '';
898
- const apiVersion = urlParams.get('api_version') || 'v2';
899
-
900
- // Build the fetch URL with current parameters
901
- let fetchUrl = `/ui/resources/routes/${encodeURIComponent(routeConfiguration)}/${encodeURIComponent(virtualHost)}`;
902
- const params = new URLSearchParams();
903
- if (region) params.append('region', region);
904
- params.append('api_version', apiVersion);
905
-
906
- if (params.toString()) {
907
- fetchUrl += '?' + params.toString();
908
- }
909
-
910
- const response = await fetch(fetchUrl, {
911
- credentials: 'same-origin' // Include cookies in the request
912
- });
913
-
914
- if (!response.ok) {
915
- throw new Error(`HTTP ${response.status}: ${response.statusText}`);
916
- }
917
-
918
- const data = await response.json();
919
- const jsonString = JSON.stringify(data, null, 2);
920
- const sizeKB = (new Blob([jsonString]).size / 1024).toFixed(1);
921
- const sizeMB = sizeKB / 1024;
922
-
923
- // Store the data globally
924
- currentResourceData = {
925
- data: data,
926
- jsonString: jsonString,
927
- sizeKB: sizeKB,
928
- sizeMB: sizeMB
929
- };
930
-
931
- // Check if the JSON is large and show warning/chunked view
932
- const threshold = localStorage.getItem('jsonSizeThreshold') || 0.5; // MB
933
- if (sizeMB > threshold) {
934
- // Check user preference for auto-chunking
935
- const autoChunk = localStorage.getItem('autoChunkLargeJson') === 'true';
936
- if (autoChunk) {
937
- showChunkedJson();
938
- } else {
939
- showLargeJsonWarning('Virtual Host', virtualHost);
940
- }
941
- } else {
942
- showFullJson();
943
- }
944
- } catch (error) {
945
- console.error('Error loading virtual host:', error);
946
- showError(error.message);
947
- }
948
- }
949
-
950
- // Close side panel when clicking outside of it
951
- document.addEventListener('click', function(event) {
952
- const sidePanel = document.getElementById('sidePanel');
953
- const backdrop = document.getElementById('sidePanelBackdrop');
954
- const isClickInsidePanel = sidePanel.contains(event.target);
955
- const isResourceLink = event.target.closest('.panel-block');
956
- const isBackdropClick = event.target === backdrop;
957
-
958
- if ((isBackdropClick || (!isClickInsidePanel && !isResourceLink)) && sidePanel.classList.contains('is-active')) {
959
- closeSidePanel();
960
- }
961
- });
962
-
963
- // Keyboard shortcuts
964
- document.addEventListener('keydown', function(event) {
965
- if (event.key === 'Escape') {
966
- const sidePanel = document.getElementById('sidePanel');
967
- if (sidePanel.classList.contains('is-active')) {
968
- closeSidePanel();
969
- }
970
- }
971
- });
972
-
973
- const perPage = 10;
974
- let currentPage = 1;
975
-
976
- function filter_results(id) {
977
- const input = document.getElementById(id);
978
- const filter = input.value.toLowerCase();
979
-
980
- filteredResources = resources.filter((res) => {
981
- const name = res.name || "";
982
- return name.toLowerCase().includes(filter);
983
- });
984
-
985
- currentPage = 1;
986
- renderPage(currentPage);
987
-
988
- // Update the resource count display
989
- const countElement = document.getElementById('resource-count');
990
- if (countElement) {
991
- const count = filteredResources.length;
992
- const plural = count === 1 ? 'resource' : 'resources';
993
- countElement.textContent = `${count} ${plural}`;
994
- }
995
- }
996
-
997
- function renderPage(page) {
998
- const container = document.getElementById('resource-container');
999
- container.innerHTML = '';
1000
-
1001
- const start = (page - 1) * perPage;
1002
- const end = start + perPage;
1003
- const pageItems = filteredResources.slice(start, end);
1004
-
1005
- for (const resource of pageItems) {
1006
- const name = resource.name;
1007
- const item = document.createElement('a');
1008
- item.className = 'panel-block has-text-weight-medium';
1009
- item.href = '#';
1010
- item.onclick = (e) => {
1011
- e.preventDefault();
1012
- loadResourceInSidePanel('{{ resource_type }}', name);
1013
- };
1014
- item.innerHTML = `
1015
- <span class="panel-icon">
1016
- <i class="fas fa-arrow-right" aria-hidden="true"></i>
1017
- </span>
1018
- ${name}
1019
- `;
1020
- container.appendChild(item);
1021
- }
1022
- renderPaginationControls();
1023
- }
1024
-
1025
- function renderPaginationControls() {
1026
- const totalPages = Math.ceil(filteredResources.length / perPage);
1027
- const pageList = document.getElementById('page-numbers');
1028
- pageList.innerHTML = '';
1029
-
1030
- for (let i = 1; i <= totalPages; i++) {
1031
- const li = document.createElement('li');
1032
- const a = document.createElement('a');
1033
- a.className = 'pagination-link';
1034
- if (i === currentPage) a.classList.add('is-current');
1035
- a.textContent = i;
1036
- a.addEventListener('click', () => {
1037
- currentPage = i;
1038
- renderPage(currentPage);
1039
- });
1040
- li.appendChild(a);
1041
- pageList.appendChild(li);
1042
- }
1043
-
1044
- document.getElementById('prev-btn').disabled = currentPage === 1;
1045
- document.getElementById('next-btn').disabled = currentPage === totalPages;
1046
- }
1047
-
1048
- document.getElementById('prev-btn').addEventListener('click', () => {
1049
- if (currentPage > 1) {
1050
- currentPage--;
1051
- renderPage(currentPage);
1052
- }
1053
- });
1054
-
1055
- document.getElementById('next-btn').addEventListener('click', () => {
1056
- const totalPages = Math.ceil(filteredResources.length / perPage);
1057
- if (currentPage < totalPages) {
1058
- currentPage++;
1059
- renderPage(currentPage);
1060
- }
1061
- });
1062
- renderPage(currentPage);
244
+ document.addEventListener('DOMContentLoaded', function() {
245
+ const resourceNames = [
246
+ {% for resource in resources %}
247
+ "{{ resource.name or resource.cluster_name or 'Unknown' }}"{% if not loop.last %},{% endif %}
248
+ {% endfor %}
249
+ ];
250
+ if (typeof initializeResources === 'function') {
251
+ initializeResources(resourceNames, '{{ resource_type }}');
252
+ }
253
+ });
254
+ function setEnvoyVersion(version) {
255
+ document.cookie = `envoy_version=${version}; path=/ui/resources/; max-age=31536000`;
256
+ window.location.reload();
257
+ }
1063
258
  </script>
1064
259
  </div>
1065
260
  {% endblock %}