diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index 52fb789..f7a1269 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -77,6 +77,7 @@ import { ConfirmDialogComponent } from './dialogs/confirm-dialog/confirm-dialog.
import { UnifiedFileCardComponent } from './components/unified-file-card/unified-file-card.component';
import { RecentVideosComponent } from './components/recent-videos/recent-videos.component';
import { EditSubscriptionDialogComponent } from './dialogs/edit-subscription-dialog/edit-subscription-dialog.component';
+import { CustomPlaylistsComponent } from './components/custom-playlists/custom-playlists.component';
registerLocaleData(es, 'es');
@@ -120,7 +121,8 @@ export function isVisible({ event, element, scrollContainer, offset }: IsVisible
ConfirmDialogComponent,
UnifiedFileCardComponent,
RecentVideosComponent,
- EditSubscriptionDialogComponent
+ EditSubscriptionDialogComponent,
+ CustomPlaylistsComponent
],
imports: [
CommonModule,
diff --git a/src/app/components/custom-playlists/custom-playlists.component.html b/src/app/components/custom-playlists/custom-playlists.component.html
new file mode 100644
index 0000000..e45cb61
--- /dev/null
+++ b/src/app/components/custom-playlists/custom-playlists.component.html
@@ -0,0 +1,13 @@
+
+
+ No playlists available. Create one from your downloading files by clicking the blue plus button.
+
+
\ No newline at end of file
diff --git a/src/app/components/custom-playlists/custom-playlists.component.scss b/src/app/components/custom-playlists/custom-playlists.component.scss
new file mode 100644
index 0000000..0246e70
--- /dev/null
+++ b/src/app/components/custom-playlists/custom-playlists.component.scss
@@ -0,0 +1,7 @@
+.add-playlist-button {
+ float: right;
+}
+
+.file-col {
+ max-width: 240px;
+}
\ No newline at end of file
diff --git a/src/app/components/custom-playlists/custom-playlists.component.spec.ts b/src/app/components/custom-playlists/custom-playlists.component.spec.ts
new file mode 100644
index 0000000..5e9348b
--- /dev/null
+++ b/src/app/components/custom-playlists/custom-playlists.component.spec.ts
@@ -0,0 +1,25 @@
+import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { CustomPlaylistsComponent } from './custom-playlists.component';
+
+describe('CustomPlaylistsComponent', () => {
+ let component: CustomPlaylistsComponent;
+ let fixture: ComponentFixture;
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ declarations: [ CustomPlaylistsComponent ]
+ })
+ .compileComponents();
+ }));
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(CustomPlaylistsComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/src/app/components/custom-playlists/custom-playlists.component.ts b/src/app/components/custom-playlists/custom-playlists.component.ts
new file mode 100644
index 0000000..6d870bf
--- /dev/null
+++ b/src/app/components/custom-playlists/custom-playlists.component.ts
@@ -0,0 +1,113 @@
+import { Component, OnInit } from '@angular/core';
+import { PostsService } from 'app/posts.services';
+import { Router } from '@angular/router';
+import { MatDialog } from '@angular/material/dialog';
+import { CreatePlaylistComponent } from 'app/create-playlist/create-playlist.component';
+import { ModifyPlaylistComponent } from 'app/dialogs/modify-playlist/modify-playlist.component';
+
+@Component({
+ selector: 'app-custom-playlists',
+ templateUrl: './custom-playlists.component.html',
+ styleUrls: ['./custom-playlists.component.scss']
+})
+export class CustomPlaylistsComponent implements OnInit {
+
+ playlists = null;
+ playlists_received = false;
+ card_size = 'medium';
+ downloading_content = {'video': {}, 'audio': {}};
+
+ constructor(private postsService: PostsService, private router: Router, private dialog: MatDialog) { }
+
+ ngOnInit(): void {
+ this.postsService.service_initialized.subscribe(init => {
+ if (init) {
+ this.getAllPlaylists();
+ }
+ });
+ }
+
+ getAllPlaylists() {
+ this.playlists_received = false;
+ this.postsService.getAllFiles().subscribe(res => {
+ this.playlists = res['playlists'];
+ this.playlists_received = true;
+ });
+ }
+
+ // creating a playlist
+ openCreatePlaylistDialog() {
+ const dialogRef = this.dialog.open(CreatePlaylistComponent, {
+ data: {
+ }
+ });
+ dialogRef.afterClosed().subscribe(result => {
+ if (result) {
+ this.getAllPlaylists();
+ this.postsService.openSnackBar('Successfully created playlist!', '');
+ } else if (result === false) {
+ this.postsService.openSnackBar('ERROR: failed to create playlist!', '');
+ }
+ });
+ }
+
+ goToPlaylist(playlist) {
+ const playlistID = playlist.id;
+ const type = playlist.type;
+
+ if (playlist) {
+ if (this.postsService.config['Extra']['download_only_mode']) {
+ this.downloading_content[type][playlistID] = true;
+ this.downloadPlaylist(playlist.fileNames, type, playlist.name, playlistID);
+ } else {
+ localStorage.setItem('player_navigator', this.router.url);
+ const fileNames = playlist.fileNames;
+ this.router.navigate(['/player', {fileNames: fileNames.join('|nvr|'), type: type, id: playlistID, uid: playlistID}]);
+ }
+ } else {
+ // playlist not found
+ console.error(`Playlist with ID ${playlistID} not found!`);
+ }
+ }
+
+ downloadPlaylist(fileNames, type, zipName = null, playlistID = null) {
+ this.postsService.downloadFileFromServer(fileNames, type, zipName).subscribe(res => {
+ if (playlistID) { this.downloading_content[type][playlistID] = false };
+ const blob: Blob = res;
+ saveAs(blob, zipName + '.zip');
+ });
+
+ }
+
+ deletePlaylist(args) {
+ const playlist = args.file;
+ const index = args.index;
+ const playlistID = playlist.id;
+ this.postsService.removePlaylist(playlistID, 'audio').subscribe(res => {
+ if (res['success']) {
+ this.playlists.splice(index, 1);
+ this.postsService.openSnackBar('Playlist successfully removed.', '');
+ }
+ this.getAllPlaylists();
+ });
+ }
+
+ editPlaylistDialog(args) {
+ const playlist = args.playlist;
+ const index = args.index;
+ const dialogRef = this.dialog.open(ModifyPlaylistComponent, {
+ data: {
+ playlist: playlist,
+ width: '65vw'
+ }
+ });
+
+ dialogRef.afterClosed().subscribe(res => {
+ // updates playlist in file manager if it changed
+ if (dialogRef.componentInstance.playlist_updated) {
+ this.playlists[index] = dialogRef.componentInstance.original_playlist;
+ }
+ });
+ }
+
+}
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 520eeaf..82377f5 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
@@ -1,18 +1,25 @@
-
{{file_obj.isAudio ? 'audiotrack' : 'movie'}} {{file_obj.registered | date:'shortDate'}}
+
{{(file_obj.type === 'audio' || file_obj.isAudio) ? 'audiotrack' : 'movie'}} {{file_obj.registered | date:'shortDate'}}
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -26,7 +33,7 @@
- {{file_obj.title}}
+ {{!is_playlist ? file_obj.title : file_obj.name}}
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 f401f88..03f148e 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
@@ -19,10 +19,12 @@ export class UnifiedFileCardComponent implements OnInit {
@Input() file_obj = null;
@Input() card_size = 'medium';
@Input() use_youtubedl_archive = false;
+ @Input() is_playlist = false;
@Input() index: number;
@Output() goToFile = new EventEmitter();
@Output() goToSubscription = new EventEmitter();
@Output() deleteFile = new EventEmitter();
+ @Output() editPlaylist = new EventEmitter();
/*
Planned sizes:
@@ -62,6 +64,13 @@ export class UnifiedFileCardComponent implements OnInit {
})
}
+ emitEditPlaylist() {
+ this.editPlaylist.emit({
+ playlist: this.file_obj,
+ index: this.index
+ });
+ }
+
}
function fancyTimeFormat(time) {
diff --git a/src/app/main/main.component.html b/src/app/main/main.component.html
index 3993de4..4d17a06 100644
--- a/src/app/main/main.component.html
+++ b/src/app/main/main.component.html
@@ -1,7 +1,7 @@