bug solving...

This commit is contained in:
Maria Teresa Paratore 2024-01-09 15:09:23 +01:00
parent 2f44c677f2
commit a1a69ea801
11 changed files with 113 additions and 56 deletions

View File

@ -31,6 +31,7 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { SpinnercontrolInterceptor } from './shared/spinnercontrol.interceptor';
import { ResourceAddComponent } from './resource-add/resource-add.component';
import { ResourceDeleteComponent } from './resource-delete/resource-delete.component';
import { MatDialogModule } from '@angular/material/dialog';
@NgModule({
imports: [
@ -48,6 +49,7 @@ import { ResourceDeleteComponent } from './resource-delete/resource-delete.compo
RawjsonPaneComponent,
ClipboardModule,
BrowserAnimationsModule,
MatDialogModule,
],
providers: [
Title,
@ -55,7 +57,8 @@ import { ResourceDeleteComponent } from './resource-delete/resource-delete.compo
{ provide: NgbDateAdapter, useClass: NgbDateDayjsAdapter },
{provide:HTTP_INTERCEPTORS,useClass:SpinnercontrolInterceptor, multi: true}
],
declarations: [MainComponent, NavbarComponent, ErrorComponent, PageRibbonComponent, ActiveMenuDirective, FooterComponent, ResourceAddComponent, ResourceDeleteComponent],
declarations: [MainComponent, NavbarComponent, ErrorComponent, PageRibbonComponent, ActiveMenuDirective, FooterComponent,
ResourceAddComponent, ResourceDeleteComponent],
bootstrap: [MainComponent],
})
export class AppModule {

View File

@ -25,25 +25,20 @@
</div>
<div class="col-md-9">
<h2 class="pt-3">Root Context: {{[allCtxs[0].path]}} - UUID: {{allCtxs[0].id}}</h2>
<h2 #titleRoot *ngIf="allCtxs && allCtxs.length!==0" class="pt-3">Root Context: {{[allCtxs[0].path]}} - UUID: {{allCtxs[0].id}}</h2>
<div>
<div class="d-inline-block my-3" ngbDropdown #myDrop="ngbDropdown" ></div>
<form [formGroup]="chooseContextForm">
<div class="my-3">
<mat-form-field [style.width.px]="400" class="form-field">
<input matInput panel
#contextInput (keyup)="(0)"
[matAutocomplete]="auto"
placeholder="Type in to select" type="text"
[formControl]="pathfield"
/>
<mat-error>Please, enter a valid name!</mat-error>
<mat-autocomplete #auto="matAutocomplete" [panelWidth]=400
[displayWith]="displayFn.bind(this)" [autoActiveFirstOption]="true">
<mat-option *ngFor="let fctx of filteredContexts | async" [value]="fctx">
<span>{{ fctx.path }}</span>
</mat-option>
</mat-autocomplete>
<mat-form-field id="pathfield" [style.width.px]="400" class="form-field">
<mat-select placeholder="Available Contexts" formControlName="pathfield">
<mat-select-filter [placeholder]="'filter by name'" [displayMember]="'path'" [array]="allCtxs" (filteredReturn)="filteredContexts =$event"></mat-select-filter>
<mat-option *ngFor="let item of filteredContexts" [value]="item">
{{item.path}}
</mat-option>
</mat-select>
</mat-form-field>
</div>

View File

@ -17,7 +17,6 @@ import { ContextsLoaderService } from 'app/services/contexts-loader.service';
import { IContextNode } from 'app/services/i-context-node';
import { AutofillValidator, instanceOfContext } from './autofill-validator';
import { SpinnerLoadingService } from 'app/services/spinner-loading.service';
//import { RscTreeComponent } from 'app/rsc-tree/rsc-tree.component';
@Component({
@ -27,12 +26,13 @@ import { SpinnerLoadingService } from 'app/services/spinner-loading.service';
providers: [ContextsLoaderService],
})
export class HomeComponent implements OnInit, OnDestroy, AfterViewInit {
export class HomeComponent implements OnInit, OnDestroy {
account: Account | null = null;
myContext: IContextNode | null = null;
//stringCtxs: string[];
allCtxs: IContextNode[];
public filteredContexts: Observable<IContextNode[]> | null = null;
allCtxs: IContextNode[] | null = null;
filteredContexts: IContextNode[] | null = null;
//public filteredContexts: Observable<IContextNode[]> | null = null;
//public filteredContextsStr: Observable<string[]>| undefined;
chooseContextForm: FormGroup | any;
resType: string;
@ -81,6 +81,7 @@ export class HomeComponent implements OnInit, OnDestroy, AfterViewInit {
// per la form dei contesti
this.ctxLoaderService.fetchAll().subscribe(res => {
this.allCtxs = res;
this.filteredContexts = this.allCtxs.slice();
});
@ -90,28 +91,18 @@ export class HomeComponent implements OnInit, OnDestroy, AfterViewInit {
this.isLoading = res;
}));
// alert('setting');
//TODO: this values are written, but soon after overwritten by default hint
/*
this.chooseContextForm.patchValue({
uidfield: this.allCtxs[0].id,
namefield: this.allCtxs[0].name
});
*/
}
/*
ngAfterViewInit(): void {
this.filteredContexts = this.chooseContextForm.get('namefield').valueChanges.pipe(
startWith(''),
map(ctx => (ctx ? this.filterContexts(ctx/*,contextInput*/) : this.allCtxs.slice()))
map(ctx => (ctx ? this.filterContexts(ctx) : this.allCtxs.slice()))
);
}
*/
ngOnDestroy(): void {
@ -120,14 +111,15 @@ export class HomeComponent implements OnInit, OnDestroy, AfterViewInit {
}
//mettere ANY come tipo dell'argomento per evitare errore TypeScript nella map!!
filterContexts(/*ctx: IContextNode,*/ item: any): IContextNode[] {
/*
filterContexts( item: any): IContextNode[] {
alert('filtering!');
if(!instanceOfContext(item)){
return this.allCtxs.filter(ctx => ctx.name.toLowerCase().includes(item.toLowerCase()));
}else{
return [];
}
}
}*/
displayFn(ctx: IContextNode): string {
return ctx.path;

View File

@ -32,7 +32,8 @@ import { MatProgressBarModule } from '@angular/material/progress-bar';
TableScreenEsModule,
AsyncPipe,
NgSwitchCase,
NgSwitchDefault],
NgSwitchDefault,
],
declarations: [HomeComponent],
schemas:[CUSTOM_ELEMENTS_SCHEMA],
})

