mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-03-11 15:20:56 +03:00
Added ability to set config from settings
theme slide toggle is now in top right menu
This commit is contained in:
@@ -8,17 +8,41 @@ import { PostsService } from 'app/posts.services';
|
||||
})
|
||||
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));
|
||||
});
|
||||
}
|
||||
|
||||
setSetting() {
|
||||
|
||||
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!');
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user