diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts
index 470c44c..df9fee2 100644
--- a/src/app/app-routing.module.ts
+++ b/src/app/app-routing.module.ts
@@ -28,9 +28,7 @@ const routes: Routes = [
{ path: 'user/myPlaylists', component: PageMyPlaylistsComponent },
{ path: 'user/history', component: PageHistoryUserComponent },
{ path: 'user/myProfil', component: PageProfilUserComponent },
- { path: 'user/watching/fromSearch/:videoId/:source/:search', component: PageWatchingVideoComponent },
- { path: 'user/watching/fromMyPlaylists/:videoId/:_idPlaylist', component: PageWatchingVideoComponent },
- { path: 'user/watching/fromHistory/:videoId/:source', component: PageWatchingVideoComponent },
+ { path: 'user/watching', component: PageWatchingVideoComponent },
// Advertiser
{ path: 'advertiser', component: PageAdListAdvertiserComponent },
diff --git a/src/app/user/history/page-history-user/page-history-user.component.ts b/src/app/user/history/page-history-user/page-history-user.component.ts
index 5687a6a..53ec37d 100644
--- a/src/app/user/history/page-history-user/page-history-user.component.ts
+++ b/src/app/user/history/page-history-user/page-history-user.component.ts
@@ -99,8 +99,12 @@ export class PageHistoryUserComponent implements AfterViewInit
.put("video/update/"+video._id, {watchedDate: true})
.subscribe(ret => this.onVideoCallback(ret), err => this.onVideoCallback(err));
- const url = '/user/watching/fromHistory/'+video.videoId+'/'+video.source ;
- this.router.navigateByUrl(url);
+ const params = {
+ videoId: video.videoId,
+ source: video.source,
+ from: "history",
+ };
+ this.router.navigate(['/user/watching'], { queryParams: params });
}
diff --git a/src/app/user/myPlaylists/video-list/video-list.component.ts b/src/app/user/myPlaylists/video-list/video-list.component.ts
index 2976d98..5d4819c 100644
--- a/src/app/user/myPlaylists/video-list/video-list.component.ts
+++ b/src/app/user/myPlaylists/video-list/video-list.component.ts
@@ -70,8 +70,13 @@ export class VideoListComponent implements OnChanges
onVideo(video: any): void
{
- const url = "user/watching/fromMyPlaylists/" + video.videoId + '/' + this.playlist._id;
- this.router.navigateByUrl(url);
+ const params = {
+ videoId: video.videoId,
+ source: video.source,
+ _idPlaylist: this.playlist._id,
+ from: "myPlaylists",
+ };
+ this.router.navigate(['/user/watching'], { queryParams: params });
}
}
diff --git a/src/app/user/search/page-search/page-search.component.html b/src/app/user/search/page-search/page-search.component.html
index 1f6f645..0039bdd 100644
--- a/src/app/user/search/page-search/page-search.component.html
+++ b/src/app/user/search/page-search/page-search.component.html
@@ -62,7 +62,7 @@
diff --git a/src/app/user/search/page-search/page-search.component.ts b/src/app/user/search/page-search/page-search.component.ts
index 6994b3a..7ab145f 100644
--- a/src/app/user/search/page-search/page-search.component.ts
+++ b/src/app/user/search/page-search/page-search.component.ts
@@ -3,6 +3,7 @@ import {MessageService} from "../../../utils/services/message/message.service";
import {VideoAll} from "../../../utils/interfaces/video";
import {ThemeService} from "../../../utils/services/theme/theme.service";
import {HttpParams} from "@angular/common/http";
+import {ActivatedRoute} from "@angular/router";
@@ -25,28 +26,55 @@ export class PageSearchComponent implements OnInit
search: string = "";
ad1: any;
ad2: any;
+ sources: string = "" ;
+ indexPage: number = 0;
constructor( private messageService: MessageService,
- public themeService: ThemeService ) { }
+ public themeService: ThemeService,
+ private activatedRoute: ActivatedRoute ) { }
ngOnInit(): void
{
+ // parametre de la route
+ this.activatedRoute
+ .queryParams
+ .subscribe(paramsFromOldPage => {
+ if(paramsFromOldPage.hasOwnProperty("search")) this.search = paramsFromOldPage.search;
+ if(paramsFromOldPage.hasOwnProperty("sources"))
+ {
+ this.sources = paramsFromOldPage.sources;
+ if(this.sources === "yt") {
+ this.tabPlateform[0].isSelected = true;
+ this.tabPlateform[1].isSelected = false;
+ }
+ else if(this.sources === "dm") {
+ this.tabPlateform[0].isSelected = false;
+ this.tabPlateform[1].isSelected = true;
+ }
+ else if(this.sources === "yt,dm") {
+ this.tabPlateform[0].isSelected = true;
+ this.tabPlateform[1].isSelected = true;
+ }
+ }
+ if(paramsFromOldPage.hasOwnProperty("indexPage")) this.indexPage = parseInt(paramsFromOldPage.indexPage, 10);
+ this.onSearch();
+ });
+
+ // Ask for ads
let params = new HttpParams();
params = params.append("quantity", 2);
this.messageService
.get("user/ad", params)
.subscribe(ret => this.adCallback(ret), err => this.adCallback(err));
-
- this.onSearch();
}
adCallback(retour: any): void
{
if(retour.status !== "success") {
- //console.log(retour);
+ console.log(retour);
}
else {
this.ad1 = retour.data[0];
@@ -60,12 +88,11 @@ export class PageSearchComponent implements OnInit
let params = new HttpParams();
params = params.append('q', this.search);
- let sources = "";
- if(this.tabPlateform[0].isSelected && this.tabPlateform[1].isSelected) sources += "yt,dm" ;
- else if((!this.tabPlateform[0].isSelected) && this.tabPlateform[1].isSelected) sources += "dm" ;
- else if(this.tabPlateform[0].isSelected && (!this.tabPlateform[1].isSelected)) sources += "yt" ;
- else sources += "" ;
- params = params.append('sources', sources);
+ if(this.tabPlateform[0].isSelected && this.tabPlateform[1].isSelected) this.sources = "yt,dm" ;
+ else if((!this.tabPlateform[0].isSelected) && this.tabPlateform[1].isSelected) this.sources = "dm" ;
+ else if(this.tabPlateform[0].isSelected && (!this.tabPlateform[1].isSelected)) this.sources = "yt" ;
+ else this.sources = "" ;
+ params = params.append('sources', this.sources);
this.messageService
.get("video/search", params)
diff --git a/src/app/user/search/video-grid/video-grid.component.html b/src/app/user/search/video-grid/video-grid.component.html
index f0227d8..841d5c3 100644
--- a/src/app/user/search/video-grid/video-grid.component.html
+++ b/src/app/user/search/video-grid/video-grid.component.html
@@ -2,7 +2,7 @@
-
+
@@ -55,13 +55,13 @@
-
+
-
+
{{page}}
diff --git a/src/app/user/search/video-grid/video-grid.component.ts b/src/app/user/search/video-grid/video-grid.component.ts
index ce2dfde..6e13887 100644
--- a/src/app/user/search/video-grid/video-grid.component.ts
+++ b/src/app/user/search/video-grid/video-grid.component.ts
@@ -1,4 +1,4 @@
-import {Component, Input } from '@angular/core';
+import {Component, Input, OnChanges, OnInit, SimpleChanges} from '@angular/core';
import {VideoAll} from "../../../utils/interfaces/video";
import {AddVideoToPlaylistsService} from "../../utils/services/addVideoToPlaylists/add-video-to-playlists.service";
import {Router} from "@angular/router";
@@ -11,11 +11,13 @@ import {MessageService} from "../../../utils/services/message/message.service";
templateUrl: './video-grid.component.html',
styleUrls: ['./video-grid.component.scss']
})
-export class VideoGridComponent
+export class VideoGridComponent implements OnChanges
{
@Input() tabVideo: VideoAll[] = [];
- @Input() search: string = '';
- indexPage: number = 0;
+ @Input() search: string = "";
+ @Input() sources: string = "";
+ @Input() indexPage: number = 0;
+ tabPage: number[] = [];
constructor( private addVideoToPlaylistsService: AddVideoToPlaylistsService,
@@ -23,6 +25,19 @@ export class VideoGridComponent
private messageService: MessageService ) {}
+ ngOnChanges(changes: SimpleChanges): void
+ {
+ if(this.tabVideoExists())
+ {
+ const nbVideo = this.tabVideo.length;
+ let nbPage = Math.floor(nbVideo/9);
+ if((nbVideo%9) !== 0) nbPage += 1;
+ this.tabPage = [];
+ for(let i=1 ; i<=nbPage ; i++) this.tabPage.push(i);
+ }
+ }
+
+
onAddToPlaylist(video: VideoAll): void
{
this.addVideoToPlaylistsService.run(video.videoId, video.source, video.interest);
@@ -41,16 +56,26 @@ export class VideoGridComponent
const data = { source: video.source, interest: video.interest };
this.messageService
.post("video/create/"+video.videoId, data)
- .subscribe(ret => this.onVideoCallback(ret), err => this.onVideoCallback(err));
-
- const url = '/user/watching/fromSearch/'+video.videoId+'/'+video.source+'/'+this.search;
- this.router.navigateByUrl(url);
+ .subscribe(ret => this.onVideoCallback(ret,video), err => this.onVideoCallback(err,video));
}
- onVideoCallback(retour: any): void
+ onVideoCallback(retour: any, video: VideoAll): void
{
- if(retour.status !== "success") console.log(retour);
+ if(retour.status !== "success") {
+ console.log(retour);
+ }
+ else {
+ const params = {
+ videoId: video.videoId,
+ source: video.source,
+ from: "search",
+ search: this.search,
+ sources: this.sources,
+ indexPage: this.indexPage
+ };
+ this.router.navigate(['/user/watching'], { queryParams: params });
+ }
}
@@ -93,4 +118,12 @@ export class VideoGridComponent
else return ellapsedTimeInYears + " ans" ;
}
+
+ tabVideoExists(): boolean
+ {
+ if((this.tabVideo === null) || (this.tabVideo === undefined)) return false;
+ else if(this.tabVideo.length === 0) return false;
+ else return true;
+ }
+
}
diff --git a/src/app/user/watching/page-watching-video/page-watching-video.component.html b/src/app/user/watching/page-watching-video/page-watching-video.component.html
index fdee7e7..9cf8392 100644
--- a/src/app/user/watching/page-watching-video/page-watching-video.component.html
+++ b/src/app/user/watching/page-watching-video/page-watching-video.component.html
@@ -17,7 +17,7 @@