Allow viscosity number predictions to be saved
This commit is contained in:
parent
014ddcc2d7
commit
06e649671f
@ -40,7 +40,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="file-input space-below">
|
<div class="file-input space-below">
|
||||||
<rb-form-file name="spectrum-upload" label="spectrum file" maxSize="10000000" class="space-below" multiple
|
<rb-form-file name="spectrum-upload" label="Spectrum File" maxSize="10000000" class="space-below" multiple
|
||||||
(ngModelChange)="fileToArray($event)" placeholder="Select file or drag and drop" dragDrop ngModel>
|
(ngModelChange)="fileToArray($event)" placeholder="Select file or drag and drop" dragDrop ngModel>
|
||||||
</rb-form-file>
|
</rb-form-file>
|
||||||
|
|
||||||
@ -72,6 +72,20 @@
|
|||||||
Export to PDF
|
Export to PDF
|
||||||
</rb-icon-button>
|
</rb-icon-button>
|
||||||
|
|
||||||
|
<!-- Save Prediction -->
|
||||||
|
<!-- Only available for single sample viscosity number predictions -->
|
||||||
|
<div *ngIf="spectrumNames.length && !multipleSamples && activeGroup.group === 'Viscosity Number'">
|
||||||
|
<rb-form-input name="prediction-name" label="Prediction Name" [(ngModel)]="predictionName"></rb-form-input>
|
||||||
|
<rb-icon-button icon="forward-right" mode="secondary" (click)="savePrediction()" [rbModal]="modalSuccess">
|
||||||
|
Save Prediction
|
||||||
|
</rb-icon-button>
|
||||||
|
<ng-template #modalSuccess>
|
||||||
|
<rb-alert alertTitle="Success" type="success" okBtnLabel="Got it">
|
||||||
|
Prediction saved!
|
||||||
|
</rb-alert>
|
||||||
|
</ng-template>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="dpt-chart space-below">
|
<div class="dpt-chart space-below">
|
||||||
<canvas baseChart
|
<canvas baseChart
|
||||||
class="dpt-chart"
|
class="dpt-chart"
|
||||||
|
@ -39,8 +39,11 @@ export class PredictionComponent implements OnInit {
|
|||||||
loading = false;
|
loading = false;
|
||||||
activeGroup: ModelItemModel = new ModelItemModel();
|
activeGroup: ModelItemModel = new ModelItemModel();
|
||||||
activeModelIndex = 0;
|
activeModelIndex = 0;
|
||||||
|
predictionName: String;
|
||||||
|
|
||||||
// If true, spectra belong to different samples, otherwise multiple spectra from the same sample are given
|
// If true, spectra belong to different samples, otherwise multiple spectra from the same sample are given
|
||||||
multipleSamples = false;
|
multipleSamples = false;
|
||||||
|
|
||||||
spectrumNames: string[] = [];
|
spectrumNames: string[] = [];
|
||||||
spectrum: string[][] = [[]];
|
spectrum: string[][] = [[]];
|
||||||
flattenedSpectra = [];
|
flattenedSpectra = [];
|
||||||
@ -122,12 +125,20 @@ export class PredictionComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
groupChange(index) { // Group was changed
|
// Group was changed
|
||||||
|
groupChange(index) {
|
||||||
this.activeGroup = this.d.arr.modelGroups[index];
|
this.activeGroup = this.d.arr.modelGroups[index];
|
||||||
this.activeModelIndex = 0;
|
this.activeModelIndex = 0;
|
||||||
this.result = undefined;
|
this.result = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Save prediction to database
|
||||||
|
// This is not suited for multiple samples
|
||||||
|
savePrediction() {
|
||||||
|
let prediction = { name: this.predictionName, value: this.result.mean[0].value };
|
||||||
|
this.api.post<any>('/prediction/new', prediction);
|
||||||
|
}
|
||||||
|
|
||||||
// Aggregates spectrum names and prediction values into an associative array
|
// Aggregates spectrum names and prediction values into an associative array
|
||||||
prepareExport() {
|
prepareExport() {
|
||||||
const zip = (a, b) => a.map((k, i) => [k, b[i]]);
|
const zip = (a, b) => a.map((k, i) => [k, b[i]]);
|
||||||
|
Loading…
Reference in New Issue
Block a user