Newer
Older
EnvoyControlPlane / static / data_loader.js
// data_loader.js
import { listClusters } from './clusters.js';
import { listListeners } from './listeners.js';
import { listSecrets } from './secrets.js';
import { setupModalTabs } from './modals.js';
import {CONSISTENCY_POLL_INTERVAL, checkConsistency} from './global.js';


// =========================================================================
// COMBINED LOADER & POLLING
// =========================================================================

/**
 * Loads all primary data (Clusters and Listeners) from the API.
 */
export function loadAllData() {
    listClusters();
    listListeners();
    listSecrets();
}


// =========================================================================
// INITIALIZATION
// =========================================================================

window.onload = () => {
    loadAllData();
    setupModalTabs(); // Setup tab logic on load
    checkConsistency(); // Initial check
    setInterval(checkConsistency, CONSISTENCY_POLL_INTERVAL); // Start polling
};


// =========================================================================
// EXPOSE GLOBAL FUNCTIONS (Required for inline HTML handlers)
// =========================================================================

// This section is necessary if your HTML uses inline onclick attributes, 
// as is common in older or simpler JS projects.
import * as Modals from './modals.js';
import * as Fetchers from './data_fetchers.js';
import * as Clusters from './clusters.js';
import * as Listeners from './listeners.js';
import * as Consistency from './consistency.js';

// Attach all necessary functions to the global window object
Object.assign(window, Modals, Fetchers, Clusters, Listeners, Consistency);