Maping data works with users.xml file
This commit is contained in:
parent
818d2ff0da
commit
94a211bb26
@ -17,7 +17,7 @@
|
||||
"build": {
|
||||
"builder": "@angular-devkit/build-angular:browser",
|
||||
"options": {
|
||||
"allowedCommonJsDependencies": ["papaparse"],
|
||||
"allowedCommonJsDependencies": ["xml2js"],
|
||||
"outputPath": "dist/nkadf",
|
||||
"index": "src/index.html",
|
||||
"main": "src/main.ts",
|
||||
|
150
frontend/package-lock.json
generated
150
frontend/package-lock.json
generated
@ -525,6 +525,12 @@
|
||||
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
|
||||
"dev": true
|
||||
},
|
||||
"ini": {
|
||||
"version": "1.3.5",
|
||||
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz",
|
||||
"integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==",
|
||||
"dev": true
|
||||
},
|
||||
"log-symbols": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.0.0.tgz",
|
||||
@ -2287,6 +2293,12 @@
|
||||
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
|
||||
"dev": true
|
||||
},
|
||||
"ini": {
|
||||
"version": "1.3.5",
|
||||
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz",
|
||||
"integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==",
|
||||
"dev": true
|
||||
},
|
||||
"log-symbols": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.0.0.tgz",
|
||||
@ -2706,6 +2718,22 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"@types/xml2js": {
|
||||
"version": "0.4.7",
|
||||
"resolved": "https://registry.npmjs.org/@types/xml2js/-/xml2js-0.4.7.tgz",
|
||||
"integrity": "sha512-f5VOKSMEE0O+/L54FHwA/a7vcx9mHeSDM71844yHCOhh8Cin2xQa0UFw0b7Vc5hoZ3Ih6ZHaDobjfLih4tWPNw==",
|
||||
"requires": {
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"@types/xml2json": {
|
||||
"version": "0.11.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/xml2json/-/xml2json-0.11.3.tgz",
|
||||
"integrity": "sha512-iuN41kDZvCGfr43ra1WizAZl2y+0v1z9UPf93B9g4629F9jaA6CZywx80GZwqosS2e7aGZEGIaU1DeU0sKFEZw==",
|
||||
"requires": {
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"@webassemblyjs/ast": {
|
||||
"version": "1.9.0",
|
||||
"resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.9.0.tgz",
|
||||
@ -3482,6 +3510,14 @@
|
||||
"integrity": "sha512-Phlt0plgpIIBOGTT/ehfFnbNlfsDEiqmzE2KRXoX1bLIlir4X/MR+zSyBEkL05ffWgnRSf/DXv+WrUAVr93/ow==",
|
||||
"dev": true
|
||||
},
|
||||
"bindings": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz",
|
||||
"integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==",
|
||||
"requires": {
|
||||
"file-uri-to-path": "1.0.0"
|
||||
}
|
||||
},
|
||||
"blob": {
|
||||
"version": "0.0.5",
|
||||
"resolved": "https://registry.npmjs.org/blob/-/blob-0.0.5.tgz",
|
||||
@ -5531,6 +5567,11 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"emitter-component": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/emitter-component/-/emitter-component-1.1.1.tgz",
|
||||
"integrity": "sha1-Bl4tvtaVm/RwZ57avq95gdEAOrY="
|
||||
},
|
||||
"emoji-regex": {
|
||||
"version": "8.0.0",
|
||||
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
|
||||
@ -6217,6 +6258,11 @@
|
||||
"schema-utils": "^2.6.5"
|
||||
}
|
||||
},
|
||||
"file-uri-to-path": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
|
||||
"integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw=="
|
||||
},
|
||||
"fill-range": {
|
||||
"version": "7.0.1",
|
||||
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
|
||||
@ -6773,6 +6819,11 @@
|
||||
"minimalistic-crypto-utils": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"hoek": {
|
||||
"version": "4.2.1",
|
||||
"resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz",
|
||||
"integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA=="
|
||||
},
|
||||
"hosted-git-info": {
|
||||
"version": "3.0.7",
|
||||
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-3.0.7.tgz",
|
||||
@ -7653,6 +7704,14 @@
|
||||
"integrity": "sha512-ORrEy+SNVqUhrCaal4hA4fBzhggQQ+BaLntyPOdoEiwlKZW9BZiJXjg3RMiruE4tPEI3pyVPpySHQF/dKWperg==",
|
||||
"dev": true
|
||||
},
|
||||
"isemail": {
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://registry.npmjs.org/isemail/-/isemail-3.2.0.tgz",
|
||||
"integrity": "sha512-zKqkK+O+dGqevc93KNsbZ/TqTUFd46MwWjYOoMrjIMZ51eU7DtQG3Wmd9SQQT7i7RVnuTPEiYEWHU3MSbxC1Tg==",
|
||||
"requires": {
|
||||
"punycode": "2.x.x"
|
||||
}
|
||||
},
|
||||
"isexe": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
|
||||
@ -7854,6 +7913,23 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"joi": {
|
||||
"version": "13.7.0",
|
||||
"resolved": "https://registry.npmjs.org/joi/-/joi-13.7.0.tgz",
|
||||
"integrity": "sha512-xuY5VkHfeOYK3Hdi91ulocfuFopwgbSORmIwzcwHKESQhC7w1kD5jaVSPnqDxS2I8t3RZ9omCKAxNwXN5zG1/Q==",
|
||||
"requires": {
|
||||
"hoek": "5.x.x",
|
||||
"isemail": "3.x.x",
|
||||
"topo": "3.x.x"
|
||||
},
|
||||
"dependencies": {
|
||||
"hoek": {
|
||||
"version": "5.0.4",
|
||||
"resolved": "https://registry.npmjs.org/hoek/-/hoek-5.0.4.tgz",
|
||||
"integrity": "sha512-Alr4ZQgoMlnere5FZJsIyfIjORBqZll5POhDsF4q64dPuJR6rNxXdDxtHSQq8OXRurhmx+PWYEE8bXRROY8h0w=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"js-tokens": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
|
||||
@ -8936,6 +9012,11 @@
|
||||
"integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==",
|
||||
"dev": true
|
||||
},
|
||||
"nan": {
|
||||
"version": "2.14.2",
|
||||
"resolved": "https://registry.npmjs.org/nan/-/nan-2.14.2.tgz",
|
||||
"integrity": "sha512-M2ufzIiINKCuDfBSAUr1vWQ+vuVcA9kqx8JJUsbQi6yf1uGRyb7HfpdfUr5qLXf3B/t8dPvcjhKMmlfnP47EzQ=="
|
||||
},
|
||||
"nanomatch": {
|
||||
"version": "1.2.13",
|
||||
"resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz",
|
||||
@ -8995,6 +9076,15 @@
|
||||
"integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node-expat": {
|
||||
"version": "2.3.18",
|
||||
"resolved": "https://registry.npmjs.org/node-expat/-/node-expat-2.3.18.tgz",
|
||||
"integrity": "sha512-9dIrDxXePa9HSn+hhlAg1wXkvqOjxefEbMclGxk2cEnq/Y3U7Qo5HNNqeo3fQ4bVmLhcdt3YN1TZy7WMZy4MHw==",
|
||||
"requires": {
|
||||
"bindings": "^1.5.0",
|
||||
"nan": "^2.13.2"
|
||||
}
|
||||
},
|
||||
"node-fetch-npm": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch-npm/-/node-fetch-npm-2.0.4.tgz",
|
||||
@ -10968,8 +11058,7 @@
|
||||
"punycode": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
|
||||
"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==",
|
||||
"dev": true
|
||||
"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A=="
|
||||
},
|
||||
"q": {
|
||||
"version": "1.5.1",
|
||||
@ -11606,8 +11695,7 @@
|
||||
"sax": {
|
||||
"version": "1.2.4",
|
||||
"resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz",
|
||||
"integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==",
|
||||
"dev": true
|
||||
"integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw=="
|
||||
},
|
||||
"schema-utils": {
|
||||
"version": "2.7.1",
|
||||
@ -12513,6 +12601,14 @@
|
||||
"integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=",
|
||||
"dev": true
|
||||
},
|
||||
"stream": {
|
||||
"version": "0.0.2",
|
||||
"resolved": "https://registry.npmjs.org/stream/-/stream-0.0.2.tgz",
|
||||
"integrity": "sha1-f1Nj8Ff2WSxVlfALyAon9c7B8O8=",
|
||||
"requires": {
|
||||
"emitter-component": "^1.1.1"
|
||||
}
|
||||
},
|
||||
"stream-browserify": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.2.tgz",
|
||||
@ -12917,6 +13013,11 @@
|
||||
"integrity": "sha512-eHY7nBftgThBqOyHGVN+l8gF0BucP09fMo0oO/Lb0w1OF80dJv+lDVpXG60WMQvkcxAkNybKsrEIE3ZtKGmPrA==",
|
||||
"dev": true
|
||||
},
|
||||
"timers": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/timers/-/timers-0.1.1.tgz",
|
||||
"integrity": "sha1-hqxceMHuQZaU81pY3k/UGDz7nB4="
|
||||
},
|
||||
"timers-browserify": {
|
||||
"version": "2.0.12",
|
||||
"resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-2.0.12.tgz",
|
||||
@ -13006,6 +13107,21 @@
|
||||
"integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==",
|
||||
"dev": true
|
||||
},
|
||||
"topo": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/topo/-/topo-3.0.3.tgz",
|
||||
"integrity": "sha512-IgpPtvD4kjrJ7CRA3ov2FhWQADwv+Tdqbsf1ZnPUSAtCJ9e1Z44MmoSGDXGk4IppoZA7jd/QRkNddlLJWlUZsQ==",
|
||||
"requires": {
|
||||
"hoek": "6.x.x"
|
||||
},
|
||||
"dependencies": {
|
||||
"hoek": {
|
||||
"version": "6.1.3",
|
||||
"resolved": "https://registry.npmjs.org/hoek/-/hoek-6.1.3.tgz",
|
||||
"integrity": "sha512-YXXAAhmF9zpQbC7LEcREFtXfGq5K1fmd+4PHkBq8NUqmzW3G+Dq10bI/i0KucLRwss3YYFQ0fSfoxBZYiGUqtQ=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"tough-cookie": {
|
||||
"version": "2.5.0",
|
||||
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz",
|
||||
@ -13641,7 +13757,11 @@
|
||||
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz",
|
||||
"integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"bindings": "^1.5.0",
|
||||
"nan": "^2.12.1"
|
||||
}
|
||||
},
|
||||
"glob-parent": {
|
||||
"version": "3.1.0",
|
||||
@ -14264,7 +14384,11 @@
|
||||
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz",
|
||||
"integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"bindings": "^1.5.0",
|
||||
"nan": "^2.12.1"
|
||||
}
|
||||
},
|
||||
"glob-parent": {
|
||||
"version": "3.1.0",
|
||||
@ -14675,17 +14799,25 @@
|
||||
"version": "0.4.23",
|
||||
"resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.23.tgz",
|
||||
"integrity": "sha512-ySPiMjM0+pLDftHgXY4By0uswI3SPKLDw/i3UXbnO8M/p28zqexCUoPmQFrYD+/1BzhGJSs2i1ERWKJAtiLrug==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"sax": ">=0.6.0",
|
||||
"xmlbuilder": "~11.0.0"
|
||||
}
|
||||
},
|
||||
"xml2json": {
|
||||
"version": "0.12.0",
|
||||
"resolved": "https://registry.npmjs.org/xml2json/-/xml2json-0.12.0.tgz",
|
||||
"integrity": "sha512-EPJHRWJnJUYbJlzR4pBhZODwWdi2IaYGtDdteJi0JpZ4OD31IplWALuit8r73dJuM4iHZdDVKY1tLqY2UICejg==",
|
||||
"requires": {
|
||||
"hoek": "^4.2.1",
|
||||
"joi": "^13.1.2",
|
||||
"node-expat": "^2.3.18"
|
||||
}
|
||||
},
|
||||
"xmlbuilder": {
|
||||
"version": "11.0.1",
|
||||
"resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz",
|
||||
"integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==",
|
||||
"dev": true
|
||||
"integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA=="
|
||||
},
|
||||
"xmlhttprequest-ssl": {
|
||||
"version": "1.5.5",
|
||||
|
@ -25,13 +25,16 @@
|
||||
"@ngrx/router-store": "^10.0.1",
|
||||
"@ngrx/store": "^10.0.1",
|
||||
"@ngrx/store-devtools": "^10.0.1",
|
||||
"@types/papaparse": "^5.0.3",
|
||||
"@types/xml2js": "^0.4.7",
|
||||
"@types/xml2json": "^0.11.3",
|
||||
"d3": "^5.16.0",
|
||||
"eva-icons": "^1.1.2",
|
||||
"ngrx-store-localstorage": "^10.1.1",
|
||||
"papaparse": "^5.2.0",
|
||||
"rxjs": "~6.5.4",
|
||||
"stream": "0.0.2",
|
||||
"timers": "^0.1.1",
|
||||
"tslib": "^2.0.0",
|
||||
"xml2js": "^0.4.23",
|
||||
"zone.js": "~0.10.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@ -7,11 +7,11 @@ export class IdToNamePipe implements PipeTransform {
|
||||
transform(
|
||||
value: number,
|
||||
pipeable: boolean,
|
||||
data: { id: number; name: string }[]
|
||||
data: { id: number; full_name: string; username: string }[]
|
||||
): string | number {
|
||||
if (pipeable) {
|
||||
const result = data.filter((element) => element.id == value)[0];
|
||||
return result ? result.name : value;
|
||||
return result ? `${result.username} (${result.full_name})` : value;
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
Wróć do wyboru dyskusji
|
||||
</button>
|
||||
<button nbButton hero status="info" (click)="mapId()">
|
||||
Zmapuj ID na dane z pliku
|
||||
Zmapuj dane z pliku users.xml
|
||||
</button>
|
||||
<button nbButton hero status="danger" (click)="resetDataMapping()">
|
||||
Usuń zmapowane dane
|
||||
@ -23,7 +23,7 @@
|
||||
id="input-for-id"
|
||||
type="file"
|
||||
(change)="fetchFile($event)"
|
||||
accept=".csv"
|
||||
accept=".xml"
|
||||
/>
|
||||
</nb-layout-header>
|
||||
|
||||
@ -61,16 +61,6 @@
|
||||
[index]="i"
|
||||
></app-styled-paragraph>
|
||||
</nb-card-body>
|
||||
<!-- <nb-card-body *ngIf="(currentDimension$ | async) !== 0">
|
||||
<app-styled-paragraph
|
||||
*ngFor="let paragraph of item.message; let i = index"
|
||||
[message]="paragraph"
|
||||
[currentCategories$]="currentCategories$"
|
||||
[paragraphId]="item.para_id[i]"
|
||||
[userEdited]="item.user_updated[i]"
|
||||
[loadedLabel]="item.label[i]"
|
||||
></app-styled-paragraph>
|
||||
</nb-card-body> -->
|
||||
</nb-card>
|
||||
</div>
|
||||
</nb-layout-column>
|
||||
|
@ -1,18 +1,11 @@
|
||||
import { ChangeDetectionStrategy, Component } from '@angular/core';
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
import { concatMap, defaultIfEmpty, map } from 'rxjs/operators';
|
||||
import { concatMap } from 'rxjs/operators';
|
||||
import {
|
||||
getDimensionCategories,
|
||||
setCurrentDiscussionId,
|
||||
} from 'src/app/actions/discussion.actions';
|
||||
import {
|
||||
NbToastrService,
|
||||
NbLayoutScrollService,
|
||||
NbScrollPosition,
|
||||
NbTrigger,
|
||||
NbMenuService,
|
||||
} from '@nebular/theme';
|
||||
import { parse } from 'papaparse';
|
||||
import { NbToastrService, NbLayoutScrollService } from '@nebular/theme';
|
||||
import { State } from 'src/app/reducers';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { getDiscussion } from 'src/app/actions/discussion.actions';
|
||||
@ -24,6 +17,7 @@ import {
|
||||
import { selectData } from 'src/app/selectors/discussion-chooser.selectors';
|
||||
import { loadDiscussions } from 'src/app/actions/discussion-chooser.actions';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import * as parser from 'xml2js';
|
||||
|
||||
@Component({
|
||||
selector: 'app-view',
|
||||
@ -36,7 +30,7 @@ export class ViewComponent {
|
||||
currentCategories$ = this.store.select(selectCurrentCategories);
|
||||
items$ = this.store.select(selectData);
|
||||
displayNamesMode: boolean;
|
||||
parsedNames: { id: number; name: string }[];
|
||||
parsedNames: { id: number; full_name: string; username: string }[];
|
||||
scrollPosition = { x: 0, y: 0 };
|
||||
|
||||
constructor(
|
||||
@ -81,104 +75,24 @@ export class ViewComponent {
|
||||
}
|
||||
|
||||
async fetchFile(event: Event) {
|
||||
let parsedNamesFromArray: Array<{ id: number; name: string }>;
|
||||
const target = event.target as HTMLInputElement;
|
||||
const file = target.files![0];
|
||||
try {
|
||||
parsedNamesFromArray = await this.parseFile(file);
|
||||
this.parsedNames = parsedNamesFromArray;
|
||||
this.displayNamesMode = true;
|
||||
} catch (e) {
|
||||
this.toastService.danger('', e, {
|
||||
icon: 'alert-circle',
|
||||
let fileReader = new FileReader();
|
||||
fileReader.readAsText(file);
|
||||
fileReader.onload = (event) => {
|
||||
parser.parseString(event.target?.result as string, (err, result) => {
|
||||
let users = result.users.user.map((el: any) => ({
|
||||
id: el['$'].id,
|
||||
username: el.username[0],
|
||||
full_name: el.firstname[0] + ' ' + el.lastname[0],
|
||||
}));
|
||||
this.parsedNames = users;
|
||||
this.displayNamesMode = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
parseFile(file: File): Promise<{ id: number; name: string }[]> {
|
||||
return new Promise((resolve, reject) => {
|
||||
parse(file, {
|
||||
header: true,
|
||||
skipEmptyLines: true,
|
||||
dynamicTyping: true,
|
||||
complete: (result) => {
|
||||
if (result.errors.length > 0) {
|
||||
reject('Błąd przy parsowaniu pliku');
|
||||
}
|
||||
resolve(result.data as { id: number; name: string }[]);
|
||||
},
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
resetDataMapping() {
|
||||
this.displayNamesMode = false;
|
||||
}
|
||||
|
||||
// data: PredictedPost[];
|
||||
// id: number;
|
||||
// subscriptionData: Subscription;
|
||||
// subscriptionId: Subscription;
|
||||
|
||||
// scrollPosition: NbScrollPosition;
|
||||
// constructor(
|
||||
// // private paragraphService: ParagraphService,
|
||||
// private router: Router,
|
||||
// private toastService: NbToastrService,
|
||||
// private scrollService: NbLayoutScrollService,
|
||||
// private store: Store<State>
|
||||
// ) {
|
||||
// this.scrollPosition = { x: 0, y: 0 };
|
||||
// }
|
||||
// discussion$: Observable<PredictedPost[]> = this.store.select((state) => {
|
||||
// return state.currentDiscussion;
|
||||
// });
|
||||
// ngOnInit(): void {
|
||||
// this.store.dispatch(getDiscussion());
|
||||
// this.store.select(selectRouteParam('id')).subscribe((id) => {
|
||||
// this.id = parseInt(id!);
|
||||
// });
|
||||
// this.scrollService
|
||||
// .onScroll()
|
||||
// .pipe(concatMap(() => this.scrollService.getPosition()))
|
||||
// .subscribe((result) => {
|
||||
// this.scrollPosition = result;
|
||||
// });
|
||||
// }
|
||||
// onBackButtonClick() {
|
||||
// this.router.navigate(['/view/discussions/']);
|
||||
// }
|
||||
// onSaveChangesButtonClick(id: number) {
|
||||
// this.paragraphService
|
||||
// .patchParagraphs(id)
|
||||
// ?.pipe(defaultIfEmpty())
|
||||
// .subscribe((result: any) => {
|
||||
// if (result === null) {
|
||||
// this.toastService.danger('', 'Brak zmian!', {
|
||||
// preventDuplicates: true,
|
||||
// icon: 'alert-circle',
|
||||
// });
|
||||
// } else {
|
||||
// this.data = result.posts;
|
||||
// this.toastService.success('', 'Zmiany zostały zapisane!', {
|
||||
// icon: 'checkmark-circle-2-outline',
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
// async fetchFile(event: Event) {
|
||||
// let parsedNamesFromArray: Array<{ id: number; name: string }>;
|
||||
// const target = event.target as HTMLInputElement;
|
||||
// const file = target.files![0];
|
||||
// try {
|
||||
// parsedNamesFromArray = await this.parseFile(file);
|
||||
// this.parsedNames = parsedNamesFromArray;
|
||||
// this.displayNamesMode = true;
|
||||
// } catch (e) {
|
||||
// this.toastService.danger('', e, {
|
||||
// icon: 'alert-circle',
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user