From 7cd4d2ba10106c10602c86f74f55743ded588896 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 9 Jul 2019 11:45:19 +0200 Subject: WIP plugins: add theme support --- .../my-account-interface/index.ts | 1 + .../my-account-interface-settings.component.html | 13 +++++ .../my-account-interface-settings.component.scss | 16 ++++++ .../my-account-interface-settings.component.ts | 64 ++++++++++++++++++++++ 4 files changed, 94 insertions(+) create mode 100644 client/src/app/+my-account/my-account-settings/my-account-interface/index.ts create mode 100644 client/src/app/+my-account/my-account-settings/my-account-interface/my-account-interface-settings.component.html create mode 100644 client/src/app/+my-account/my-account-settings/my-account-interface/my-account-interface-settings.component.scss create mode 100644 client/src/app/+my-account/my-account-settings/my-account-interface/my-account-interface-settings.component.ts (limited to 'client/src/app/+my-account/my-account-settings/my-account-interface') diff --git a/client/src/app/+my-account/my-account-settings/my-account-interface/index.ts b/client/src/app/+my-account/my-account-settings/my-account-interface/index.ts new file mode 100644 index 000000000..62fce79a8 --- /dev/null +++ b/client/src/app/+my-account/my-account-settings/my-account-interface/index.ts @@ -0,0 +1 @@ +export * from './my-account-interface-settings.component' diff --git a/client/src/app/+my-account/my-account-settings/my-account-interface/my-account-interface-settings.component.html b/client/src/app/+my-account/my-account-settings/my-account-interface/my-account-interface-settings.component.html new file mode 100644 index 000000000..f34e77f6a --- /dev/null +++ b/client/src/app/+my-account/my-account-settings/my-account-interface/my-account-interface-settings.component.html @@ -0,0 +1,13 @@ +
+
+ + +
+ +
+
+
diff --git a/client/src/app/+my-account/my-account-settings/my-account-interface/my-account-interface-settings.component.scss b/client/src/app/+my-account/my-account-settings/my-account-interface/my-account-interface-settings.component.scss new file mode 100644 index 000000000..629f01733 --- /dev/null +++ b/client/src/app/+my-account/my-account-settings/my-account-interface/my-account-interface-settings.component.scss @@ -0,0 +1,16 @@ +@import '_variables'; +@import '_mixins'; + +input[type=submit] { + @include peertube-button; + @include orange-button; + + display: block; + margin-top: 15px; +} + +.peertube-select-container { + @include peertube-select-container(340px); + + margin-bottom: 30px; +} diff --git a/client/src/app/+my-account/my-account-settings/my-account-interface/my-account-interface-settings.component.ts b/client/src/app/+my-account/my-account-settings/my-account-interface/my-account-interface-settings.component.ts new file mode 100644 index 000000000..f7055072f --- /dev/null +++ b/client/src/app/+my-account/my-account-settings/my-account-interface/my-account-interface-settings.component.ts @@ -0,0 +1,64 @@ +import { Component, Input, OnInit } from '@angular/core' +import { Notifier, ServerService } from '@app/core' +import { UserUpdateMe } from '../../../../../../shared' +import { AuthService } from '../../../core' +import { FormReactive, User, UserService } from '../../../shared' +import { I18n } from '@ngx-translate/i18n-polyfill' +import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' +import { Subject } from 'rxjs' + +@Component({ + selector: 'my-account-interface-settings', + templateUrl: './my-account-interface-settings.component.html', + styleUrls: [ './my-account-interface-settings.component.scss' ] +}) +export class MyAccountInterfaceSettingsComponent extends FormReactive implements OnInit { + @Input() user: User = null + @Input() userInformationLoaded: Subject + + constructor ( + protected formValidatorService: FormValidatorService, + private authService: AuthService, + private notifier: Notifier, + private userService: UserService, + private serverService: ServerService, + private i18n: I18n + ) { + super() + } + + get availableThemes () { + return this.serverService.getConfig().theme.registered + } + + ngOnInit () { + this.buildForm({ + theme: null + }) + + this.userInformationLoaded + .subscribe(() => { + this.form.patchValue({ + theme: this.user.theme + }) + }) + } + + updateInterfaceSettings () { + const theme = this.form.value['theme'] + + const details: UserUpdateMe = { + theme + } + + this.userService.updateMyProfile(details).subscribe( + () => { + this.notifier.success(this.i18n('Interface settings updated.')) + + window.location.reload() + }, + + err => this.notifier.error(err.message) + ) + } +} -- cgit v1.2.3