From cc1561f9f7b33d739d66b23bacae23ea49f2fa12 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 17 Apr 2018 10:35:08 +0200 Subject: Simplify client syndications --- .../src/app/shared/video/abstract-video-list.scss | 5 +- client/src/app/shared/video/abstract-video-list.ts | 5 +- .../src/app/shared/video/video-feed.component.html | 9 ++- .../src/app/shared/video/video-feed.component.ts | 8 +-- client/src/app/shared/video/video.service.ts | 64 ++++++++++++---------- 5 files changed, 47 insertions(+), 44 deletions(-) (limited to 'client/src/app/shared') diff --git a/client/src/app/shared/video/abstract-video-list.scss b/client/src/app/shared/video/abstract-video-list.scss index b75907dc9..913fcfe22 100644 --- a/client/src/app/shared/video/abstract-video-list.scss +++ b/client/src/app/shared/video/abstract-video-list.scss @@ -8,9 +8,12 @@ } } +.title-page.title-page-single { + margin-right: 5px; +} + my-video-feed { display: inline-block; - margin-left: -45px; } @media screen and (max-width: 500px) { diff --git a/client/src/app/shared/video/abstract-video-list.ts b/client/src/app/shared/video/abstract-video-list.ts index 024834dfc..c1c07e628 100644 --- a/client/src/app/shared/video/abstract-video-list.ts +++ b/client/src/app/shared/video/abstract-video-list.ts @@ -3,7 +3,6 @@ import { ActivatedRoute, Router } from '@angular/router' import { isInMobileView } from '@app/shared/misc/utils' import { InfiniteScrollerDirective } from '@app/shared/video/infinite-scroller.directive' import { NotificationsService } from 'angular2-notifications' -import { PopoverModule } from 'ngx-bootstrap/popover' import 'rxjs/add/operator/debounceTime' import { Observable } from 'rxjs/Observable' import { fromEvent } from 'rxjs/observable/fromEvent' @@ -12,8 +11,6 @@ import { AuthService } from '../../core/auth' import { ComponentPagination } from '../rest/component-pagination.model' import { SortField } from './sort-field.type' import { Video } from './video.model' -import { FeedFormat } from '../../../../../shared' -import { VideoFeedComponent } from '@app/shared/video/video-feed.component' export abstract class AbstractVideoList implements OnInit, OnDestroy { private static LINES_PER_PAGE = 4 @@ -28,7 +25,7 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy { } sort: SortField = '-createdAt' defaultSort: SortField = '-createdAt' - syndicationItems = {} + syndicationItems = [] loadOnInit = true pageHeight: number diff --git a/client/src/app/shared/video/video-feed.component.html b/client/src/app/shared/video/video-feed.component.html index 7733ef221..5ef13e1ed 100644 --- a/client/src/app/shared/video/video-feed.component.html +++ b/client/src/app/shared/video/video-feed.component.html @@ -1,14 +1,13 @@
- -
- {{ key }} +
+ {{ item.label }}
-
- \ No newline at end of file +
\ No newline at end of file diff --git a/client/src/app/shared/video/video-feed.component.ts b/client/src/app/shared/video/video-feed.component.ts index 41257ca99..6922153c0 100644 --- a/client/src/app/shared/video/video-feed.component.ts +++ b/client/src/app/shared/video/video-feed.component.ts @@ -1,14 +1,10 @@ -import { Component, Input, OnChanges, SimpleChanges } from '@angular/core' +import { Component, Input } from '@angular/core' @Component({ selector: 'my-video-feed', styleUrls: [ './video-feed.component.scss' ], templateUrl: './video-feed.component.html' }) -export class VideoFeedComponent implements OnChanges { +export class VideoFeedComponent { @Input() syndicationItems - - ngOnChanges (changes: SimpleChanges) { - this.syndicationItems = changes.syndicationItems.currentValue - } } diff --git a/client/src/app/shared/video/video.service.ts b/client/src/app/shared/video/video.service.ts index 009155410..4c19c3765 100644 --- a/client/src/app/shared/video/video.service.ts +++ b/client/src/app/shared/video/video.service.ts @@ -117,45 +117,53 @@ export class VideoService { .catch((res) => this.restExtractor.handleError(res)) } - baseFeed () { - const feed = {} - - for (let item in FeedFormat) { - feed[FeedFormat[item]] = VideoService.BASE_FEEDS_URL + item.toLowerCase() - } - - return feed - } - - getFeed ( - filter?: VideoFilter - ) { + buildBaseFeedUrls () { + const feeds = [ + { + label: 'rss 2.0', + url: VideoService.BASE_FEEDS_URL + FeedFormat.RSS.toLowerCase() + }, + { + label: 'atom 1.0', + url: VideoService.BASE_FEEDS_URL + FeedFormat.ATOM.toLowerCase() + }, + { + label: 'json 1.0', + url: VideoService.BASE_FEEDS_URL + FeedFormat.JSON.toLowerCase() + } + ] + + return feeds + } + + getVideoFeedUrls (filter?: VideoFilter) { let params = this.restService.addRestGetParams(new HttpParams()) - const feed = this.baseFeed() + const feeds = this.buildBaseFeedUrls() - if (filter) { - params = params.set('filter', filter) - } - for (let item in feed) { - feed[item] = feed[item] + ((params.toString().length === 0) ? '' : '?') + params.toString() + if (filter) params = params.set('filter', filter) + + if (params.keys().length !== 0) { + for (let item of feeds) { + item.url += `?${params.toString()}` + } } - return feed + return feeds } - getAccountFeed ( - accountId: number, - host?: string - ) { + getAccountFeedUrls (accountId: number) { let params = this.restService.addRestGetParams(new HttpParams()) - const feed = this.baseFeed() + const feeds = this.buildBaseFeedUrls() params = params.set('accountId', accountId.toString()) - for (let item in feed) { - feed[item] = feed[item] + ((params.toString().length === 0) ? '' : '?') + params.toString() + + if (params.keys().length !== 0) { + for (let item of feeds) { + item.url += `?${params.toString()}` + } } - return feed + return feeds } searchVideos ( -- cgit v1.2.3