Skip to content

Commit b4a6f05

Browse files
committed
add docstrings
1 parent 9a5a118 commit b4a6f05

File tree

4 files changed

+72
-1
lines changed

4 files changed

+72
-1
lines changed

web-app/admin/src/app/admin/admin-teams/create-team/create-team.component.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import { FormBuilder, FormGroup, Validators } from '@angular/forms';
44
import { TeamsService } from '../teams-service';
55
import { Team } from '../team';
66

7+
/**
8+
* Dialog component for creating new teams.
9+
* Provides a form interface with validation for team name (required) and description (optional).
10+
*/
711
@Component({
812
selector: 'mage-admin-team-create',
913
templateUrl: './create-team.component.html',
@@ -25,6 +29,10 @@ export class CreateTeamDialogComponent {
2529
});
2630
}
2731

32+
/**
33+
* Handles form submission for creating a new team.
34+
* Validates the form, creates the team via the teams service, and closes the dialog on success.
35+
*/
2836
save(): void {
2937
if (this.teamForm.invalid) {
3038
this.errorMessage = 'Please fill in all required fields.';
@@ -43,6 +51,9 @@ export class CreateTeamDialogComponent {
4351
});
4452
}
4553

54+
/**
55+
* Closes the dialog without saving any data or making any changes.
56+
*/
4657
cancel(): void {
4758
this.dialogRef.close();
4859
}

web-app/admin/src/app/admin/admin-teams/dashboard/team-dashboard.component.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ import { TeamsService } from '../teams-service';
88
import { CreateTeamDialogComponent } from '../create-team/create-team.component';
99
import { CardActionButton } from '../../../core/card-navbar/card-navbar.component';
1010

11+
/**
12+
* Team dashboard component that displays a paginated list of teams with search functionality.
13+
* Provides capabilities to view, search, and create new teams through a data table interface.
14+
*/
1115
@Component({
1216
selector: 'mage-admin-teams',
1317
templateUrl: './team-dashboard.component.html',
@@ -33,15 +37,24 @@ export class TeamDashboardComponent implements OnInit, OnDestroy {
3337
private teamService: TeamsService
3438
) { }
3539

40+
/**
41+
* Fetches the initial set of teams when the component loads
42+
*/
3643
ngOnInit(): void {
3744
this.fetchTeams();
3845
}
3946

47+
/**
48+
* Component destruction lifecycle hook
49+
*/
4050
ngOnDestroy(): void {
4151
this.destroy$.next();
4252
this.destroy$.complete();
4353
}
4454

55+
/**
56+
* Fetches teams from the service based on current search term and pagination settings
57+
*/
4558
fetchTeams(): void {
4659
this.teamService.getTeams({
4760
term: this.teamSearch,
@@ -58,24 +71,41 @@ export class TeamDashboardComponent implements OnInit, OnDestroy {
5871
});
5972
}
6073

74+
/**
75+
* Handles pagination change events from the Material paginator
76+
*
77+
* @param event - The page event containing new page size and index
78+
*/
6179
onPageChange(event: PageEvent): void {
6280
this.pageSize = event.pageSize;
6381
this.pageIndex = event.pageIndex;
6482
this.fetchTeams();
6583
}
6684

85+
/**
86+
* Resets pagination to the first page and refetches teams with the new search term
87+
*
88+
* @param term - The new search term entered by the user
89+
*/
6790
onSearchTermChanged(term: string): void {
6891
this.teamSearch = term;
6992
this.pageIndex = 0; // Reset to first page when searching
7093
this.fetchTeams();
7194
}
7295

96+
/**
97+
* Resets the search term, pagination to the first page, and refetches all teams
98+
*/
7399
onSearchCleared(): void {
74100
this.teamSearch = '';
75101
this.pageIndex = 0;
76102
this.fetchTeams();
77103
}
78104

105+
/**
106+
* Opens the create team dialog and handles the result.
107+
* If a new team is created, refetches the teams list to include the new team.
108+
*/
79109
newTeam(): void {
80110
const dialogRef = this.modal.open(CreateTeamDialogComponent, {
81111
width: '50rem',
@@ -90,6 +120,11 @@ export class TeamDashboardComponent implements OnInit, OnDestroy {
90120
});
91121
}
92122

123+
/**
124+
* Navigates to the detailed view of a specific team
125+
*
126+
* @param team - The team to navigate to
127+
*/
93128
gotoTeam(team: Team): void {
94129
// TODO: convert to this to using a router once upgrade is complete
95130
const baseUrl = window.location.href.split('#')[0];

web-app/admin/src/app/core/card-navbar/card-navbar.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ <h3 class="navbar-brand">{{ title }}</h3>
77
<div class="navbar-form navbar-left search-container" *ngIf="isSearchable">
88
<input type="text" class="form-control search-input" [placeholder]="searchPlaceholder"
99
[(ngModel)]="searchTerm" (ngModelChange)="onSearchChange($event)">
10-
<button type="button" class="btn clear-search-btn" (click)="clearSearch()">
10+
<button type="button" class="btn clear-search-btn" (click)="clearSearch()"
11+
*ngIf="searchTerm && searchTerm.trim()">
1112
<i class="fa fa-times"></i>
1213
</button>
1314
</div>

web-app/admin/src/app/core/card-navbar/card-navbar.component.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ export interface CardActionButton {
99
action: () => void;
1010
}
1111

12+
/**
13+
* A reusable card navbar component that provides a title, optional search functionality,
14+
* and configurable action buttons. The component handles search debouncing and emits
15+
* events for search term changes and search clearing.
16+
*/
1217
@Component({
1318
selector: 'mage-card-navbar',
1419
templateUrl: './card-navbar.component.html',
@@ -31,6 +36,9 @@ export class CardNavbarComponent implements OnInit, OnDestroy {
3136

3237
constructor() { }
3338

39+
/**
40+
* Sets up the search subject with debouncing and change detection.
41+
*/
3442
ngOnInit(): void {
3543
this.searchSubject$.pipe(
3644
debounceTime(this.debounceTime),
@@ -41,23 +49,39 @@ export class CardNavbarComponent implements OnInit, OnDestroy {
4149
});
4250
}
4351

52+
/**
53+
* Component destruction lifecycle hook
54+
*/
4455
ngOnDestroy(): void {
4556
this.destroy$.next();
4657
this.destroy$.complete();
4758
}
4859

60+
/**
61+
* Clears the search input and emits the searchCleared event
62+
*/
4963
clearSearch(): void {
5064
this.searchTerm = '';
5165
this.searchSubject$.next('');
5266
this.searchCleared.emit();
5367
}
5468

69+
/**
70+
* Handles action button click events
71+
*
72+
* @param button - The action button that was clicked
73+
*/
5574
onActionButtonClick(button: CardActionButton): void {
5675
if (button.action) {
5776
button.action();
5877
}
5978
}
6079

80+
/**
81+
* Handles search input changes
82+
*
83+
* @param term - The new search term entered by the user
84+
*/
6185
onSearchChange(term: string): void {
6286
this.searchTerm = term;
6387
this.searchSubject$.next(term);

0 commit comments

Comments
 (0)