added components and directives for Bootstrap tables ordering and

filtering
This commit is contained in:
Maria Teresa Paratore 2023-10-12 17:07:48 +02:00
parent ad55f05b57
commit da9db179ff
8 changed files with 56 additions and 40 deletions

View File

@ -83,11 +83,10 @@
"@angular/platform-browser": "14.2.0",
"@angular/platform-browser-dynamic": "14.2.0",
"@angular/router": "14.2.0",
"ng-bootstrap/ng-bootstrap": "15.1.1",
"@fortawesome/angular-fontawesome": "0.11.1",
"@fortawesome/fontawesome-svg-core": "6.2.0",
"@fortawesome/free-solid-svg-icons": "6.2.0",
"@ng-bootstrap/ng-bootstrap": "13.0.0",
"@ng-bootstrap/ng-bootstrap": "15.1.1",
"@ngx-translate/core": "14.0.0",
"@ngx-translate/http-loader": "7.0.0",
"@popperjs/core": "2.11.6",
@ -98,7 +97,8 @@
"ngx-webstorage": "10.0.1",
"rxjs": "7.5.6",
"tslib": "2.4.0",
"zone.js": "0.11.6"
"zone.js": "0.11.6",
"typescript": "5.0.4"
},
"devDependencies": {
"@angular-builders/custom-webpack": "14.0.1",

View File

@ -25,8 +25,8 @@ import { FooterComponent } from './layouts/footer/footer.component';
import { PageRibbonComponent } from './layouts/profiles/page-ribbon.component';
import { ActiveMenuDirective } from './layouts/navbar/active-menu.directive';
import { ErrorComponent } from './layouts/error/error.component';
import { TableNodesComponent } from './table-nodes/table-nodes.component';
import { SortableDirective } from './table-nodes/sortable.directive';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
@NgModule({
imports: [
@ -40,8 +40,8 @@ import { SortableDirective } from './table-nodes/sortable.directive';
HttpClientModule,
NgxWebstorageModule.forRoot({ prefix: 'jhi', separator: '-', caseSensitive: true }),
TranslationModule,
TableNodesComponent,
SortableDirective
SortableDirective,
NgbModule
],
providers: [
Title,

View File

@ -36,12 +36,11 @@ function sort(hnodes: IHostingnode[], column: SortColumn, direction: string): IH
}
}
//matching SOLO sul campo UUID
function matches(hnode: IHostingnode, term: string, pipe: PipeTransform){
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return (
hnode.name.toLowerCase().includes(term.toLowerCase()) ||
pipe.transform(hnode.id).includes(term) ||
pipe.transform(hnode.status).includes(term)
pipe.transform(hnode.id).includes(term.toLowerCase())
);
}

View File

@ -14,9 +14,11 @@ import { SortDirective } from './sort/sort.directive';
import { ItemCountComponent } from './pagination/item-count.component';
import { FilterComponent } from './filter/filter.component';
import { ContextTransformPipe } from './pipe/contexttransform.pipe';
import { NgbPagination, NgbTypeahead } from '@ng-bootstrap/ng-bootstrap';
import { SortableDirective } from 'app/table-nodes/sortable.directive';
@NgModule({
imports: [SharedLibsModule],
imports: [SharedLibsModule,SortableDirective],
declarations: [
FindLanguageFromKeyPipe,
TranslateDirective,
@ -30,7 +32,8 @@ import { ContextTransformPipe } from './pipe/contexttransform.pipe';
SortDirective,
ItemCountComponent,
FilterComponent,
ContextTransformPipe
ContextTransformPipe,
],
exports: [
SharedLibsModule,
@ -46,7 +49,10 @@ import { ContextTransformPipe } from './pipe/contexttransform.pipe';
SortDirective,
ItemCountComponent,
FilterComponent,
ContextTransformPipe
ContextTransformPipe,
NgbPagination,
NgbTypeahead,
SortableDirective
],
})
export class SharedModule {}

View File

@ -1,3 +1,4 @@
/* eslint-disable @angular-eslint/directive-selector */
/* eslint-disable @angular-eslint/no-host-metadata-property */
import { Directive, EventEmitter, Input, Output } from '@angular/core';
import { IHostingnode } from 'app/services/i-hostinngnode';
@ -14,7 +15,7 @@ export interface SortEvent {
@Directive({
selector: '[jhiSortable]',
selector: 'th[sortable]',
standalone: true,
host: {
'[class.asc]': 'direction === "asc"',

View File

@ -1,10 +1,12 @@
<div class="mb-3 row">
<form>
<div class="mb-3 row">
<label for="table-complete-search" class="col-xs-3 col-sm-auto col-form-label">Full text search:</label>
<div class="col-xs-3 col-sm-auto">
<input type="text" id="table-complete-search"
[(ngModel)]="service.searchTerm"
class="form-control"
name="searchTerm"
[(ngModel)]="service.searchTerm"/>
/>
</div>
<span class="col col-form-label" *ngIf="service.loading$ | async">Loading...</span>
</div>
@ -12,26 +14,22 @@
<thead>
<tr>
<th scope="col">#</th>
<th scope="col" sortable="name" (sort)="onSort($event)">Country</th>
<th scope="col" sortable="id" (sort)="onSort($event)">Area</th>
<th scope="col" sortable="status" (sort)="onSort($event)">Population</th>
<th scope="col" sortable="status" (sort)="onSort($event)">Population</th>
<th scope="col" sortable="status" (sort)="onSort($event)">Population</th>
<!--<th scope="col" sortable="type" (sort)="onSort($event)">Type</th>-->
<th scope="col" sortable="name" (sort)="onSort($event)">Name</th>
<th scope="col" sortable="id" (sort)="onSort($event)">Id</th>
<th scope="col" sortable="status" (sort)="onSort($event)">Status</th>
<th scope="col" sortable="lastmod" (sort)="onSort($event)">Lat Modified</th>
<th scope="col" sortable="memavailable" (sort)="onSort($event)">Available Memory</th>
<th scope="col" sortable="hdspace" (sort)="onSort($event)">HD Space</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let country of countries$ | async">
<th scope="row">{{ country.id }}</th>
<td>
<img
[src]="'https://upload.wikimedia.org/wikipedia/commons/' + country.flag"
class="me-2"
style="width: 20px"
/>
<ngb-highlight [result]="country.name" [term]="service.searchTerm"></ngb-highlight>
</td>
<td><ngb-highlight [result]="country.area | number" [term]="service.searchTerm"></ngb-highlight></td>
<td><ngb-highlight [result]="country.population | number" [term]="service.searchTerm"></ngb-highlight></td>
<tr *ngFor="let hnode of hnodes$ | async">
<th scope="row">{{ hnode.id }}</th>
<td><ngb-highlight [result]="hnode.name" [term]="service.searchTerm"></ngb-highlight></td>
<td><ngb-highlight [result]="hnode.id" [term]="service.searchTerm"></ngb-highlight></td>
<td><ngb-highlight [result]="hnode.memavailable" [term]="service.searchTerm"></ngb-highlight></td>
<td><ngb-highlight [result]="hnode.hdspace" [term]="service.searchTerm"></ngb-highlight></td>
</tr>
</tbody>
</table>

View File

@ -1,14 +1,10 @@
import { Component, Input, OnInit, Output, QueryList, ViewChildren } from '@angular/core';
import { IContextNode } from 'app/services/i-context-node';
import { Component, QueryList, ViewChildren } from '@angular/core';
import { IHostingnode } from 'app/services/i-hostinngnode';
import { HnodesLoaderService } from 'app/services/hnodes-loader.service';
//import EventEmitter from 'events';
/////////
import { AsyncPipe, DecimalPipe, NgIf } from '@angular/common';
import { DecimalPipe, NgIf } from '@angular/common';
import { Observable } from 'rxjs';
import { SortableDirective, SortEvent } from './sortable.directive';
import { FormsModule } from '@angular/forms';
import { NgbPaginationModule, NgbTypeaheadModule } from '@ng-bootstrap/ng-bootstrap';
/*
Tabella con paginazione, ordinamento e ricerca - dati presi da servizio
*/
@ -18,8 +14,8 @@ Tabella con paginazione, ordinamento e ricerca - dati presi da servizio
selector: 'jhi-table-nodes',
templateUrl: './table-nodes.component.html',
styleUrls: ['./table-nodes.component.scss'],
standalone: true,
providers: [HnodesLoaderService, DecimalPipe],
})
export class TableNodesComponent{

View File

@ -0,0 +1,16 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { SharedModule } from 'app/shared/shared.module';
import { TableNodesComponent } from './table-nodes.component';
@NgModule({
declarations: [TableNodesComponent],
entryComponents: [TableNodesComponent],
imports: [
CommonModule,
SharedModule,
]
})
export class TableNodesModule { }