small adjustments...

This commit is contained in:
Maria Teresa Paratore 2023-12-20 16:18:30 +01:00
parent 0fc8c60648
commit 2f44c677f2
2 changed files with 71 additions and 79 deletions

View File

@ -14,7 +14,9 @@
<button mat-raised-button color="primary"><mat-icon>edit</mat-icon> <span>Edit</span></button>
<button mat-raised-button color="primary"><mat-icon>explore</mat-icon> <span>View</span></button>
<button mat-raised-button color="primary"><mat-icon>help</mat-icon><span>Help</span></button>
<div id="restree" class="m-3 py-3">
<div id="restree" class="m-3 py-4">
<h4>Resource Types</h4>
<div class="col-md-3" id="tree-view">
<jhi-rsc-tree id="leftTree" (resourceTypeEm)="buildTableData($event)"></jhi-rsc-tree>
@ -23,43 +25,42 @@
</div>
<div class="col-md-9">
<div>
<h2 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 >
<input matInput panel
#contextInput
[matAutocomplete]="auto"
placeholder="Type in for other contexts" type="text"
[formControl]="pathfield"
/>
<mat-autocomplete id="myauto" #auto="matAutocomplete" [panelWidth]=400 [displayWith]="displayFn.bind(this)" autoActiveFirstOption="true">
<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>
</div>
<mat-form-field [style.width.px]=327 appearance="outline" class="form-field">
<mat-label for="namefield" class="ml-4 ">Name</mat-label>
<input matInput class="uid-input" type="text" placeholder="Name"
readonly [value]="pathfield.value.name"
[formControl]="namefield"/>
</div>
<mat-form-field id="namefield" [style.width.px]=400 appearance="outline" class="form-field">
<mat-label for="namefield">Context Name</mat-label>
<input matInput type="text" placeholder="Name"
formControlName="namefield" readonly [value]="pathfield.value.name" />
</mat-form-field>
<mat-form-field [style.width.px]=327 appearance="outline" class="form-field">
<mat-form-field id="uidfield" [style.width.px]=400 appearance="outline" class="form-field">
<mat-label for="uidfield">Context UUID</mat-label>
<input matInput class="uid-input" type="text" placeholder="UUID"
readonly [value]="pathfield.value.id"
[formControl]="uidfield"/>
<input matInput type="text" placeholder="UUID"
formControlName="uidfield" readonly [value]="pathfield.value.id" />
</mat-form-field>
<button mat-button (click)="copyUid(namefield)" color="primary" matTooltip="copy UUID" matTooltipPosition="below">
<button mat-button (click)="copyUid(pathfield)" color="primary" matTooltip="copy UUID" matTooltipPosition="below">
<mat-icon class="icon-wide2">content_copy</mat-icon>
</button>
<button mat-button color="primary" matTooltip="locate" matTooltipPosition="below">

View File

@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/prefer-optional-chain */
/* eslint-disable @typescript-eslint/no-inferrable-types */
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable no-var */
@ -11,13 +10,14 @@ import { Component, OnDestroy, OnInit, ViewChild,ElementRef, AfterContentInit, A
import { LoginService } from 'app/login/login.service';
import { AccountService } from 'app/core/auth/account.service';
import { Account } from 'app/core/auth/account.model';
import { FormBuilder, FormControl, FormGroup, FormGroupDirective, NgForm, ValidationErrors, ValidatorFn, Validators } from '@angular/forms';
import { FormBuilder, FormControl, FormGroup, ValidationErrors, ValidatorFn, Validators } from '@angular/forms';
import { Clipboard } from '@angular/cdk/clipboard'
import { Observable, Subject, Subscription, delay, map, startWith, takeUntil } from 'rxjs';
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({
@ -30,15 +30,17 @@ import { SpinnerLoadingService } from 'app/services/spinner-loading.service';
export class HomeComponent implements OnInit, OnDestroy, AfterViewInit {
account: Account | null = null;
myContext: IContextNode | null = null;
//stringCtxs: string[];
allCtxs: IContextNode[];
rootPath: string;
rootName: string;
rootId: string;
public filteredContexts: Observable<IContextNode[]> | null = null;
//public filteredContextsStr: Observable<string[]>| undefined;
chooseContextForm: FormGroup | any;
resType: string;
isLoading: boolean = false;
subscriptions: Subscription[] = [];
//@ViewChild('leftTree') leftTree: ElementRef | undefined;
constructor(
private accountService: AccountService,
@ -50,16 +52,12 @@ export class HomeComponent implements OnInit, OnDestroy, AfterViewInit {
//initialise on HostingNodes
this.resType="HostingNode";
this.allCtxs = [];
this.rootPath = "";
this.rootName = "";
this.rootId = "";
}
get pathfield(): any {
get pathfield(): any {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return this.chooseContextForm.get('pathfield');
}
}
get namefield(): any {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return this.chooseContextForm.get('namefield');
@ -70,58 +68,52 @@ export class HomeComponent implements OnInit, OnDestroy, AfterViewInit {
}
ngOnInit(): void {
this.chooseContextForm = this.fb.group({
pathfield: [[Validators.required,AutofillValidator]],
});
;
//to identify users and their account
this.accountService.identity().subscribe(account => (this.account = account));
//to identify users and their account
this.accountService.identity().subscribe(account => (this.account = account));
this.ctxLoaderService.fetchAll().subscribe(res => {
this.allCtxs = res;
this.namefield.setValue(res[0].name);
this.uidfield.setValue(res[0].id);
this.pathfield.setValue(res[0].path);
});
alert('valore namefield: '+this.allCtxs[0].id);
this.subscriptions.push(this.progressService.getState()
.pipe()
.subscribe(res => {
this.isLoading = res;
}));
this.chooseContextForm = this.fb.group({
pathfield: ['', [Validators.required,AutofillValidator]],
uidfield: [],
namefield: []
});
// per la form dei contesti
this.ctxLoaderService.fetchAll().subscribe(res => {
this.allCtxs = res;
});
this.subscriptions.push(this.progressService.getState()
.pipe()
.subscribe(res => {
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('pathfield').valueChanges.pipe(
this.filteredContexts = this.chooseContextForm.get('namefield').valueChanges.pipe(
startWith(''),
map(ctx => (ctx ? this.filterContexts(ctx/*,contextInput*/) : this.allCtxs.slice()))
);
}
/*
getContexts(): string[] {
if (this.account != null && this.account.resourceAccessDTO != null) {
// eslint-disable-next-line no-console
var sc=this.account.resourceAccessDTO.resourceAccess;
var contexts=Array.from(Object.keys(sc));
contexts=contexts.filter(element=>
element!==null&&element.startsWith("%2F"));
contexts=contexts.sort();
// eslint-disable-next-line no-console
console.log(contexts);
return contexts;
} else {
return [];
}
}
*/
//TODO: CHECK WHY UNSUBSCRIBE DOES NOT WORK
ngOnDestroy(): void {
//alert(this.subscriptions.length);
this.subscriptions.forEach(sub => sub.unsubscribe());
@ -138,7 +130,6 @@ export class HomeComponent implements OnInit, OnDestroy, AfterViewInit {
displayFn(ctx: IContextNode): string {
//return ctx.name ? ctx.name + ' | ' + ctx.id : '';
return ctx.path;
}