mirror of https://github.com/status-im/consul.git
ui: Tweak some code related meta information (#12117)
* ui: Correct some meta info * Encoder doesn't take an argument whereas decoder does * Math.trunc looks like the closest to parseInt but using the correct type * use a dynamic string when setting things on window
This commit is contained in:
parent
89ed18dc42
commit
61d7acd51f
|
@ -1,6 +1,6 @@
|
|||
import base64js from 'base64-js';
|
||||
export default function(str, encoding = 'utf-8') {
|
||||
export default function(str) {
|
||||
// encode
|
||||
const bytes = new TextEncoder(encoding).encode(str);
|
||||
const bytes = new TextEncoder().encode(str);
|
||||
return base64js.fromByteArray(bytes);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ export default function(config = {}, win = window, doc = document) {
|
|||
.startsWith('CONSUL_')
|
||||
);
|
||||
};
|
||||
win.Scenario = function(str = '') {
|
||||
win['Scenario'] = function(str = '') {
|
||||
if (str.length > 0) {
|
||||
cookies(str).forEach(item => (doc.cookie = `${item};Path=/`));
|
||||
win.location.hash = '';
|
||||
|
@ -41,7 +41,7 @@ export default function(config = {}, win = window, doc = document) {
|
|||
typeof win.location.hash === 'string' &&
|
||||
win.location.hash.length > 0
|
||||
) {
|
||||
win.Scenario(win.location.hash.substr(1));
|
||||
win['Scenario'](win.location.hash.substr(1));
|
||||
}
|
||||
});
|
||||
const dev = function(str = doc.cookie) {
|
||||
|
@ -107,7 +107,9 @@ export default function(config = {}, win = window, doc = document) {
|
|||
case 'CONSUL_DATACENTER_PRIMARY':
|
||||
return operatorConfig.PrimaryDatacenter;
|
||||
case 'CONSUL_UI_CONFIG':
|
||||
dashboards = {};
|
||||
dashboards = {
|
||||
service: undefined
|
||||
};
|
||||
provider = env('CONSUL_METRICS_PROVIDER');
|
||||
proxy = env('CONSUL_METRICS_PROXY_ENABLED');
|
||||
dashboards.service = env('CONSUL_SERVICE_DASHBOARD_URL');
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
* an array. If the key name is simply the separator (for example '/')
|
||||
* then the array should contain a single empty string value
|
||||
*
|
||||
* @param {string} key - The separated path/key
|
||||
* @param {string} [separator=/] - The separator
|
||||
* @returns {string[]}
|
||||
* @param {String} key - The separated path/key
|
||||
* @param {String} separator - The separator
|
||||
* @returns {String[]}
|
||||
*/
|
||||
export default function(key, separator = '/') {
|
||||
return (key === separator ? '' : key).split(separator);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Promise aware conditional function call
|
||||
*
|
||||
* @param {function} cb - The function to possibily call
|
||||
* @param {function} [what] - A function returning a boolean resolving promise
|
||||
* @param {Promise} [what] - A boolean resolving promise
|
||||
* @returns {function} - function when called returns a Promise that resolves the argument it is called with
|
||||
*/
|
||||
export default function(cb, what) {
|
||||
|
|
|
@ -8,10 +8,10 @@ import MultiMap from 'mnemonist/multi-map';
|
|||
* proxy is likely to be on the same node, without adding something extra here
|
||||
* the node check will likely end up in the list twice.
|
||||
*
|
||||
* @param {array} checks - Multiple lists of healthchecks to merge each one of the items in this array should be a further array of healthchecks
|
||||
* @param {boolean} exposed - Whether the checks should be marked as exposed via the proxy or not
|
||||
* @param {class} MMap - A MultiMap class. This is only exposed to allow for an easier interface but still allow an innjectable MultiMap if we choose to do that during testing
|
||||
* @returns {array} - The final array of all of the healthchecks with any duplicate node checks removed, and also marked as exposed if required
|
||||
* @param {Array} checks - Multiple lists of healthchecks to merge each one of the items in this array should be a further array of healthchecks
|
||||
* @param {Boolean} exposed - Whether the checks should be marked as exposed via the proxy or not
|
||||
* @param {Object} MMap - A MultiMap class. This is only exposed to allow for an easier interface but still allow an injectable MultiMap if we choose to do that during testing
|
||||
* @returns {Array} - The final array of all of the healthchecks with any duplicate node checks removed, and also marked as exposed if required
|
||||
*/
|
||||
export default (checks = [], exposed = false, MMap = MultiMap) => {
|
||||
const ids = new MMap();
|
||||
|
|
|
@ -37,7 +37,7 @@ export default function(routes) {
|
|||
};
|
||||
}
|
||||
|
||||
export let dump = () => {};
|
||||
export let dump = (routes) => {};
|
||||
|
||||
runInDebug(() => {
|
||||
const indent = function(num) {
|
||||
|
|
|
@ -44,9 +44,9 @@ export default function(distance) {
|
|||
}
|
||||
return {
|
||||
distances: distances,
|
||||
min: parseInt(min * 100) / 100,
|
||||
median: parseInt(median * 100) / 100,
|
||||
max: parseInt(max * 100) / 100,
|
||||
min: Math.trunc(min * 100) / 100,
|
||||
median: Math.trunc(median * 100) / 100,
|
||||
max: Math.trunc(max * 100) / 100,
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue