added sample and entry count to csv import
This commit is contained in:
parent
b9397fc81a
commit
e508ce83ca
@ -51,7 +51,13 @@
|
||||
</div>
|
||||
<div class="csv-header-pill-content">
|
||||
<div class="csv-header-pill" *ngFor="let field of parseResult?.meta?.fields">
|
||||
{{ field }}
|
||||
<div class="name">
|
||||
{{ field }}
|
||||
</div>
|
||||
<div class="secondary">
|
||||
<div class="entry-count small-label">{{ getEntries(field) }} entries</div>
|
||||
<div class="sample small-label">Sample: {{ getSample(field) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -68,6 +68,23 @@
|
||||
border-radius: 8px;
|
||||
padding: 10px;
|
||||
background: $white;
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
.name {
|
||||
}
|
||||
.secondary {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
||||
.sample {
|
||||
max-width: 200px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -40,7 +40,26 @@ export class FileAttributesCsvImportDialogComponent implements OnInit {
|
||||
if (!this.delimiter) {
|
||||
this.delimiter = this.parseResult.meta.delimiter;
|
||||
}
|
||||
console.log(this.parseResult);
|
||||
});
|
||||
reader.readAsText(this.csvFile, this.encoding);
|
||||
}
|
||||
|
||||
getSample(field: string) {
|
||||
return this.parseResult?.data ? this.parseResult?.data[0][field] : '';
|
||||
}
|
||||
|
||||
getEntries(field: any) {
|
||||
if (this.parseResult?.data) {
|
||||
let count = 0;
|
||||
for (let entry of this.parseResult.data) {
|
||||
if (entry[field]) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user