aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-04-17 10:35:08 +0200
committerChocobozzz <me@florianbigard.com>2018-04-17 10:35:08 +0200
commitcc1561f9f7b33d739d66b23bacae23ea49f2fa12 (patch)
tree4ba9e905eaff4c80e9412b1ccf344c81c8c41ea8 /client/src/app/shared
parente6f627975bebd00d396d11442e582d80856bc6bd (diff)
downloadPeerTube-cc1561f9f7b33d739d66b23bacae23ea49f2fa12.tar.gz
PeerTube-cc1561f9f7b33d739d66b23bacae23ea49f2fa12.tar.zst
PeerTube-cc1561f9f7b33d739d66b23bacae23ea49f2fa12.zip
Simplify client syndications
Diffstat (limited to 'client/src/app/shared')
-rw-r--r--client/src/app/shared/video/abstract-video-list.scss5
-rw-r--r--client/src/app/shared/video/abstract-video-list.ts5
-rw-r--r--client/src/app/shared/video/video-feed.component.html9
-rw-r--r--client/src/app/shared/video/video-feed.component.ts8
-rw-r--r--client/src/app/shared/video/video.service.ts64
5 files changed, 47 insertions, 44 deletions
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 @@
8 } 8 }
9} 9}
10 10
11.title-page.title-page-single {
12 margin-right: 5px;
13}
14
11my-video-feed { 15my-video-feed {
12 display: inline-block; 16 display: inline-block;
13 margin-left: -45px;
14} 17}
15 18
16@media screen and (max-width: 500px) { 19@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'
3import { isInMobileView } from '@app/shared/misc/utils' 3import { isInMobileView } from '@app/shared/misc/utils'
4import { InfiniteScrollerDirective } from '@app/shared/video/infinite-scroller.directive' 4import { InfiniteScrollerDirective } from '@app/shared/video/infinite-scroller.directive'
5import { NotificationsService } from 'angular2-notifications' 5import { NotificationsService } from 'angular2-notifications'
6import { PopoverModule } from 'ngx-bootstrap/popover'
7import 'rxjs/add/operator/debounceTime' 6import 'rxjs/add/operator/debounceTime'
8import { Observable } from 'rxjs/Observable' 7import { Observable } from 'rxjs/Observable'
9import { fromEvent } from 'rxjs/observable/fromEvent' 8import { fromEvent } from 'rxjs/observable/fromEvent'
@@ -12,8 +11,6 @@ import { AuthService } from '../../core/auth'
12import { ComponentPagination } from '../rest/component-pagination.model' 11import { ComponentPagination } from '../rest/component-pagination.model'
13import { SortField } from './sort-field.type' 12import { SortField } from './sort-field.type'
14import { Video } from './video.model' 13import { Video } from './video.model'
15import { FeedFormat } from '../../../../../shared'
16import { VideoFeedComponent } from '@app/shared/video/video-feed.component'
17 14
18export abstract class AbstractVideoList implements OnInit, OnDestroy { 15export abstract class AbstractVideoList implements OnInit, OnDestroy {
19 private static LINES_PER_PAGE = 4 16 private static LINES_PER_PAGE = 4
@@ -28,7 +25,7 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy {
28 } 25 }
29 sort: SortField = '-createdAt' 26 sort: SortField = '-createdAt'
30 defaultSort: SortField = '-createdAt' 27 defaultSort: SortField = '-createdAt'
31 syndicationItems = {} 28 syndicationItems = []
32 29
33 loadOnInit = true 30 loadOnInit = true
34 pageHeight: number 31 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 @@
1<div class="video-feed"> 1<div class="video-feed">
2 <span *ngIf="(syndicationItems | myObjectLength) >= 1" class="icon icon-syndication" 2 <span *ngIf="syndicationItems.length !== 0" class="icon icon-syndication"
3 [popover]="feedsList" 3 [popover]="feedsList"
4 placement="bottom" 4 placement="bottom"
5 [outsideClick]="true"> 5 [outsideClick]="true">
6 </span> 6 </span>
7 7
8 <ng-template #feedsList> 8 <ng-template #feedsList>
9 <div *ngFor="let key of syndicationItems | keys"> 9 <div *ngFor="let item of syndicationItems">
10 <a [href]="syndicationItems[key]">{{ key }}</a> 10 <a [href]="item.url" target="_blank" rel="noopener noreferrer">{{ item.label }}</a>
11 </div> 11 </div>
12 </ng-template> 12 </ng-template>
13</div> 13</div> \ No newline at end of file
14 \ 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 @@
1import { Component, Input, OnChanges, SimpleChanges } from '@angular/core' 1import { Component, Input } from '@angular/core'
2 2
3@Component({ 3@Component({
4 selector: 'my-video-feed', 4 selector: 'my-video-feed',
5 styleUrls: [ './video-feed.component.scss' ], 5 styleUrls: [ './video-feed.component.scss' ],
6 templateUrl: './video-feed.component.html' 6 templateUrl: './video-feed.component.html'
7}) 7})
8export class VideoFeedComponent implements OnChanges { 8export class VideoFeedComponent {
9 @Input() syndicationItems 9 @Input() syndicationItems
10
11 ngOnChanges (changes: SimpleChanges) {
12 this.syndicationItems = changes.syndicationItems.currentValue
13 }
14} 10}
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 {
117 .catch((res) => this.restExtractor.handleError(res)) 117 .catch((res) => this.restExtractor.handleError(res))
118 } 118 }
119 119
120 baseFeed () { 120 buildBaseFeedUrls () {
121 const feed = {} 121 const feeds = [
122 122 {
123 for (let item in FeedFormat) { 123 label: 'rss 2.0',
124 feed[FeedFormat[item]] = VideoService.BASE_FEEDS_URL + item.toLowerCase() 124 url: VideoService.BASE_FEEDS_URL + FeedFormat.RSS.toLowerCase()
125 } 125 },
126 126 {
127 return feed 127 label: 'atom 1.0',
128 } 128 url: VideoService.BASE_FEEDS_URL + FeedFormat.ATOM.toLowerCase()
129 129 },
130 getFeed ( 130 {
131 filter?: VideoFilter 131 label: 'json 1.0',
132 ) { 132 url: VideoService.BASE_FEEDS_URL + FeedFormat.JSON.toLowerCase()
133 }
134 ]
135
136 return feeds
137 }
138
139 getVideoFeedUrls (filter?: VideoFilter) {
133 let params = this.restService.addRestGetParams(new HttpParams()) 140 let params = this.restService.addRestGetParams(new HttpParams())
134 const feed = this.baseFeed() 141 const feeds = this.buildBaseFeedUrls()
135 142
136 if (filter) { 143 if (filter) params = params.set('filter', filter)
137 params = params.set('filter', filter) 144
138 } 145 if (params.keys().length !== 0) {
139 for (let item in feed) { 146 for (let item of feeds) {
140 feed[item] = feed[item] + ((params.toString().length === 0) ? '' : '?') + params.toString() 147 item.url += `?${params.toString()}`
148 }
141 } 149 }
142 150
143 return feed 151 return feeds
144 } 152 }
145 153
146 getAccountFeed ( 154 getAccountFeedUrls (accountId: number) {
147 accountId: number,
148 host?: string
149 ) {
150 let params = this.restService.addRestGetParams(new HttpParams()) 155 let params = this.restService.addRestGetParams(new HttpParams())
151 const feed = this.baseFeed() 156 const feeds = this.buildBaseFeedUrls()
152 157
153 params = params.set('accountId', accountId.toString()) 158 params = params.set('accountId', accountId.toString())
154 for (let item in feed) { 159
155 feed[item] = feed[item] + ((params.toString().length === 0) ? '' : '?') + params.toString() 160 if (params.keys().length !== 0) {
161 for (let item of feeds) {
162 item.url += `?${params.toString()}`
163 }
156 } 164 }
157 165
158 return feed 166 return feeds
159 } 167 }
160 168
161 searchVideos ( 169 searchVideos (