mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2025-01-09 01:37:24 +03:00
Replace json-csv parsing library
This commit is contained in:
parent
b72a5d0a66
commit
617a3b767b
3 changed files with 12 additions and 13 deletions
|
@ -17,7 +17,7 @@
|
||||||
"bootstrap": "^4.1.1",
|
"bootstrap": "^4.1.1",
|
||||||
"chart.js": "^2.7.2",
|
"chart.js": "^2.7.2",
|
||||||
"classnames": "^2.2.6",
|
"classnames": "^2.2.6",
|
||||||
"jsonexport": "^2.2.1",
|
"csvjson": "^5.1.0",
|
||||||
"moment": "^2.22.2",
|
"moment": "^2.22.2",
|
||||||
"promise": "8.0.1",
|
"promise": "8.0.1",
|
||||||
"prop-types": "^15.6.2",
|
"prop-types": "^15.6.2",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import Storage from '../../utils/Storage';
|
import Storage from '../../utils/Storage';
|
||||||
import jsonexport from 'jsonexport/dist';
|
import { dissoc, head, keys, values } from 'ramda';
|
||||||
import { dissoc, values } from 'ramda';
|
import csvjson from 'csvjson';
|
||||||
|
|
||||||
const SERVERS_STORAGE_KEY = 'servers';
|
const SERVERS_STORAGE_KEY = 'servers';
|
||||||
|
|
||||||
|
@ -27,10 +27,10 @@ const saveCsv = (window, csv) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export class ServersExporter {
|
export class ServersExporter {
|
||||||
constructor(storage, window, jsonexport) {
|
constructor(storage, window, csvjson) {
|
||||||
this.storage = storage;
|
this.storage = storage;
|
||||||
this.window = window;
|
this.window = window;
|
||||||
this.jsonexport = jsonexport;
|
this.csvjson = csvjson;
|
||||||
}
|
}
|
||||||
|
|
||||||
exportServers = async () => {
|
exportServers = async () => {
|
||||||
|
@ -39,10 +39,9 @@ export class ServersExporter {
|
||||||
);
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const csv = await new Promise((resolve, reject) => {
|
const csv = this.csvjson.toCSV(servers, {
|
||||||
this.jsonexport(servers, (err, csv) => err ? reject(err) : resolve(csv));
|
headers: keys(head(servers)).join(',')
|
||||||
});
|
});
|
||||||
|
|
||||||
saveCsv(this.window, csv);
|
saveCsv(this.window, csv);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// FIXME Handle error
|
// FIXME Handle error
|
||||||
|
@ -51,4 +50,4 @@ export class ServersExporter {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export default new ServersExporter(Storage, global.window, jsonexport);
|
export default new ServersExporter(Storage, global.window, csvjson);
|
||||||
|
|
|
@ -2002,6 +2002,10 @@ cssom@0.3.x, "cssom@>= 0.3.2 < 0.4.0":
|
||||||
dependencies:
|
dependencies:
|
||||||
cssom "0.3.x"
|
cssom "0.3.x"
|
||||||
|
|
||||||
|
csvjson@^5.1.0:
|
||||||
|
version "5.1.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/csvjson/-/csvjson-5.1.0.tgz#f055660824ebfb44dc089d901267fdc5d9e8414a"
|
||||||
|
|
||||||
currently-unhandled@^0.4.1:
|
currently-unhandled@^0.4.1:
|
||||||
version "0.4.1"
|
version "0.4.1"
|
||||||
resolved "https://registry.yarnpkg.com/currently-unhandled/-/currently-unhandled-0.4.1.tgz#988df33feab191ef799a61369dd76c17adf957ea"
|
resolved "https://registry.yarnpkg.com/currently-unhandled/-/currently-unhandled-0.4.1.tgz#988df33feab191ef799a61369dd76c17adf957ea"
|
||||||
|
@ -4436,10 +4440,6 @@ json5@^0.5.0, json5@^0.5.1:
|
||||||
version "0.5.1"
|
version "0.5.1"
|
||||||
resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821"
|
resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821"
|
||||||
|
|
||||||
jsonexport@^2.2.1:
|
|
||||||
version "2.2.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/jsonexport/-/jsonexport-2.2.1.tgz#b25a8a6e805e7179ef20460715ba2b92ebc32753"
|
|
||||||
|
|
||||||
jsonfile@^2.1.0:
|
jsonfile@^2.1.0:
|
||||||
version "2.4.0"
|
version "2.4.0"
|
||||||
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-2.4.0.tgz#3736a2b428b87bbda0cc83b53fa3d633a35c2ae8"
|
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-2.4.0.tgz#3736a2b428b87bbda0cc83b53fa3d633a35c2ae8"
|
||||||
|
|
Loading…
Reference in a new issue