@@ -234,9 +237,11 @@
+
-
@@ -328,3 +333,4 @@
Do you really want to delete {{samples.length > 1 ? 'these samples' : 'this sample'}}?
+
diff --git a/src/app/sample/sample.component.ts b/src/app/sample/sample.component.ts
index dadcfc1..9fa4ba0 100644
--- a/src/app/sample/sample.component.ts
+++ b/src/app/sample/sample.component.ts
@@ -1,6 +1,7 @@
import cloneDeep from 'lodash/cloneDeep';
import merge from 'lodash/merge';
import omit from 'lodash/omit';
+import pick from 'lodash/pick';
import isEqual from 'lodash/isEqual';
import strCompare from 'str-compare';
import {
@@ -210,6 +211,7 @@ export class SampleComponent implements OnInit, AfterContentChecked {
}
});
}
+ this.checkFormAfterInit = true;
this.loading--;
sampleIds.slice(1).forEach(sampleId => {
this.api.get('/sample/' + sampleId, data => {
@@ -225,6 +227,7 @@ export class SampleComponent implements OnInit, AfterContentChecked {
}
this.loading--;
this.checkFormAfterInit = true;
+ console.log(this.baseSample.material.name);
});
});
});
@@ -279,6 +282,7 @@ export class SampleComponent implements OnInit, AfterContentChecked {
}
if (formReady) { // fields are ready, do validation
this.checkFormAfterInit = false;
+ console.log('init');
Object.keys(this.cmForm.form.controls).forEach(field => {
this.cmForm.form.get(field).updateValueAndValidity();
});
@@ -310,6 +314,10 @@ export class SampleComponent implements OnInit, AfterContentChecked {
}
}
+ reValidate() {
+ setTimeout(() => this.checkFormAfterInit = true, 0);
+ }
+
// save base sample
saveSample() {
if (this.samples.length === 0) {
@@ -355,7 +363,7 @@ export class SampleComponent implements OnInit, AfterContentChecked {
else {
this.samples.forEach((sample, i) => {
console.log(sample._id);
- this.api.put('/sample/' + sample._id, this.baseSample.sendFormat(), data => {
+ this.api.put('/sample/' + sample._id, this.baseSample.sendFormat(false), data => {
merge(this.samples[i], omit(data, ['condition']));
this.samples[i].material = this.d.arr.materials.find(e => e._id === this.samples[0].material_id);
this.view.base = false;
@@ -370,7 +378,13 @@ export class SampleComponent implements OnInit, AfterContentChecked {
cmSave() { // save measurements and conditions
this.samples.forEach(sample => {
if (sample.condition.condition_template) { // condition was set
- this.api.put('/sample/' + sample._id, {condition: sample.condition});
+ console.log(sample.condition);
+ console.log(this.d.id.conditionTemplates[sample.condition.condition_template]);
+ this.api.put('/sample/' + sample._id,
+ {condition: pick(sample.condition,
+ ['condition_template', ...this.d.id.conditionTemplates[sample.condition.condition_template].parameters.map(e => e.name)]
+ )}
+ );
}
sample.measurements.forEach(measurement => { // save measurements
if (Object.keys(measurement.values).map(e => measurement.values[e]).join('') !== '') {
diff --git a/src/app/samples/samples.component.ts b/src/app/samples/samples.component.ts
index 33ce4fd..4cdf0f3 100644
--- a/src/app/samples/samples.component.ts
+++ b/src/app/samples/samples.component.ts
@@ -340,7 +340,7 @@ export class SamplesComponent implements OnInit {
updateFilterFields(field) {
const filter = this.filters.filters.find(e => e.field === field);
- filter.active = true;
+ filter.active = !(filter.values.length === 1 && filter.values[0] === '');
}
setSort(string) {
diff --git a/src/app/users/users.component.html b/src/app/users/users.component.html
index 2b7a457..16c5fb9 100644
--- a/src/app/users/users.component.html
+++ b/src/app/users/users.component.html
@@ -56,7 +56,6 @@
Device |
Models |
|
- |
@@ -71,8 +70,7 @@
{{(i > 0 ? ', ' : '') + modelIds[model]}}
- |
+ |
@@ -134,6 +132,37 @@
|
+
+ Deleted users
+
+
+
+ Name |
+ Email |
+ Level |
+ Location |
+ Device |
+ Models |
+ |
+
+
+
+ {{user.name}} |
+ {{user.email}} |
+ {{user.level}} |
+ {{user.location}} |
+ {{user.devices}} |
+
+
+ {{(i > 0 ? ', ' : '') + modelIds[model]}}
+
+ |
+ |
+
+
+
+
+
diff --git a/src/app/users/users.component.ts b/src/app/users/users.component.ts
index 27c587f..fad50dd 100644
--- a/src/app/users/users.component.ts
+++ b/src/app/users/users.component.ts
@@ -14,6 +14,7 @@ import {DataService} from '../services/data.service';
export class UsersComponent implements OnInit {
users: UserModel[] = [];
+ deletedUsers: UserModel[] = [];
newUser: UserModel | null = null;
newUserPass = '';
modelSelect: {id: string, name: string}[] = [];
@@ -28,7 +29,8 @@ export class UsersComponent implements OnInit {
ngOnInit(): void {
this.api.get('/users', data => {
- this.users = data.map(e => new UserModel().deserialize(e));
+ this.users = data.map(e => new UserModel().deserialize(e)).filter(e => e.status !== 'deleted');
+ this.deletedUsers = data.map(e => new UserModel().deserialize(e)).filter(e => e.status === 'deleted');
});
this.d.load('modelGroups', () => {
this.d.arr.modelGroups.forEach(group => {
@@ -63,6 +65,8 @@ export class UsersComponent implements OnInit {
this.api.delete('/user/' + user.name, () => {
user.status = 'deleted';
user.edit = false;
+ this.deletedUsers.push(user);
+ this.users.splice(this.users.findIndex(e => e.name === user.name), 1);
});
}
});
@@ -71,6 +75,8 @@ export class UsersComponent implements OnInit {
restoreUser(user) {
this.api.put('/user/restore/' + user.name, {}, () => {
user.status = 'new';
+ this.users.push(user);
+ this.deletedUsers.splice(this.deletedUsers.findIndex(e => e.name === user.name), 1);
});
}
}