2020-07-27 17:52:03 +02:00
|
|
|
<script src="samples.component.ts"></script>
|
2020-05-22 12:52:17 +02:00
|
|
|
<div class="header-addnew">
|
|
|
|
<h2>Samples</h2>
|
2020-06-19 08:43:22 +02:00
|
|
|
<a routerLink="/samples/new">
|
2020-07-30 11:33:56 +02:00
|
|
|
<rb-icon-button icon="add" mode="primary">New sample</rb-icon-button>
|
2020-06-19 08:43:22 +02:00
|
|
|
</a>
|
2020-05-22 12:52:17 +02:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<rb-accordion>
|
2020-07-22 10:45:34 +02:00
|
|
|
<rb-accordion-title [open]="false"><span class="rb-ic rb-ic-filter"></span> Filter</rb-accordion-title>
|
2020-05-22 12:52:17 +02:00
|
|
|
<rb-accordion-body>
|
2020-07-13 10:52:10 +02:00
|
|
|
<form class="filters">
|
2020-06-26 11:09:59 +02:00
|
|
|
<div class="status-selection">
|
|
|
|
<label class="label">Status</label>
|
2020-07-30 11:33:56 +02:00
|
|
|
<rb-form-checkbox name="status-validated" [(ngModel)]="filters.status.validated"
|
|
|
|
[disabled]="!filters.status.new" (ngModelChange)="loadSamples({firstPage: true})">
|
2020-06-26 11:09:59 +02:00
|
|
|
validated
|
|
|
|
</rb-form-checkbox>
|
2020-07-30 11:33:56 +02:00
|
|
|
<rb-form-checkbox name="status-new" [(ngModel)]="filters.status.new" [disabled]="!filters.status.validated"
|
|
|
|
(ngModelChange)="loadSamples({firstPage: true})">
|
2020-06-26 11:09:59 +02:00
|
|
|
new
|
|
|
|
</rb-form-checkbox>
|
|
|
|
</div>
|
2020-07-30 11:33:56 +02:00
|
|
|
<rb-form-select name="pageSizeSelection" label="page size" [(ngModel)]="filters.pageSize" class="selection"
|
|
|
|
(ngModelChange)="loadSamples({firstPage: true})" #pageSizeSelection>
|
2020-07-13 10:52:10 +02:00
|
|
|
<option value="3">3</option>
|
2020-06-26 11:09:59 +02:00
|
|
|
<option value="10">10</option>
|
|
|
|
<option value="25">25</option>
|
|
|
|
<option value="50">50</option>
|
|
|
|
<option value="100">100</option>
|
|
|
|
<option value="250">250</option>
|
|
|
|
<option value="500">500</option>
|
2020-06-19 08:43:22 +02:00
|
|
|
</rb-form-select>
|
|
|
|
|
2020-07-30 11:33:56 +02:00
|
|
|
<rb-form-multi-select name="fieldSelect" idField="id" [items]="keys" [(ngModel)]="isActiveKey" label="Fields"
|
|
|
|
class="selection" (ngModelChange)="loadSamples({}, $event)">
|
2020-07-13 10:52:10 +02:00
|
|
|
<span *rbFormMultiSelectOption="let item" class="load-first-page">{{item.label}}</span>
|
|
|
|
</rb-form-multi-select>
|
|
|
|
|
|
|
|
<div class="fieldfilters">
|
|
|
|
<div *ngFor="let filter of filters.filters">
|
2020-07-22 10:45:34 +02:00
|
|
|
<ng-container *ngIf="isActiveKey[filter.field]">
|
2020-07-30 11:33:56 +02:00
|
|
|
<rb-form-checkbox [name]="'filteractive-' + filter.field" [(ngModel)]="filter.active"
|
|
|
|
(ngModelChange)="loadSamples({firstPage: true})"></rb-form-checkbox>
|
|
|
|
<rb-form-select [name]="'filtermode-' + filter.field" class="filtermode" [(ngModel)]="filter.mode"
|
|
|
|
(ngModelChange)="updateFilterFields(filter.field)">
|
2020-07-22 10:45:34 +02:00
|
|
|
<option value="eq" title="field is equal to value">=</option>
|
|
|
|
<option value="ne" title="field is not equal to value">≠</option>
|
|
|
|
<option value="lt" title="field is lower than value"><</option>
|
|
|
|
<option value="lte" title="field is lower than or equal to value">≤</option>
|
|
|
|
<option value="gt" title="field is greater than value">></option>
|
|
|
|
<option value="gte" title="field is greater than or equal to value">≥</option>
|
|
|
|
<option value="stringin" title="field contains value">⊇</option>
|
|
|
|
<option value="in" title="field is one of the values">∈</option>
|
|
|
|
<option value="nin" title="field is not one of the values">∉</option>
|
|
|
|
</rb-form-select>
|
|
|
|
<div class="filter-inputs">
|
2020-07-30 11:33:56 +02:00
|
|
|
<rb-array-input [(ngModel)]="filter.values" [name]="'filter-' + filter.field"
|
|
|
|
[pushTemplate]="!(filter.mode === 'in' || filter.mode === 'nin') ? null :''"
|
|
|
|
(ngModelChange)="updateFilterFields(filter.field)">
|
|
|
|
<ng-container *rbArrayInputItem="let item"
|
|
|
|
[ngSwitch]="(filter.autocomplete.length ? 'autocomplete' : '') +
|
|
|
|
(filter.field == 'added' ? 'date' : '')">
|
|
|
|
<rb-form-date-input *ngSwitchCase="'date'" [rbArrayInputListener]="'filter-' + filter.field"
|
|
|
|
[name]="'filter-' + filter.field + item.i" [index]="item.i"
|
|
|
|
[label]="filter.label" [(ngModel)]="item.value"></rb-form-date-input>
|
|
|
|
<rb-form-input *ngSwitchCase="''" [rbArrayInputListener]="'filter-' + filter.field"
|
|
|
|
[name]="'filter-' + filter.field + item.i" [index]="item.i"
|
|
|
|
[label]="filter.label" [(ngModel)]="item.value"></rb-form-input>
|
|
|
|
<rb-form-input *ngSwitchCase="'autocomplete'" [rbArrayInputListener]="'filter-' + filter.field"
|
|
|
|
[name]="'filter-' + filter.field + item.i" [index]="item.i"
|
|
|
|
[label]="filter.label" [(ngModel)]="item.value"
|
|
|
|
[rbDebounceTime]="0" (keydown)="preventDefault($event, 'Enter')"
|
|
|
|
[rbFormInputAutocomplete]="autocomplete.bind(this, filter.autocomplete)"
|
|
|
|
ngModel></rb-form-input>
|
|
|
|
</ng-container>
|
|
|
|
</rb-array-input>
|
2020-07-22 10:45:34 +02:00
|
|
|
</div>
|
|
|
|
</ng-container>
|
2020-07-13 10:52:10 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2020-06-19 08:43:22 +02:00
|
|
|
</form>
|
2020-05-22 12:52:17 +02:00
|
|
|
</rb-accordion-body>
|
|
|
|
</rb-accordion>
|
|
|
|
|
2020-07-13 10:52:10 +02:00
|
|
|
|
2020-06-26 11:09:59 +02:00
|
|
|
<ng-container *ngTemplateOutlet="paging"></ng-container>
|
|
|
|
|
2020-07-13 10:52:10 +02:00
|
|
|
<div class="download">
|
2020-07-30 11:33:56 +02:00
|
|
|
<rb-icon-button icon="download" mode="secondary" [rbModal]="linkModal">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>
|
2020-07-13 10:52:10 +02:00
|
|
|
<rb-form-checkbox name="download-csv" [(ngModel)]="downloadCsv">
|
|
|
|
add spectra
|
|
|
|
</rb-form-checkbox>
|
2020-07-30 11:33:56 +02:00
|
|
|
<rb-icon-button icon="clipboard" mode="secondary" (click)="clipboard()">Copy to clipboard</rb-icon-button>
|
2020-07-13 10:52:10 +02:00
|
|
|
</ng-template>
|
|
|
|
<a [href]="csvUrl" download="samples.csv">
|
2020-07-30 11:33:56 +02:00
|
|
|
<rb-icon-button icon="download" mode="secondary" (mousedown)="csvUrl = sampleUrl({csv: true, export: true})">
|
|
|
|
Download result as CSV
|
|
|
|
</rb-icon-button>
|
2020-07-13 10:52:10 +02:00
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
2020-05-22 12:52:17 +02:00
|
|
|
<rb-table>
|
|
|
|
<tr>
|
2020-07-22 10:45:34 +02:00
|
|
|
<th *ngFor="let key of activeKeys">
|
2020-06-26 11:09:59 +02:00
|
|
|
<div class="sort-header">
|
2020-07-13 10:52:10 +02:00
|
|
|
<span>{{key.label}}</span>
|
2020-07-27 17:52:03 +02:00
|
|
|
<ng-container *ngIf="key.sortable">
|
2020-07-30 11:33:56 +02:00
|
|
|
<span class="rb-ic rb-ic-up sort-arr-up" (click)="setSort(key.id + '-' + 'desc')">
|
|
|
|
<span *ngIf="filters.sort === key.id + '-' + 'desc'"></span>
|
|
|
|
</span>
|
|
|
|
<span class="rb-ic rb-ic-down sort-arr-down" (click)="setSort(key.id + '-' + 'asc')">
|
|
|
|
<span *ngIf="filters.sort === key.id + '-' + 'asc'"></span>
|
|
|
|
</span>
|
2020-07-27 17:52:03 +02:00
|
|
|
</ng-container>
|
2020-06-26 11:09:59 +02:00
|
|
|
</div>
|
|
|
|
</th>
|
2020-06-19 08:43:22 +02:00
|
|
|
<th></th>
|
2020-05-22 12:52:17 +02:00
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr *ngFor="let sample of samples">
|
2020-07-22 10:45:34 +02:00
|
|
|
<td *ngIf="isActiveKey['number']">{{sample.number}}</td>
|
|
|
|
<td *ngIf="isActiveKey['material.numbers']">{{materials[sample.material_id].numbers}}</td>
|
|
|
|
<td *ngIf="isActiveKey['material.name']">{{materials[sample.material_id].name}}</td>
|
|
|
|
<td *ngIf="isActiveKey['material.supplier']">{{materials[sample.material_id].supplier}}</td>
|
|
|
|
<td *ngIf="isActiveKey['material.group']">{{materials[sample.material_id].group}}</td>
|
2020-07-30 11:33:56 +02:00
|
|
|
<td *ngFor="let key of activeTemplateKeys.material">
|
|
|
|
{{materials[sample.material_id].properties[key[2]] | exists}}
|
|
|
|
</td>
|
2020-07-22 10:45:34 +02:00
|
|
|
<td *ngIf="isActiveKey['type']">{{sample.type}}</td>
|
|
|
|
<td *ngIf="isActiveKey['color']">{{sample.color}}</td>
|
|
|
|
<td *ngIf="isActiveKey['batch']">{{sample.batch}}</td>
|
2020-07-27 17:52:03 +02:00
|
|
|
<td *ngIf="isActiveKey['notes']">{{sample.notes | object: ['_id', 'sample_references']}}</td>
|
2020-07-22 10:45:34 +02:00
|
|
|
<td *ngFor="let key of activeTemplateKeys.measurements">{{sample[key[1]] | exists: key[2]}}</td>
|
|
|
|
<td *ngIf="isActiveKey['added']">{{sample.added | date:'dd/MM/yy'}}</td>
|
2020-06-19 08:43:22 +02:00
|
|
|
<td><a [routerLink]="'/samples/edit/' + sample._id"><span class="rb-ic rb-ic-edit"></span></a></td>
|
2020-05-22 12:52:17 +02:00
|
|
|
</tr>
|
|
|
|
</rb-table>
|
2020-06-26 11:09:59 +02:00
|
|
|
|
|
|
|
<ng-container *ngTemplateOutlet="paging"></ng-container>
|
|
|
|
|
|
|
|
<ng-template #paging>
|
|
|
|
<div class="paging">
|
|
|
|
<button class="rb-btn rb-link" type="button" (click)="loadPage(-1)" [disabled]="page === 1">
|
|
|
|
<span class="rb-ic rb-ic-back-left"></span>
|
|
|
|
</button>
|
2020-07-30 11:33:56 +02:00
|
|
|
<rb-form-input label="page" (change)="loadPage({toPage: $event.target.value - page})" [ngModel]="page">
|
|
|
|
</rb-form-input>
|
2020-06-26 11:09:59 +02:00
|
|
|
<span>
|
2020-07-22 10:45:34 +02:00
|
|
|
of {{pages}} ({{totalSamples}} samples)
|
2020-06-26 11:09:59 +02:00
|
|
|
</span>
|
2020-07-22 10:45:34 +02:00
|
|
|
<button class="rb-btn rb-link" type="button" (click)="loadPage(1)" [disabled]="page >= pages">
|
2020-06-26 11:09:59 +02:00
|
|
|
<span class="rb-ic rb-ic-forward-right"></span>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</ng-template>
|
|
|
|
|