Skip to content
This repository was archived by the owner on Jul 5, 2024. It is now read-only.

Commit 1d88f78

Browse files
authored
Merge pull request #14 from llTheBlankll/issue-13
attendance-management-angular-13 (JS-0323) Detected usage of the `any…
2 parents d7d9b98 + b40cbde commit 1d88f78

File tree

12 files changed

+53
-66
lines changed

12 files changed

+53
-66
lines changed

src/app/authentication/auth.service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {inject, Injectable} from '@angular/core';
22
import {HttpClient, HttpResponse} from "@angular/common/http";
33
import {environment} from "../../environments/environment";
44
import {map, Observable, of} from "rxjs";
5-
import {LoginDTO} from "../DTO/DTOList";
5+
import {LoginDTO, LoginToken} from "../DTO/DTOList";
66
import {StatusMessageResponse} from "../DTO/StatusMessageResponse";
77
import {ExecutionStatus} from "../enums/ExecutionStatus";
88

@@ -28,7 +28,7 @@ export class AuthService {
2828
// Check response body if it is valid
2929
if (response.body) {
3030
const message = response.body;
31-
if (message?.status == ExecutionStatus.VALID) {
31+
if (message?.status === ExecutionStatus.VALID) {
3232
return of(true);
3333
}
3434
}
@@ -43,9 +43,9 @@ export class AuthService {
4343
return false;
4444
}
4545

46-
login(login: LoginDTO): Observable<HttpResponse<LoginDTO | StatusMessageResponse>> {
46+
login(login: LoginDTO): Observable<HttpResponse<LoginToken | StatusMessageResponse>> {
4747
console.log("Requesting login to " + this.loginUrl);
48-
return this.http.post<LoginDTO | StatusMessageResponse>(this.loginUrl, login, {
48+
return this.http.post<LoginToken | StatusMessageResponse>(this.loginUrl, login, {
4949
responseType: 'json',
5050
observe: 'response'
5151
});

src/app/authentication/login/auth.component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {Router} from "@angular/router";
1616
import {TeacherService} from "../../services/teacher/teacher.service";
1717
import {Roles} from "../../enums/Roles";
1818
import {Teacher} from "../../DTO/TeacherDTO";
19+
import {StatusMessageResponse} from "../../DTO/StatusMessageResponse";
1920

2021
@Component({
2122
selector: 'app-login',
@@ -74,10 +75,10 @@ export class AuthComponent {
7475
console.log("Logging in");
7576
// Check if status code 200
7677
this.loginService.login(loginData).pipe(
77-
map((response: HttpResponse<any>) => {
78+
map((response: HttpResponse<LoginToken | StatusMessageResponse>) => {
7879
console.log("Login successful");
7980
// Get token
80-
const loginToken: LoginToken = response.body;
81+
const loginToken: LoginToken = response.body as LoginToken;
8182

8283
// Show alert message
8384
this.alert.open("Login successful", "Close");

src/app/components/top-header/top-header.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import {NgOptimizedImage} from "@angular/common";
3636
})
3737
export class TopHeaderComponent implements OnInit {
3838
@Input()
39-
public sidenav: MatDrawer | any;
39+
public sidenav: MatDrawer | undefined;
4040

4141
@Output()
4242
public readonly sectionSelected: EventEmitter<number> = new EventEmitter<number>();

src/app/dashboard/admin/admin-dashboard/admin-dashboard.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export class AdminDashboardComponent implements OnInit {
9191
protected displayedColumns: string[] = ['name', 'grade', 'section', 'time', 'date', 'status'];
9292
protected recentActivitiesRow: RecentActivitiesRow[] = [
9393
];
94-
protected recentActivitiesTableDataSource: MatTableDataSource<any> = new MatTableDataSource(this.recentActivitiesRow);
94+
protected recentActivitiesTableDataSource: MatTableDataSource<RecentActivitiesRow> = new MatTableDataSource(this.recentActivitiesRow);
9595

9696

9797
constructor() {

src/app/dashboard/announcements/announcements.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export class AnnouncementsComponent implements OnInit {
9393

9494
// Mat Table data
9595
displayedColumns: string[] = ['title', 'status', 'viewers'];
96-
announcementTableDataSource: MatTableDataSource<any> = new MatTableDataSource(this.announcements);
96+
announcementTableDataSource: MatTableDataSource<{}> = new MatTableDataSource(this.announcements);
9797

9898
// Announcement Pagination
9999
// Pagination info

src/app/dashboard/teacher/teacher-dashboard/teacher-dashboard.component.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export class TeacherDashboardComponent implements OnInit, OnChanges {
9494
// Recent Activities table and Data Source
9595
protected displayedColumns: string[] = ['name', 'grade', 'section', 'time', 'date', 'status'];
9696
protected recentActivitiesRow: RecentActivitiesRow[] = [];
97-
protected recentActivitiesTableDataSource: MatTableDataSource<any> = new MatTableDataSource(this.recentActivitiesRow);
97+
protected recentActivitiesTableDataSource: MatTableDataSource<RecentActivitiesRow> = new MatTableDataSource(this.recentActivitiesRow);
9898

9999
// Section
100100
@Input()
@@ -384,9 +384,11 @@ export class TeacherDashboardComponent implements OnInit, OnChanges {
384384
}
385385

386386
updateAttendanceOverviewData(label: string[], data: number[], dataset = 0) {
387-
this.attendanceOverviewChart.data.labels = label;
388-
this.attendanceOverviewChart.data.datasets[dataset].data = data;
389-
this.attendanceOverviewChart.update();
387+
if (this.attendanceOverviewChart !== undefined) {
388+
this.attendanceOverviewChart.data.labels = label;
389+
this.attendanceOverviewChart.data.datasets[dataset].data = data;
390+
this.attendanceOverviewChart.update();
391+
}
390392
}
391393

392394
updateDashboardStatistics() {

src/app/dashboard/teacher/teacher-students/teacher-students.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export class TeacherStudentsComponent implements OnInit {
4949
// Pie Chart with Chart JS
5050
public pieChartLabels = ["Male", "Female"];
5151
public pieChartData = [512, 235];
52-
public pieChart: any;
52+
public pieChart: Chart<"pie", number[], string> | undefined;
5353

5454
ngOnInit() {
5555
this.pieChart = new Chart('pieChart', {

src/app/services/attendance/attendance.service.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import {inject, Injectable} from '@angular/core';
22
import {environment} from "../../../environments/environment";
3-
import {HttpClient} from "@angular/common/http";
3+
import {HttpClient, HttpResponse} from "@angular/common/http";
44
import {DateRange, Status} from "../../DTO/DTOList";
55
import {Observable} from "rxjs";
66
import {CountDTO} from "../../DTO/CountDTO";
77
import {SortDirection} from "../../enums/SortDirection";
8+
import {AttendancePaging} from "../../DTO/AttendanceDTO";
89

910
@Injectable({
1011
providedIn: 'root'
@@ -14,35 +15,32 @@ export class AttendanceService {
1415
apiUrl: string = environment.apiUrl + "/api/v1/attendances";
1516
http: HttpClient = inject(HttpClient);
1617

17-
constructor() {
18-
}
19-
20-
countAttendance(dateRange: DateRange, status: Status): Observable<any> {
21-
return this.http.post(this.apiUrl + `/status/${status}/date-range`, dateRange, {
18+
countAttendance(dateRange: DateRange, status: Status): Observable<HttpResponse<number>> {
19+
return this.http.post<number>(this.apiUrl + `/status/${status}/date-range`, dateRange, {
2220
observe: 'response',
2321
responseType: 'json'
2422
});
2523
}
2624

27-
countAttendanceInSectionByDateRange(sectionId: number, dateRange: DateRange, status: Status): Observable<any> {
25+
countAttendanceInSectionByDateRange(sectionId: number, dateRange: DateRange, status: Status) {
2826
return this.http.post(this.apiUrl + `/status/${status}/section/${sectionId}/date-range`, dateRange, {
2927
observe: 'response',
3028
responseType: 'json'
3129
});
3230
}
3331

34-
countAttendanceInSectionByDate(sectionId: number, date: Date, status: Status): Observable<any> {
32+
countAttendanceInSectionByDate(sectionId: number, date: Date, status: Status): Observable<HttpResponse<CountDTO>> {
3533
const formattedDate: string = date.toISOString().split('T')[0];
3634
return this.http.get<CountDTO>(this.apiUrl + `/status/${status}/section/${sectionId}/date?date=${formattedDate}`, {
3735
observe: 'response',
3836
responseType: 'json'
3937
});
4038
}
4139

42-
getAllSectionAndGradeLevelAttendanceByDate(sectionId: number, gradeLevelId: number, date: Date, page: number, size: number, sortBy = "date", orderBy: SortDirection = SortDirection.ASC): Observable<any> {
40+
getAllSectionAndGradeLevelAttendanceByDate(sectionId: number, gradeLevelId: number, date: Date, page: number, size: number, sortBy = "date", orderBy: SortDirection = SortDirection.ASC): Observable<HttpResponse<AttendancePaging>> {
4341
const formattedDate = date.toISOString().split('T')[0];
4442

45-
return this.http.get(this.apiUrl + `/statistics/section/${sectionId}/grade-level/${gradeLevelId}/date`, {
43+
return this.http.get<AttendancePaging>(this.apiUrl + `/statistics/section/${sectionId}/grade-level/${gradeLevelId}/date`, {
4644
params: {
4745
date: formattedDate,
4846
page: page,
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {inject, Injectable} from '@angular/core';
22
import {environment} from "../../../../environments/environment";
3-
import {HttpClient} from "@angular/common/http";
4-
import {DateRange, Status} from "../../../DTO/DTOList";
3+
import {HttpClient, HttpResponse} from "@angular/common/http";
4+
import {DateRange, LineChartDTO, Status} from "../../../DTO/DTOList";
55
import {Observable} from "rxjs";
66

77
@Injectable({
@@ -12,11 +12,11 @@ export class AttendanceLineChartService {
1212
private baseUrl: string = environment.apiUrl;
1313
private http: HttpClient = inject(HttpClient);
1414

15-
getAttendanceLineChart(status: Status, dateRange: DateRange): Observable<any> {
16-
return this.http.post(`${this.baseUrl}/api/v1/attendances/graphic-organizers/line-chart?status=${status}`, dateRange, {observe: 'response', responseType: 'json'});
15+
getAttendanceLineChart(status: Status, dateRange: DateRange): Observable<HttpResponse<LineChartDTO>> {
16+
return this.http.post<LineChartDTO>(`${this.baseUrl}/api/v1/attendances/graphic-organizers/line-chart?status=${status}`, dateRange, {observe: 'response', responseType: 'json'});
1717
}
1818

19-
getSectionAttendanceLineChart(sectionId: number, status: Status, dateRange: DateRange): Observable<any> {
20-
return this.http.post(`${this.baseUrl}/api/v1/attendances/graphic-organizers/sections/${sectionId}/line-chart?status=${status}`, dateRange, {observe: 'response', responseType: 'json'});
19+
getSectionAttendanceLineChart(sectionId: number, status: Status, dateRange: DateRange): Observable<HttpResponse<LineChartDTO>> {
20+
return this.http.post<LineChartDTO>(`${this.baseUrl}/api/v1/attendances/graphic-organizers/sections/${sectionId}/line-chart?status=${status}`, dateRange, {observe: 'response', responseType: 'json'});
2121
}
2222
}

src/app/services/section/section.service.ts

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import {inject, Injectable} from '@angular/core';
22
import {environment} from "../../../environments/environment";
3-
import {HttpClient} from "@angular/common/http";
3+
import {HttpClient, HttpResponse} from "@angular/common/http";
44
import {Observable} from "rxjs";
55
import {Section} from "../../DTO/SectionDTO";
66
import {SortDirection} from "../../enums/SortDirection";
7+
import {StatusMessageResponse} from "../../DTO/StatusMessageResponse";
78

89
@Injectable({
910
providedIn: 'root'
@@ -13,27 +14,15 @@ export class SectionService {
1314
private apiUrl: string = environment.apiUrl + "/api/v1/sections";
1415
private http: HttpClient = inject(HttpClient);
1516

16-
public createSection(section: Section) {
17-
return this.http.post(this.apiUrl + "/create", section, {responseType: 'json', observe: 'response'});
17+
public createSection(section: Section): Observable<HttpResponse<StatusMessageResponse>> {
18+
return this.http.post<StatusMessageResponse>(this.apiUrl + "/create", section, {responseType: 'json', observe: 'response'});
1819
}
1920

20-
public updateSection(sectionId: number, section: Section) {
21-
return this.http.put(this.apiUrl + `/${sectionId}`, section, {responseType: 'json', observe: 'response'});
21+
public updateSection(sectionId: number, section: Section): Observable<HttpResponse<StatusMessageResponse>> {
22+
return this.http.put<StatusMessageResponse>(this.apiUrl + `/${sectionId}`, section, {responseType: 'json', observe: 'response'});
2223
}
23-
24-
public updateSectionTeacher(sectionId: number, teacherId: number) {
25-
return this.http.patch(this.apiUrl + `/${sectionId}/teacher`, {
26-
params: {
27-
sectionId: sectionId,
28-
teacherId: teacherId
29-
},
30-
responseType: 'json',
31-
observe: 'response'
32-
});
33-
}
34-
35-
public updateSectionGradeLevel(sectionId: number, gradeLevelId: number) {
36-
return this.http.patch(this.apiUrl + `/${sectionId}/grade-level`, {
24+
public updateSectionGradeLevel(sectionId: number, gradeLevelId: number): Observable<StatusMessageResponse> {
25+
return this.http.patch<StatusMessageResponse>(this.apiUrl + `/${sectionId}/grade-level`, {
3726
params: {
3827
gradeLevelId: gradeLevelId
3928
},
@@ -42,8 +31,8 @@ export class SectionService {
4231
});
4332
}
4433

45-
public updateSectionName(sectionId: number, name: string) {
46-
return this.http.patch(this.apiUrl + `/${sectionId}/name`, null, {
34+
public updateSectionName(sectionId: number, name: string): Observable<HttpResponse<StatusMessageResponse>> {
35+
return this.http.patch<StatusMessageResponse>(this.apiUrl + `/${sectionId}/name`, null, {
4736
params: {
4837
name: name
4938
},
@@ -52,15 +41,15 @@ export class SectionService {
5241
});
5342
}
5443

55-
public deleteSection(sectionId: number) {
56-
return this.http.delete(this.apiUrl + `/${sectionId}`, {
44+
public deleteSection(sectionId: number): Observable<HttpResponse<StatusMessageResponse>> {
45+
return this.http.delete<StatusMessageResponse>(this.apiUrl + `/${sectionId}`, {
5746
responseType: 'json',
5847
observe: 'response'
5948
}
6049
);
6150
}
6251

63-
public getAllSectionsNoPaging() {
52+
public getAllSectionsNoPaging(): Observable<HttpResponse<Section[]>> {
6453
return this.http.get<Section[]>(this.apiUrl + "/all", {
6554
params: {
6655
noPaging: true
@@ -70,7 +59,7 @@ export class SectionService {
7059
});
7160
}
7261

73-
public getAllSections(page: number, size: number, orderBy: SortDirection = SortDirection.ASC, sortBy = "sectionName"): Observable<any> {
62+
public getAllSections(page: number, size: number, orderBy: SortDirection = SortDirection.ASC, sortBy = "sectionName") {
7463
return this.http.get(this.apiUrl + "/all", {
7564
params: {
7665
page: page,
@@ -83,7 +72,7 @@ export class SectionService {
8372
});
8473
}
8574

86-
public getSectionById(sectionId: number): Observable<any> {
75+
public getSectionById(sectionId: number) {
8776
return this.http.get(this.apiUrl + `/${sectionId}`, {responseType: 'json', observe: 'response'});
8877
}
8978

0 commit comments

Comments
 (0)