From 00a446454d4721fc49517815655f6b4f8a17b554 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 10 Jun 2016 17:43:40 +0200 Subject: Add tags support to the video list --- .../app/videos/video-list/video-list.component.ts | 36 +++++++++++-------- .../video-list/video-miniature.component.html | 14 +++++--- .../video-list/video-miniature.component.scss | 42 ++++++++++++++++++---- .../videos/video-list/video-miniature.component.ts | 2 +- 4 files changed, 68 insertions(+), 26 deletions(-) (limited to 'client/src/app/videos/video-list') diff --git a/client/src/app/videos/video-list/video-list.component.ts b/client/src/app/videos/video-list/video-list.component.ts index 059317383..46263eb65 100644 --- a/client/src/app/videos/video-list/video-list.component.ts +++ b/client/src/app/videos/video-list/video-list.component.ts @@ -1,5 +1,5 @@ import { Component, OnInit } from '@angular/core'; -import { Router, ROUTER_DIRECTIVES, RouteParams } from '@angular/router-deprecated'; +import { Router, ROUTER_DIRECTIVES, RouteSegment } from '@angular/router'; import { PAGINATION_DIRECTIVES } from 'ng2-bootstrap/components/pagination'; @@ -13,6 +13,7 @@ import { import { AuthService, Search, SearchField, User } from '../../shared'; import { VideoMiniatureComponent } from './video-miniature.component'; import { VideoSortComponent } from './video-sort.component'; +import { SearchService } from '../../shared'; @Component({ selector: 'my-videos-list', @@ -37,22 +38,26 @@ export class VideoListComponent implements OnInit { constructor( private authService: AuthService, private router: Router, - private routeParams: RouteParams, - private videoService: VideoService - ) { - this.search = { - value: this.routeParams.get('search'), - field: this.routeParams.get('field') - }; - - this.sort = this.routeParams.get('sort') || '-createdDate'; - } + private routeSegment: RouteSegment, + private videoService: VideoService, + private searchService: SearchService // Temporary + ) {} ngOnInit() { if (this.authService.isLoggedIn()) { this.user = User.load(); } + this.search = { + value: this.routeSegment.getParam('search'), + field: this.routeSegment.getParam('field') + }; + + // Temporary + this.searchChanged(this.search); + + this.sort = this.routeSegment.getParam('sort') || '-createdDate'; + this.getVideos(); } @@ -62,7 +67,7 @@ export class VideoListComponent implements OnInit { let observable = null; - if (this.search.value !== null) { + if (this.search.value) { observable = this.videoService.searchVideos(this.search, this.pagination, this.sort); } else { observable = this.videoService.getVideos(this.pagination, this.sort); @@ -99,7 +104,10 @@ export class VideoListComponent implements OnInit { params.search = this.search.value; } - this.router.navigate(['VideosList', params]); - this.getVideos(); + this.router.navigate(['/videos/list', params]); + } + + searchChanged(search: Search) { + this.searchService.searchChanged.next(search); } } diff --git a/client/src/app/videos/video-list/video-miniature.component.html b/client/src/app/videos/video-list/video-miniature.component.html index 244254b5a..92e19bb8b 100644 --- a/client/src/app/videos/video-list/video-miniature.component.html +++ b/client/src/app/videos/video-list/video-miniature.component.html @@ -1,6 +1,6 @@
video thumbnail @@ -12,11 +12,15 @@ >
- - {{ video.name }} - + + {{ video.name }} - by {{ video.by }} + + {{ tag }} + + + + by {{ video.by }} on {{ video.createdDate | date:'short' }}
diff --git a/client/src/app/videos/video-list/video-miniature.component.scss b/client/src/app/videos/video-list/video-miniature.component.scss index 3aa0ca63b..40d37b83f 100644 --- a/client/src/app/videos/video-list/video-miniature.component.scss +++ b/client/src/app/videos/video-list/video-miniature.component.scss @@ -1,5 +1,5 @@ .video-miniature { - height: 200px; + margin-top: 30px; display: inline-block; position: relative; @@ -35,13 +35,34 @@ .video-miniature-informations { margin-left: 3px; + width: 200px; - .video-miniature-name { + .video-miniature-name-tags { display: block; - font-weight: bold; - &:hover { - text-decoration: none; + .video-miniature-name { + font-weight: bold; + + &:hover { + text-decoration: none; + } + + &::after { + content: '\002022'; + margin-left: 3px; + } + } + + .video-miniature-tag { + font-size: 12px; + cursor: pointer; + transition: opacity 0.5s; + position: relative; + top: -2px; + + &:hover { + opacity: 0.9; + } } } @@ -49,7 +70,16 @@ display: block; margin-left: 1px; font-size: 11px; - color: rgba(0, 0, 0, 0.5); + color: rgb(54, 118, 173); + } + + .video-miniature-author { + transition: opacity 0.5s; + + &:hover { + text-decoration: none; + opacity: 0.9; + } } } } diff --git a/client/src/app/videos/video-list/video-miniature.component.ts b/client/src/app/videos/video-list/video-miniature.component.ts index 639339b44..90645d67f 100644 --- a/client/src/app/videos/video-list/video-miniature.component.ts +++ b/client/src/app/videos/video-list/video-miniature.component.ts @@ -1,6 +1,6 @@ import { DatePipe } from '@angular/common'; import { Component, Input, Output, EventEmitter } from '@angular/core'; -import { ROUTER_DIRECTIVES } from '@angular/router-deprecated'; +import { ROUTER_DIRECTIVES } from '@angular/router'; import { Video, VideoService } from '../shared'; import { User } from '../../shared'; -- cgit v1.2.3