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';
|
import base64js from 'base64-js';
|
||||||
export default function(str, encoding = 'utf-8') {
|
export default function(str) {
|
||||||
// encode
|
// encode
|
||||||
const bytes = new TextEncoder(encoding).encode(str);
|
const bytes = new TextEncoder().encode(str);
|
||||||
return base64js.fromByteArray(bytes);
|
return base64js.fromByteArray(bytes);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ export default function(config = {}, win = window, doc = document) {
|
||||||
.startsWith('CONSUL_')
|
.startsWith('CONSUL_')
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
win.Scenario = function(str = '') {
|
win['Scenario'] = function(str = '') {
|
||||||
if (str.length > 0) {
|
if (str.length > 0) {
|
||||||
cookies(str).forEach(item => (doc.cookie = `${item};Path=/`));
|
cookies(str).forEach(item => (doc.cookie = `${item};Path=/`));
|
||||||
win.location.hash = '';
|
win.location.hash = '';
|
||||||
|
@ -41,7 +41,7 @@ export default function(config = {}, win = window, doc = document) {
|
||||||
typeof win.location.hash === 'string' &&
|
typeof win.location.hash === 'string' &&
|
||||||
win.location.hash.length > 0
|
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) {
|
const dev = function(str = doc.cookie) {
|
||||||
|
@ -107,7 +107,9 @@ export default function(config = {}, win = window, doc = document) {
|
||||||
case 'CONSUL_DATACENTER_PRIMARY':
|
case 'CONSUL_DATACENTER_PRIMARY':
|
||||||
return operatorConfig.PrimaryDatacenter;
|
return operatorConfig.PrimaryDatacenter;
|
||||||
case 'CONSUL_UI_CONFIG':
|
case 'CONSUL_UI_CONFIG':
|
||||||
dashboards = {};
|
dashboards = {
|
||||||
|
service: undefined
|
||||||
|
};
|
||||||
provider = env('CONSUL_METRICS_PROVIDER');
|
provider = env('CONSUL_METRICS_PROVIDER');
|
||||||
proxy = env('CONSUL_METRICS_PROXY_ENABLED');
|
proxy = env('CONSUL_METRICS_PROXY_ENABLED');
|
||||||
dashboards.service = env('CONSUL_SERVICE_DASHBOARD_URL');
|
dashboards.service = env('CONSUL_SERVICE_DASHBOARD_URL');
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
* an array. If the key name is simply the separator (for example '/')
|
* an array. If the key name is simply the separator (for example '/')
|
||||||
* then the array should contain a single empty string value
|
* then the array should contain a single empty string value
|
||||||
*
|
*
|
||||||
* @param {string} key - The separated path/key
|
* @param {String} key - The separated path/key
|
||||||
* @param {string} [separator=/] - The separator
|
* @param {String} separator - The separator
|
||||||
* @returns {string[]}
|
* @returns {String[]}
|
||||||
*/
|
*/
|
||||||
export default function(key, separator = '/') {
|
export default function(key, separator = '/') {
|
||||||
return (key === separator ? '' : key).split(separator);
|
return (key === separator ? '' : key).split(separator);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* Promise aware conditional function call
|
* Promise aware conditional function call
|
||||||
*
|
*
|
||||||
* @param {function} cb - The function to possibily 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
|
* @returns {function} - function when called returns a Promise that resolves the argument it is called with
|
||||||
*/
|
*/
|
||||||
export default function(cb, what) {
|
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
|
* 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.
|
* 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 {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 {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
|
* @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
|
* @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) => {
|
export default (checks = [], exposed = false, MMap = MultiMap) => {
|
||||||
const ids = new MMap();
|
const ids = new MMap();
|
||||||
|
|
|
@ -37,7 +37,7 @@ export default function(routes) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export let dump = () => {};
|
export let dump = (routes) => {};
|
||||||
|
|
||||||
runInDebug(() => {
|
runInDebug(() => {
|
||||||
const indent = function(num) {
|
const indent = function(num) {
|
||||||
|
|
|
@ -44,9 +44,9 @@ export default function(distance) {
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
distances: distances,
|
distances: distances,
|
||||||
min: parseInt(min * 100) / 100,
|
min: Math.trunc(min * 100) / 100,
|
||||||
median: parseInt(median * 100) / 100,
|
median: Math.trunc(median * 100) / 100,
|
||||||
max: parseInt(max * 100) / 100,
|
max: Math.trunc(max * 100) / 100,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue