Fix/csv logs (#505)

* fix: use async csv lib

* fix: wording on the wizard

* chore: builded react files
This commit is contained in:
Rafael Taranto 2020-11-09 10:27:44 +00:00 committed by GitHub
parent 55c4aae8d5
commit 5434e9f8e6
10 changed files with 49 additions and 18 deletions

View file

@ -1,5 +1,5 @@
const { gql } = require('apollo-server-express') const { gql } = require('apollo-server-express')
const converter = require('json-2-csv') const { parseAsync } = require('json2csv')
const { GraphQLDateTime } = require('graphql-iso-date') const { GraphQLDateTime } = require('graphql-iso-date')
const { GraphQLJSON, GraphQLJSONObject } = require('graphql-type-json') const { GraphQLJSON, GraphQLJSONObject } = require('graphql-type-json')
const got = require('got') const got = require('got')
@ -261,17 +261,17 @@ const resolvers = {
machineLogs: (...[, { deviceId, from, until, limit, offset }]) => machineLogs: (...[, { deviceId, from, until, limit, offset }]) =>
logs.simpleGetMachineLogs(deviceId, from, until, limit, offset), logs.simpleGetMachineLogs(deviceId, from, until, limit, offset),
machineLogsCsv: (...[, { deviceId, from, until, limit, offset }]) => machineLogsCsv: (...[, { deviceId, from, until, limit, offset }]) =>
logs.simpleGetMachineLogs(deviceId, from, until, limit, offset).then(converter.json2csvAsync), logs.simpleGetMachineLogs(deviceId, from, until, limit, offset).then(parseAsync),
serverVersion: () => serverVersion, serverVersion: () => serverVersion,
uptime: () => supervisor.getAllProcessInfo(), uptime: () => supervisor.getAllProcessInfo(),
serverLogs: (...[, { from, until, limit, offset }]) => serverLogs: (...[, { from, until, limit, offset }]) =>
serverLogs.getServerLogs(from, until, limit, offset), serverLogs.getServerLogs(from, until, limit, offset),
serverLogsCsv: (...[, { from, until, limit, offset }]) => serverLogsCsv: (...[, { from, until, limit, offset }]) =>
serverLogs.getServerLogs(from, until, limit, offset).then(converter.json2csvAsync), serverLogs.getServerLogs(from, until, limit, offset).then(parseAsync),
transactions: (...[, { from, until, limit, offset }]) => transactions: (...[, { from, until, limit, offset }]) =>
transactions.batch(from, until, limit, offset), transactions.batch(from, until, limit, offset),
transactionsCsv: (...[, { from, until, limit, offset }]) => transactionsCsv: (...[, { from, until, limit, offset }]) =>
transactions.batch(from, until, limit, offset).then(converter.json2csvAsync), transactions.batch(from, until, limit, offset).then(parseAsync),
config: () => settingsLoader.loadLatestConfigOrNone(), config: () => settingsLoader.loadLatestConfigOrNone(),
accounts: () => settingsLoader.loadAccounts() accounts: () => settingsLoader.loadAccounts()
}, },

View file

@ -192,8 +192,10 @@ const LogsDownloaderPopover = ({ name, query, args, title, getLogs }) => {
FileSaver.saveAs( FileSaver.saveAs(
blob, blob,
selectedRadio === ALL selectedRadio === ALL
? `${formatDateFile(new Date())}_${name}` ? `${formatDateFile(new Date())}_${name}.csv`
: `${formatDateFile(range.from)}_${formatDateFile(range.until)}_${name}` : `${formatDateFile(range.from)}_${formatDateFile(
range.until
)}_${name}.csv`
) )
} }

View file

