Compare commits
No commits in common. "c08017bd5914830cc0c682d1ced50790e1dcdb6c" and "70e444d6a347ce4c0db6495589701d418e31d1be" have entirely different histories.
c08017bd59
...
70e444d6a3
14
package-lock.json
generated
14
package-lock.json
generated
@ -9,8 +9,7 @@
|
|||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"csvtojson": "^2.0.10",
|
"csvtojson": "^2.0.10"
|
||||||
"htmlfy": "^0.7.5"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/csvtojson": "^1.1.5",
|
"@types/csvtojson": "^1.1.5",
|
||||||
@ -2204,12 +2203,6 @@
|
|||||||
"safe-buffer": "~5.1.0"
|
"safe-buffer": "~5.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/htmlfy": {
|
|
||||||
"version": "0.7.5",
|
|
||||||
"resolved": "https://registry.npmjs.org/htmlfy/-/htmlfy-0.7.5.tgz",
|
|
||||||
"integrity": "sha512-woog97QSD0MJVXDs4nNz3S/XIb+wa/UgunpaI29tbXaTB9SlNvQalw1XolE4m3BPp3xkJMx96I27Lb/clesPLA==",
|
|
||||||
"license": "MIT"
|
|
||||||
},
|
|
||||||
"node_modules/http-deceiver": {
|
"node_modules/http-deceiver": {
|
||||||
"version": "1.2.7",
|
"version": "1.2.7",
|
||||||
"resolved": "https://registry.npmjs.org/http-deceiver/-/http-deceiver-1.2.7.tgz",
|
"resolved": "https://registry.npmjs.org/http-deceiver/-/http-deceiver-1.2.7.tgz",
|
||||||
@ -6043,11 +6036,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"htmlfy": {
|
|
||||||
"version": "0.7.5",
|
|
||||||
"resolved": "https://registry.npmjs.org/htmlfy/-/htmlfy-0.7.5.tgz",
|
|
||||||
"integrity": "sha512-woog97QSD0MJVXDs4nNz3S/XIb+wa/UgunpaI29tbXaTB9SlNvQalw1XolE4m3BPp3xkJMx96I27Lb/clesPLA=="
|
|
||||||
},
|
|
||||||
"http-deceiver": {
|
"http-deceiver": {
|
||||||
"version": "1.2.7",
|
"version": "1.2.7",
|
||||||
"resolved": "https://registry.npmjs.org/http-deceiver/-/http-deceiver-1.2.7.tgz",
|
"resolved": "https://registry.npmjs.org/http-deceiver/-/http-deceiver-1.2.7.tgz",
|
||||||
|
@ -10,8 +10,7 @@
|
|||||||
"author": "nplayfair",
|
"author": "nplayfair",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"csvtojson": "^2.0.10",
|
"csvtojson": "^2.0.10"
|
||||||
"htmlfy": "^0.7.5"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/csvtojson": "^1.1.5",
|
"@types/csvtojson": "^1.1.5",
|
||||||
|
@ -3,6 +3,7 @@ const csv = require('csvtojson');
|
|||||||
|
|
||||||
export async function getBOM(csvBOM: string) {
|
export async function getBOM(csvBOM: string) {
|
||||||
const rawBOM = await csv(csvConfig).fromString(csvBOM);
|
const rawBOM = await csv(csvConfig).fromString(csvBOM);
|
||||||
|
// const bom = rawBOM.filter((part: Part) => !isJunk(part));
|
||||||
const bom = rawBOM.filter((part: Part) => !rejectedParts.includes(part.Part));
|
const bom = rawBOM.filter((part: Part) => !rejectedParts.includes(part.Part));
|
||||||
return bom;
|
return bom;
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,11 @@
|
|||||||
import { getBOM } from './csvToJSON';
|
import { getBOM } from './csvToJSON';
|
||||||
import { PartsTable } from './table';
|
import { PartsTable } from './table';
|
||||||
import { headers } from './config';
|
import { headers } from './config';
|
||||||
import { printHTMLtable } from './utils';
|
|
||||||
|
|
||||||
//DOM elements
|
//DOM elements
|
||||||
const input = document.getElementById('csvInput') as HTMLInputElement;
|
const input = document.getElementById('csvInput') as HTMLInputElement;
|
||||||
const csvTextOutput = document.getElementById('csvText') as HTMLPreElement;
|
const csvTextOutput = document.getElementById('csvText') as HTMLPreElement;
|
||||||
const jsonTextOutput = document.getElementById('partsJSON') as HTMLPreElement;
|
const jsonTextOutput = document.getElementById('partsJSON') as HTMLPreElement;
|
||||||
const partsHTML = document.getElementById('partsHTML') as HTMLPreElement;
|
|
||||||
const htmlTable = document.getElementById('partsTable') as HTMLTableElement;
|
const htmlTable = document.getElementById('partsTable') as HTMLTableElement;
|
||||||
|
|
||||||
let csvBOM: string;
|
let csvBOM: string;
|
||||||
@ -37,7 +35,6 @@ function processCSV(fileReader: Event) {
|
|||||||
printJSONbom(csvString);
|
printJSONbom(csvString);
|
||||||
//Table
|
//Table
|
||||||
createTable();
|
createTable();
|
||||||
//TODO Table HTML code
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Print JSON
|
//Print JSON
|
||||||
@ -50,8 +47,7 @@ async function printJSONbom(csvString: string) {
|
|||||||
async function createTable() {
|
async function createTable() {
|
||||||
const bomJSON = await getBOM(csvBOM);
|
const bomJSON = await getBOM(csvBOM);
|
||||||
const partsTable = new PartsTable(htmlTable, headers, bomJSON);
|
const partsTable = new PartsTable(htmlTable, headers, bomJSON);
|
||||||
const tableMarkup = await partsTable.createTable();
|
partsTable.createTable();
|
||||||
printHTMLtable(tableMarkup as HTMLTableElement, partsHTML);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Add event listener
|
//Add event listener
|
||||||
|
@ -40,10 +40,9 @@ export class PartsTable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Create full table
|
//Create full table
|
||||||
public createTable(): HTMLElement {
|
public createTable(): void {
|
||||||
this.clearTable();
|
this.clearTable();
|
||||||
this.createTableHeader();
|
this.createTableHeader();
|
||||||
this.createTableBody();
|
this.createTableBody();
|
||||||
return this.htmlTable;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
11
src/utils.ts
11
src/utils.ts
@ -1,13 +1,4 @@
|
|||||||
import { prettify } from 'htmlfy';
|
import { rejectedParts } from './config';
|
||||||
|
|
||||||
//Print HTML code
|
|
||||||
export async function printHTMLtable(
|
|
||||||
table: HTMLTableElement,
|
|
||||||
codeBlock: HTMLPreElement,
|
|
||||||
) {
|
|
||||||
codeBlock.innerText = prettify(table.outerHTML);
|
|
||||||
}
|
|
||||||
|
|
||||||
// no longer needed
|
// no longer needed
|
||||||
// export function isJunk(element: Part): boolean {
|
// export function isJunk(element: Part): boolean {
|
||||||
// // Returns true if element is in the rejected list
|
// // Returns true if element is in the rejected list
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
// "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */
|
// "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */
|
||||||
|
|
||||||
/* Module Resolution Options */
|
/* Module Resolution Options */
|
||||||
"moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
|
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
||||||
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
||||||
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
||||||
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user