Newer
Older
EnvoyControlPlane / static / js / store / configStore.js
// static/js/store/configStore.js

export let API_BASE_URL = window.location.href;
API_BASE_URL = API_BASE_URL.replace(/\/$/, "");

/**
 * Global In-Memory Store
 */
export const configStore = {
    clusters: {},
    listeners: {},
    secrets: {},
    extension_configs: {}
};

/**
 * Cleans up the cached YAML data in configStore for all resources.
 */
export function cleanupConfigStore() {
    for (const name in configStore.clusters) {
        if (configStore.clusters.hasOwnProperty(name)) {
            configStore.clusters[name].yaml = 'Loading YAML...';
        }
    }

    for (const name in configStore.listeners) {
        if (configStore.listeners.hasOwnProperty(name)) {
            configStore.listeners[name].yaml = 'Loading YAML...';
        }
    }
    for (const name in configStore.secrets) {
        if (configStore.secrets.hasOwnProperty(name)) {
            configStore.secrets[name].yaml = 'Loading YAML...';
        }
    }
    for (const name in configStore.extension_configs) {
        if (configStore.extension_configs.hasOwnProperty(name)) {
            configStore.extension_configs[name].yaml = 'Loading YAML...';
        }
    }
}

export const CONSISTENCY_POLL_INTERVAL = 5000;
export let inconsistencyData = null;

export function setInconsistencyData(data) {
    inconsistencyData = data;
}

export function getInconsistencyData() {
    return inconsistencyData;
}