View File

@ -1 +1,9 @@
<p>resource-add works!</p>
<div>
<h1>Tipo: {{data.type}}</h1>
<h2>Contesto: {{data.context.path}}</h2>
</div>
<mat-dialog-actions align="end">
<button mat-button mat-dialog-close>Cancel</button>
<button mat-button [mat-dialog-close]="true" cdkFocusInitial>Confirm</button>
</mat-dialog-actions>

View File

@ -1,13 +1,18 @@
import { Component } from '@angular/core';
import { Component, Inject } from '@angular/core';
import {MAT_DIALOG_DATA} from '@angular/material/dialog';
import { IContextNode } from 'app/services/i-context-node';
@Component({
selector: 'jhi-resource-add',
templateUrl: './resource-add.component.html',
styleUrls: ['./resource-add.component.scss']
styleUrls: ['./resource-add.component.scss'],
})
export class ResourceAddComponent {
// eslint-disable-next-line @typescript-eslint/no-empty-function
constructor() { }
constructor(@Inject(MAT_DIALOG_DATA) public data: {type: string,context:IContextNode}) { }
}

View File

@ -1,13 +1,27 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import {MatDialogModule} from '@angular/material/dialog';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
import { FormsModule } from '@angular/forms';
import { MatButtonModule } from '@angular/material/button';
@NgModule({
imports: [
CommonModule,
MatDialogModule
MatFormFieldModule,
MatInputModule,
FormsModule,
MatButtonModule,
MatFormFieldModule,
MatInputModule,
FormsModule,
MatButtonModule
],
})
export class ResourceAddModule { }
export class ResourceAddModule {
}

View File

@ -2,7 +2,7 @@
<div class="d-flex flex-row">
<h1>Type: {{resourceType}}</h1>
<div id="btn-group" class="col-md-3 mx-5 mt-2">
<button mat-raised-button color="primary"><mat-icon>add</mat-icon><span>Add new</span></button>
<button mat-raised-button color="primary" (click)="openDialogAdd()"><mat-icon>add</mat-icon><span>Add new</span></button>
</div>
</div>
<!-- Component for EServices -->

View File

