From 8fd993b362cb20a2ab343665f46c6b7bc564e69e Mon Sep 17 00:00:00 2001 From: VLE2FE Date: Mon, 31 Aug 2020 17:10:44 +0200 Subject: [PATCH 1/4] renamed material name to product name, removed headings --- src/app/changelog/changelog.component.html | 1 - .../documentation-architecture.component.html | 1 - .../documentation-database.component.html | 1 - src/app/documentation/documentation.component.html | 1 - src/app/material/material.component.html | 4 ++-- src/app/materials/materials.component.html | 1 - src/app/materials/materials.component.scss | 2 -- src/app/model-templates/model-templates.component.html | 1 - src/app/prediction/prediction.component.html | 1 - src/app/sample/sample.component.html | 2 +- src/app/samples/samples.component.html | 1 - src/app/samples/samples.component.scss | 1 + src/app/samples/samples.component.ts | 5 ++--- src/app/settings/settings.component.html | 1 - src/app/templates/templates.component.html | 1 - src/app/users/users.component.html | 1 - src/app/users/users.component.ts | 1 + src/styles.scss | 4 ++++ 18 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/app/changelog/changelog.component.html b/src/app/changelog/changelog.component.html index 8954f31..e237f9a 100644 --- a/src/app/changelog/changelog.component.html +++ b/src/app/changelog/changelog.component.html @@ -1,4 +1,3 @@ -

Changelog

Architecture architecture diff --git a/src/app/documentation/documentation-database/documentation-database.component.html b/src/app/documentation/documentation-database/documentation-database.component.html index 0f324f9..4977ed6 100644 --- a/src/app/documentation/documentation-database/documentation-database.component.html +++ b/src/app/documentation/documentation-database/documentation-database.component.html @@ -1,4 +1,3 @@ -

Database

The used database instance is a MongoDB instance running on the BIC, storing all application data. The admin database diff --git a/src/app/documentation/documentation.component.html b/src/app/documentation/documentation.component.html index 0596bb3..1eb1257 100644 --- a/src/app/documentation/documentation.component.html +++ b/src/app/documentation/documentation.component.html @@ -1,4 +1,3 @@ -

Documentation

diff --git a/src/app/material/material.component.html b/src/app/material/material.component.html index 9c195ff..6338780 100644 --- a/src/app/material/material.component.html +++ b/src/app/material/material.component.html @@ -1,7 +1,7 @@ -

Edit material

+

{{material.name | exists}}

- {{materialnameInput.errors.failure}} diff --git a/src/app/materials/materials.component.html b/src/app/materials/materials.component.html index d4ee65e..0ef6e63 100644 --- a/src/app/materials/materials.component.html +++ b/src/app/materials/materials.component.html @@ -1,5 +1,4 @@
-

Materials

