### Sakai-NG CLI Development Commands Source: https://context7.com/primefaces/sakai-ng/llms.txt Provides essential command-line interface commands for developing the Sakai-NG Angular application. These commands cover dependency installation, starting the development server, building for production, running unit tests, generating new components, and formatting code. ```bash # Install dependencies npm install # Start development server (http://localhost:4200) ng serve # Build for production ng build # Run unit tests ng test # Generate new component ng generate component component-name # Format code npm run format ``` -------------------------------- ### Configure Angular Application with PrimeNG Theming and HTTP Source: https://context7.com/primefaces/sakai-ng/llms.txt This snippet configures the main Angular application, bootstrapping it with PrimeNG theming (Aura preset with dark mode support), HTTP client using fetch, router settings for in-memory scrolling and enabled blocking navigation, and enables zoneless change detection. ```typescript // src/app.config.ts import { provideHttpClient, withFetch } from '@angular/common/http'; import { ApplicationConfig, provideZonelessChangeDetection } from '@angular/core'; import { provideRouter, withEnabledBlockingInitialNavigation, withInMemoryScrolling } from '@angular/router'; import Aura from '@primeuix/themes/aura'; import { providePrimeNG } from 'primeng/config'; import { appRoutes } from './app.routes'; export const appConfig: ApplicationConfig = { providers: [ provideRouter(appRoutes, withInMemoryScrolling({ anchorScrolling: 'enabled', scrollPositionRestoration: 'enabled' }), withEnabledBlockingInitialNavigation()), provideHttpClient(withFetch()), provideZonelessChangeDetection(), providePrimeNG({ theme: { preset: Aura, options: { darkModeSelector: '.app-dark' } } }) ] }; ``` -------------------------------- ### ProductService Data Management (Angular) Source: https://context7.com/primefaces/sakai-ng/llms.txt Implements the ProductService using the data service pattern in Angular. It provides methods for retrieving product data, including mock data generation and filtering capabilities. This service is designed to manage product information, likely for display or manipulation within an application. ```typescript // src/app/pages/service/product.service.ts import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; export interface Product { id?: string; code?: string; name?: string; description?: string; price?: number; quantity?: number; inventoryStatus?: string; category?: string; image?: string; rating?: number; } @Injectable() export class ProductService { constructor(private http: HttpClient) {} getProductsData(): Product[] { return [ { id: '1000', code: 'f230fh0g3', name: 'Bamboo Watch', price: 65, category: 'Accessories', quantity: 24, inventoryStatus: 'INSTOCK', rating: 5 }, { id: '1001', code: 'nvklal433', name: 'Black Watch', price: 72, category: 'Accessories', quantity: 61, inventoryStatus: 'INSTOCK', rating: 4 }, // ... more products ]; } getProductsMini() { return Promise.resolve(this.getProductsData().slice(0, 5)); } getProductsSmall() { return Promise.resolve(this.getProductsData().slice(0, 10)); } getProducts() { return Promise.resolve(this.getProductsData()); } generateProduct(): Product { return { id: this.generateId(), name: this.generateName(), description: 'Product Description', price: this.generatePrice(), quantity: this.generateQuantity(), inventoryStatus: this.generateStatus(), rating: this.generateRating() }; } private generateId(): string { const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; return Array.from({ length: 5 }, () => chars.charAt(Math.floor(Math.random() * chars.length))).join(''); } } ``` -------------------------------- ### Implement AppLayout Component with Angular (TypeScript) Source: https://context7.com/primefaces/sakai-ng/llms.txt The AppLayout component serves as the main application shell, integrating the topbar, sidebar, main content area, and footer. It uses computed properties based on LayoutService to dynamically apply CSS classes for different layout modes (overlay, static) and states (inactive, active). Dependencies include Angular's Component, computed, effect, inject decorators, CommonModule, RouterModule, and custom components like AppTopbar, AppSidebar, and AppFooter. ```typescript import { Component, computed, effect, inject } from '@angular/core'; import { CommonModule } from '@angular/common'; import { RouterModule } from '@angular/router'; import { AppTopbar } from './app.topbar'; import { AppSidebar } from './app.sidebar'; import { AppFooter } from './app.footer'; import { LayoutService } from '@/app/layout/service/layout.service'; @Component({ selector: 'app-layout', standalone: true, imports: [CommonModule, AppTopbar, AppSidebar, RouterModule, AppFooter], template: `
` }) export class AppLayout { layoutService = inject(LayoutService); containerClass = computed(() => { const config = this.layoutService.layoutConfig(); const state = this.layoutService.layoutState(); return { 'layout-overlay': config.menuMode === 'overlay', 'layout-static': config.menuMode === 'static', 'layout-static-inactive': state.staticMenuDesktopInactive && config.menuMode === 'static', 'layout-overlay-active': state.overlayMenuActive, 'layout-mobile-active': state.mobileMenuActive }; }); } ``` -------------------------------- ### Manage Layout State with Angular Signals (TypeScript) Source: https://context7.com/primefaces/sakai-ng/llms.txt The LayoutService utilizes Angular signals to manage application-wide layout configurations such as theme presets, color schemes, dark mode, and menu state. It provides computed signals for derived states and methods to toggle dark mode and handle menu interactions. Dependencies include Angular's Injectable, effect, signal, and computed decorators. ```typescript import { Injectable, effect, signal, computed } from '@angular/core'; export interface LayoutConfig { preset: string; primary: string; surface: string | undefined | null; darkTheme: boolean; menuMode: string; } @Injectable({ providedIn: 'root' }) export class LayoutService { layoutConfig = signal({ preset: 'Aura', primary: 'emerald', surface: null, darkTheme: false, menuMode: 'static' }); layoutState = signal({ staticMenuDesktopInactive: false, overlayMenuActive: false, configSidebarVisible: false, mobileMenuActive: false, menuHoverActive: false, activePath: null }); isDarkTheme = computed(() => this.layoutConfig().darkTheme); isSidebarActive = computed(() => this.layoutState().overlayMenuActive || this.layoutState().mobileMenuActive); isOverlay = computed(() => this.layoutConfig().menuMode === 'overlay'); toggleDarkMode(config?: LayoutConfig): void { const _config = config || this.layoutConfig(); if (_config.darkTheme) { document.documentElement.classList.add('app-dark'); } else { document.documentElement.classList.remove('app-dark'); } } onMenuToggle() { if (this.isOverlay()) { this.layoutState.update((prev) => ({ ...prev, overlayMenuActive: !this.layoutState().overlayMenuActive })); } if (this.isDesktop()) { this.layoutState.update((prev) => ({ ...prev, staticMenuDesktopInactive: !this.layoutState().staticMenuDesktopInactive })); } else { this.layoutState.update((prev) => ({ ...prev, mobileMenuActive: !this.layoutState().mobileMenuActive })); } } isDesktop() { return window.innerWidth > 991; } } ``` -------------------------------- ### Angular AppConfigurator: Theme Customization Component Source: https://context7.com/primefaces/sakai-ng/llms.txt This Angular component, AppConfigurator, facilitates runtime theme customization. It uses PrimeUI themes and Angular's computed properties to manage and update theme presets, primary colors, and menu modes based on user interactions. It depends on LayoutService for state management and PrimeUI's theme utilities. ```typescript // src/app/layout/component/app.configurator.ts import { Component, computed, inject } from '@angular/core'; import { $t, updatePreset, updateSurfacePalette } from '@primeuix/themes'; import Aura from '@primeuix/themes/aura'; import Lara from '@primeuix/themes/lara'; import Nora from '@primeuix/themes/nora'; import { LayoutService } from '@/app/layout/service/layout.service'; const presets = { Aura, Lara, Nora } as const; @Component({ selector: 'app-configurator', standalone: true, template: `
Primary
@for (color of primaryColors(); track color.name) { }
Presets
Menu Mode
` }) export class AppConfigurator { layoutService = inject(LayoutService); presetOptions = Object.keys(presets); selectedPreset = computed(() => this.layoutService.layoutConfig().preset); menuMode = computed(() => this.layoutService.layoutConfig().menuMode); primaryColors = computed(() => { const colors = ['emerald', 'green', 'lime', 'orange', 'amber', 'teal', 'cyan', 'blue', 'indigo', 'violet', 'purple', 'pink']; return colors.map(name => ({ name, palette: presets[this.selectedPreset()].primitive?.[name] })); }); updateColors(event: Event, type: string, color: any) { if (type === 'primary') { this.layoutService.layoutConfig.update(state => ({ ...state, primary: color.name })); updatePreset(this.getPresetExt()); } event.stopPropagation(); } onPresetChange(preset: string) { this.layoutService.layoutConfig.update(state => ({ ...state, preset })); $t().preset(presets[preset]).use({ useDefaultOptions: true }); } onMenuModeChange(mode: string) { this.layoutService.layoutConfig.update(prev => ({ ...prev, menuMode: mode })); } } ``` -------------------------------- ### Define Angular Application Routes with Lazy Loading Source: https://context7.com/primefaces/sakai-ng/llms.txt This snippet defines the main routing configuration for the Angular application. It sets up a layout component with child routes for the dashboard and other modules, includes lazy-loaded modules for UI kit and pages, and handles authentication and not found routes. ```typescript // src/app.routes.ts import { Routes } from '@angular/router'; import { AppLayout } from './app/layout/component/app.layout'; import { Dashboard } from './app/pages/dashboard/dashboard'; import { Documentation } from './app/pages/documentation/documentation'; import { Landing } from './app/pages/landing/landing'; import { Notfound } from './app/pages/notfound/notfound'; export const appRoutes: Routes = [ { path: '', component: AppLayout, children: [ { path: '', component: Dashboard }, { path: 'uikit', loadChildren: () => import('./app/pages/uikit/uikit.routes') }, { path: 'documentation', component: Documentation }, { path: 'pages', loadChildren: () => import('./app/pages/pages.routes') } ] }, { path: 'landing', component: Landing }, { path: 'notfound', component: Notfound }, { path: 'auth', loadChildren: () => import('./app/pages/auth/auth.routes') }, { path: '**', redirectTo: '/notfound' } ]; ``` -------------------------------- ### Angular Menu Component for Sidebar Navigation Source: https://context7.com/primefaces/sakai-ng/llms.txt Defines an Angular component that renders a hierarchical navigation menu based on a configuration object. It supports nested items, icons, and router links, utilizing PrimeNG's MenuItem interface and a custom AppMenuitem directive for rendering individual menu items. The component is standalone and imports AppMenuitem. ```typescript import { Component } from '@angular/core'; import { MenuItem } from 'primeng/api'; import { AppMenuitem } from './app.menuitem'; @Component({ selector: 'app-menu', standalone: true, imports: [AppMenuitem], template: ` ` }) export class AppMenu { model: MenuItem[] = []; ngOnInit() { this.model = [ { label: 'Home', items: [{ label: 'Dashboard', icon: 'pi pi-fw pi-home', routerLink: ['/'] }] }, { label: 'UI Components', items: [ { label: 'Form Layout', icon: 'pi pi-fw pi-id-card', routerLink: ['/uikit/formlayout'] }, { label: 'Input', icon: 'pi pi-fw pi-check-square', routerLink: ['/uikit/input'] }, { label: 'Button', icon: 'pi pi-fw pi-mobile', routerLink: ['/uikit/button'] }, { label: 'Table', icon: 'pi pi-fw pi-table', routerLink: ['/uikit/table'] }, { label: 'Panel', icon: 'pi pi-fw pi-tablet', routerLink: ['/uikit/panel'] }, { label: 'Chart', icon: 'pi pi-fw pi-chart-bar', routerLink: ['/uikit/charts'] } ] }, { label: 'Pages', items: [ { label: 'Landing', icon: 'pi pi-fw pi-globe', routerLink: ['/landing'] }, { label: 'Crud', icon: 'pi pi-fw pi-pencil', routerLink: ['/pages/crud'] }, { label: 'Auth', icon: 'pi pi-fw pi-user', items: [ { label: 'Login', routerLink: ['/auth/login'] }, { label: 'Error', routerLink: ['/auth/error'] } ] } ] } ]; } } ``` -------------------------------- ### Angular CRUD Component with PrimeNG Table Source: https://context7.com/primefaces/sakai-ng/llms.txt This Angular component implements a full CRUD interface using PrimeNG's Table. It handles product data, including displaying, editing, deleting, and exporting. Dependencies include PrimeNG modules, Angular signals, and custom services for product data and messaging. ```typescript import { Component, OnInit, signal, ViewChild } from '@angular/core'; import { ConfirmationService, MessageService } from 'primeng/api'; import { Table, TableModule } from 'primeng/table'; import { Product, ProductService } from '@/app/pages/service/product.service'; @Component({ selector: 'app-crud', standalone: true, imports: [TableModule, DialogModule, ToolbarModule, ButtonModule /* ... */], providers: [MessageService, ProductService, ConfirmationService], template: ` Name Price Actions {{ product.name }} {{ product.price | currency: 'USD' }} ` }) export class Crud implements OnInit { products = signal([]); selectedProducts: Product[] | null = null; productDialog = false; product!: Product; @ViewChild('dt') dt!: Table; constructor( private productService: ProductService, private messageService: MessageService, private confirmationService: ConfirmationService ) {} ngOnInit() { this.productService.getProducts().then(data => this.products.set(data)); } openNew() { this.product = {}; this.productDialog = true; } editProduct(product: Product) { this.product = { ...product }; this.productDialog = true; } deleteProduct(product: Product) { this.confirmationService.confirm({ message: `Are you sure you want to delete ${product.name}?`, accept: () => { this.products.set(this.products().filter(p => p.id !== product.id)); this.messageService.add({ severity: 'success', summary: 'Deleted', detail: 'Product Deleted' }); } }); } exportCSV() { this.dt.exportCSV(); } onGlobalFilter(table: Table, event: Event) { table.filterGlobal((event.target as HTMLInputElement).value, 'contains'); } } ``` -------------------------------- ### Dashboard Component Structure (Angular) Source: https://context7.com/primefaces/sakai-ng/llms.txt Defines the main dashboard component, which composes several widget components to display a data-rich overview. It utilizes Angular's component architecture and template syntax for layout and integration of child components. ```typescript // src/app/pages/dashboard/dashboard.ts import { Component } from '@angular/core'; import { NotificationsWidget } from './components/notificationswidget'; import { StatsWidget } from './components/statswidget'; import { RecentSalesWidget } from './components/recentsaleswidget'; import { BestSellingWidget } from './components/bestsellingwidget'; import { RevenueStreamWidget } from './components/revenuestreamwidget'; @Component({ selector: 'app-dashboard', imports: [StatsWidget, RecentSalesWidget, BestSellingWidget, RevenueStreamWidget, NotificationsWidget], template: `
` }) export class Dashboard {} ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.