diff --git a/src/app/app.component.html b/src/app/app.component.html
index a6aabeb..d49c48e 100644
--- a/src/app/app.component.html
+++ b/src/app/app.component.html
@@ -38,15 +38,15 @@
-
+
- Home
+ Home
Login
- Subscriptions
- Downloads
+ Subscriptions
+ Downloads
- {{subscription.name}}
+ {{subscription.name}}
diff --git a/src/app/app.component.ts b/src/app/app.component.ts
index 3d022f5..d8540bb 100644
--- a/src/app/app.component.ts
+++ b/src/app/app.component.ts
@@ -1,4 +1,4 @@
-import { Component, OnInit, ElementRef, ViewChild, HostBinding } from '@angular/core';
+import { Component, OnInit, ElementRef, ViewChild, HostBinding, AfterViewInit } from '@angular/core';
import {PostsService} from './posts.services';
import {FileCardComponent} from './file-card/file-card.component';
import { Observable } from 'rxjs/Observable';
@@ -30,11 +30,13 @@ import { SetDefaultAdminDialogComponent } from './dialogs/set-default-admin-dial
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
-export class AppComponent implements OnInit {
+export class AppComponent implements OnInit, AfterViewInit {
@HostBinding('class') componentCssClass;
THEMES_CONFIG = THEMES_CONFIG;
+ window = window;
+
// config items
topBarTitle = 'Youtube Downloader';
defaultTheme = null;
@@ -69,6 +71,29 @@ export class AppComponent implements OnInit {
}
+ ngOnInit() {
+ if (localStorage.getItem('theme')) {
+ this.setTheme(localStorage.getItem('theme'));
+ }
+
+ this.postsService.open_create_default_admin_dialog.subscribe(open => {
+ if (open) {
+ const dialogRef = this.dialog.open(SetDefaultAdminDialogComponent);
+ dialogRef.afterClosed().subscribe(success => {
+ if (success) {
+ if (this.router.url !== '/login') { this.router.navigate(['/login']); }
+ } else {
+ console.error('Failed to create default admin account. See logs for details.');
+ }
+ });
+ }
+ });
+ }
+
+ ngAfterViewInit() {
+ this.postsService.sidenav = this.sidenav;
+ }
+
toggleSidenav() {
this.sidenav.toggle();
}
@@ -122,9 +147,9 @@ export class AppComponent implements OnInit {
this.postsService.setTheme(theme);
this.onSetTheme(this.THEMES_CONFIG[theme]['css_label'], old_theme ? this.THEMES_CONFIG[old_theme]['css_label'] : old_theme);
-}
+ }
-onSetTheme(theme, old_theme) {
+ onSetTheme(theme, old_theme) {
if (old_theme) {
document.body.classList.remove(old_theme);
this.overlayContainer.getContainerElement().classList.remove(old_theme);
@@ -146,27 +171,6 @@ onSetTheme(theme, old_theme) {
event.stopPropagation();
}
- ngOnInit() {
- if (localStorage.getItem('theme')) {
- this.setTheme(localStorage.getItem('theme'));
- } else {
- //
- }
- this.postsService.open_create_default_admin_dialog.subscribe(open => {
- if (open) {
- const dialogRef = this.dialog.open(SetDefaultAdminDialogComponent);
- dialogRef.afterClosed().subscribe(success => {
- if (success) {
- if (this.router.url !== '/login') { this.router.navigate(['/login']); }
- } else {
- console.error('Failed to create default admin account. See logs for details.');
- }
- });
- }
- });
- }
-
-
getSubscriptions() {
}
diff --git a/src/app/player/player.component.ts b/src/app/player/player.component.ts
index b5e10e6..6582cd7 100644
--- a/src/app/player/player.component.ts
+++ b/src/app/player/player.component.ts
@@ -1,4 +1,4 @@
-import { Component, OnInit, HostListener, EventEmitter, OnDestroy } from '@angular/core';
+import { Component, OnInit, HostListener, EventEmitter, OnDestroy, AfterViewInit } from '@angular/core';
import { VgAPI } from 'ngx-videogular';
import { PostsService } from 'app/posts.services';
import { ActivatedRoute, Router } from '@angular/router';
@@ -20,7 +20,7 @@ export interface IMedia {
templateUrl: './player.component.html',
styleUrls: ['./player.component.css']
})
-export class PlayerComponent implements OnInit, OnDestroy {
+export class PlayerComponent implements OnInit, AfterViewInit, OnDestroy {
playlist: Array = [];
original_playlist: string = null;
@@ -95,6 +95,10 @@ export class PlayerComponent implements OnInit, OnDestroy {
}
}
+ ngAfterViewInit() {
+ this.postsService.sidenav.close();
+ }
+
ngOnDestroy() {
// prevents volume save feature from running in the background
clearInterval(this.save_volume_timer);
diff --git a/src/app/posts.services.ts b/src/app/posts.services.ts
index 42dc721..67e3bd1 100644
--- a/src/app/posts.services.ts
+++ b/src/app/posts.services.ts
@@ -15,16 +15,14 @@ import * as Fingerprint2 from 'fingerprintjs2';
@Injectable()
export class PostsService implements CanActivate {
path = '';
- audioFolder = '';
- videoFolder = '';
- startPath = null; // 'http://localhost:17442/';
- startPathSSL = null; // 'https://localhost:17442/'
- handShakeComplete = false;
+
+ // local settings
THEMES_CONFIG = THEMES_CONFIG;
theme;
card_size = 'medium';
sidepanel_mode = 'over';
- settings_changed = new BehaviorSubject(false);
+
+ // auth
auth_token = '4241b401-7236-493e-92b5-b72696b9d853';
session_id = null;
httpOptions = null;
@@ -41,20 +39,24 @@ export class PostsService implements CanActivate {
available_permissions = null;
+ // behavior subjects
reload_config = new BehaviorSubject(false);
config_reloaded = new BehaviorSubject(false);
service_initialized = new BehaviorSubject(false);
- initialized = false;
-
+ settings_changed = new BehaviorSubject(false);
open_create_default_admin_dialog = new BehaviorSubject(false);
+ // app status
+ initialized = false;
+
+ // global vars
config = null;
subscriptions = null;
+ sidenav = null;
+
constructor(private http: HttpClient, private router: Router, @Inject(DOCUMENT) private document: Document,
public snackBar: MatSnackBar) {
console.log('PostsService Initialized...');
- // this.startPath = window.location.href + '/api/';
- // this.startPathSSL = window.location.href + '/api/';
this.path = this.document.location.origin + '/api/';
if (isDevMode()) {
@@ -152,14 +154,6 @@ export class PostsService implements CanActivate {
});
}
- getVideoFolder() {
- return this.http.get(this.startPath + 'videofolder');
- }
-
- getAudioFolder() {
- return this.http.get(this.startPath + 'audiofolder');
- }
-
// tslint:disable-next-line: max-line-length
makeMP3(url: string, selectedQuality: string, customQualityConfiguration: string, customArgs: string = null, customOutput: string = null, youtubeUsername: string = null, youtubePassword: string = null, ui_uid = null) {
return this.http.post(this.path + 'tomp3', {url: url,