Commit 79e157df authored by Kaustubh Negi's avatar Kaustubh Negi

Merge branch 'develop' into 'master'

01-03-2023

See merge request !7
parents 31ec07f1 55144538
......@@ -149,6 +149,17 @@
<td>Oppo</td>
<td>OneClick</td>
</tr>
<tr *ngFor="let entry of timeEntries">
<td>{{ entry['S. No.'] }}</td>
<td>{{ entry['Date'] }}</td>
<td>{{ entry['Punch In'] }}</td>
<td>{{ entry['Punch Out'] }}</td>
<td>{{ entry['Project 1'] }}</td>
<td>{{ entry['Project 2'] }}</td>
<td>{{ entry['Project 3'] }}</td>
</tr>
</tbody>
</table>
</div>
......
import { Component, OnInit } from '@angular/core';
import { SendDateService } from '../send-date.service';
import { TimeEntryServiceService } from '../time-entry-service.service';
// import { interval } from 'rxjs';
import { DatePipe } from '@angular/common';
import "bootstrap";
import { ToastrService } from 'ngx-toastr';
import { Router } from '@angular/router';
import { HttpClient } from '@angular/common/http';
@Component({
......@@ -17,13 +20,21 @@ export class AttendComponent implements OnInit {
timeEntries: any[] = [];
// constructor(private datePipe: DatePipe) {}
constructor(private sendDateService: SendDateService, private toastr:ToastrService,private router: Router){}
constructor(private http: HttpClient,private timeEntryService: TimeEntryServiceService,private sendDateService: SendDateService, private toastr:ToastrService,private router: Router){}
getTimeEntries() {
// Call an API endpoint to get the time entries from the backend
this.http.get<any[]>('http://localhost:3000/timeEntries')
.subscribe((data: any[]) => {
this.timeEntries = data;
console.log(this.timeEntries);
});
}
ngOnInit(): void {
// const clock$ = interval(1000);
// clock$.subscribe(() => {
......@@ -44,6 +55,23 @@ export class AttendComponent implements OnInit {
// }
// const empCode = 'ABC123'; // replace with the employee code to fetch the time entries for
// this.timeEntryService.getTimeEntriesForEmployee(empCode).subscribe(
// (data) => {
// this.timeEntries = data; // assign the time entries to the component property
// console.log("checking if the time entries are fetched");
// console.log(this.timeEntries);
// console.log("time entries should be displayed above this line")
// },
// (error) => {
// console.error('Error fetching time entries:', error);
// }
// );
this.getTimeEntries();
}
startTime: Date;
endTime: Date;
......
import { TestBed } from '@angular/core/testing';
import { TimeEntryServiceService } from './time-entry-service.service';
describe('TimeEntryServiceService', () => {
let service: TimeEntryServiceService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(TimeEntryServiceService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
@Injectable({
providedIn: 'root'
})
export class TimeEntryServiceService {
private baseUrl = 'http://localhost:3000/timeEntries'; // replace with your backend API endpoint
constructor(private http: HttpClient) { }
// fetch the time entries for an employee from the backend
getTimeEntriesForEmployee(empCode: string): Observable<any> {
let token:string ="";
let json: string | null = localStorage.getItem("response");
if (json) {
console.log("json "+json);
token = JSON.parse(json).token;
console.log(token);
}
const headers = {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`
};
return this.http.get<any>(this.baseUrl, { headers }).pipe(
map((response) => response.data) // extract the data property from the response
);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment