From 066e94c5382a761180c7d82fa24b31b66dbeaca4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 13 Mar 2018 10:24:28 +0100 Subject: Add "local" videos in menu --- client/src/app/menu/menu.component.html | 5 +++ client/src/app/menu/menu.component.scss | 8 +++++ client/src/app/shared/video/video.service.ts | 11 ++++++- .../app/videos/video-list/video-local.component.ts | 37 ++++++++++++++++++++++ client/src/app/videos/videos-routing.module.ts | 10 ++++++ client/src/app/videos/videos.module.ts | 2 ++ client/src/assets/images/menu/home.svg | 15 +++++++++ 7 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 client/src/app/videos/video-list/video-local.component.ts create mode 100644 client/src/assets/images/menu/home.svg (limited to 'client/src') diff --git a/client/src/app/menu/menu.component.html b/client/src/app/menu/menu.component.html index d174c76ba..d827a4dd4 100644 --- a/client/src/app/menu/menu.component.html +++ b/client/src/app/menu/menu.component.html @@ -43,6 +43,11 @@ Recently added + + + + Local +
diff --git a/client/src/app/menu/menu.component.scss b/client/src/app/menu/menu.component.scss index 1f3c889cf..da5a581a1 100644 --- a/client/src/app/menu/menu.component.scss +++ b/client/src/app/menu/menu.component.scss @@ -126,6 +126,14 @@ menu { background-image: url('../../assets/images/menu/recently-added.svg'); } + &.icon-videos-local { + width: 23px; + height: 23px; + position: relative; + top: -1px; + background-image: url('../../assets/images/menu/home.svg'); + } + &.icon-administration { width: 23px; height: 23px; diff --git a/client/src/app/shared/video/video.service.ts b/client/src/app/shared/video/video.service.ts index a151a2983..0a8894fd9 100644 --- a/client/src/app/shared/video/video.service.ts +++ b/client/src/app/shared/video/video.service.ts @@ -7,6 +7,7 @@ import { Video as VideoServerModel, VideoDetails as VideoDetailsServerModel } fr import { ResultList } from '../../../../../shared/models/result-list.model' import { UserVideoRateUpdate } from '../../../../../shared/models/videos/user-video-rate-update.model' import { UserVideoRate } from '../../../../../shared/models/videos/user-video-rate.model' +import { VideoFilter } from '../../../../../shared/models/videos/video-query.type' import { VideoRateType } from '../../../../../shared/models/videos/video-rate.type' import { VideoUpdate } from '../../../../../shared/models/videos/video-update.model' import { environment } from '../../../environments/environment' @@ -94,12 +95,20 @@ export class VideoService { .catch((res) => this.restExtractor.handleError(res)) } - getVideos (videoPagination: ComponentPagination, sort: SortField): Observable<{ videos: Video[], totalVideos: number}> { + getVideos ( + videoPagination: ComponentPagination, + sort: SortField, + filter?: VideoFilter + ): Observable<{ videos: Video[], totalVideos: number}> { const pagination = this.restService.componentPaginationToRestPagination(videoPagination) let params = new HttpParams() params = this.restService.addRestGetParams(params, pagination, sort) + if (filter) { + params = params.set('filter', filter) + } + return this.authHttp .get(VideoService.BASE_VIDEO_URL, { params }) .map(this.extractVideos) diff --git a/client/src/app/videos/video-list/video-local.component.ts b/client/src/app/videos/video-list/video-local.component.ts new file mode 100644 index 000000000..8cac2c12c --- /dev/null +++ b/client/src/app/videos/video-list/video-local.component.ts @@ -0,0 +1,37 @@ +import { Component, OnInit } from '@angular/core' +import { ActivatedRoute, Router } from '@angular/router' +import { immutableAssign } from '@app/shared/misc/utils' +import { NotificationsService } from 'angular2-notifications' +import { AuthService } from '../../core/auth' +import { AbstractVideoList } from '../../shared/video/abstract-video-list' +import { SortField } from '../../shared/video/sort-field.type' +import { VideoService } from '../../shared/video/video.service' + +@Component({ + selector: 'my-videos-local', + styleUrls: [ '../../shared/video/abstract-video-list.scss' ], + templateUrl: '../../shared/video/abstract-video-list.html' +}) +export class VideoLocalComponent extends AbstractVideoList implements OnInit { + titlePage = 'Local videos' + currentRoute = '/videos/local' + sort = '-createdAt' as SortField + + constructor (protected router: Router, + protected route: ActivatedRoute, + protected notificationsService: NotificationsService, + protected authService: AuthService, + private videoService: VideoService) { + super() + } + + ngOnInit () { + super.ngOnInit() + } + + getVideosObservable (page: number) { + const newPagination = immutableAssign(this.pagination, { currentPage: page }) + + return this.videoService.getVideos(newPagination, this.sort, 'local') + } +} diff --git a/client/src/app/videos/videos-routing.module.ts b/client/src/app/videos/videos-routing.module.ts index 29ec5fd4f..561137b70 100644 --- a/client/src/app/videos/videos-routing.module.ts +++ b/client/src/app/videos/videos-routing.module.ts @@ -1,5 +1,6 @@ import { NgModule } from '@angular/core' import { RouterModule, Routes } from '@angular/router' +import { VideoLocalComponent } from '@app/videos/video-list/video-local.component' import { MetaGuard } from '@ngx-meta/core' import { VideoSearchComponent } from './video-list' import { VideoRecentlyAddedComponent } from './video-list/video-recently-added.component' @@ -35,6 +36,15 @@ const videosRoutes: Routes = [ } } }, + { + path: 'local', + component: VideoLocalComponent, + data: { + meta: { + title: 'Local videos' + } + } + }, { path: 'search', component: VideoSearchComponent, diff --git a/client/src/app/videos/videos.module.ts b/client/src/app/videos/videos.module.ts index 4b14d1da8..7c3d457b3 100644 --- a/client/src/app/videos/videos.module.ts +++ b/client/src/app/videos/videos.module.ts @@ -1,4 +1,5 @@ import { NgModule } from '@angular/core' +import { VideoLocalComponent } from '@app/videos/video-list/video-local.component' import { SharedModule } from '../shared' import { VideoSearchComponent } from './video-list' import { VideoRecentlyAddedComponent } from './video-list/video-recently-added.component' @@ -17,6 +18,7 @@ import { VideosComponent } from './videos.component' VideoTrendingComponent, VideoRecentlyAddedComponent, + VideoLocalComponent, VideoSearchComponent ], diff --git a/client/src/assets/images/menu/home.svg b/client/src/assets/images/menu/home.svg new file mode 100644 index 000000000..bb95e949a --- /dev/null +++ b/client/src/assets/images/menu/home.svg @@ -0,0 +1,15 @@ + + + + home + Created with Sketch. + + + + + + + + + + -- cgit v1.2.3