@ -21,6 +21,8 @@ import { MatTab, MatTabGroup } from '@angular/material/tabs';
import { ITabbedEntity } from 'app/i-tabbed-entity';
import { IEService } from 'app/services/i-e-service';
import { ResourcesImplService } from 'app/services/resources-impl.service';
import { ResourceAddComponent } from 'app/resource-add/resource-add.component';
import { MatDialog, MatDialogRef } from '@angular/material/dialog';
@Component({
@ -37,6 +39,7 @@ export class TableScreenEsComponent implements OnInit, AfterViewInit, OnChanges
dataFromService: IEService[];
dataSource = new MatTableDataSource();
tableDetail: IEService;
dialogRef: MatDialogRef<ResourceAddComponent> |undefined;
@Input() myCtx: IContextNode; //fetching event from parent
@Input() resourceType: string;
@ -52,15 +55,18 @@ export class TableScreenEsComponent implements OnInit, AfterViewInit, OnChanges
public tabs: ITabbedEntity[] = [{ title: 'JSON View', content: '', type: 0, id: '' }];
selectedIdx = 0;
chosenIds: string[] = [];
dummyRes: string;
constructor(private myDataService: ResourcesImplService) {
constructor(private myDataService: ResourcesImplService, private myDialog: MatDialog) {
this.myCtx = {} as IContextNode;
this.tableDetail = {} as IEService;
this.dataFromService = [];
this.sort = new MatSort();
this.paginator = {} as MatPaginator;
this.resourceType = '';
this.dummyRes = '';
}
ngAfterViewInit(): void {
@ -153,4 +159,18 @@ export class TableScreenEsComponent implements OnInit, AfterViewInit, OnChanges
//this.chosenIds.indexOf();
this.tabs.splice(index, 1);
}
openDialogAdd(): void {
// alert('contesto...'+this.myCtx.name);
this.dialogRef = this.myDialog.open(ResourceAddComponent, {
//TODO: passare tipo e contesto
data: {type: this.resourceType, context: this.myCtx},
});
this.dialogRef.afterClosed().subscribe(result => {
console.log('The dialog was closed');
this.dummyRes = result;
});
}
}

View File

@ -2,7 +2,7 @@
<div class="d-flex flex-row">
<h1>Type: {{resourceType}}</h1>
<div id="btn-group" class="col-md-3 mx-5 mt-2">
<button mat-raised-button color="primary"><mat-icon>add</mat-icon><span>Add new</span></button>
<button mat-raised-button color="primary" (click)="openDialogAdd()"><mat-icon>add</mat-icon><span>Add new</span></button>
</div>
</div>
@ -50,7 +50,7 @@
<!--<div class="d-flex flex-row py-4">-->
<div class="d-flex flex-row">
<button mat-button class="action-btn" color="primary" (click)="addTab(this.item.id)" ><mat-icon>visibility</mat-icon></button>
<button mat-button class="action-btn" color="primary"><mat-icon>edit</mat-icon></button>
<button mat-button class="action-btn" color="primary" ><mat-icon>edit</mat-icon></button>
<button mat-button class="action-btn" color="primary"><mat-icon>delete</mat-icon></button>
</div>
</td>

View File

@ -17,7 +17,7 @@ import { MatSort} from '@angular/material/sort';
import { IContextNode } from 'app/services/i-context-node';
import { MatPaginator} from '@angular/material/paginator';
import { MatTab, MatTabGroup } from '@angular/material/tabs';
import { MatDialog, MatDialogConfig } from '@angular/material/dialog';
import { MatDialogRef, MatDialog } from '@angular/material/dialog';
import { ITabbedEntity } from 'app/i-tabbed-entity';
import { IHostingNode } from 'app/services/i-hosting-node';
import { ResourcesImplService } from 'app/services/resources-impl.service';
@ -38,7 +38,8 @@ export class TableScreenComponent implements OnInit, AfterViewInit, OnChanges {
dataFromService: IHostingNode[];
dataSource = new MatTableDataSource();
tableDetail: IHostingNode;
dialogRef: MatDialogRef<ResourceAddComponent> |undefined;
@Input() myCtx: IContextNode; //fetching event from parent
@Input() resourceType: string;
@Output() jsonEmitter = new EventEmitter<IHostingNode>();
@ -54,6 +55,8 @@ export class TableScreenComponent implements OnInit, AfterViewInit, OnChanges {
public tabs: ITabbedEntity[] = [{ title: 'JSON View', content: '', type: 0, id: '' }];
selectedIdx = 0;
chosenIds: string[] = [];
//TODO: a regime questa sarà la nuova resource creata (visualizzerò il titolo)
dummyRes: string;
////////// fine tabbed view
constructor(private myDataService: ResourcesImplService, private myDialog: MatDialog) {
@ -63,6 +66,7 @@ export class TableScreenComponent implements OnInit, AfterViewInit, OnChanges {
this.sort = new MatSort();
this.paginator = {} as MatPaginator;
this.resourceType = '';
this.dummyRes = '';
}
ngAfterViewInit(): void {
@ -148,15 +152,30 @@ export class TableScreenComponent implements OnInit, AfterViewInit, OnChanges {
this.tabs.splice(index, 1);
}
/*
openDialog():void {
const dialogConfig = new MatDialogConfig();
dialogConfig.disableClose = true;
dialogConfig.autoFocus = true;
this.myDialog.open(ResourceAddComponent, dialogConfig);
const dialogRef = new MatDialogRef();
alert('Open Dialog!');
dialogRef.disableClose = true;
dialogRef.autoFocus = true;
this.myDialog.open(ResourceAddComponent, dialogRef);
}
*/
openDialogAdd(): void {
// alert('contesto...'+this.myCtx.name);
this.dialogRef = this.myDialog.open(ResourceAddComponent, {
//TODO: passare tipo e contesto
data: {type: this.resourceType, context: this.myCtx},
});
this.dialogRef.afterClosed().subscribe(result => {
console.log('The dialog was closed');
this.dummyRes = result;
});
}
/*
emitDataItem(node: IHostingNode):void {
this.jsonEmitter.emit(node);