mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-23 01:20: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",
|
||||
"chart.js": "^2.7.2",
|
||||
"classnames": "^2.2.6",
|
||||
"jsonexport": "^2.2.1",
|
||||
"csvjson": "^5.1.0",
|
||||
"moment": "^2.22.2",
|
||||
"promise": "8.0.1",
|
||||
"prop-types": "^15.6.2",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import Storage from '../../utils/Storage';
|
||||
import jsonexport from 'jsonexport/dist';
|
||||
import { dissoc, values } from 'ramda';
|
||||
import { dissoc, head, keys, values } from 'ramda';
|
||||
import csvjson from 'csvjson';
|
||||
|
||||
const SERVERS_STORAGE_KEY = 'servers';
|
||||
|
||||
|
@ -27,10 +27,10 @@ const saveCsv = (window, csv) => {
|
|||
};
|
||||
|
||||
export class ServersExporter {
|
||||
constructor(storage, window, jsonexport) {
|
||||
constructor(storage, window, csvjson) {
|
||||
this.storage = storage;
|
||||
this.window = window;
|
||||
this.jsonexport = jsonexport;
|
||||
this.csvjson = csvjson;
|
||||
}
|
||||
|
||||
exportServers = async () => {
|
||||
|
@ -39,10 +39,9 @@ export class ServersExporter {
|
|||
);
|
||||
|
||||
try {
|
||||
const csv = await new Promise((resolve, reject) => {
|
||||
this.jsonexport(servers, (err, csv) => err ? reject(err) : resolve(csv));
|
||||
const csv = this.csvjson.toCSV(servers, {
|
||||
headers: keys(head(servers)).join(',')
|
||||
});
|
||||
|
||||
saveCsv(this.window, csv);
|
||||
} catch (e) {
|
||||
// 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:
|
||||
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:
|
||||
version "0.4.1"
|
||||
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"
|
||||
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:
|
||||
version "2.4.0"
|
||||
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-2.4.0.tgz#3736a2b428b87bbda0cc83b53fa3d633a35c2ae8"
|
||||
|
|
Loading…
Reference in a new issue