mirror of
https://github.com/yldio/copilot.git
synced 2024-11-28 14:10:04 +02:00
Add metrics copy and ui data and flatten intl messages
This commit is contained in:
parent
5c52332f67
commit
f802177f60
@ -18,5 +18,24 @@
|
||||
"mem-res-set-size": "Memory resident set size",
|
||||
"mem-res-set-size-sm": "Process memory that is actually stored in the RAM",
|
||||
"apache-http-reqs": "Apache HTTP requests",
|
||||
"apache-http-reqs-sm": "Number of website requests to apache if it is used"
|
||||
}
|
||||
"apache-http-reqs-sm": "Number of website requests to apache if it is used",
|
||||
"metrics": {
|
||||
"add": {
|
||||
"add-label": "Add",
|
||||
"added-label": "Added",
|
||||
"link-label": "Learn more"
|
||||
},
|
||||
"cpu_agg_usage": {
|
||||
"title": "Aggregated CPU usage",
|
||||
"description": "CPU usages accross all of the CPU cores."
|
||||
},
|
||||
"cpu_wait_time": {
|
||||
"title": "Memory resident set size (tmp)",
|
||||
"description": "Process memory that is actually stored in the RAM. (tmp)"
|
||||
},
|
||||
"zfs_used": {
|
||||
"title": "Apache HTTP requests (tmp)",
|
||||
"description": "Number of website requests to apache if it is used. (tmp)"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,13 +22,32 @@ const source = ({
|
||||
})();
|
||||
`;
|
||||
|
||||
const flattenMessages = (nestedMessages, prefix='') => {
|
||||
return Object.keys(nestedMessages).reduce((messages, key) => {
|
||||
const value = nestedMessages[key];
|
||||
const prefixedKey = prefix ? `${prefix}.${key}` : key;
|
||||
|
||||
if(typeof value === 'string') {
|
||||
messages[prefixedKey] = value;
|
||||
}
|
||||
else {
|
||||
Object.assign(messages, flattenMessages(value, prefixedKey));
|
||||
}
|
||||
|
||||
return messages;
|
||||
}, {});
|
||||
};
|
||||
|
||||
const compile = async () => {
|
||||
const files = await readdir(root);
|
||||
const jsons = files.filter(filename => path.extname(filename) === '.json');
|
||||
|
||||
const locales = jsons.reduce((res, filename) => {
|
||||
const name = path.parse(filename).name;
|
||||
const json = JSON.stringify(require(path.join(root, filename)));
|
||||
const messages = require(path.join(root, filename));
|
||||
const flattenedMessages = flattenMessages(messages);
|
||||
console.log('flattenedMessages = ', flattenedMessages);
|
||||
const json = JSON.stringify(flattenedMessages);
|
||||
const lang = name.split(/\-/)[0];
|
||||
|
||||
return {
|
||||
|
@ -47,6 +47,24 @@
|
||||
}]
|
||||
},
|
||||
"metrics": {
|
||||
"ui": {
|
||||
"types": [
|
||||
"cpu_agg_usage",
|
||||
"cpu_wait_time",
|
||||
"zfs_used",
|
||||
"zfs_available",
|
||||
"load_average",
|
||||
"mem_agg_usage",
|
||||
"mem_limit",
|
||||
"mem_swap",
|
||||
"mem_swap_limit",
|
||||
"net_agg_packets_in",
|
||||
"net_agg_packets_out",
|
||||
"net_agg_bytes_in",
|
||||
"net_agg_bytes_out",
|
||||
"time_of_day"
|
||||
]
|
||||
},
|
||||
"data": [{
|
||||
"uuid": "dca08514-72e5-46ce-ad91-e68b3b0914d4",
|
||||
"id": "agg-cpu-usage"
|
||||
|
@ -9,6 +9,7 @@ module.exports = () => {
|
||||
account: require('@state/reducers/account'),
|
||||
app: require('@state/reducers/app'),
|
||||
intl: require('@state/reducers/intl'),
|
||||
metrics: require('@state/reducers/metrics'),
|
||||
orgs: require('@state/reducers/orgs'),
|
||||
projects: require('@state/reducers/projects'),
|
||||
services: require('@state/reducers/services')
|
||||
|
9
frontend/src/state/reducers/metrics.js
Normal file
9
frontend/src/state/reducers/metrics.js
Normal file
@ -0,0 +1,9 @@
|
||||
const ReduxActions = require('redux-actions');
|
||||
|
||||
const {
|
||||
handleActions
|
||||
} = ReduxActions;
|
||||
|
||||
module.exports = handleActions({
|
||||
'x': (state) => state // somehow handleActions needs at least one reducer
|
||||
}, {});
|
Loading…
Reference in New Issue
Block a user