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 ++++++++++++++++++++++ .../my-account-settings.component.html | 5 +- .../my-account-settings.component.ts | 2 +- client/src/app/+my-account/my-account.module.ts | 14 ++--- 7 files changed, 104 insertions(+), 11 deletions(-) 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') 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) + ) + } +} diff --git a/client/src/app/+my-account/my-account-settings/my-account-settings.component.html b/client/src/app/+my-account/my-account-settings/my-account-settings.component.html index e51302f7c..eb9367d1f 100644 --- a/client/src/app/+my-account/my-account-settings/my-account-settings.component.html +++ b/client/src/app/+my-account/my-account-settings/my-account-settings.component.html @@ -10,9 +10,12 @@ - + + + + diff --git a/client/src/app/+my-account/my-account-settings/my-account-settings.component.ts b/client/src/app/+my-account/my-account-settings/my-account-settings.component.ts index f4b954e54..95fd2a3db 100644 --- a/client/src/app/+my-account/my-account-settings/my-account-settings.component.ts +++ b/client/src/app/+my-account/my-account-settings/my-account-settings.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, ViewChild } from '@angular/core' +import { Component, OnInit } from '@angular/core' import { Notifier } from '@app/core' import { BytesPipe } from 'ngx-pipes' import { AuthService } from '../../core' diff --git a/client/src/app/+my-account/my-account.module.ts b/client/src/app/+my-account/my-account.module.ts index a1b198e3e..5be1b0d05 100644 --- a/client/src/app/+my-account/my-account.module.ts +++ b/client/src/app/+my-account/my-account.module.ts @@ -25,19 +25,14 @@ import { MyAccountServerBlocklistComponent } from '@app/+my-account/my-account-b import { MyAccountHistoryComponent } from '@app/+my-account/my-account-history/my-account-history.component' import { MyAccountNotificationsComponent } from '@app/+my-account/my-account-notifications/my-account-notifications.component' import { MyAccountNotificationPreferencesComponent } from '@app/+my-account/my-account-settings/my-account-notification-preferences' -import { - MyAccountVideoPlaylistCreateComponent -} from '@app/+my-account/my-account-video-playlists/my-account-video-playlist-create.component' -import { - MyAccountVideoPlaylistUpdateComponent -} from '@app/+my-account/my-account-video-playlists/my-account-video-playlist-update.component' +import { MyAccountVideoPlaylistCreateComponent } from '@app/+my-account/my-account-video-playlists/my-account-video-playlist-create.component' +import { MyAccountVideoPlaylistUpdateComponent } from '@app/+my-account/my-account-video-playlists/my-account-video-playlist-update.component' import { MyAccountVideoPlaylistsComponent } from '@app/+my-account/my-account-video-playlists/my-account-video-playlists.component' -import { - MyAccountVideoPlaylistElementsComponent -} from '@app/+my-account/my-account-video-playlists/my-account-video-playlist-elements.component' +import { MyAccountVideoPlaylistElementsComponent } from '@app/+my-account/my-account-video-playlists/my-account-video-playlist-elements.component' import { DragDropModule } from '@angular/cdk/drag-drop' import { MyAccountChangeEmailComponent } from '@app/+my-account/my-account-settings/my-account-change-email' import { MultiSelectModule } from 'primeng/primeng' +import { MyAccountInterfaceSettingsComponent } from '@app/+my-account/my-account-settings/my-account-interface' @NgModule({ imports: [ @@ -58,6 +53,7 @@ import { MultiSelectModule } from 'primeng/primeng' MyAccountVideoSettingsComponent, MyAccountProfileComponent, MyAccountChangeEmailComponent, + MyAccountInterfaceSettingsComponent, MyAccountVideosComponent, -- cgit v1.2.3