flattened result
This commit is contained in:
@ -104,13 +104,18 @@
|
||||
JSON download link
|
||||
</rb-icon-button>
|
||||
<ng-template #linkModal>
|
||||
<label for="jsonUrl">URL for JSON download</label>
|
||||
<textarea class="linkmodal" id="jsonUrl" #linkarea [value]="sampleUrl({export: true, host: true})"
|
||||
(keydown)="preventDefault($event)"></textarea>
|
||||
<rb-form-checkbox class="space-below" name="download-csv" [(ngModel)]="downloadCsv">
|
||||
add spectra
|
||||
</rb-form-checkbox>
|
||||
<rb-icon-button icon="clipboard" mode="secondary" (click)="clipboard()">Copy to clipboard</rb-icon-button>
|
||||
<div class="link-dialog">
|
||||
<label for="jsonUrl">URL for JSON download</label>
|
||||
<textarea class="linkmodal" id="jsonUrl" #linkarea [value]="sampleUrl({export: true, host: true})"
|
||||
(keydown)="preventDefault($event)"></textarea>
|
||||
<rb-form-checkbox class="space-right" name="download-spectra" [(ngModel)]="downloadSpectra">
|
||||
add spectra
|
||||
</rb-form-checkbox>
|
||||
<rb-form-checkbox name="download-flatten" [(ngModel)]="downloadFlatten">
|
||||
flatten object
|
||||
</rb-form-checkbox>
|
||||
<rb-icon-button icon="clipboard" mode="secondary" (click)="clipboard()">Copy to clipboard</rb-icon-button>
|
||||
</div>
|
||||
</ng-template>
|
||||
<a [href]="csvUrl" download="samples.csv">
|
||||
<rb-icon-button icon="download" mode="secondary" (mousedown)="csvUrl = sampleUrl({csv: true, export: true})">
|
||||
|
@ -210,3 +210,13 @@ textarea.linkmodal {
|
||||
padding-top: 0;
|
||||
margin-top: -4.5px;
|
||||
}
|
||||
|
||||
.link-dialog {
|
||||
rb-form-checkbox {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
rb-icon-button {
|
||||
float: right;
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,8 @@ export class SamplesComponent implements OnInit {
|
||||
@ViewChild('pageSizeSelection') pageSizeSelection: ElementRef<HTMLElement>;
|
||||
@ViewChild('linkarea') linkarea: ElementRef<HTMLTextAreaElement>;
|
||||
|
||||
downloadCsv = false;
|
||||
downloadSpectra = false;
|
||||
downloadFlatten = true;
|
||||
samples: SampleModel[] = [];
|
||||
totalSamples = 0; // total number of samples
|
||||
csvUrl = ''; // store url separate so it only has to be generated when clicking the download button
|
||||
@ -94,8 +95,6 @@ export class SamplesComponent implements OnInit {
|
||||
this.calcFieldSelectKeys();
|
||||
this.d.load('materials', () => {
|
||||
this.filters.filters.find(e => e.field === 'material.name').autocomplete = this.d.arr.materials.map(e => e.name);
|
||||
this.filters.filters.find(e => e.field === 'color').autocomplete =
|
||||
[...new Set(this.d.arr.materials.reduce((s, e) => {s.push(...e.numbers.map(el => el.color)); return s; }, []))];
|
||||
this.loadSamples();
|
||||
});
|
||||
this.d.load('materialSuppliers', () => {
|
||||
@ -200,7 +199,7 @@ export class SamplesComponent implements OnInit {
|
||||
}
|
||||
query.push('sort=' + this.filters.sort);
|
||||
if (options.csv) {
|
||||
query.push('csv=true');
|
||||
query.push('output=csv');
|
||||
}
|
||||
if (options.export) {
|
||||
query.push('key=' + this.d.d.userKey.key);
|
||||
@ -230,8 +229,13 @@ export class SamplesComponent implements OnInit {
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (this.downloadCsv) {
|
||||
query.push('fields[]=measurements.spectrum.dpt');
|
||||
else {
|
||||
if (this.downloadFlatten) {
|
||||
query.push('output=flatten');
|
||||
}
|
||||
if (this.downloadSpectra) {
|
||||
query.push('fields[]=measurements.spectrum.dpt');
|
||||
}
|
||||
}
|
||||
return (options.host && isDevMode() ? window.location.host : '') +
|
||||
(options.export ? this.api.hostName : '') +
|
||||
|
Reference in New Issue
Block a user