ciyidogan commited on
Commit
d0d519b
·
verified ·
1 Parent(s): 6752d44

Update flare-ui/src/app/components/activity-log/activity-log.component.ts

Browse files
flare-ui/src/app/components/activity-log/activity-log.component.ts CHANGED
@@ -252,17 +252,28 @@ export class ActivityLogComponent implements OnInit {
252
  this.loading = true;
253
  this.currentPage = page;
254
 
255
- this.http.get<ActivityLogResponse>(
256
- `/api/activity-log?page=${page}&limit=${this.pageSize}`
 
 
 
257
  ).subscribe({
258
  next: (response) => {
259
- this.activities = response.items;
260
- this.totalItems = response.total;
261
- this.totalPages = response.pages;
 
 
 
 
 
 
 
262
  this.loading = false;
263
  },
264
  error: (error) => {
265
  console.error('Failed to load activities:', error);
 
266
  this.loading = false;
267
  }
268
  });
 
252
  this.loading = true;
253
  this.currentPage = page;
254
 
255
+ // Backend sadece limit parametresi alıyor, page almıyor
256
+ const limit = this.pageSize * page; // Toplam kaç kayıt istediğimizi hesapla
257
+
258
+ this.http.get<ActivityLog[]>(
259
+ `/api/activity-log?limit=${limit}`
260
  ).subscribe({
261
  next: (response) => {
262
+ // Response direkt array olarak geliyor
263
+ const allActivities = response || [];
264
+
265
+ // Manuel pagination yap
266
+ const startIndex = (page - 1) * this.pageSize;
267
+ const endIndex = startIndex + this.pageSize;
268
+
269
+ this.activities = allActivities.slice(startIndex, endIndex);
270
+ this.totalItems = allActivities.length;
271
+ this.totalPages = Math.ceil(allActivities.length / this.pageSize);
272
  this.loading = false;
273
  },
274
  error: (error) => {
275
  console.error('Failed to load activities:', error);
276
+ this.activities = []; // Hata durumunda boş array
277
  this.loading = false;
278
  }
279
  });