diff --git a/src/app/app.component.html b/src/app/app.component.html index 5f44212..ea7a055 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -38,15 +38,15 @@
- + Home Login Subscriptions Downloads - + - {{subscription.name}} + {{subscription.name}} diff --git a/src/app/app.component.ts b/src/app/app.component.ts index b2ec5bf..fad0760 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -46,8 +46,6 @@ export class AppComponent implements OnInit { @ViewChild('hamburgerMenu', { read: ElementRef }) hamburgerMenuButton: ElementRef; navigator: string = null; - subscriptions = null; - constructor(public postsService: PostsService, public snackBar: MatSnackBar, private dialog: MatDialog, public router: Router, public overlayContainer: OverlayContainer, private elementRef: ElementRef) { @@ -92,7 +90,7 @@ export class AppComponent implements OnInit { // gets the subscriptions if (this.allowSubscriptions) { this.postsService.getAllSubscriptions().subscribe(res => { - this.subscriptions = res['subscriptions']; + this.postsService.subscriptions = res['subscriptions']; }) } } diff --git a/src/app/components/recent-videos/recent-videos.component.html b/src/app/components/recent-videos/recent-videos.component.html index b9b92b4..80db562 100644 --- a/src/app/components/recent-videos/recent-videos.component.html +++ b/src/app/components/recent-videos/recent-videos.component.html @@ -2,7 +2,7 @@
- +
diff --git a/src/app/components/recent-videos/recent-videos.component.ts b/src/app/components/recent-videos/recent-videos.component.ts index 7ac5a73..dd70649 100644 --- a/src/app/components/recent-videos/recent-videos.component.ts +++ b/src/app/components/recent-videos/recent-videos.component.ts @@ -1,5 +1,6 @@ import { Component, OnInit } from '@angular/core'; import { PostsService } from 'app/posts.services'; +import { Router } from '@angular/router'; @Component({ selector: 'app-recent-videos', @@ -12,7 +13,7 @@ export class RecentVideosComponent implements OnInit { subscription_files_received = false; files: any[] = null; - constructor(private postsService: PostsService) { } + constructor(private postsService: PostsService, private router: Router) { } ngOnInit(): void { this.postsService.service_initialized.subscribe(init => { @@ -30,6 +31,43 @@ export class RecentVideosComponent implements OnInit { }); } + goToFile(file) { + if (this.postsService.config['Extra']['download_only_mode']) { + this.downloadFile(file); + } else { + this.navigateToFile(file); + } + } + + navigateToFile(file) { + localStorage.setItem('player_navigator', this.router.url); + if (file.sub_id) { + const sub = this.postsService.getSubscriptionByID(file.sub_id) + if (sub.streamingOnly) { + this.router.navigate(['/player', {name: file.id, + url: file.requested_formats ? file.requested_formats[0].url : file.url}]); + } else { + this.router.navigate(['/player', {fileNames: file.id, + type: file.isAudio ? 'audio' : 'video', subscriptionName: sub.name, + subPlaylist: sub.isPlaylist, uuid: this.postsService.user ? this.postsService.user.uid : null}]); + } + } else { + this.router.navigate(['/player', {type: file.isAudio ? 'audio' : 'video', uid: file.uid}]); + } + } + + downloadFile(file) { + if (file.sub_id) { + + } else { + + } + } + + goToSubscription(file) { + this.router.navigate(['/subscription', {id: file.sub_id}]); + } + sortFiles(a, b) { // uses the 'registered' flag as the timestamp const result = b.registered - a.registered; diff --git a/src/app/components/unified-file-card/unified-file-card.component.html b/src/app/components/unified-file-card/unified-file-card.component.html index 5816a3c..2f59220 100644 --- a/src/app/components/unified-file-card/unified-file-card.component.html +++ b/src/app/components/unified-file-card/unified-file-card.component.html @@ -5,6 +5,7 @@ + diff --git a/src/app/components/unified-file-card/unified-file-card.component.ts b/src/app/components/unified-file-card/unified-file-card.component.ts index 2d600de..1a99894 100644 --- a/src/app/components/unified-file-card/unified-file-card.component.ts +++ b/src/app/components/unified-file-card/unified-file-card.component.ts @@ -1,4 +1,6 @@ -import { Component, OnInit, Input } from '@angular/core'; +import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; +import { MatDialog } from '@angular/material/dialog'; +import { VideoInfoDialogComponent } from 'app/dialogs/video-info-dialog/video-info-dialog.component'; @Component({ selector: 'app-unified-file-card', @@ -14,28 +16,46 @@ export class UnifiedFileCardComponent implements OnInit { type = null; use_youtubedl_archive = false; - isSubscriptionFile: boolean = null; - @Input() file_obj = null; + @Output() goToFile = new EventEmitter(); + @Output() goToSubscription = new EventEmitter(); - constructor() { } + /* + Planned sizes: + small: 150x175 + medium: 200x200 + big: 250x200 + */ + + constructor(private dialog: MatDialog) { } ngOnInit(): void { this.file_length = fancyTimeFormat(this.file_obj.duration); } deleteFile(blacklistMode = false) { + if (this.file_obj.sub_id) { + } } navigateToFile() { + this.goToFile.emit(this.file_obj); + } + navigateToSubscription() { + this.goToSubscription.emit(this.file_obj); } openFileInfoDialog() { - + this.dialog.open(VideoInfoDialogComponent, { + data: { + file: this.file_obj, + }, + minWidth: '50vw' + }) } - + } function fancyTimeFormat(time) { diff --git a/src/app/main/main.component.html b/src/app/main/main.component.html index ed7f1fe..63cb3a2 100644 --- a/src/app/main/main.component.html +++ b/src/app/main/main.component.html @@ -183,6 +183,7 @@ +
diff --git a/src/app/posts.services.ts b/src/app/posts.services.ts index 62ce5d2..c3331f3 100644 --- a/src/app/posts.services.ts +++ b/src/app/posts.services.ts @@ -47,6 +47,7 @@ export class PostsService implements CanActivate { open_create_default_admin_dialog = new BehaviorSubject(false); config = null; + subscriptions = null; constructor(private http: HttpClient, private router: Router, @Inject(DOCUMENT) private document: Document, public snackBar: MatSnackBar) { console.log('PostsService Initialized...'); @@ -113,6 +114,15 @@ export class PostsService implements CanActivate { this.theme = this.THEMES_CONFIG[theme]; } + getSubscriptionByID(sub_id) { + for (let i = 0; i < this.subscriptions.length; i++) { + if (this.subscriptions[i]['id'] === sub_id) { + return this.subscriptions[i]; + } + } + return null; + } + startHandshake(url: string) { return this.http.get(url + 'geturl'); }