UNPKG

glass-app-manager

Version:

Informatica's Glass Framework CLI for bootstrapping

48 lines (43 loc) 2.32 kB
/** * This file gets called after Glass_Config has been loaded. This will read the configuration from Glass_Config for all the Products. * It will create & inject <script /> and <link> tags in index.html for each products. * If location of the bundle files is changed, update the path for same in this file. * Current location of bundles is: /public/[product] */ (() => { ////** remove this code if updated in service */ const updateGlassConfig = () => { const GLASS_UI = window.GLASS_UI_CONFIG ? window.GLASS_UI_CONFIG : {}; const SUPPORTED_PRODUCTS = GLASS_UI.plugins ? GLASS_UI.plugins.slice() : []; if (SUPPORTED_PRODUCTS && SUPPORTED_PRODUCTS.length > 0) { const TEMP_PLUGINS_LIST = ['home']; if (SUPPORTED_PRODUCTS.indexOf('infrastructure') !== -1) { TEMP_PLUGINS_LIST.push('infrastructure'); } if (SUPPORTED_PRODUCTS.indexOf('cdi') !== -1) { TEMP_PLUGINS_LIST.push('cdi'); } if (SUPPORTED_PRODUCTS.indexOf('cai') !== -1) { TEMP_PLUGINS_LIST.push('cai'); } window.GLASS_UI_CONFIG.plugins = TEMP_PLUGINS_LIST.slice(); } } ////** remove this code if updated in service */ updateGlassConfig(); const GLASS_UI = window.GLASS_UI_CONFIG ? window.GLASS_UI_CONFIG : {}; const SUPPORTED_PRODUCTS = GLASS_UI.plugins ? GLASS_UI.plugins.slice() : []; if(SUPPORTED_PRODUCTS && SUPPORTED_PRODUCTS.length > 0) { SUPPORTED_PRODUCTS.forEach(product => { const PRODUCT_KEY = product; // const CURRENT_PRODUCT = GLASS_UI[PRODUCT_KEY]; // // check if product is enabled // if(CURRENT_PRODUCT && CURRENT_PRODUCT.enabled) { // Inject <script /> & <link> tags for bundle.[product].js & [product].css in index.html // need to use document.write to load the script synchronously document.write(`<script type="text/javascript" src="plugins/${PRODUCT_KEY}/bundle.${PRODUCT_KEY}.js"></script>`); document.write(`<link rel="stylesheet" href="plugins/${PRODUCT_KEY}/static/css/${PRODUCT_KEY}.css"></script>`); // } }); } })();