diff options
Diffstat (limited to 'client/src/app/+my-account/my-account-settings/my-account-interface')
4 files changed, 0 insertions, 128 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 deleted file mode 100644 index 62fce79a8..000000000 --- a/client/src/app/+my-account/my-account-settings/my-account-interface/index.ts +++ /dev/null | |||
@@ -1 +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 deleted file mode 100644 index 0d0ddc0f2..000000000 --- a/client/src/app/+my-account/my-account-settings/my-account-interface/my-account-interface-settings.component.html +++ /dev/null | |||
@@ -1,17 +0,0 @@ | |||
1 | <form role="form" (ngSubmit)="updateInterfaceSettings()" [formGroup]="form"> | ||
2 | |||
3 | <div class="form-group"> | ||
4 | <label i18n for="theme">Theme</label> | ||
5 | |||
6 | <div class="peertube-select-container"> | ||
7 | <select formControlName="theme" id="theme" class="form-control"> | ||
8 | <option i18n value="instance-default">instance default</option> | ||
9 | <option i18n value="default">peertube default</option> | ||
10 | |||
11 | <option *ngFor="let theme of availableThemes" [value]="theme">{{ theme }}</option> | ||
12 | </select> | ||
13 | </div> | ||
14 | </div> | ||
15 | |||
16 | <input *ngIf="!reactiveUpdate" type="submit" class="mt-0" i18n-value value="Save" [disabled]="!form.valid"> | ||
17 | </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 deleted file mode 100644 index 7818dfc02..000000000 --- a/client/src/app/+my-account/my-account-settings/my-account-interface/my-account-interface-settings.component.scss +++ /dev/null | |||
@@ -1,21 +0,0 @@ | |||
1 | @import '_variables'; | ||
2 | @import '_mixins'; | ||
3 | |||
4 | label { | ||
5 | font-weight: $font-regular; | ||
6 | font-size: 100%; | ||
7 | } | ||
8 | |||
9 | input[type=submit] { | ||
10 | @include peertube-button; | ||
11 | @include orange-button; | ||
12 | |||
13 | display: block; | ||
14 | margin-top: 15px; | ||
15 | } | ||
16 | |||
17 | .peertube-select-container { | ||
18 | @include peertube-select-container(340px); | ||
19 | |||
20 | margin-bottom: 30px; | ||
21 | } | ||
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 deleted file mode 100644 index b6c17c0e3..000000000 --- a/client/src/app/+my-account/my-account-settings/my-account-interface/my-account-interface-settings.component.ts +++ /dev/null | |||
@@ -1,89 +0,0 @@ | |||
1 | import { Component, Input, OnInit, OnDestroy } from '@angular/core' | ||
2 | import { Notifier, ServerService } from '@app/core' | ||
3 | import { ServerConfig, UserUpdateMe } from '../../../../../../shared' | ||
4 | import { AuthService } from '../../../core' | ||
5 | import { FormReactive } from '../../../shared/forms/form-reactive' | ||
6 | import { User, UserService } from '../../../shared/users' | ||
7 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
8 | import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' | ||
9 | import { Subject, Subscription } from 'rxjs' | ||
10 | |||
11 | @Component({ | ||
12 | selector: 'my-account-interface-settings', | ||
13 | templateUrl: './my-account-interface-settings.component.html', | ||
14 | styleUrls: [ './my-account-interface-settings.component.scss' ] | ||
15 | }) | ||
16 | export class MyAccountInterfaceSettingsComponent extends FormReactive implements OnInit, OnDestroy { | ||
17 | @Input() user: User = null | ||
18 | @Input() reactiveUpdate = false | ||
19 | @Input() notifyOnUpdate = true | ||
20 | @Input() userInformationLoaded: Subject<any> | ||
21 | |||
22 | formValuesWatcher: Subscription | ||
23 | |||
24 | private serverConfig: ServerConfig | ||
25 | |||
26 | constructor ( | ||
27 | protected formValidatorService: FormValidatorService, | ||
28 | private authService: AuthService, | ||
29 | private notifier: Notifier, | ||
30 | private userService: UserService, | ||
31 | private serverService: ServerService, | ||
32 | private i18n: I18n | ||
33 | ) { | ||
34 | super() | ||
35 | } | ||
36 | |||
37 | get availableThemes () { | ||
38 | return this.serverConfig.theme.registered | ||
39 | .map(t => t.name) | ||
40 | } | ||
41 | |||
42 | ngOnInit () { | ||
43 | this.serverConfig = this.serverService.getTmpConfig() | ||
44 | this.serverService.getConfig() | ||
45 | .subscribe(config => this.serverConfig = config) | ||
46 | |||
47 | this.buildForm({ | ||
48 | theme: null | ||
49 | }) | ||
50 | |||
51 | this.userInformationLoaded | ||
52 | .subscribe(() => { | ||
53 | this.form.patchValue({ | ||
54 | theme: this.user.theme | ||
55 | }) | ||
56 | |||
57 | if (this.reactiveUpdate) { | ||
58 | this.formValuesWatcher = this.form.valueChanges.subscribe(val => this.updateInterfaceSettings()) | ||
59 | } | ||
60 | }) | ||
61 | } | ||
62 | |||
63 | ngOnDestroy () { | ||
64 | this.formValuesWatcher?.unsubscribe() | ||
65 | } | ||
66 | |||
67 | updateInterfaceSettings () { | ||
68 | const theme = this.form.value['theme'] | ||
69 | |||
70 | const details: UserUpdateMe = { | ||
71 | theme | ||
72 | } | ||
73 | |||
74 | if (this.authService.isLoggedIn()) { | ||
75 | this.userService.updateMyProfile(details).subscribe( | ||
76 | () => { | ||
77 | this.authService.refreshUserInformation() | ||
78 | |||
79 | if (this.notifyOnUpdate) this.notifier.success(this.i18n('Interface settings updated.')) | ||
80 | }, | ||
81 | |||
82 | err => this.notifier.error(err.message) | ||
83 | ) | ||
84 | } else { | ||
85 | this.userService.updateMyAnonymousProfile(details) | ||
86 | if (this.notifyOnUpdate) this.notifier.success(this.i18n('Interface settings updated.')) | ||
87 | } | ||
88 | } | ||
89 | } | ||