mirror of
https://github.com/status-im/consul.git
synced 2025-01-09 13:26:07 +00:00
5fb9df1640
* Adding explicit MPL license for sub-package This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Adding explicit MPL license for sub-package This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Updating the license from MPL to Business Source License Going forward, this project will be licensed under the Business Source License v1.1. Please see our blog post for more details at <Blog URL>, FAQ at www.hashicorp.com/licensing-faq, and details of the license at www.hashicorp.com/bsl. * add missing license headers * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 --------- Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
48 lines
1.9 KiB
JavaScript
48 lines
1.9 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
(function(doc, appName) {
|
|
const fs = new Map(
|
|
Object.entries(JSON.parse(doc.querySelector(`[data-${appName}-fs]`).textContent))
|
|
);
|
|
const appendScript = function(src) {
|
|
var $script = doc.createElement('script');
|
|
$script.src = src;
|
|
doc.body.appendChild($script);
|
|
};
|
|
|
|
// polyfills
|
|
if (!('TextDecoder' in window)) {
|
|
appendScript(fs.get(`${['text-encoding', 'encoding-indexes'].join('/')}.js`));
|
|
appendScript(fs.get(`${['text-encoding', 'encoding'].join('/')}.js`));
|
|
}
|
|
if (!(window.CSS && window.CSS.escape)) {
|
|
appendScript(fs.get(`${['css.escape', 'css.escape'].join('/')}.js`));
|
|
}
|
|
|
|
try {
|
|
const $appMeta = doc.querySelector(`[name="${appName}/config/environment"]`);
|
|
// pick out the operatorConfig from our application/json script tag
|
|
const operatorConfig = JSON.parse(doc.querySelector(`[data-${appName}-config]`).textContent);
|
|
// pick out the ember config from its meta tag
|
|
const emberConfig = JSON.parse(decodeURIComponent($appMeta.getAttribute('content')));
|
|
|
|
// rootURL is a special variable that requires settings before ember
|
|
// boots via ember's HTML metadata tag, the variable is equivalent to
|
|
// the -ui-content-path Consul flag (or `ui_config { content_path = ""}`)
|
|
// There will potentially be one or two more 'pre-init' variables that we need.
|
|
// Anything not 'pre-init' should use ui_config.
|
|
// Check the value to make sure its there and a string
|
|
const rootURL =
|
|
typeof operatorConfig.ContentPath !== 'string' ? '' : operatorConfig.ContentPath;
|
|
if (rootURL.length > 0) {
|
|
emberConfig.rootURL = rootURL;
|
|
}
|
|
$appMeta.setAttribute('content', encodeURIComponent(JSON.stringify(emberConfig)));
|
|
} catch (e) {
|
|
throw new Error(`Unable to parse ${appName} settings: ${e.message}`);
|
|
}
|
|
})(document, 'consul-ui');
|