From 2548bcfd63613245ff705939961c71423b2a9499 Mon Sep 17 00:00:00 2001 From: mariateresa Date: Fri, 10 Nov 2023 19:28:50 +0100 Subject: [PATCH] Linked form with autocompletion to JHipster REST for fetching Contexts. Consequently fixed Angular Material CSS. --- src/main/webapp/app/home/home.component.html | 26 ++++++----- src/main/webapp/app/home/home.component.scss | 2 + src/main/webapp/app/home/home.component.ts | 45 ++++++++----------- .../app/services/contexts-loader.service.ts | 2 +- .../table-screen/table-screen.component.scss | 5 ++- 5 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/main/webapp/app/home/home.component.html b/src/main/webapp/app/home/home.component.html index 451a010..da1ba0a 100644 --- a/src/main/webapp/app/home/home.component.html +++ b/src/main/webapp/app/home/home.component.html @@ -34,32 +34,36 @@
-
- -
+
+ +
- Context name - + Context name + {{ checkForErrorsIn(namefield) }} - + - {{ fctx.name }} | ID: {{ fctx.id }} - - + Context UUID - + -
+ +
diff --git a/src/main/webapp/app/home/home.component.scss b/src/main/webapp/app/home/home.component.scss index a22e3e8..633cccc 100644 --- a/src/main/webapp/app/home/home.component.scss +++ b/src/main/webapp/app/home/home.component.scss @@ -21,3 +21,5 @@ Main page styles background-size: contain; } } + + diff --git a/src/main/webapp/app/home/home.component.ts b/src/main/webapp/app/home/home.component.ts index aa5f17e..4740f06 100644 --- a/src/main/webapp/app/home/home.component.ts +++ b/src/main/webapp/app/home/home.component.ts @@ -63,35 +63,26 @@ export class HomeComponent implements OnInit { ngOnInit(): void { //questo identifica l'utente e riempie il campo account this.accountService.identity().subscribe(account => (this.account = account)); - //contexts fetched from User - //this.stringCtxs = this.getContexts(); - //console.debug("***stringCtxs..."+this.stringCtxs); - //contexts fetched from Service - this.ctxLoaderService.fetchContexts().subscribe(res => this.allCtxs = res); - console.debug("+++++allCtxs..."+this.allCtxs); + + // per la form dei contesti + this.ctxLoaderService.fetchAll().subscribe(res => { + this.allCtxs = res; + // console.log('*******numero contesti...', this.allCtxs); + }); + console.debug("+++++allCtxs..."+this.allCtxs.toString); this.filteredContexts = this.chooseContextForm.get('namefield').valueChanges.pipe( startWith(''), map(ctx => (ctx ? this.filterContexts(ctx) : this.allCtxs.slice())) ); } - //mettere ANY come tipo dell'argomento per evitare errore TypeScript nella map!! - filterContexts(name: any): IContextNode[] { - return this.allCtxs.filter(ctx => ctx.name.toLowerCase().includes(name.toLowerCase())); + //mettere ANY come tipo dell'argomento per evitare errore TypeScript nella map!! + filterContexts(name: any): IContextNode[] { + //console.log("in filterContext...(name)..."+name); + return this.allCtxs.filter(ctx => ctx.name.toLowerCase().includes(name.toLowerCase())); } - //TEMPORANEO: CTX E' TEMPORANEAMENTE UNA STRINGA (NON A REGIME) - /* - filterContexts(name: any): string[] { - return this.stringCtxs.filter(ctx => ctx.toLowerCase().includes(name.toLowerCase())); - } -*/ - /* - this.filteredContexts = this.chooseContextForm.get('namefield').valueChanges.pipe( - startWith(''), - map(ctx => (ctx ? this.filterContexts(ctx) : this.contexts.slice())) - );*/ - + //PER VALIDAZIONE FORM checkForErrorsIn(formControl: AbstractControl): string { if (formControl.hasError('required')) { @@ -100,18 +91,20 @@ export class HomeComponent implements OnInit { return ''; } - /* + displayFn(ctx: IContextNode): string { - return ctx.name ? ctx.name + ' | ' + ctx.id : ''; + //return ctx.name ? ctx.name + ' | ' + ctx.id : ''; + return ctx.name; } -*/ - + + +/* displayFn(ctx: string): string { const tmp = ctx ? ctx + ' (poi ci va id) ': ''; console.log("***"+tmp); return tmp; } - +*/ getContexts(): string[] { if (this.account != null && this.account.resourceAccessDTO != null) { // eslint-disable-next-line no-console diff --git a/src/main/webapp/app/services/contexts-loader.service.ts b/src/main/webapp/app/services/contexts-loader.service.ts index 21d7846..1edf49e 100644 --- a/src/main/webapp/app/services/contexts-loader.service.ts +++ b/src/main/webapp/app/services/contexts-loader.service.ts @@ -15,7 +15,7 @@ export class ContextsLoaderService { constructor(private http: HttpClient) {} - fetchContexts(): Observable { + fetchAll(): Observable { return this.http.get(appProperties.BASEURL_API + 'is/allcontexts'); } diff --git a/src/main/webapp/app/table-screen/table-screen.component.scss b/src/main/webapp/app/table-screen/table-screen.component.scss index 846f306..026ed53 100644 --- a/src/main/webapp/app/table-screen/table-screen.component.scss +++ b/src/main/webapp/app/table-screen/table-screen.component.scss @@ -19,10 +19,11 @@ */ -.mat-mdc-form-field { +mat-option { font-size: 14px; width: 100%; -} + display:block + } th.mat-header-cell, td.mat-cell, td.mat-footer-cell{ padding:18px;