From ea2ef3c355ad6f424da8e1e944c95d7fe358658d Mon Sep 17 00:00:00 2001 From: mariateresa Date: Mon, 8 Apr 2024 17:57:02 +0200 Subject: [PATCH] work in progress --- .gitattributes | 150 ++++++++++++++ .../table-screen-vs.component.html | 74 +++++++ .../table-screen-vs.component.scss | 0 .../table-screen-vs.component.ts | 187 ++++++++++++++++++ .../table-screen-vs/table-screen-vs.module.ts | 31 +++ .../table-screen/table-screen.component.ts | 4 +- .../app/table-screen/table-screen.module.ts | 4 - 7 files changed, 443 insertions(+), 7 deletions(-) create mode 100644 .gitattributes create mode 100644 src/main/webapp/app/table-screen-vs/table-screen-vs.component.html create mode 100644 src/main/webapp/app/table-screen-vs/table-screen-vs.component.scss create mode 100644 src/main/webapp/app/table-screen-vs/table-screen-vs.component.ts create mode 100644 src/main/webapp/app/table-screen-vs/table-screen-vs.module.ts diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..ca61722 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,150 @@ +# This file is inspired by https://github.com/alexkaratarakis/gitattributes +# +# Auto detect text files and perform LF normalization +# http://davidlaing.com/2012/09/19/customise-your-gitattributes-to-become-a-git-ninja/ +* text=auto + +# The above will handle all files NOT found below +# These files are text and should be normalized (Convert crlf => lf) + +*.bat text eol=crlf +*.cmd text eol=crlf +*.ps1 text eol=crlf +*.coffee text +*.css text +*.cql text +*.df text +*.ejs text +*.html text +*.java text +*.js text +*.json text +*.less text +*.properties text +*.sass text +*.scss text +*.sh text eol=lf +*.sql text +*.txt text +*.ts text +*.xml text +*.yaml text +*.yml text + +# Documents +*.doc diff=astextplain +*.DOC diff=astextplain +*.docx diff=astextplain +*.DOCX diff=astextplain +*.dot diff=astextplain +*.DOT diff=astextplain +*.pdf diff=astextplain +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain +*.markdown text +*.md text +*.adoc text +*.textile text +*.mustache text +*.csv text +*.tab text +*.tsv text +*.txt text +AUTHORS text +CHANGELOG text +CHANGES text +CONTRIBUTING text +COPYING text +copyright text +*COPYRIGHT* text +INSTALL text +license text +LICENSE text +NEWS text +readme text +*README* text +TODO text + +# Graphics +*.png binary +*.jpg binary +*.jpeg binary +*.gif binary +*.tif binary +*.tiff binary +*.ico binary +# SVG treated as an asset (binary) by default. If you want to treat it as text, +# comment-out the following line and uncomment the line after. +*.svg binary +#*.svg text +*.eps binary + +# These files are binary and should be left untouched +# (binary is a macro for -text -diff) +*.class binary +*.jar binary +*.war binary + +## LINTERS +.csslintrc text +.eslintrc text +.jscsrc text +.jshintrc text +.jshintignore text +.stylelintrc text + +## CONFIGS +*.conf text +*.config text +.editorconfig text +.gitattributes text +.gitconfig text +.gitignore text +.htaccess text +*.npmignore text + +## HEROKU +Procfile text +.slugignore text + +## AUDIO +*.kar binary +*.m4a binary +*.mid binary +*.midi binary +*.mp3 binary +*.ogg binary +*.ra binary + +## VIDEO +*.3gpp binary +*.3gp binary +*.as binary +*.asf binary +*.asx binary +*.fla binary +*.flv binary +*.m4v binary +*.mng binary +*.mov binary +*.mp4 binary +*.mpeg binary +*.mpg binary +*.swc binary +*.swf binary +*.webm binary + +## ARCHIVES +*.7z binary +*.gz binary +*.rar binary +*.tar binary +*.zip binary + +## FONTS +*.ttf binary +*.eot binary +*.otf binary +*.woff binary +*.woff2 binary diff --git a/src/main/webapp/app/table-screen-vs/table-screen-vs.component.html b/src/main/webapp/app/table-screen-vs/table-screen-vs.component.html new file mode 100644 index 0000000..6df2433 --- /dev/null +++ b/src/main/webapp/app/table-screen-vs/table-screen-vs.component.html @@ -0,0 +1,74 @@ +
+
+ + Search by Name + + +
+ + +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Id{{ item.id }} Last Modified{{ item.lastMod }}Actions + +
+ + + +
+
No data matching the filter "{{ input.value }}"
+ +
+
+
+ + + + + +
{{ tab.title }}
+ +
+ +
+ +
+ + +
+
+
+
diff --git a/src/main/webapp/app/table-screen-vs/table-screen-vs.component.scss b/src/main/webapp/app/table-screen-vs/table-screen-vs.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/main/webapp/app/table-screen-vs/table-screen-vs.component.ts b/src/main/webapp/app/table-screen-vs/table-screen-vs.component.ts new file mode 100644 index 0000000..9a5367b --- /dev/null +++ b/src/main/webapp/app/table-screen-vs/table-screen-vs.component.ts @@ -0,0 +1,187 @@ +/* eslint-disable @typescript-eslint/no-unnecessary-condition */ +import { + Component, + Output, + EventEmitter, + OnInit, + ViewChild, + AfterViewInit, + OnChanges, + SimpleChanges, + Input, + QueryList, +} from '@angular/core'; + +import { MatTableDataSource } from '@angular/material/table'; +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 { MatDialogRef, MatDialog, MatDialogConfig } from '@angular/material/dialog'; +import { ITabbedEntity } from 'app/i-tabbed-entity'; +import { ResourcesImplService } from 'app/services/resources-impl.service'; +import { IResource } from 'app/services/i-resource'; +import { IResourceType } from 'app/services/i-resource-type'; +import { MatFormFieldControl } from '@angular/material/form-field'; + +import { FacetComposerComponent } from 'app/facet-composer/facet-composer.component'; +import { FacetEditorComponent } from 'app/facet-editor/facet-editor.component'; +import { IVirtualService } from 'app/services/i-virtual-service'; + + +@Component({ + selector: 'jhi-table-screen-vs', + templateUrl: './table-screen-vs.component.html', + styleUrls: ['./table-screen-vs.component.scss'], + //NB->dialog form is a provider + providers: [{provide:MatFormFieldControl, + // useExisting:ResourceAddComponent }, + useExisting:FacetComposerComponent }, + ResourcesImplService] +}) + + +export class TableScreenVsComponent implements OnInit, AfterViewInit, OnChanges { + displayedColumns: string[] = ['id','lastMod']; + dataFromService: IVirtualService[]; + dataSource = new MatTableDataSource(); + tableDetail: IVirtualService; + dialogAddRef: MatDialogRef |undefined; + errorMessage = ''; + + @Input() currentCtx: IContextNode; //fetching event from parent + @Input() currentCtxPath: string; //fetching event from parent + @Input() typeObject: IResource; + @Output() jsonEmitter = new EventEmitter(); + @ViewChild(MatSort) sort: MatSort; + @ViewChild(MatPaginator) paginator: MatPaginator; + + //per tabbed view + @ViewChild(MatTab) + public tabGroup: MatTabGroup | any; + public tabNodes: QueryList | any; + public closedTabs = []; + public tabs: ITabbedEntity[] = [{ title: 'JSON View', content: '', type: 0, id: '' }]; + selectedIdx = 0; + chosenIds: string[] = []; + rawJson: string; + ////////// fine tabbed view + + constructor(private myDataService: ResourcesImplService, private createDialog: MatDialog, private editDialog: MatDialog) { + this.currentCtx = {} as IContextNode; + this.tableDetail = {} as IVirtualService; + this.dataFromService = []; + this.sort = new MatSort(); + this.paginator = {} as MatPaginator; + //this.resourceType = ''; + this.typeObject = {} as IResourceType; + this.currentCtxPath = ''; + this.rawJson = ''; + } + + ngAfterViewInit(): void { + this.dataSource.sort = this.sort; + this.dataSource.paginator = this.paginator; + } + + + ngOnInit(): void { + + let ctxPath = ''; + if(this.currentCtx.path !== undefined){ + ctxPath = this.currentCtx.path; + }else if(this.currentCtxPath !== undefined){ + ctxPath = this.currentCtxPath + } + + this.myDataService.fetchResourceImpls(ctxPath,this.typeObject.name).subscribe(res => { + this.dataFromService = res; + this.dataSource.data = res; + //this is to filter only on the 'name' property + this.dataSource.filterPredicate = function (record:any,filter:string) { + return record.name.indexOf(filter)!==-1; + } + }); + } + + ngOnChanges(changes: SimpleChanges): void { + + for (const propName in changes) { + if (propName === 'currentCtx') { + const param = changes[propName]; + this.currentCtx = param.currentValue; + //controllo che l'oggetto non sia vuoto + if (Object.keys(this.currentCtx).length !== 0) { + this.myDataService.fetchResourceImpls(this.currentCtx.path,this.typeObject.name).subscribe(res => { + this.dataFromService = res; + this.dataSource.data = res; + }); + } + } + } + } + + applyFilter(event: Event): void { + const filterValue = (event.target as HTMLInputElement).value; + this.dataSource.filter = filterValue.trim().toLowerCase(); + } + + // for the dynamic tabbed pane + + removeTab(index: number): void { + this.tabs.splice(index, 1); + } + + addTab(itemId: string): void { + if (!this.chosenIds.includes(itemId)) { + const newItem = { + id: itemId, + title: itemId.substring(0, 20) + '...', + //TODO: content a regime รจ la stringa JSON + content: itemId, + type: 0, + }; + this.selectedIdx++; + this.chosenIds.push(itemId); + this.tabs.push(newItem); + } + } + +reloadTable():void{ + this.myDataService.fetchResourceImpls(this.currentCtx.path,this.typeObject.name).subscribe(res => { + this.dataFromService = res; + this.dataSource.data = res; + }) + } + + closeTab(index: number): void { + + const x = this.chosenIds.indexOf(this.tabs[index].id); + if (x !== -1) { + this.chosenIds.splice(x, 1); + } + + // this.closedTabs.push(index); + this.tabGroup.selectedIndex = this.tabs.length - 1; + //this.chosenIds.indexOf(); + this.tabs.splice(index, 1); + } + + openFacetComposer(): void { + const dialogConfig = new MatDialogConfig(); + dialogConfig.disableClose = true; + dialogConfig.autoFocus = true; + dialogConfig.data= {type: this.typeObject, context: this.currentCtx}; + this.createDialog.open(FacetComposerComponent,dialogConfig); + +} + + openFacetEditor(uid: string): void { + const dialogConfig = new MatDialogConfig(); + dialogConfig.disableClose = true; + dialogConfig.autoFocus = true; + dialogConfig.data= {type: this.typeObject, context: this.currentCtx, uid}; + this.editDialog.open(FacetEditorComponent,dialogConfig); + } + +} diff --git a/src/main/webapp/app/table-screen-vs/table-screen-vs.module.ts b/src/main/webapp/app/table-screen-vs/table-screen-vs.module.ts new file mode 100644 index 0000000..cf76145 --- /dev/null +++ b/src/main/webapp/app/table-screen-vs/table-screen-vs.module.ts @@ -0,0 +1,31 @@ +import { NgModule } from '@angular/core'; +import { SharedModule } from 'app/shared/shared.module'; +import { MatTableModule } from '@angular/material/table'; +import { MatIconModule } from '@angular/material/icon'; +import { MatSortModule } from '@angular/material/sort'; +import { MatPaginatorModule } from '@angular/material/paginator'; +import { RawjsonPaneComponent } from 'app/rawjson-pane/rawjson-pane.component'; +import { MAT_DIALOG_DEFAULT_OPTIONS, MatDialogModule } from '@angular/material/dialog'; +import { ResourceAddComponent } from 'app/resource-add/resource-add.component'; +import { TypeHeadlineModule } from 'app/type-headline/type-headline.module'; +import { AsyncPipe } from '@angular/common'; +import { RouterModule } from '@angular/router'; +import { TableScreenVsComponent } from './table-screen-vs.component'; + +@NgModule({ + imports: [ + SharedModule,MatTableModule,MatIconModule,MatSortModule, + MatPaginatorModule, MatDialogModule, RawjsonPaneComponent, + TypeHeadlineModule, AsyncPipe, RouterModule + ], + + declarations:[TableScreenVsComponent], + exports: [TableScreenVsComponent], + //NB: QUI VA DICHIARATO IL DIALOG DI DATAENTRY COME COMPONENT + entryComponents: [ResourceAddComponent], + bootstrap: [TableScreenVsComponent], +}) + + + +export class TableScreenVsModule { } diff --git a/src/main/webapp/app/table-screen/table-screen.component.ts b/src/main/webapp/app/table-screen/table-screen.component.ts index b3bdd80..39129b4 100644 --- a/src/main/webapp/app/table-screen/table-screen.component.ts +++ b/src/main/webapp/app/table-screen/table-screen.component.ts @@ -24,10 +24,8 @@ import { MatDialogRef, MatDialog, MatDialogConfig } from '@angular/material/dial import { ITabbedEntity } from 'app/i-tabbed-entity'; import { IHostingNode } from 'app/services/i-hosting-node'; import { ResourcesImplService } from 'app/services/resources-impl.service'; -//import { ResourceAddComponent } from 'app/resource-add/resource-add.component'; import { IResource } from 'app/services/i-resource'; import { IResourceType } from 'app/services/i-resource-type'; -import { DummyService } from 'app/services/dummy.service'; import { MatFormFieldControl } from '@angular/material/form-field'; import { FacetComposerComponent } from 'app/facet-composer/facet-composer.component'; @@ -41,7 +39,7 @@ import { FacetEditorComponent } from 'app/facet-editor/facet-editor.component'; providers: [{provide:MatFormFieldControl, // useExisting:ResourceAddComponent }, useExisting:FacetComposerComponent }, - ResourcesImplService, DummyService], + ResourcesImplService] }) export class TableScreenComponent implements OnInit, AfterViewInit, OnChanges { //NB 'actions' CI DEVE ESSERE, altrimenti la tabella non viene visualizzata diff --git a/src/main/webapp/app/table-screen/table-screen.module.ts b/src/main/webapp/app/table-screen/table-screen.module.ts index 4b8265d..99ed1b8 100644 --- a/src/main/webapp/app/table-screen/table-screen.module.ts +++ b/src/main/webapp/app/table-screen/table-screen.module.ts @@ -23,10 +23,6 @@ import { RouterModule } from '@angular/router'; //NB: QUI VA DICHIARATO IL DIALOG DI DATAENTRY COME COMPONENT entryComponents: [ResourceAddComponent], bootstrap: [TableScreenComponent], - /* - providers: [{provide: MAT_DIALOG_DEFAULT_OPTIONS, - useValue: { height: '200px', width: '250px', autoFocus: true }}] - */ }) export class TableScreenModule {