From c2f5aaff8d304bf72ff26e5cd4ab85e1bf93fe56 Mon Sep 17 00:00:00 2001 From: VLE2FE Date: Mon, 10 Aug 2020 14:28:17 +0200 Subject: [PATCH 1/2] fixed new sample material group/supplier autocomplete, template refresh after changes, template array input --- src/app/app.component.html | 2 +- src/app/sample/sample.component.html | 9 +++++---- src/app/sample/sample.component.ts | 7 +++++-- src/app/services/validation.service.ts | 1 + src/app/templates/templates.component.html | 3 ++- src/app/templates/templates.component.ts | 10 +++++++--- 6 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/app/app.component.html b/src/app/app.component.html index 43aa0c7..6899d22 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -32,7 +32,7 @@ Send report - + DEVELOPMENT DeFinMa diff --git a/src/app/sample/sample.component.html b/src/app/sample/sample.component.html index aae27cd..c5b484a 100644 --- a/src/app/sample/sample.component.html +++ b/src/app/sample/sample.component.html @@ -19,16 +19,17 @@

Material properties

+ (focusout)="checkTypo($event, 'materialSuppliers', 'supplier', modalWarning)"> {{supplierInput.errors.failure}} - + (focusout)="checkTypo($event, 'materialGroups', 'group', modalWarning)"> {{groupInput.errors.failure}} diff --git a/src/app/sample/sample.component.ts b/src/app/sample/sample.component.ts index d5a71b0..5168dff 100644 --- a/src/app/sample/sample.component.ts +++ b/src/app/sample/sample.component.ts @@ -434,8 +434,11 @@ export class SampleComponent implements OnInit, AfterContentChecked { } } - checkTypo(list, mKey, modal: TemplateRef) { - if (this.d.arr[list].indexOf(this.material[list]) < 0) { // entry is not in list + checkTypo(event, list, mKey, modal: TemplateRef) { + // user did not click on suggestion and entry is not in list + if (!(event.relatedTarget && (event.relatedTarget.className.indexOf('rb-dropdown-item') >= 0 || + event.relatedTarget.className.indexOf('close-btn rb-btn rb-passive-link') >= 0)) && + this.d.arr[list].indexOf(this.material[mKey]) < 0) { this.modalText.list = mKey; this.modalText.suggestion = this.d.arr[list] // find possible entry from list .map(e => ({v: e, s: strCompare.sorensenDice(e, this.material[mKey])})) diff --git a/src/app/services/validation.service.ts b/src/app/services/validation.service.ts index 070e3a5..47134e2 100644 --- a/src/app/services/validation.service.ts +++ b/src/app/services/validation.service.ts @@ -122,6 +122,7 @@ export class ValidationService { const {ignore, error} = Joi.string() .max(128) .invalid('condition_template', 'material_template') + .allow('') .pattern(/^[^.]+$/) .required() .messages({'string.pattern.base': 'name must not contain a dot'}) diff --git a/src/app/templates/templates.component.html b/src/app/templates/templates.component.html index 6d71ebc..7a6b46e 100644 --- a/src/app/templates/templates.component.html +++ b/src/app/templates/templates.component.html @@ -55,7 +55,8 @@ Edit template - + Save template diff --git a/src/app/templates/templates.component.ts b/src/app/templates/templates.component.ts index f858665..5782be6 100644 --- a/src/app/templates/templates.component.ts +++ b/src/app/templates/templates.component.ts @@ -5,6 +5,7 @@ import {animate, style, transition, trigger} from '@angular/animations'; import {ValidationService} from '../services/validation.service'; import cloneDeep from 'lodash/cloneDeep'; import omit from 'lodash/omit'; +import {DataService} from '../services/data.service'; @Component({ selector: 'app-templates', @@ -36,7 +37,8 @@ export class TemplatesComponent implements OnInit { constructor( private api: ApiService, - private validate: ValidationService + private validate: ValidationService, + public d: DataService ) { } ngOnInit(): void { @@ -44,8 +46,8 @@ export class TemplatesComponent implements OnInit { } loadTemplates() { - this.api.get(`/template/${this.collection}s`, data => { - this.templates = data; + this.d.load(this.collection + 'Templates', () => { + this.templates = this.d.arr[this.collection + 'Templates']; this.templateFormat(); }); } @@ -99,6 +101,7 @@ export class TemplatesComponent implements OnInit { this.templates.push(data); } this.templateFormat(); + this.d.idReload(this.collection + 'Templates'); }); } else { @@ -107,6 +110,7 @@ export class TemplatesComponent implements OnInit { this.templates.push(data); } this.templateFormat(); + this.d.idReload(this.collection + 'Templates'); }); } } From c0b410c4830179c6f5dcc41901da4b234134ee8e Mon Sep 17 00:00:00 2001 From: VLE2FE Date: Mon, 10 Aug 2020 16:15:17 +0200 Subject: [PATCH 2/2] fixed material numbers in new dialog --- src/app/app-routing.module.ts | 2 + src/app/app.component.html | 1 + src/app/app.module.ts | 4 +- src/app/changelog/changelog.component.html | 35 ++++++++++++++++++ src/app/changelog/changelog.component.scss | 10 +++++ src/app/changelog/changelog.component.spec.ts | 25 +++++++++++++ src/app/changelog/changelog.component.ts | 32 ++++++++++++++++ src/app/models/changelog.model.spec.ts | 7 ++++ src/app/models/changelog.model.ts | 9 +++++ src/app/sample/sample.component.html | 6 +-- src/app/sample/sample.component.ts | 14 ++++--- src/app/services/data.service.ts | 37 +++++++++++++------ src/app/services/login.service.ts | 1 + 13 files changed, 163 insertions(+), 20 deletions(-) create mode 100644 src/app/changelog/changelog.component.html create mode 100644 src/app/changelog/changelog.component.scss create mode 100644 src/app/changelog/changelog.component.spec.ts create mode 100644 src/app/changelog/changelog.component.ts create mode 100644 src/app/models/changelog.model.spec.ts create mode 100644 src/app/models/changelog.model.ts diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index e17a583..e4fffe7 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -8,6 +8,7 @@ import {DocumentationComponent} from './documentation/documentation.component'; import {TemplatesComponent} from './templates/templates.component'; import {SettingsComponent} from './settings/settings.component'; import {UsersComponent} from './users/users.component'; +import {ChangelogComponent} from './changelog/changelog.component'; const routes: Routes = [ @@ -17,6 +18,7 @@ const routes: Routes = [ {path: 'samples/new', component: SampleComponent, canActivate: [LoginService]}, {path: 'samples/edit/:id', component: SampleComponent, canActivate: [LoginService]}, {path: 'templates', component: TemplatesComponent, canActivate: [LoginService]}, + {path: 'changelog', component: ChangelogComponent, canActivate: [LoginService]}, {path: 'users', component: UsersComponent, canActivate: [LoginService]}, {path: 'settings', component: SettingsComponent, canActivate: [LoginService]}, {path: 'documentation', component: DocumentationComponent}, diff --git a/src/app/app.component.html b/src/app/app.component.html index 6899d22..648446a 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -5,6 +5,7 @@ Templates + Changelog Users Documentation diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 18590d1..79a2602 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -25,6 +25,7 @@ import { TemplatesComponent } from './templates/templates.component'; import { ParametersPipe } from './parameters.pipe'; import { SettingsComponent } from './settings/settings.component'; import { UsersComponent } from './users/users.component'; +import { ChangelogComponent } from './changelog/changelog.component'; @NgModule({ declarations: [ @@ -42,7 +43,8 @@ import { UsersComponent } from './users/users.component'; TemplatesComponent, ParametersPipe, SettingsComponent, - UsersComponent + UsersComponent, + ChangelogComponent ], imports: [ LocalStorageModule.forRoot({ diff --git a/src/app/changelog/changelog.component.html b/src/app/changelog/changelog.component.html new file mode 100644 index 0000000..9d59d0c --- /dev/null +++ b/src/app/changelog/changelog.component.html @@ -0,0 +1,35 @@ +

Changelog

+ +
+ + + + + + + + + + + + + + +
+ + + + Date + Action + Data + + + {{entry.date}} + {{entry.action}} + {{entry.data | json}} + + diff --git a/src/app/changelog/changelog.component.scss b/src/app/changelog/changelog.component.scss new file mode 100644 index 0000000..c36c6b1 --- /dev/null +++ b/src/app/changelog/changelog.component.scss @@ -0,0 +1,10 @@ +.header { + + & > * { + float: left; + } + + button { + float: right; + } +} diff --git a/src/app/changelog/changelog.component.spec.ts b/src/app/changelog/changelog.component.spec.ts new file mode 100644 index 0000000..a9ebfb6 --- /dev/null +++ b/src/app/changelog/changelog.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ChangelogComponent } from './changelog.component'; + +describe('ChangelogComponent', () => { + let component: ChangelogComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ ChangelogComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ChangelogComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/changelog/changelog.component.ts b/src/app/changelog/changelog.component.ts new file mode 100644 index 0000000..55da828 --- /dev/null +++ b/src/app/changelog/changelog.component.ts @@ -0,0 +1,32 @@ +import { Component, OnInit } from '@angular/core'; +import {ChangelogModel} from '../models/changelog.model'; +import {ApiService} from '../services/api.service'; + +@Component({ + selector: 'app-changelog', + templateUrl: './changelog.component.html', + styleUrls: ['./changelog.component.scss'] +}) +export class ChangelogComponent implements OnInit { + + timestamp = new Date(); + pageSize = 25; + changelog: ChangelogModel[] = []; + + constructor( + private api: ApiService + ) { } + + ngOnInit(): void { + this.loadChangelog(); + } + + loadChangelog(page = 0) { + this.api.get(`/changelog/${this.timestamp.toISOString()}/${page}/${this.pageSize}`, data => { + this.changelog = data.map(e => new ChangelogModel().deserialize(e)); + this.timestamp = new Date(this.changelog[0].date); + console.log(this.changelog); + }); + } + +} diff --git a/src/app/models/changelog.model.spec.ts b/src/app/models/changelog.model.spec.ts new file mode 100644 index 0000000..49eea17 --- /dev/null +++ b/src/app/models/changelog.model.spec.ts @@ -0,0 +1,7 @@ +import { ChangelogModel } from './changelog.model'; + +describe('ChangelogModel', () => { + it('should create an instance', () => { + expect(new ChangelogModel()).toBeTruthy(); + }); +}); diff --git a/src/app/models/changelog.model.ts b/src/app/models/changelog.model.ts new file mode 100644 index 0000000..3ed5c21 --- /dev/null +++ b/src/app/models/changelog.model.ts @@ -0,0 +1,9 @@ +import {BaseModel} from './base.model'; + +export class ChangelogModel extends BaseModel { + date: Date; + action: string; + collection: string; + conditions: {[key: string]: any}; + data: {[key: string]: any}; +} diff --git a/src/app/sample/sample.component.html b/src/app/sample/sample.component.html index c5b484a..017fa35 100644 --- a/src/app/sample/sample.component.html +++ b/src/app/sample/sample.component.html @@ -45,7 +45,7 @@ - + - + - +