|
| 1 | +import { ChangeDetectionStrategy, Component } from '@angular/core'; |
| 2 | +import { |
| 3 | + KBQ_AG_GRID_COLUMN_MENU_LABELS_EN, |
| 4 | + kbqAgGridColumnMenuLabelsProvider, |
| 5 | + KbqAgGridThemeModule |
| 6 | +} from '@koobiq/ag-grid-angular-theme'; |
| 7 | +import { AgGridModule } from 'ag-grid-angular'; |
| 8 | +import { AllCommunityModule, ColDef, ModuleRegistry } from 'ag-grid-community'; |
| 9 | + |
| 10 | +ModuleRegistry.registerModules([AllCommunityModule]); |
| 11 | + |
| 12 | +/** |
| 13 | + * @title AG Grid with column menu |
| 14 | + */ |
| 15 | +@Component({ |
| 16 | + selector: 'ag-grid-column-menu-example', |
| 17 | + imports: [AgGridModule, KbqAgGridThemeModule], |
| 18 | + template: ` |
| 19 | + <ag-grid-angular |
| 20 | + kbqAgGridTheme |
| 21 | + kbqAgGridSelectRowsByShiftClick |
| 22 | + kbqAgGridThemeDisableCellFocusStyles |
| 23 | + kbqAgGridToNextRowByTab |
| 24 | + kbqAgGridSelectRowsByShiftArrow |
| 25 | + kbqAgGridSelectRowsByCtrlClick |
| 26 | + kbqAgGridColumnMenu |
| 27 | + [rowData]="rowData" |
| 28 | + [columnDefs]="columnDefs" |
| 29 | + [alwaysMultiSort]="true" |
| 30 | + /> |
| 31 | + `, |
| 32 | + styles: ` |
| 33 | + ag-grid-angular { |
| 34 | + height: 400px; |
| 35 | + max-width: 100%; |
| 36 | + } |
| 37 | + `, |
| 38 | + providers: [kbqAgGridColumnMenuLabelsProvider(KBQ_AG_GRID_COLUMN_MENU_LABELS_EN)], |
| 39 | + changeDetection: ChangeDetectionStrategy.OnPush |
| 40 | +}) |
| 41 | +export class AgGridColumnMenuExample { |
| 42 | + readonly columnDefs: ColDef[] = [ |
| 43 | + // Pinned and always visible — can't be hidden. |
| 44 | + { field: 'incidentId', headerName: 'Incident ID', lockVisible: true, pinned: 'left', width: 110 }, |
| 45 | + // Shown by default. Severity and status are also locked from hiding. |
| 46 | + { field: 'severity', headerName: 'Severity', lockVisible: true, width: 100 }, |
| 47 | + { field: 'status', headerName: 'Status', lockVisible: true, width: 140 }, |
| 48 | + { field: 'attackType', headerName: 'Attack type', width: 170 }, |
| 49 | + { field: 'sourceIp', headerName: 'Source IP', width: 128 }, |
| 50 | + // Hidden by default, but available to show from the column menu. |
| 51 | + { field: 'affectedHost', headerName: 'Affected host', hide: true, width: 170 }, |
| 52 | + { field: 'destinationIp', headerName: 'Destination IP', hide: true, width: 128 }, |
| 53 | + { field: 'assignedAnalyst', headerName: 'Assigned analyst', hide: true, width: 170 }, |
| 54 | + { field: 'mitreTechnique', headerName: 'MITRE technique', hide: true, width: 130 }, |
| 55 | + { field: 'mitreTechniqueName', headerName: 'MITRE technique name', hide: true, width: 260 }, |
| 56 | + { field: 'responseAction', headerName: 'Response action', hide: true, width: 180 }, |
| 57 | + { field: 'sourcePort', headerName: 'Source port', hide: true, width: 130 }, |
| 58 | + { field: 'destinationPort', headerName: 'Destination port', hide: true, width: 150 }, |
| 59 | + { field: 'protocol', headerName: 'Protocol', hide: true, width: 120 }, |
| 60 | + { field: 'detectionSource', headerName: 'Detection source', hide: true, width: 170 }, |
| 61 | + { field: 'confidenceScore', headerName: 'Confidence score', hide: true, width: 160 }, |
| 62 | + { field: 'assetOwner', headerName: 'Asset owner', hide: true, width: 150 }, |
| 63 | + { field: 'businessUnit', headerName: 'Business unit', hide: true, width: 150 }, |
| 64 | + { field: 'threatActor', headerName: 'Threat actor', hide: true, width: 150 }, |
| 65 | + { field: 'malwareFamily', headerName: 'Malware family', hide: true, width: 160 }, |
| 66 | + { field: 'remediationStatus', headerName: 'Remediation status', hide: true, width: 180 } |
| 67 | + ]; |
| 68 | + |
| 69 | + readonly rowData = Array.from({ length: 30 }, (_, index) => |
| 70 | + Object.fromEntries(this.columnDefs.map(({ field }) => [field as string, 'Text ' + index])) |
| 71 | + ); |
| 72 | +} |
0 commit comments