|
1 | 1 | # Build a Dedicated AI Section in Angular with Submenu Navigation |
2 | 2 |
|
3 | | -## How to Refactor a Tabbed Widget into Four Focused Standalone Pages |
| 3 | +## How to Build Four Focused Standalone Pages with Sidebar Sub-Menu Navigation |
4 | 4 |
|
5 | | -A single component with tabs works well for two modes. It breaks down at four. This article refactors the TalentManagement Angular app's AI features from a single `ai-chat` route with tabs into a proper **AI submenu** — four dedicated pages, each with a single responsibility, registered as children of an `ai` route group in the sidebar. |
| 5 | +AI features deserve their own section. This article adds a proper **AI submenu** to the TalentManagement Angular app — four dedicated pages, each with a single responsibility, registered as children of an `ai` route group in the sidebar. Each page is a standalone Angular component with its own route, template, and styles. |
6 | 6 |
|
7 | 7 |  |
8 | 8 |
|
@@ -192,7 +192,7 @@ src/app/routes/ai/ |
192 | 192 |
|
193 | 193 | #### AI Assistant Component |
194 | 194 |
|
195 | | -This page extracts the "General Chat" tab from the original `ai-chat` page and gives it a dedicated route. |
| 195 | +This page provides general-purpose chat with the LLM at a dedicated route. |
196 | 196 |
|
197 | 197 | **`ai-assistant.component.ts`:** |
198 | 198 |
|
@@ -274,15 +274,15 @@ export class AiAssistantComponent implements OnDestroy { |
274 | 274 |
|
275 | 275 | **Key design decisions:** |
276 | 276 |
|
277 | | -* **Extracted from the old `AiChatComponent` General Chat tab** — All the chat logic moved here unchanged. The only difference is the selector name and that it's no longer wrapped in a `MatTabGroup`. |
| 277 | +* **Single responsibility** — This component handles only the general chat flow. HR Insight, NL Search, and Vector Search each live in their own component. |
278 | 278 | * **`private destroy$ = new Subject<void>()`** — The `takeUntil` pattern ensures in-flight Ollama requests are cancelled cleanly when the user navigates away. |
279 | 279 | * **State is scoped to this component** — Navigating to HR Insight and back does not clear the chat history here. |
280 | 280 |
|
281 | 281 | --- |
282 | 282 |
|
283 | 283 | #### HR Insight Component |
284 | 284 |
|
285 | | -Extracts the "HR Insights" tab. Full implementation follows the same pattern as AI Assistant — replace `chat()` with `hrInsight()` and add the suggestion chips. |
| 285 | +Provides data-aware chat grounded in live workforce metrics. Full implementation follows the same pattern as AI Assistant — replace `chat()` with `hrInsight()` and add the suggestion chips. |
286 | 286 |
|
287 | 287 | The `ai-hr-insight.component.ts` structure is identical to AI Assistant, differing only in: |
288 | 288 | * Calls `aiService.hrInsight(question)` instead of `aiService.chat(message)` |
@@ -435,18 +435,18 @@ public/ |
435 | 435 |
|
436 | 436 | ## 📊 Real-World Impact |
437 | 437 |
|
438 | | -**Before this article:** |
| 438 | +**Without this structure:** |
439 | 439 |
|
440 | | -* ❌ One page with two tabs — grows unmanageable as AI features are added |
441 | | -* ❌ Single route `/ai-chat` — no URL structure for bookmarking or deep linking |
442 | | -* ❌ All AI features in one file — a change to HR Insight breaks the General Chat component |
| 440 | +* ❌ A flat sidebar link gives AI one entry point — no room to grow |
| 441 | +* ❌ Mixing AI features in a single component creates tight coupling — a change to HR Insight risks breaking General Chat |
| 442 | +* ❌ No URL structure for bookmarking or deep linking into specific AI tools |
443 | 443 |
|
444 | | -**After this article:** |
| 444 | +**With this structure:** |
445 | 445 |
|
446 | 446 | * ✅ Four focused pages — each component is ~80 lines, easy to read and test independently |
447 | 447 | * ✅ Clean URL structure — `/ai/assistant`, `/ai/hr-insight`, `/ai/nl-search`, `/ai/vector-search` |
448 | 448 | * ✅ Sidebar group — users discover all four AI features naturally via the collapsible sub-menu |
449 | | -* ✅ Zero breakage — the backward-compat redirect keeps existing bookmarks working |
| 449 | +* ✅ Backward-compat redirect — any old `/ai-chat` bookmarks silently redirect to `/ai/assistant` |
450 | 450 |
|
451 | 451 | --- |
452 | 452 |
|
@@ -481,7 +481,8 @@ The refactoring from tabs to child routes mirrors how any growing feature sectio |
481 | 481 | * [Run a Local LLM in Your .NET 10 API with Ollama](6.1-dotnet-ai-foundation.md) — AI Foundation (Series 6.1) |
482 | 482 | * [Build an HR AI Assistant That Knows Your Data](6.2-dotnet-ai-hr-assistant.md) — HR AI Assistant (Series 6.2) |
483 | 483 | * **This Article** — Build a Dedicated AI Section in Angular with Submenu Navigation (Series 6.3) |
484 | | -* [Natural Language Employee Search in Angular Material](6.4-angular-ai-nl-search.md) — NL Search (Series 6.4) |
| 484 | +* [Natural Language Employee Search in Angular Material](6.4-angular-ai-nl-search.md) — NL Search Angular (Series 6.4) |
| 485 | +* [Natural Language Employee Search with LLM Query Parsing](6.4.1-dotnet-natural-language-search.md) — NL Search .NET backend (Series 6.4.1) |
485 | 486 | * [Semantic Position Search with Vector Embeddings](6.5-angular-ai-vector-search.md) — Vector Search (Series 6.5) |
486 | 487 |
|
487 | 488 | --- |
|
0 commit comments