diff --git a/.gitignore b/.gitignore
index a68b4b9..e508e72 100644
--- a/.gitignore
+++ b/.gitignore
@@ -52,4 +52,7 @@ backend/subscriptions/archives/*
backend/subscriptions/playlists/*
backend/subscriptions/channels/*
backend/db.json
+backend/subscriptions/channels/*
+backend/subscriptions/playlists/*
+backend/subscriptions/archives/*
src/assets/default.json
diff --git a/backend/app.js b/backend/app.js
index c5894b5..dea5e47 100644
--- a/backend/app.js
+++ b/backend/app.js
@@ -557,6 +557,20 @@ app.get('/api/config', function(req, res) {
});
});
+app.post('/api/setConfig', function(req, res) {
+ let new_config_file = req.body.new_config_file;
+ if (new_config_file && new_config_file['YoutubeDLMaterial']) {
+ let success = config_api.setConfigFile(new_config_file);
+ res.send({
+ success: success
+ });
+ } else {
+ console.log('ERROR: Tried to save invalid config file!')
+ res.sendStatus(400);
+ }
+
+});
+
app.get('/api/using-encryption', function(req, res) {
res.send(usingEncryption);
});
diff --git a/backend/config.js b/backend/config.js
index 4a5334b..04ef5ca 100644
--- a/backend/config.js
+++ b/backend/config.js
@@ -112,5 +112,6 @@ module.exports = {
setConfigItem: setConfigItem,
setConfigItems: setConfigItems,
getConfigFile: getConfigFile,
+ setConfigFile: setConfigFile,
CONFIG_ITEMS: CONFIG_ITEMS
}
\ No newline at end of file
diff --git a/src/app/app.component.css b/src/app/app.component.css
index d7ef823..a902545 100644
--- a/src/app/app.component.css
+++ b/src/app/app.component.css
@@ -10,4 +10,10 @@
flex-direction: column;
flex-basis: 100%;
flex: 1;
+}
+
+.theme-slide-toggle {
+ top: 2px;
+ left: 10px;
+ position: relative;
}
\ No newline at end of file
diff --git a/src/app/app.component.html b/src/app/app.component.html
index 426a303..8d3ca9a 100644
--- a/src/app/app.component.html
+++ b/src/app/app.component.html
@@ -13,8 +13,25 @@
-
-
+
+
+
+
+
+
+
+
+
+
diff --git a/src/app/app.component.ts b/src/app/app.component.ts
index add0194..f41f809 100644
--- a/src/app/app.component.ts
+++ b/src/app/app.component.ts
@@ -4,7 +4,7 @@ import {FileCardComponent} from './file-card/file-card.component';
import { Observable } from 'rxjs/Observable';
import {FormControl, Validators} from '@angular/forms';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
-import {MatSnackBar, MatSidenav} from '@angular/material';
+import {MatSnackBar, MatDialog, MatSidenav} from '@angular/material';
import { saveAs } from 'file-saver';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/mapTo';
@@ -18,6 +18,7 @@ import { YoutubeSearchService, Result } from './youtube-search.service';
import { Router, NavigationStart } from '@angular/router';
import { OverlayContainer } from '@angular/cdk/overlay';
import { THEMES_CONFIG } from '../themes';
+import { SettingsComponent } from './settings/settings.component';
@Component({
selector: 'app-root',
@@ -37,7 +38,7 @@ export class AppComponent implements OnInit {
@ViewChild('sidenav', {static: false}) sidenav: MatSidenav;
navigator: string = null;
- constructor(public postsService: PostsService, public snackBar: MatSnackBar,
+ constructor(public postsService: PostsService, public snackBar: MatSnackBar, private dialog: MatDialog,
public router: Router, public overlayContainer: OverlayContainer, private elementRef: ElementRef) {
this.navigator = localStorage.getItem('player_navigator');
@@ -132,5 +133,9 @@ onSetTheme(theme, old_theme) {
this.router.navigateByUrl(this.navigator);
}
}
+
+ openSettingsDialog() {
+ const dialogRef = this.dialog.open(SettingsComponent);
+ }
}
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index 928b4d4..3eb3a7d 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -7,6 +7,7 @@ import {MatNativeDateModule, MatRadioModule, MatInputModule, MatButtonModule, Ma
MatButtonToggleModule,
MatDialogModule,
MatRippleModule,
+ MatSlideToggleModule,
MatMenuModule} from '@angular/material';
import {DragDropModule} from '@angular/cdk/drag-drop';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
@@ -35,6 +36,7 @@ import { SubscribeDialogComponent } from './dialogs/subscribe-dialog/subscribe-d
import { SubscriptionComponent } from './subscription//subscription/subscription.component';
import { SubscriptionFileCardComponent } from './subscription/subscription-file-card/subscription-file-card.component';
import { SubscriptionInfoDialogComponent } from './dialogs/subscription-info-dialog/subscription-info-dialog.component';
+import { SettingsComponent } from './settings/settings.component';
export function isVisible({ event, element, scrollContainer, offset }: IsVisibleProps) {
return (element.id === 'video' ? videoFilesMouseHovering || videoFilesOpened : audioFilesMouseHovering || audioFilesOpened);
@@ -53,7 +55,8 @@ export function isVisible({ event, element, scrollContainer, offset }: IsVisible
SubscribeDialogComponent,
SubscriptionComponent,
SubscriptionFileCardComponent,
- SubscriptionInfoDialogComponent
+ SubscriptionInfoDialogComponent,
+ SettingsComponent
],
imports: [
BrowserModule,
@@ -82,6 +85,8 @@ export function isVisible({ event, element, scrollContainer, offset }: IsVisible
MatRippleModule,
MatMenuModule,
MatDialogModule,
+ MatSlideToggleModule,
+ MatMenuModule,
DragDropModule,
VgCoreModule,
VgControlsModule,
@@ -96,7 +101,8 @@ export function isVisible({ event, element, scrollContainer, offset }: IsVisible
InputDialogComponent,
CreatePlaylistComponent,
SubscribeDialogComponent,
- SubscriptionInfoDialogComponent
+ SubscriptionInfoDialogComponent,
+ SettingsComponent
],
providers: [PostsService],
bootstrap: [AppComponent]
diff --git a/src/app/posts.services.ts b/src/app/posts.services.ts
index 2b3e31e..baf9ab2 100644
--- a/src/app/posts.services.ts
+++ b/src/app/posts.services.ts
@@ -92,6 +92,10 @@ export class PostsService {
}
}
+ setConfig(config) {
+ return this.http.post(this.path + 'setConfig', {new_config_file: config});
+ }
+
deleteFile(name: string, isAudio: boolean) {
if (isAudio) {
return this.http.post(this.path + 'deleteMp3', {name: name});
diff --git a/src/app/settings/settings.component.html b/src/app/settings/settings.component.html
new file mode 100644
index 0000000..2d5ca10
--- /dev/null
+++ b/src/app/settings/settings.component.html
@@ -0,0 +1,193 @@
+Settings
+
+
+
+
+
+
+ Host
+
+
+
+
+
+
+
+
+
+ Encryption
+
+
+
+
+
+ Use encryption
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Downloader
+
+
+
+
+
+
+
+
+
+ Extra
+
+
+
+
+
+
+
+
+
+
+
+ File manager enabled
+
+
+ Allow quality select
+
+
+ Download only mode
+
+
+ Allow multi-download mode
+
+
+
+
+
+
+
+
+
+ API
+
+
+
+
+
+ Use YouTube API
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Themes
+
+
+
+
+
+
+ Default
+ Dark
+
+
+
+
+ Allow theme change
+
+
+
+
+
+
+
+
+
+ Advanced
+
+
+
+
+
+ Use default downloading agent
+
+
+
+
+
+
+
+
+ Allow advanced download
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/app/settings/settings.component.scss b/src/app/settings/settings.component.scss
new file mode 100644
index 0000000..22cef34
--- /dev/null
+++ b/src/app/settings/settings.component.scss
@@ -0,0 +1,3 @@
+.settings-expansion-panel {
+ margin-bottom: 20px;
+}
\ No newline at end of file
diff --git a/src/app/settings/settings.component.spec.ts b/src/app/settings/settings.component.spec.ts
new file mode 100644
index 0000000..91588f3
--- /dev/null
+++ b/src/app/settings/settings.component.spec.ts
@@ -0,0 +1,25 @@
+import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { SettingsComponent } from './settings.component';
+
+describe('SettingsComponent', () => {
+ let component: SettingsComponent;
+ let fixture: ComponentFixture;
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ declarations: [ SettingsComponent ]
+ })
+ .compileComponents();
+ }));
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(SettingsComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/src/app/settings/settings.component.ts b/src/app/settings/settings.component.ts
new file mode 100644
index 0000000..39cdcbc
--- /dev/null
+++ b/src/app/settings/settings.component.ts
@@ -0,0 +1,48 @@
+import { Component, OnInit } from '@angular/core';
+import { PostsService } from 'app/posts.services';
+
+@Component({
+ selector: 'app-settings',
+ templateUrl: './settings.component.html',
+ styleUrls: ['./settings.component.scss']
+})
+export class SettingsComponent implements OnInit {
+
+ initial_config = null;
+ new_config = null
+ loading_config = false;
+
+ constructor(private postsService: PostsService) { }
+
+ ngOnInit() {
+ this.getConfig();
+ }
+
+ getConfig() {
+ this.loading_config = true;
+ this.postsService.loadNavItems().subscribe(res => {
+ this.loading_config = false;
+ // successfully loaded config
+
+ this.initial_config = !this.postsService.debugMode ? res['config_file']['YoutubeDLMaterial'] : res['YoutubeDLMaterial'];
+ this.new_config = JSON.parse(JSON.stringify(this.initial_config));
+ });
+ }
+
+ settingsSame() {
+ return JSON.stringify(this.new_config) === JSON.stringify(this.initial_config);
+ }
+
+ saveSettings() {
+ const settingsToSave = {'YoutubeDLMaterial': this.new_config};
+ this.postsService.setConfig(settingsToSave).subscribe(res => {
+ if (res['success']) {
+ // sets new config as old config
+ this.initial_config = JSON.parse(JSON.stringify(this.new_config));
+ }
+ }, err => {
+ console.error('Failed to save config!');
+ })
+ }
+
+}