Skip to content

Commit de990a2

Browse files
committed
NIFI-14319: address initial feedback
* check if window.matchMedia has value before calling method * add empty states to explorer table * destroy direct store subscriptions * add filtered count to droplet table filter
1 parent 971ce0e commit de990a2

File tree

8 files changed

+91
-10
lines changed

8 files changed

+91
-10
lines changed

nifi-frontend/src/main/frontend/apps/nifi-registry/src/app/app.module.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,21 @@ import { ExplorerModule } from './pages/expolorer/feature/explorer.module';
3737
import { BucketsEffects } from './state/buckets/buckets.effects';
3838

3939
const entry = localStorage.getItem('disable-animations');
40-
let disableAnimations: string = entry !== null ? JSON.parse(entry).item : '';
40+
let disableAnimations = '';
41+
42+
try {
43+
disableAnimations = entry !== null ? JSON.parse(entry).item : '';
44+
} catch (error) {
45+
/* empty */
46+
}
4147

4248
// honor OS settings if user has not explicitly disabled animations for the application
43-
if (disableAnimations !== 'true' && disableAnimations !== 'false') {
44-
disableAnimations = window.matchMedia('(prefers-reduced-motion: reduce)').matches.toString();
49+
try {
50+
if (disableAnimations !== 'true' && disableAnimations !== 'false') {
51+
disableAnimations = window.matchMedia('(prefers-reduced-motion: reduce)').matches.toString();
52+
}
53+
} catch (error) {
54+
/* empty */
4555
}
4656

4757
@NgModule({

nifi-frontend/src/main/frontend/apps/nifi-registry/src/app/pages/expolorer/feature/explorer.component.html

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<h3 class="primary-color">Flows</h3>
2121
<div class="flex justify-between items-center">
2222
<droplet-table-filter [buckets]="buckets" [filterTerm]="filterTerm" [filterBucket]="filterBucket"
23-
[filterColumn]="filterColumn" (filterChanged)="applyFilter($event)"></droplet-table-filter>
23+
[filterColumn]="filterColumn" [filteredCount]="dataSource.filteredData.length" [totalCount]="dataSource.data.length" (filterChanged)="applyFilter($event)"></droplet-table-filter>
2424
<button mat-flat-button (click)="openImportNewFlowDialog()">Import New Flow</button>
2525
</div>
2626
@if (droplets$; as droplets) {
@@ -123,6 +123,15 @@ <h3 class="primary-color">Flows</h3>
123123
<tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: true"></tr>
124124
<tr mat-row *matRowDef="let row; let even = even; columns: displayedColumns"></tr>
125125
</table>
126+
<div class="py-5" *ngIf="dataSource.filteredData.length === 0 && buckets.length !== 0 && filterTerm">
127+
<p class="text-center">No results match this query.</p>
128+
</div>
129+
<div class="py-5" *ngIf="dataSource.data.length === 0 && buckets.length === 0">
130+
<p class="text-center">There are no buckets to display.</p>
131+
</div>
132+
<div class="py-5" *ngIf="dataSource.data.length === 0 && buckets.length !== 0">
133+
<p class="text-center">There are no flows to display.</p>
134+
</div>
126135
</div>
127136
</div>
128137
}

nifi-frontend/src/main/frontend/apps/nifi-registry/src/app/pages/expolorer/feature/explorer.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ export class ExplorerComponent implements OnInit {
7272
private router: Router,
7373
private activatedRoute: ActivatedRoute
7474
) {
75-
this.droplets$ = this.store.select(selectDroplets);
76-
this.buckets$ = this.store.select(selectBuckets);
75+
this.droplets$ = this.store.select(selectDroplets).pipe(takeUntilDestroyed());
76+
this.buckets$ = this.store.select(selectBuckets).pipe(takeUntilDestroyed());
7777
this.store
7878
.select(selectQueryParams)
7979
.pipe(takeUntilDestroyed())

nifi-frontend/src/main/frontend/apps/nifi-registry/src/app/pages/expolorer/feature/ui/droplet-table-filter/droplet-table-filter.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@
4848
</div>
4949
</div>
5050
</form>
51-
<!-- <div class="my-2 tertiary-color font-medium">Filter matched {{ filteredCount }} of {{ totalCount }}</div> -->
51+
<div class="my-2 tertiary-color font-medium">Filter matched {{ filteredCount }} of {{ totalCount }}</div>
5252
</div>
5353
</div>

nifi-frontend/src/main/frontend/apps/nifi-registry/src/app/pages/expolorer/feature/ui/droplet-table-filter/droplet-table-filter.component.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ export class DropletTableFilterComponent implements AfterViewInit {
5353
private _initialFilterColumn = 'name';
5454
private _filterableColumns: DropletTableFilterColumn[] = [];
5555
private _buckets: Bucket[] = [];
56+
private _filteredCount = 0;
57+
private _totalCount = 0;
5658
private destroyRef: DestroyRef = inject(DestroyRef);
5759

5860
set filterableColumns(filterableColumns: DropletTableFilterColumn[]) {
@@ -90,6 +92,22 @@ export class DropletTableFilterComponent implements AfterViewInit {
9092
this.filterForm.controls['filterBucket']?.setValue(term);
9193
}
9294

95+
@Input() set filteredCount(filteredCount: number) {
96+
this._filteredCount = filteredCount;
97+
}
98+
99+
get filteredCount(): number {
100+
return this._filteredCount;
101+
}
102+
103+
@Input() set totalCount(totalCount: number) {
104+
this._totalCount = totalCount;
105+
}
106+
107+
get totalCount(): number {
108+
return this._totalCount;
109+
}
110+
93111
@Output() filterChanged: EventEmitter<DropletTableFilterContext> = new EventEmitter<DropletTableFilterContext>();
94112

95113
constructor(private formBuilder: FormBuilder) {

nifi-frontend/src/main/frontend/apps/nifi/src/app/app.module.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,21 @@ import { CLIPBOARD_OPTIONS, provideMarkdown } from 'ngx-markdown';
5959
import { CopyEffects } from './state/copy/copy.effects';
6060

6161
const entry = localStorage.getItem('disable-animations');
62-
let disableAnimations: string = entry !== null ? JSON.parse(entry).item : '';
62+
let disableAnimations: string = '';
63+
64+
try {
65+
disableAnimations = entry !== null ? JSON.parse(entry).item : '';
66+
} catch (error) {
67+
/* empty */
68+
}
6369

6470
// honor OS settings if user has not explicitly disabled animations for the application
65-
if (disableAnimations !== 'true' && disableAnimations !== 'false') {
66-
disableAnimations = window.matchMedia('(prefers-reduced-motion: reduce)').matches.toString();
71+
try {
72+
if (disableAnimations !== 'true' && disableAnimations !== 'false') {
73+
disableAnimations = window.matchMedia('(prefers-reduced-motion: reduce)').matches.toString();
74+
}
75+
} catch (error) {
76+
/* empty */
6777
}
6878

6979
export const customTooltipDefaults: MatTooltipDefaultOptions = {
Loading
Lines changed: 17 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)