added basic subscriptions support for playlists and channels

update youtube-dl binary on windows

updated favicon to the new icon
This commit is contained in:
Isaac Grynsztein
2020-03-05 20:14:36 -05:00
parent a755b0b281
commit a70abb3945
38 changed files with 1200 additions and 32 deletions

View File

@@ -0,0 +1,54 @@
<br/>
<h2 style="text-align: center; margin-bottom: 15px;">Your subscriptions</h2>
<mat-divider style="width: 80%; margin: 0 auto"></mat-divider>
<br/>
<h4 style="text-align: center;">Channels</h4>
<mat-nav-list class="sub-nav-list">
<mat-list-item *ngFor="let sub of channel_subscriptions">
<a class="a-list-item" matLine (click)="goToSubscription(sub)" href="javascript:void(0)">
<strong *ngIf="sub.name">{{ sub.name }}</strong>
<div *ngIf="!sub.name">
<ngx-content-loading [width]="200" [height]="20">
<svg:g ngx-rect width="200" height="20" y="0" x="0" rx="4" ry="4"></svg:g>
</ngx-content-loading>
</div>
</a>
<button mat-icon-button (click)="showSubInfo(sub)">
<mat-icon>info</mat-icon>
</button>
</mat-list-item>
</mat-nav-list>
<div style="width: 80%; margin: 0 auto; padding-left: 15px;" *ngIf="channel_subscriptions.length === 0 && subscriptions">
<p>You have no channel subscriptions.</p>
</div>
<h4 style="text-align: center;">Playlists</h4>
<mat-nav-list class="sub-nav-list">
<mat-list-item *ngFor="let sub of playlist_subscriptions">
<a class="a-list-item" matLine (click)="goToSubscription(sub)" href="javascript:void(0)">
<strong>{{ sub.name }}</strong>
<div class="content-loading-div" *ngIf="!sub.name">
<ngx-content-loading [primaryColor]="postsService.theme.background_color" [secondaryColor]="postsService.theme.alternate_color" [width]="200" [height]="20">
<svg:g ngx-rect width="200" height="20" y="0" x="0" rx="4" ry="4"></svg:g>
</ngx-content-loading>
</div>
</a>
<button mat-icon-button (click)="showSubInfo(sub)">
<mat-icon>info</mat-icon>
</button>
</mat-list-item>
</mat-nav-list>
<div style="width: 80%; margin: 0 auto; padding-left: 15px;" *ngIf="!playlist_subscriptions && subscriptions">
<p>You have no playlist subscriptions.</p>
</div>
<div style="margin: 0 auto" *ngIf="subscriptions_loading">
<mat-progress-bar mode="indeterminate"></mat-progress-bar>
</div>
<button class="add-subscription-button" (click)="openSubscribeDialog()" mat-fab><mat-icon>add</mat-icon></button>

View File

@@ -0,0 +1,27 @@
.add-subscription-button {
position: fixed;
bottom: 30px;
right: 30px;
}
.subscription-card {
height: 200px;
width: 300px;
}
.content-loading-div {
position: absolute;
width: 200px;
height: 50px;
bottom: -18px;
}
.a-list-item {
height: 48px;
padding-top: 12px !important;
}
.sub-nav-list {
margin: 0 auto;
width: 80%;
}

View File

@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { SubscriptionsComponent } from './subscriptions.component';
describe('SubscriptionsComponent', () => {
let component: SubscriptionsComponent;
let fixture: ComponentFixture<SubscriptionsComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ SubscriptionsComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(SubscriptionsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,93 @@
import { Component, OnInit, EventEmitter } from '@angular/core';
import { MatDialog, MatSnackBar } from '@angular/material';
import { SubscribeDialogComponent } from 'app/dialogs/subscribe-dialog/subscribe-dialog.component';
import { PostsService } from 'app/posts.services';
import { Router } from '@angular/router';
import { SubscriptionInfoDialogComponent } from 'app/dialogs/subscription-info-dialog/subscription-info-dialog.component';
@Component({
selector: 'app-subscriptions',
templateUrl: './subscriptions.component.html',
styleUrls: ['./subscriptions.component.scss']
})
export class SubscriptionsComponent implements OnInit {
playlist_subscriptions = [];
channel_subscriptions = [];
subscriptions = null;
subscriptions_loading = false;
constructor(private dialog: MatDialog, private postsService: PostsService, private router: Router, private snackBar: MatSnackBar) { }
ngOnInit() {
this.getSubscriptions();
}
getSubscriptions() {
this.subscriptions_loading = true;
this.subscriptions = [];
this.channel_subscriptions = [];
this.playlist_subscriptions = [];
this.postsService.getAllSubscriptions().subscribe(res => {
this.subscriptions_loading = false;
this.subscriptions = res['subscriptions'];
for (let i = 0; i < this.subscriptions.length; i++) {
const sub = this.subscriptions[i];
// parse subscriptions into channels and playlists
if (sub.isPlaylist) {
this.playlist_subscriptions.push(sub);
} else {
this.channel_subscriptions.push(sub);
}
}
});
}
goToSubscription(sub) {
this.router.navigate(['/subscription', {id: sub.id}]);
}
openSubscribeDialog() {
const dialogRef = this.dialog.open(SubscribeDialogComponent, {
maxWidth: 500,
width: '80vw'
});
dialogRef.afterClosed().subscribe(result => {
if (result) {
if (result.isPlaylist) {
this.playlist_subscriptions.push(result);
} else {
this.channel_subscriptions.push(result);
}
}
});
}
showSubInfo(sub) {
const unsubbedEmitter = new EventEmitter<any>();
const dialogRef = this.dialog.open(SubscriptionInfoDialogComponent, {
data: {
sub: sub,
unsubbedEmitter: unsubbedEmitter
}
});
unsubbedEmitter.subscribe(success => {
if (success) {
this.openSnackBar(`${sub.name} successfully deleted!`)
this.getSubscriptions();
}
})
}
// snackbar helper
public openSnackBar(message: string, action = '') {
this.snackBar.open(message, action, {
duration: 2000,
});
}
}