aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+my-account/my-account-settings/my-account-interface
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/+my-account/my-account-settings/my-account-interface')
-rw-r--r--client/src/app/+my-account/my-account-settings/my-account-interface/index.ts1
-rw-r--r--client/src/app/+my-account/my-account-settings/my-account-interface/my-account-interface-settings.component.html13
-rw-r--r--client/src/app/+my-account/my-account-settings/my-account-interface/my-account-interface-settings.component.scss16
-rw-r--r--client/src/app/+my-account/my-account-settings/my-account-interface/my-account-interface-settings.component.ts64
4 files changed, 94 insertions, 0 deletions
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 @@
1<form role="form" (ngSubmit)="updateInterfaceSettings()" [formGroup]="form">
2 <div class="form-group">
3 <label i18n for="theme">Theme</label>
4
5 <div class="peertube-select-container">
6 <select formControlName="theme" id="theme">
7 <option i18n value="default">default</option>
8
9 <option *ngFor="let theme of availableThemes" [value]="theme">{{ theme }}</option>
10 </select>
11 </div>
12 </div>
13</form>
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 @@
1@import '_variables';
2@import '_mixins';
3
4input[type=submit] {
5 @include peertube-button;
6 @include orange-button;
7
8 display: block;
9 margin-top: 15px;
10}
11
12.peertube-select-container {
13 @include peertube-select-container(340px);
14
15 margin-bottom: 30px;
16}
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 @@
1import { Component, Input, OnInit } from '@angular/core'
2import { Notifier, ServerService } from '@app/core'
3import { UserUpdateMe } from '../../../../../../shared'
4import { AuthService } from '../../../core'
5import { FormReactive, User, UserService } from '../../../shared'
6import { I18n } from '@ngx-translate/i18n-polyfill'
7import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
8import { Subject } from 'rxjs'
9
10@Component({
11 selector: 'my-account-interface-settings',
12 templateUrl: './my-account-interface-settings.component.html',
13 styleUrls: [ './my-account-interface-settings.component.scss' ]
14})
15export class MyAccountInterfaceSettingsComponent extends FormReactive implements OnInit {
16 @Input() user: User = null
17 @Input() userInformationLoaded: Subject<any>
18
19 constructor (
20 protected formValidatorService: FormValidatorService,
21 private authService: AuthService,
22 private notifier: Notifier,
23 private userService: UserService,
24 private serverService: ServerService,
25 private i18n: I18n
26 ) {
27 super()
28 }
29
30 get availableThemes () {
31 return this.serverService.getConfig().theme.registered
32 }
33
34 ngOnInit () {
35 this.buildForm({
36 theme: null
37 })
38
39 this.userInformationLoaded
40 .subscribe(() => {
41 this.form.patchValue({
42 theme: this.user.theme
43 })
44 })
45 }
46
47 updateInterfaceSettings () {
48 const theme = this.form.value['theme']
49
50 const details: UserUpdateMe = {
51 theme
52 }
53
54 this.userService.updateMyProfile(details).subscribe(
55 () => {
56 this.notifier.success(this.i18n('Interface settings updated.'))
57
58 window.location.reload()
59 },
60
61 err => this.notifier.error(err.message)
62 )
63 }
64}