Skip to content

Commit 3d6bb30

Browse files
committed
Log feed improvements
1 parent 3410cef commit 3d6bb30

File tree

2 files changed

+96
-53
lines changed

2 files changed

+96
-53
lines changed

SampleApp/src/app/features/features.component.html

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,52 +1199,32 @@ <h3>Using Convenience Configuration Objects</h3>
11991199
<mat-chip-listbox aria-label="Feed Filters" class="inline-chips">
12001200
<mat-chip-option
12011201
[selected]="feedFilter.size === 0"
1202-
(click)="feedFilter.clear()"
1202+
(click)="clearFilters()"
12031203
>All</mat-chip-option
12041204
>
12051205
<mat-chip-option
1206-
[selected]="feedFilter.has('documentLoad')"
1207-
(click)="
1208-
feedFilter.has('documentLoad')
1209-
? feedFilter.delete('documentLoad')
1210-
: feedFilter.add('documentLoad')
1211-
"
1212-
>Document</mat-chip-option
1206+
[selected]="feedFilter.has('document')"
1207+
(click)="selectFilterCategory('document')"
1208+
>Document & Viewer</mat-chip-option
12131209
>
12141210
<mat-chip-option
1215-
[selected]="feedFilter.has('pageRendered')"
1216-
(click)="
1217-
feedFilter.has('pageRendered')
1218-
? feedFilter.delete('pageRendered')
1219-
: feedFilter.add('pageRendered')
1220-
"
1211+
[selected]="feedFilter.has('render')"
1212+
(click)="selectFilterCategory('render')"
12211213
>Render</mat-chip-option
12221214
>
12231215
<mat-chip-option
12241216
[selected]="feedFilter.has('find')"
1225-
(click)="
1226-
feedFilter.has('find')
1227-
? feedFilter.delete('find')
1228-
: feedFilter.add('find')
1229-
"
1217+
(click)="selectFilterCategory('find')"
12301218
>Find</mat-chip-option
12311219
>
12321220
<mat-chip-option
1233-
[selected]="feedFilter.has('outlineLoaded')"
1234-
(click)="
1235-
feedFilter.has('outlineLoaded')
1236-
? feedFilter.delete('outlineLoaded')
1237-
: feedFilter.add('outlineLoaded')
1238-
"
1221+
[selected]="feedFilter.has('outline')"
1222+
(click)="selectFilterCategory('outline')"
12391223
>Outline</mat-chip-option
12401224
>
12411225
<mat-chip-option
1242-
[selected]="feedFilter.has('documentError')"
1243-
(click)="
1244-
feedFilter.has('documentError')
1245-
? feedFilter.delete('documentError')
1246-
: feedFilter.add('documentError')
1247-
"
1226+
[selected]="feedFilter.has('error')"
1227+
(click)="selectFilterCategory('error')"
12481228
>Errors</mat-chip-option
12491229
>
12501230
</mat-chip-listbox>

SampleApp/src/app/features/features.component.ts

Lines changed: 85 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,82 @@ export class FeaturesComponent implements OnInit {
142142
public feedPaused = false;
143143
public feedFilter: Set<string> = new Set();
144144

145+
// Select a single filter category (exclusive selection)
146+
// Clicking a filter button selects only that category and clears others
147+
public selectFilterCategory(category: string): void {
148+
// If clicking the same category that's already selected, deselect it (show all)
149+
if (this.feedFilter.has(category) && this.feedFilter.size === 1) {
150+
this.feedFilter = new Set();
151+
} else {
152+
// Select only this category (exclusive)
153+
this.feedFilter = new Set([category]);
154+
}
155+
}
156+
157+
// Clear all filters (for "All" button)
158+
public clearFilters(): void {
159+
this.feedFilter = new Set();
160+
}
161+
162+
// Map event types to categories
163+
// Categories match the filter buttons in the UI: document, render, find, outline, error
164+
// IMPORTANT: Order matters - check specific categories first, then broader ones
165+
private getEventCategory(eventType: string): string {
166+
// Render events - visual rendering of pages and annotations ONLY
167+
// Check this FIRST to avoid false matches (e.g., pageChange should NOT match pageRendered)
168+
if (['pageRendered', 'annotationLayerRendered'].includes(eventType)) {
169+
return 'render';
170+
}
171+
172+
// Find events - search functionality
173+
if (['find', 'updateFindMatchesCount'].includes(eventType)) {
174+
return 'find';
175+
}
176+
177+
// Outline events - navigation structure (bookmarks/outline)
178+
if (['outlineLoaded', 'bookmarkClick'].includes(eventType)) {
179+
return 'outline';
180+
}
181+
182+
// Error events - error conditions
183+
if (['documentError'].includes(eventType)) {
184+
return 'error';
185+
}
186+
187+
// Document events - document lifecycle, viewer navigation, and print operations
188+
// Note: "Document" button includes document lifecycle + navigation + print
189+
// This is broader than ideal, but keeps the UI simple with 5 buttons
190+
if (['documentLoad', 'documentInit', 'pagesInit', 'metadataLoaded', 'openFile',
191+
'pageChange', 'scaleChange', 'rotationChange', 'presentationModeChanged',
192+
'beforePrint', 'afterPrint'].includes(eventType)) {
193+
return 'document';
194+
}
195+
196+
// System/other events - internal events that don't fit other categories
197+
// These will show when "All" is selected but won't have a dedicated filter button
198+
if (['idle'].includes(eventType)) {
199+
return 'other';
200+
}
201+
202+
// Default - uncategorized events
203+
return 'other';
204+
}
205+
145206
// Getter for filtered events
146207
get filteredEventFeed() {
208+
// If no filters selected, show all events
147209
if (this.feedFilter.size === 0) {
148210
return this.eventFeed;
149211
}
150-
return this.eventFeed.filter((event) => this.feedFilter.has(event.type));
212+
213+
// Filter events by category - only include events whose category is in the selected filters
214+
const filtered = this.eventFeed.filter((event) => {
215+
const category = this.getEventCategory(event.type);
216+
const isSelected = this.feedFilter.has(category);
217+
return isSelected;
218+
});
219+
220+
return filtered;
151221
}
152222

153223
private pushEventToFeed(type: string, data?: any) {
@@ -171,28 +241,21 @@ export class FeaturesComponent implements OnInit {
171241

172242
// Get CSS class for event type based on category
173243
public getEventTypeClass(type: string): string {
174-
// Document events
175-
if (type.includes('document') || type.includes('metadata')) {
176-
return 'event-document';
177-
}
178-
// Render events
179-
if (type.includes('render') || type.includes('Rendered')) {
180-
return 'event-render';
181-
}
182-
// Find events
183-
if (type.includes('find') || type.includes('Find')) {
184-
return 'event-find';
185-
}
186-
// Outline events
187-
if (type.includes('outline') || type.includes('bookmark')) {
188-
return 'event-outline';
189-
}
190-
// Error events
191-
if (type.includes('error') || type.includes('Error')) {
192-
return 'event-error';
244+
const category = this.getEventCategory(type);
245+
switch (category) {
246+
case 'document':
247+
return 'event-document';
248+
case 'render':
249+
return 'event-render';
250+
case 'find':
251+
return 'event-find';
252+
case 'outline':
253+
return 'event-outline';
254+
case 'error':
255+
return 'event-error';
256+
default:
257+
return 'event-default';
193258
}
194-
// Default
195-
return 'event-default';
196259
}
197260

198261
// Event tracking for demonstration

0 commit comments

Comments
 (0)