// Define the RequestsConfig object with the plugin's unique ID const RequestsConfig = { pluginUniqueId: '35562a17-cce6-4d0d-9b8e-0b4c69d1fb9c' // This should match the Guid in your Plugin.cs }; export default class RequestsController { constructor(element, params) { this.element = element; this.params = params; this.initIframe(); window.addEventListener('resize', () => this.adjustIframeSize()); } initIframe() { // Use the new public endpoint to get the Requests URL fetch('/Requests/PublicGetRequestsUrl') .then(response => { if (!response.ok) throw new Error('Failed to load the Requests URL'); return response.text(); }) .then(url => { const iframe = document.createElement('iframe'); iframe.src = url || "https://example.com"; // Use the URL from the response or fallback to default iframe.style.width = "100%"; iframe.style.height = "100%"; iframe.frameBorder = "0"; iframe.allow = "fullscreen"; iframe.allowFullscreen = true; this.element.appendChild(iframe); this.adjustIframeSize(); }) .catch(error => { console.error('There was a problem with the fetch operation:', error); }); } adjustIframeSize() { const iframe = this.element.querySelector('iframe'); if (iframe) { iframe.style.height = `${window.innerHeight}px`; iframe.style.width = `${window.innerWidth}px`; } } refreshIframeSrc() { fetch('/Requests/PublicGetRequestsUrl') .then(response => { if (!response.ok) throw new Error('Failed to load the Requests URL'); return response.text(); }) .then(url => { const iframe = this.element.querySelector('iframe'); iframe.src = url; }) .catch(error => { console.error('Failed to refresh the iframe URL:', error); }); } onResume(options) { console.log('Requests tab resumed with options:', options); this.refreshIframeSrc(); } onPause() { console.log('Requests tab paused'); } } document.addEventListener('DOMContentLoaded', () => { const element = document.querySelector('#requestsTab'); const params = {}; new RequestsController(element, params); });