From ea02ba0f09dd7a94b5eb98db22503a39266e3680 Mon Sep 17 00:00:00 2001 From: VLE2FE Date: Tue, 1 Sep 2020 13:55:13 +0200 Subject: [PATCH] fixed new user model input and renaming model group --- .../documentation-architecture.component.html | 8 ++++++-- .../documentation-database.component.html | 7 ++++--- .../model-templates/model-templates.component.ts | 2 +- src/app/models/user.model.ts | 2 ++ .../rb-array-input/rb-array-input.component.ts | 14 ++++++++++---- src/app/users/users.component.ts | 3 +++ 6 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/app/documentation/documentation-architecture/documentation-architecture.component.html b/src/app/documentation/documentation-architecture/documentation-architecture.component.html index 3688364..b0ab06f 100644 --- a/src/app/documentation/documentation-architecture/documentation-architecture.component.html +++ b/src/app/documentation/documentation-architecture/documentation-architecture.component.html @@ -11,8 +11,8 @@ https://definma-api.apps.de1.bosch-iot-cloud.com/api-doc/
Admin database management page: - - https://definma-db.apps.de1.bosch-iot-cloud.com/api-doc/ + + https://definma-db.apps.de1.bosch-iot-cloud.com/
Code repository UI @@ -22,6 +22,10 @@ https://sourcecode.socialcoding.bosch.com/users/vle2fe/repos/definma-api
+ Code repository Models + + https://sourcecode.socialcoding.bosch.com/users/poe2rng/repos/definma-models +

diff --git a/src/app/documentation/documentation-database/documentation-database.component.html b/src/app/documentation/documentation-database/documentation-database.component.html index 4977ed6..e2ede6d 100644 --- a/src/app/documentation/documentation-database/documentation-database.component.html +++ b/src/app/documentation/documentation-database/documentation-database.component.html @@ -30,11 +30,12 @@ Every time:

Backup

For creating a database backup, you must follow the same steps from above (except the last one). Additionally you need - the MongoDB server installed. Open the MongoDB bin folder + the mongodump installed. + Open the MongoDB bin folder (normally at C:\Program Files\MongoDB\Server\4.2\bin) in a PowerShell and execute following command for backup, adjust parameters and credentials as needed:

- mongodump.exe /port:1120 /db:"6ebe4c5d-0da3-4347-b484-66894dcf3f27" /username:"<:username>" - /password:"<:username>" /out:"C:\Path\to\backup\folder"

+ .\mongodump.exe /port:1120 /db:"6ebe4c5d-0da3-4347-b484-66894dcf3f27" /username:"<username>" + /password:"<username>" /out:"C:\Path\to\backup\folder"

Restoring the database from a backup is done with mongorestore.exe, more information can be found at the documentation.
The BIC service also creates internal backup, which can be requested to restore, see diff --git a/src/app/model-templates/model-templates.component.ts b/src/app/model-templates/model-templates.component.ts index 17e2fdb..849592d 100644 --- a/src/app/model-templates/model-templates.component.ts +++ b/src/app/model-templates/model-templates.component.ts @@ -43,7 +43,7 @@ export class ModelTemplatesComponent implements OnInit { console.log(this.modelGroup); console.log(this.oldModelGroup); if (this.oldModelGroup !== '' && this.modelGroup !== this.oldModelGroup) { // group was changed, delete model in old group - this.delete(null, this.oldModelGroup, this.oldModelName); + this.delete(null, this.oldModelName, this.oldModelGroup); } this.api.post('/model/' + this.modelGroup, omit(this.model, '_id'), () => { this.newModel = false; diff --git a/src/app/models/user.model.ts b/src/app/models/user.model.ts index d98e40d..172008d 100644 --- a/src/app/models/user.model.ts +++ b/src/app/models/user.model.ts @@ -25,6 +25,8 @@ export class UserModel extends BaseModel{ if (mode === 'admin') { keys.push('level'); keys.push('models'); + this.devices = this.devices.filter(e => e); + this.models = this.models.filter(e => e); } return pick(this, keys); } diff --git a/src/app/rb-custom-inputs/rb-array-input/rb-array-input.component.ts b/src/app/rb-custom-inputs/rb-array-input/rb-array-input.component.ts index e27d579..4e48ee0 100644 --- a/src/app/rb-custom-inputs/rb-array-input/rb-array-input.component.ts +++ b/src/app/rb-custom-inputs/rb-array-input/rb-array-input.component.ts @@ -122,16 +122,22 @@ export class RbArrayInputComponent implements ControlValueAccessor, OnInit, Afte this.values = [this.values[0]]; res = this.values; } - if (!res.length) { - res = ['']; - } + // if (!res.length) { + // res = ['']; + // } this.onChange(res); // trigger ngModel with filled elements } writeValue(obj: any) { // add empty value on init + console.log(obj); if (obj) { if (this.pushTemplate !== null) { - this.values = [...obj.filter(e => e[this.pushPath] !== ''), cloneDeep(this.pushTemplate)]; + if (this.pushPath) { + this.values = [...obj.filter(e => e[this.pushPath] !== ''), cloneDeep(this.pushTemplate)]; + } + else { + this.values = [...obj.filter(e => e !== ''), cloneDeep(this.pushTemplate)]; + } } else { this.values = obj; diff --git a/src/app/users/users.component.ts b/src/app/users/users.component.ts index 7d9954f..7ae4c85 100644 --- a/src/app/users/users.component.ts +++ b/src/app/users/users.component.ts @@ -41,7 +41,9 @@ export class UsersComponent implements OnInit { } saveUser(user: UserModel) { + console.log(user.models); user.models = user.models.filter(e => e !== ''); + console.log(user.models); this.api.put('/user/' + user.origName, user.sendFormat('admin'), data => { user.deserialize(data); user.edit = false; @@ -49,6 +51,7 @@ export class UsersComponent implements OnInit { } saveNewUser() { + // this.newUser.models = this.newUser.models.filter(e => e !== '' || e !== undefined); this.api.post('/user/new', {...this.newUser.sendFormat('admin'), pass: this.newUserPass}, data => { this.newUser = null; this.users.push(new UserModel().deserialize(data));