@ -29,11 +29,11 @@ function Welcome({ doContinue }) {
return ( return (
<div className={classes.welcome}> <div className={classes.welcome}>
<H1 className={classes.title}>Welcome to Lamassu Admin</H1> <H1 className={classes.title}>Welcome to the Lamassu Admin</H1>
<P className={classes.getStarted}> <P className={classes.getStarted}>
To get started, weve put together wizard that will To get you started, weve put together a wizard that will
<br /> <br />
help set up you need before start adding machines. help set up what you need before pairing your machines.
</P> </P>
<Button size="xl" onClick={doContinue}> <Button size="xl" onClick={doContinue}>
Get started Get started

27
package-lock.json generated
View file

@ -6110,6 +6110,23 @@
"resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz",
"integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus="
}, },
"json2csv": {
"version": "5.0.3",
"resolved": "https://registry.npmjs.org/json2csv/-/json2csv-5.0.3.tgz",
"integrity": "sha512-e3gEZU/4fp8CVQMHlwT77RayAR7nylCzCYN7jTIbPTEqk0oTaE8GTcBudLgXrHt4ltOs9SAsbveMJT0YK/QUSg==",
"requires": {
"commander": "^6.1.0",
"jsonparse": "^1.3.1",
"lodash.get": "^4.4.2"
},
"dependencies": {
"commander": {
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-6.2.0.tgz",
"integrity": "sha512-zP4jEKbe8SHzKJYQmq8Y9gYjtO/POJLgIdKgV7B9qNmABVFVc+ctqSX6iXh4mCpJfRBOabiZ2YKPg8ciDw6C+Q=="
}
}
},
"jsonfile": { "jsonfile": {
"version": "2.4.0", "version": "2.4.0",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz",
@ -6118,6 +6135,11 @@
"graceful-fs": "^4.1.6" "graceful-fs": "^4.1.6"
} }
}, },
"jsonparse": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz",
"integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA="
},
"jsonschema": { "jsonschema": {
"version": "1.2.2", "version": "1.2.2",
"resolved": "https://registry.npmjs.org/jsonschema/-/jsonschema-1.2.2.tgz", "resolved": "https://registry.npmjs.org/jsonschema/-/jsonschema-1.2.2.tgz",
@ -6357,6 +6379,11 @@
"integrity": "sha1-+wMJF/hqMTTlvJvsDWngAT3f7bI=", "integrity": "sha1-+wMJF/hqMTTlvJvsDWngAT3f7bI=",
"dev": true "dev": true
}, },
"lodash.get": {
"version": "4.4.2",
"resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz",
"integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk="
},
"lodash.includes": { "lodash.includes": {
"version": "4.3.0", "version": "4.3.0",
"resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz", "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz",

View file

@ -36,7 +36,7 @@
"graphql-type-json": "^0.3.1", "graphql-type-json": "^0.3.1",
"helmet": "^3.8.1", "helmet": "^3.8.1",
"inquirer": "^5.2.0", "inquirer": "^5.2.0",
"json-2-csv": "^3.7.8", "json2csv": "^5.0.3",
"kraken-api": "github:DeX3/npm-kraken-api", "kraken-api": "github:DeX3/npm-kraken-api",
"libphonenumber-js": "^1.7.38", "libphonenumber-js": "^1.7.38",
"lnd-async": "^1.8.0", "lnd-async": "^1.8.0",
@ -114,7 +114,9 @@
"watch": "concurrently \"npm:server\" \"npm:admin-server\" \"npm:graphql-server\"" "watch": "concurrently \"npm:server\" \"npm:admin-server\" \"npm:graphql-server\""
}, },
"nodemonConfig": { "nodemonConfig": {
"ignore": ["new-lamassu-admin/*"] "ignore": [
"new-lamassu-admin/*"
]
}, },
"devDependencies": { "devDependencies": {
"ava": "3.8.2", "ava": "3.8.2",

View file

@ -1,7 +1,7 @@
{ {
"files": { "files": {
"main.js": "/static/js/main.4f43f678.chunk.js", "main.js": "/static/js/main.d0c68b02.chunk.js",
"main.js.map": "/static/js/main.4f43f678.chunk.js.map", "main.js.map": "/static/js/main.d0c68b02.chunk.js.map",
"runtime-main.js": "/static/js/runtime-main.f0000622.js", "runtime-main.js": "/static/js/runtime-main.f0000622.js",
"runtime-main.js.map": "/static/js/runtime-main.f0000622.js.map", "runtime-main.js.map": "/static/js/runtime-main.f0000622.js.map",
"static/js/2.e506a40f.chunk.js": "/static/js/2.e506a40f.chunk.js", "static/js/2.e506a40f.chunk.js": "/static/js/2.e506a40f.chunk.js",
@ -81,6 +81,6 @@
"entrypoints": [ "entrypoints": [
"static/js/runtime-main.f0000622.js", "static/js/runtime-main.f0000622.js",
"static/js/2.e506a40f.chunk.js", "static/js/2.e506a40f.chunk.js",
"static/js/main.4f43f678.chunk.js" "static/js/main.d0c68b02.chunk.js"
] ]
} }

View file

@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="shortcut icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><meta name="theme-color" content="#000000"/><link rel="manifest" href="/manifest.json"/><title>Lamassu Admin</title></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root" class="root"></div><script>!function(e){function r(r){for(var n,a,l=r[0],i=r[1],f=r[2],c=0,s=[];c<l.length;c++)a=l[c],Object.prototype.hasOwnProperty.call(o,a)&&o[a]&&s.push(o[a][0]),o[a]=0;for(n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n]);for(p&&p(r);s.length;)s.shift()();return u.push.apply(u,f||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,l=1;l<t.length;l++){var i=t[l];0!==o[i]&&(n=!1)}n&&(u.splice(r--,1),e=a(a.s=t[0]))}return e}var n={},o={1:0},u=[];function a(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,a),t.l=!0,t.exports}a.m=e,a.c=n,a.d=function(e,r,t){a.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,r){if(1&r&&(e=a(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(a.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)a.d(t,n,function(r){return e[r]}.bind(null,n));return t},a.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(r,"a",r),r},a.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},a.p="/";var l=this["webpackJsonplamassu-admin"]=this["webpackJsonplamassu-admin"]||[],i=l.push.bind(l);l.push=r,l=l.slice();for(var f=0;f<l.length;f++)r(l[f]);var p=i;t()}([])</script><script src="/static/js/2.e506a40f.chunk.js"></script><script src="/static/js/main.4f43f678.chunk.js"></script></body></html> <!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="shortcut icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><meta name="theme-color" content="#000000"/><link rel="manifest" href="/manifest.json"/><title>Lamassu Admin</title></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root" class="root"></div><script>!function(e){function r(r){for(var n,a,l=r[0],i=r[1],f=r[2],c=0,s=[];c<l.length;c++)a=l[c],Object.prototype.hasOwnProperty.call(o,a)&&o[a]&&s.push(o[a][0]),o[a]=0;for(n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n]);for(p&&p(r);s.length;)s.shift()();return u.push.apply(u,f||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,l=1;l<t.length;l++){var i=t[l];0!==o[i]&&(n=!1)}n&&(u.splice(r--,1),e=a(a.s=t[0]))}return e}var n={},o={1:0},u=[];function a(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,a),t.l=!0,t.exports}a.m=e,a.c=n,a.d=function(e,r,t){a.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,r){if(1&r&&(e=a(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(a.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)a.d(t,n,function(r){return e[r]}.bind(null,n));return t},a.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(r,"a",r),r},a.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},a.p="/";var l=this["webpackJsonplamassu-admin"]=this["webpackJsonplamassu-admin"]||[],i=l.push.bind(l);l.push=r,l=l.slice();for(var f=0;f<l.length;f++)r(l[f]);var p=i;t()}([])</script><script src="/static/js/2.e506a40f.chunk.js"></script><script src="/static/js/main.d0c68b02.chunk.js"></script></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long