]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+stats/video/video-stats.service.ts
Cleanup title-page CSS
[github/Chocobozzz/PeerTube.git] / client / src / app / +stats / video / video-stats.service.ts
index 8f9d48f6083d67f29226119c02bea3167d14c379..e019c87f71e485e20a3ae2c33f1c7f3647648d3a 100644 (file)
@@ -1,6 +1,6 @@
 import { catchError } from 'rxjs'
 import { environment } from 'src/environments/environment'
-import { HttpClient } from '@angular/common/http'
+import { HttpClient, HttpParams } from '@angular/common/http'
 import { Injectable } from '@angular/core'
 import { RestExtractor } from '@app/core'
 import { VideoService } from '@app/shared/shared-main'
@@ -17,13 +17,34 @@ export class VideoStatsService {
     private restExtractor: RestExtractor
   ) { }
 
-  getOverallStats (videoId: string) {
-    return this.authHttp.get<VideoStatsOverall>(VideoService.BASE_VIDEO_URL + '/' + videoId + '/stats/overall')
+  getOverallStats (options: {
+    videoId: string
+    startDate?: Date
+    endDate?: Date
+  }) {
+    const { videoId, startDate, endDate } = options
+
+    let params = new HttpParams()
+    if (startDate) params = params.append('startDate', startDate.toISOString())
+    if (endDate) params = params.append('endDate', endDate.toISOString())
+
+    return this.authHttp.get<VideoStatsOverall>(VideoService.BASE_VIDEO_URL + '/' + videoId + '/stats/overall', { params })
       .pipe(catchError(err => this.restExtractor.handleError(err)))
   }
 
-  getTimeserieStats (videoId: string, metric: VideoStatsTimeserieMetric) {
-    return this.authHttp.get<VideoStatsTimeserie>(VideoService.BASE_VIDEO_URL + '/' + videoId + '/stats/timeseries/' + metric)
+  getTimeserieStats (options: {
+    videoId: string
+    metric: VideoStatsTimeserieMetric
+    startDate?: Date
+    endDate?: Date
+  }) {
+    const { videoId, metric, startDate, endDate } = options
+
+    let params = new HttpParams()
+    if (startDate) params = params.append('startDate', startDate.toISOString())
+    if (endDate) params = params.append('endDate', endDate.toISOString())
+
+    return this.authHttp.get<VideoStatsTimeserie>(VideoService.BASE_VIDEO_URL + '/' + videoId + '/stats/timeseries/' + metric, { params })
       .pipe(catchError(err => this.restExtractor.handleError(err)))
   }