* { display: inline; margin-bottom: 10px; diff --git a/src/app/model-templates/model-templates.component.html b/src/app/model-templates/model-templates.component.html index 6fb2fac..fd62fcf 100644 --- a/src/app/model-templates/model-templates.component.html +++ b/src/app/model-templates/model-templates.component.html @@ -1,4 +1,3 @@ -

Models

New model diff --git a/src/app/prediction/prediction.component.html b/src/app/prediction/prediction.component.html index b8bd37b..b503af5 100644 --- a/src/app/prediction/prediction.component.html +++ b/src/app/prediction/prediction.component.html @@ -1,4 +1,3 @@ -

Prediction

diff --git a/src/app/sample/sample.component.html b/src/app/sample/sample.component.html index 119f1f2..3f25923 100644 --- a/src/app/sample/sample.component.html +++ b/src/app/sample/sample.component.html @@ -9,7 +9,7 @@
- -

Samples

New sample diff --git a/src/app/samples/samples.component.scss b/src/app/samples/samples.component.scss index 2505628..8f7e06d 100644 --- a/src/app/samples/samples.component.scss +++ b/src/app/samples/samples.component.scss @@ -2,6 +2,7 @@ .header-addnew { margin-bottom: 40px; + height: 42px; & > * { display: inline; diff --git a/src/app/samples/samples.component.ts b/src/app/samples/samples.component.ts index 4cdf0f3..1569347 100644 --- a/src/app/samples/samples.component.ts +++ b/src/app/samples/samples.component.ts @@ -13,7 +13,6 @@ import {Router} from '@angular/router'; // TODO: turn off sort field // TODO reset sort when field is excluded -// TODO: material name to product // TODO: Eh DPT // TODO: filter button // TODO: check if connect-src to model works @@ -55,7 +54,7 @@ export class SamplesComponent implements OnInit { sort: 'added-asc', filters: [ {field: 'number', label: 'Number', active: false, autocomplete: [], mode: 'eq', values: ['']}, - {field: 'material.name', label: 'Material name', active: false, autocomplete: [], mode: 'eq', values: ['']}, + {field: 'material.name', label: 'Product name', active: false, autocomplete: [], mode: 'eq', values: ['']}, {field: 'material.supplier', label: 'Supplier', active: false, autocomplete: [], mode: 'eq', values: ['']}, {field: 'material.group', label: 'Material', active: false, autocomplete: [], mode: 'eq', values: ['']}, {field: 'material.glass_fiber', label: 'GF', active: false, autocomplete: [], mode: 'eq', values: ['']}, @@ -74,7 +73,7 @@ export class SamplesComponent implements OnInit { keys: KeyInterface[] = [ {id: 'number', label: 'Number', active: true, sortable: true}, {id: 'material.numbers', label: 'Material numbers', active: false, sortable: false}, - {id: 'material.name', label: 'Material name', active: true, sortable: true}, + {id: 'material.name', label: 'Product name', active: true, sortable: true}, {id: 'material.supplier', label: 'Supplier', active: false, sortable: true}, {id: 'material.group', label: 'Material', active: true, sortable: true}, {id: 'type', label: 'Type', active: true, sortable: true}, diff --git a/src/app/settings/settings.component.html b/src/app/settings/settings.component.html index 2b5b9b4..4c3ae5e 100644 --- a/src/app/settings/settings.component.html +++ b/src/app/settings/settings.component.html @@ -1,4 +1,3 @@ -

Settings

Templates diff --git a/src/app/users/users.component.html b/src/app/users/users.component.html index 16c5fb9..6c297ec 100644 --- a/src/app/users/users.component.html +++ b/src/app/users/users.component.html @@ -1,4 +1,3 @@ -

Users

New user diff --git a/src/app/users/users.component.ts b/src/app/users/users.component.ts index fad50dd..7d9954f 100644 --- a/src/app/users/users.component.ts +++ b/src/app/users/users.component.ts @@ -41,6 +41,7 @@ export class UsersComponent implements OnInit { } saveUser(user: UserModel) { + user.models = user.models.filter(e => e !== ''); this.api.put('/user/' + user.origName, user.sendFormat('admin'), data => { user.deserialize(data); user.edit = false; diff --git a/src/styles.scss b/src/styles.scss index b3fd216..b57aeff 100644 --- a/src/styles.scss +++ b/src/styles.scss @@ -69,3 +69,7 @@ ul { } } } + +.nav-main a.active { + font-weight: bold; +} From ea02ba0f09dd7a94b5eb98db22503a39266e3680 Mon Sep 17 00:00:00 2001 From: VLE2FE Date: Tue, 1 Sep 2020 13:55:13 +0200 Subject: [PATCH 2/4] 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)); From 206169e13513b53346a814bc2401ef98310009a5 Mon Sep 17 00:00:00 2001 From: VLE2FE Date: Tue, 1 Sep 2020 14:41:15 +0200 Subject: [PATCH 3/4] added material search --- src/app/app.module.ts | 4 ++- .../documentation-models.component.html | 1 + .../documentation-models.component.scss | 0 .../documentation-models.component.spec.ts | 25 +++++++++++++++++++ .../documentation-models.component.ts | 15 +++++++++++ src/app/materials/materials.component.html | 8 +++++- src/app/materials/materials.component.scss | 12 +++++++++ src/app/materials/materials.component.ts | 5 ++++ 8 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 src/app/documentation/documentation-models/documentation-models.component.html create mode 100644 src/app/documentation/documentation-models/documentation-models.component.scss create mode 100644 src/app/documentation/documentation-models/documentation-models.component.spec.ts create mode 100644 src/app/documentation/documentation-models/documentation-models.component.ts diff --git a/src/app/app.module.ts b/src/app/app.module.ts index a2441d2..2d04295 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -34,6 +34,7 @@ import { SizePipe } from './size.pipe'; import { DocumentationArchitectureComponent } from './documentation/documentation-architecture/documentation-architecture.component'; import { MaterialsComponent } from './materials/materials.component'; import { MaterialComponent } from './material/material.component'; +import { DocumentationModelsComponent } from './documentation/documentation-models/documentation-models.component'; @NgModule({ declarations: [ @@ -60,7 +61,8 @@ import { MaterialComponent } from './material/material.component'; SizePipe, DocumentationArchitectureComponent, MaterialsComponent, - MaterialComponent + MaterialComponent, + DocumentationModelsComponent ], imports: [ LocalStorageModule.forRoot({ diff --git a/src/app/documentation/documentation-models/documentation-models.component.html b/src/app/documentation/documentation-models/documentation-models.component.html new file mode 100644 index 0000000..3af7244 --- /dev/null +++ b/src/app/documentation/documentation-models/documentation-models.component.html @@ -0,0 +1 @@ +

documentation-models works!

diff --git a/src/app/documentation/documentation-models/documentation-models.component.scss b/src/app/documentation/documentation-models/documentation-models.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/documentation/documentation-models/documentation-models.component.spec.ts b/src/app/documentation/documentation-models/documentation-models.component.spec.ts new file mode 100644 index 0000000..d1adf71 --- /dev/null +++ b/src/app/documentation/documentation-models/documentation-models.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { DocumentationModelsComponent } from './documentation-models.component'; + +describe('DocumentationModelsComponent', () => { + let component: DocumentationModelsComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ DocumentationModelsComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(DocumentationModelsComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/documentation/documentation-models/documentation-models.component.ts b/src/app/documentation/documentation-models/documentation-models.component.ts new file mode 100644 index 0000000..b7f7b30 --- /dev/null +++ b/src/app/documentation/documentation-models/documentation-models.component.ts @@ -0,0 +1,15 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'app-documentation-models', + templateUrl: './documentation-models.component.html', + styleUrls: ['./documentation-models.component.scss'] +}) +export class DocumentationModelsComponent implements OnInit { + + constructor() { } + + ngOnInit(): void { + } + +} diff --git a/src/app/materials/materials.component.html b/src/app/materials/materials.component.html index 0ef6e63..0aa854f 100644 --- a/src/app/materials/materials.component.html +++ b/src/app/materials/materials.component.html @@ -26,6 +26,11 @@
+ + @@ -40,7 +45,8 @@ Numbers - + diff --git a/src/app/materials/materials.component.scss b/src/app/materials/materials.component.scss index 637cf7c..ceec451 100644 --- a/src/app/materials/materials.component.scss +++ b/src/app/materials/materials.component.scss @@ -49,3 +49,15 @@ float: right; } } + +.material-search { + width: 300px; + float: left; + position: relative; + + span { + position: absolute; + right: 5px; + top: 24px; + } +} diff --git a/src/app/materials/materials.component.ts b/src/app/materials/materials.component.ts index c6e692b..c7a331a 100644 --- a/src/app/materials/materials.component.ts +++ b/src/app/materials/materials.component.ts @@ -15,6 +15,7 @@ export class MaterialsComponent implements OnInit { materials: MaterialModel[] = []; templateKeys: {key: string, label: string}[] = []; materialStatus = {validated: true, new: true, deleted: false}; + materialSearch = ''; sampleSelect = false; page = 1; @@ -89,4 +90,8 @@ export class MaterialsComponent implements OnInit { return string[0].toUpperCase() + string.slice(1); } + materialFilter(ms) { + return e => e.name.indexOf(ms) >= 0; + } + } From cd4e2aa77b5dd66d4898adf7494e47a0466a9595 Mon Sep 17 00:00:00 2001 From: VLE2FE Date: Tue, 1 Sep 2020 15:15:21 +0200 Subject: [PATCH 4/4] added model documentation --- src/app/app-routing.module.ts | 2 + src/app/app.component.html | 1 + .../documentation-models.component.html | 57 ++++++++++++++++++- 3 files changed, 59 insertions(+), 1 deletion(-) diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 5bcbf68..3c3ebdd 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -15,6 +15,7 @@ import {ModelTemplatesComponent} from './model-templates/model-templates.compone import {DocumentationArchitectureComponent} from './documentation/documentation-architecture/documentation-architecture.component'; import {MaterialsComponent} from './materials/materials.component'; import {MaterialComponent} from './material/material.component'; +import {DocumentationModelsComponent} from './documentation/documentation-models/documentation-models.component'; const routes: Routes = [ @@ -34,6 +35,7 @@ const routes: Routes = [ {path: 'documentation', component: DocumentationComponent}, {path: 'documentation/architecture', component: DocumentationArchitectureComponent}, {path: 'documentation/database', component: DocumentationDatabaseComponent}, + {path: 'documentation/models', component: DocumentationModelsComponent}, // if not authenticated { path: '**', redirectTo: '' } diff --git a/src/app/app.component.html b/src/app/app.component.html index 75d8741..3310240 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -18,6 +18,7 @@ General Architecture Database + Models diff --git a/src/app/documentation/documentation-models/documentation-models.component.html b/src/app/documentation/documentation-models/documentation-models.component.html index 3af7244..45f211d 100644 --- a/src/app/documentation/documentation-models/documentation-models.component.html +++ b/src/app/documentation/documentation-models/documentation-models.component.html @@ -1 +1,56 @@ -

documentation-models works!

+

Model file upload

+ +

+ Model files have to be saved as a .pkl file in 80_Modelle_BIC.
+ For upload the upload script has to be opened (can be in every environment). The name of the model file has to be + entered wih the .pkl ending in the first command and without .pkl in the second. +

+ +

Adding new model scripts

+ +

+ Open Spyder in the base environment and open the model.py within. +

+ +
    +
  • Enter model file name without .pkl in fetchData
  • +
  • Add new prediction function below others
  • +
  • duplicate another @app.route and rename according to desired route name and prediction function name
  • +
+ +

Testing locally

+ +

+ To test the model Python script locally, you need to execute it in the base environment, in which all necessary + packages have to be installed. Note that Spyder also has to be opened in the base environment. +

+ +
    +
  • Open a separate Anaconda Prompt and cd into the definma-UI folder
  • +
  • Adapt the model-mock.json at definma-UI/assets/ and enter the new model URL and name
  • +
  • Execute "python -m http.server" in the Anaconda Prompt
  • +
  • Execute the model.py script in Spyder
  • +
  • Navigate to http://localhost:8000 in the browser
  • +
  • If there are problems with cached data, open the Browser developer console (Ctrl+Shift+I) and tick + "Disable cache" in the Network tab. The console then has to stay open.
  • +
+ +

Model script upload

+ +In the Windows Powershell: + +
    +
  • cf login (only at the first time)
  • +
  • API endpoint: https://api.sys.de1.bosch-iot-cloud.com
  • +
  • Enter email with .de.bosch.com
  • +
  • Enter BIC password
  • +
  • Select space to upload to (currently 3 - development)
  • +
  • cd into the folder containing the manifest.yaml (here is also model.py)
  • +
  • cf push
  • +
+ +

+ After upload the new model details have to be entered in the UI. +

+ +