From 67ed6552b831df66713bac9e672738796128d33f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 23 Jun 2020 14:10:17 +0200 Subject: Reorganize client shared modules --- .../my-account-change-email.component.ts | 13 +- .../my-account-change-password.component.ts | 10 +- .../my-account-danger-zone.component.ts | 5 +- .../my-account-interface/index.ts | 1 - .../my-account-interface-settings.component.html | 17 --- .../my-account-interface-settings.component.scss | 21 --- .../my-account-interface-settings.component.ts | 89 ------------- ...y-account-notification-preferences.component.ts | 11 +- .../my-account-profile.component.ts | 9 +- .../my-account-settings.component.html | 4 +- .../my-account-settings.component.ts | 9 +- .../my-account-video-settings/index.ts | 1 - .../my-account-video-settings.component.html | 75 ----------- .../my-account-video-settings.component.scss | 24 ---- .../my-account-video-settings.component.ts | 142 --------------------- 15 files changed, 23 insertions(+), 408 deletions(-) delete mode 100644 client/src/app/+my-account/my-account-settings/my-account-interface/index.ts delete mode 100644 client/src/app/+my-account/my-account-settings/my-account-interface/my-account-interface-settings.component.html delete mode 100644 client/src/app/+my-account/my-account-settings/my-account-interface/my-account-interface-settings.component.scss delete mode 100644 client/src/app/+my-account/my-account-settings/my-account-interface/my-account-interface-settings.component.ts delete mode 100644 client/src/app/+my-account/my-account-settings/my-account-video-settings/index.ts delete mode 100644 client/src/app/+my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.html delete mode 100644 client/src/app/+my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.scss delete mode 100644 client/src/app/+my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.ts (limited to 'client/src/app/+my-account/my-account-settings') diff --git a/client/src/app/+my-account/my-account-settings/my-account-change-email/my-account-change-email.component.ts b/client/src/app/+my-account/my-account-settings/my-account-change-email/my-account-change-email.component.ts index 9d406805f..5444b97ae 100644 --- a/client/src/app/+my-account/my-account-settings/my-account-change-email/my-account-change-email.component.ts +++ b/client/src/app/+my-account/my-account-settings/my-account-change-email/my-account-change-email.component.ts @@ -1,12 +1,10 @@ +import { forkJoin } from 'rxjs' +import { tap } from 'rxjs/operators' import { Component, OnInit } from '@angular/core' -import { AuthService, Notifier, ServerService } from '@app/core' -import { FormReactive, UserService } from '../../../shared' +import { AuthService, ServerService, UserService } from '@app/core' +import { FormReactive, FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms' import { I18n } from '@ngx-translate/i18n-polyfill' -import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' -import { UserValidatorsService } from '@app/shared/forms/form-validators/user-validators.service' -import { User } from '../../../../../../shared' -import { tap } from 'rxjs/operators' -import { forkJoin } from 'rxjs' +import { User } from '@shared/models' @Component({ selector: 'my-account-change-email', @@ -21,7 +19,6 @@ export class MyAccountChangeEmailComponent extends FormReactive implements OnIni constructor ( protected formValidatorService: FormValidatorService, private userValidatorsService: UserValidatorsService, - private notifier: Notifier, private authService: AuthService, private userService: UserService, private serverService: ServerService, diff --git a/client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.ts b/client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.ts index cbb068c7c..6a16f8a2c 100644 --- a/client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.ts +++ b/client/src/app/+my-account/my-account-settings/my-account-change-password/my-account-change-password.component.ts @@ -1,11 +1,9 @@ +import { filter } from 'rxjs/operators' import { Component, OnInit } from '@angular/core' -import { AuthService, Notifier } from '@app/core' -import { FormReactive, UserService } from '../../../shared' +import { AuthService, Notifier, UserService } from '@app/core' +import { FormReactive, FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms' import { I18n } from '@ngx-translate/i18n-polyfill' -import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' -import { UserValidatorsService } from '@app/shared/forms/form-validators/user-validators.service' -import { filter } from 'rxjs/operators' -import { User } from '../../../../../../shared' +import { User } from '@shared/models' @Component({ selector: 'my-account-change-password', diff --git a/client/src/app/+my-account/my-account-settings/my-account-danger-zone/my-account-danger-zone.component.ts b/client/src/app/+my-account/my-account-settings/my-account-danger-zone/my-account-danger-zone.component.ts index 25d862867..ae6ac5387 100644 --- a/client/src/app/+my-account/my-account-settings/my-account-danger-zone/my-account-danger-zone.component.ts +++ b/client/src/app/+my-account/my-account-settings/my-account-danger-zone/my-account-danger-zone.component.ts @@ -1,9 +1,6 @@ import { Component, Input } from '@angular/core' -import { Notifier } from '@app/core' -import { AuthService, ConfirmService, RedirectService } from '../../../core' -import { UserService } from '../../../shared' +import { AuthService, ConfirmService, Notifier, RedirectService, User, UserService } from '@app/core' import { I18n } from '@ngx-translate/i18n-polyfill' -import { User } from '@app/shared' @Component({ selector: 'my-account-danger-zone', 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 @@ -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 @@ -
- -
- - -
- -
-
- - -
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 @@ -@import '_variables'; -@import '_mixins'; - -label { - font-weight: $font-regular; - font-size: 100%; -} - -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 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 @@ -import { Component, Input, OnInit, OnDestroy } from '@angular/core' -import { Notifier, ServerService } from '@app/core' -import { ServerConfig, UserUpdateMe } from '../../../../../../shared' -import { AuthService } from '../../../core' -import { FormReactive } from '../../../shared/forms/form-reactive' -import { User, UserService } from '../../../shared/users' -import { I18n } from '@ngx-translate/i18n-polyfill' -import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' -import { Subject, Subscription } 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, OnDestroy { - @Input() user: User = null - @Input() reactiveUpdate = false - @Input() notifyOnUpdate = true - @Input() userInformationLoaded: Subject - - formValuesWatcher: Subscription - - private serverConfig: ServerConfig - - constructor ( - protected formValidatorService: FormValidatorService, - private authService: AuthService, - private notifier: Notifier, - private userService: UserService, - private serverService: ServerService, - private i18n: I18n - ) { - super() - } - - get availableThemes () { - return this.serverConfig.theme.registered - .map(t => t.name) - } - - ngOnInit () { - this.serverConfig = this.serverService.getTmpConfig() - this.serverService.getConfig() - .subscribe(config => this.serverConfig = config) - - this.buildForm({ - theme: null - }) - - this.userInformationLoaded - .subscribe(() => { - this.form.patchValue({ - theme: this.user.theme - }) - - if (this.reactiveUpdate) { - this.formValuesWatcher = this.form.valueChanges.subscribe(val => this.updateInterfaceSettings()) - } - }) - } - - ngOnDestroy () { - this.formValuesWatcher?.unsubscribe() - } - - updateInterfaceSettings () { - const theme = this.form.value['theme'] - - const details: UserUpdateMe = { - theme - } - - if (this.authService.isLoggedIn()) { - this.userService.updateMyProfile(details).subscribe( - () => { - this.authService.refreshUserInformation() - - if (this.notifyOnUpdate) this.notifier.success(this.i18n('Interface settings updated.')) - }, - - err => this.notifier.error(err.message) - ) - } else { - this.userService.updateMyAnonymousProfile(details) - if (this.notifyOnUpdate) this.notifier.success(this.i18n('Interface settings updated.')) - } - } -} diff --git a/client/src/app/+my-account/my-account-settings/my-account-notification-preferences/my-account-notification-preferences.component.ts b/client/src/app/+my-account/my-account-settings/my-account-notification-preferences/my-account-notification-preferences.component.ts index af17a0352..cfa514b26 100644 --- a/client/src/app/+my-account/my-account-settings/my-account-notification-preferences/my-account-notification-preferences.component.ts +++ b/client/src/app/+my-account/my-account-settings/my-account-notification-preferences/my-account-notification-preferences.component.ts @@ -1,11 +1,10 @@ +import { debounce } from 'lodash-es' +import { Subject } from 'rxjs' import { Component, Input, OnInit } from '@angular/core' -import { User } from '@app/shared' +import { Notifier, ServerService, User } from '@app/core' +import { UserNotificationService } from '@app/shared/shared-main' import { I18n } from '@ngx-translate/i18n-polyfill' -import { Subject } from 'rxjs' -import { UserNotificationSetting, UserNotificationSettingValue, UserRight } from '../../../../../../shared' -import { Notifier, ServerService } from '@app/core' -import { debounce } from 'lodash-es' -import { UserNotificationService } from '@app/shared/users/user-notification.service' +import { UserNotificationSetting, UserNotificationSettingValue, UserRight } from '@shared/models' @Component({ selector: 'my-account-notification-preferences', diff --git a/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.ts b/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.ts index fcad5a6c2..b0d8494e7 100644 --- a/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.ts +++ b/client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.ts @@ -1,11 +1,8 @@ +import { Subject } from 'rxjs' import { Component, Input, OnInit } from '@angular/core' -import { Notifier } from '@app/core' -import { FormReactive, UserService } from '../../../shared' -import { User } from '@app/shared' +import { Notifier, User, UserService } from '@app/core' +import { FormReactive, FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms' import { I18n } from '@ngx-translate/i18n-polyfill' -import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' -import { Subject } from 'rxjs' -import { UserValidatorsService } from '@app/shared/forms/form-validators/user-validators.service' @Component({ selector: 'my-account-profile', 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 040b2130f..2826d8d83 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 @@ -34,7 +34,7 @@
- +
@@ -55,7 +55,7 @@
- +
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 f73f3aa1e..4800be24b 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,11 +1,8 @@ -import { Component, OnInit, AfterViewChecked } from '@angular/core' -import { Notifier } from '@app/core' import { BytesPipe } from 'ngx-pipes' -import { AuthService } from '../../core' -import { User } from '../../shared' -import { UserService } from '../../shared/users' -import { I18n } from '@ngx-translate/i18n-polyfill' import { ViewportScroller } from '@angular/common' +import { AfterViewChecked, Component, OnInit } from '@angular/core' +import { AuthService, Notifier, User, UserService } from '@app/core' +import { I18n } from '@ngx-translate/i18n-polyfill' @Component({ selector: 'my-account-settings', diff --git a/client/src/app/+my-account/my-account-settings/my-account-video-settings/index.ts b/client/src/app/+my-account/my-account-settings/my-account-video-settings/index.ts deleted file mode 100644 index 1253bd369..000000000 --- a/client/src/app/+my-account/my-account-settings/my-account-video-settings/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './my-account-video-settings.component' diff --git a/client/src/app/+my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.html b/client/src/app/+my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.html deleted file mode 100644 index 0dda33af2..000000000 --- a/client/src/app/+my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.html +++ /dev/null @@ -1,75 +0,0 @@ -
-
- - - - - With Do not list or Blur thumbnails, a confirmation will be requested to watch the video. - - - - -
- -
-
- -
- - - - In Recently added, Trending, Local, Most liked and Search pages - - - -
- -
-
- - - -
- - - The sharing system implies that some technical information about your system (such as a public IP address) can be sent to other peers, but greatly helps to reduce server load. - - -
- -
- - - When on a video page, directly start playing the video. - - -
- -
- - - When a video ends, follow up with the next suggested video. - - -
- - -
diff --git a/client/src/app/+my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.scss b/client/src/app/+my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.scss deleted file mode 100644 index 430250b87..000000000 --- a/client/src/app/+my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.scss +++ /dev/null @@ -1,24 +0,0 @@ -@import '_variables'; -@import '_mixins'; - -label { - font-weight: $font-regular; - font-size: 100%; -} - -input[type=submit] { - @include peertube-button; - @include orange-button; - - margin-top: 15px; -} - -.peertube-select-container { - @include peertube-select-container(340px); - - margin-bottom: 30px; -} - -.form-group-select { - margin-bottom: 30px; -} diff --git a/client/src/app/+my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.ts b/client/src/app/+my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.ts deleted file mode 100644 index 0aaa54cd7..000000000 --- a/client/src/app/+my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.ts +++ /dev/null @@ -1,142 +0,0 @@ -import { Component, Input, OnInit, OnDestroy } from '@angular/core' -import { Notifier, ServerService } from '@app/core' -import { UserUpdateMe } from '../../../../../../shared/models/users' -import { User, UserService } from '@app/shared/users' -import { AuthService } from '../../../core' -import { FormReactive } from '@app/shared/forms/form-reactive' -import { I18n } from '@ngx-translate/i18n-polyfill' -import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' -import { forkJoin, Subject, Subscription } from 'rxjs' -import { SelectItem } from 'primeng/api' -import { first } from 'rxjs/operators' -import { NSFWPolicyType } from '@shared/models/videos/nsfw-policy.type' -import { pick } from 'lodash-es' - -@Component({ - selector: 'my-account-video-settings', - templateUrl: './my-account-video-settings.component.html', - styleUrls: [ './my-account-video-settings.component.scss' ] -}) -export class MyAccountVideoSettingsComponent extends FormReactive implements OnInit, OnDestroy { - @Input() user: User = null - @Input() reactiveUpdate = false - @Input() notifyOnUpdate = true - @Input() userInformationLoaded: Subject - - languageItems: SelectItem[] = [] - defaultNSFWPolicy: NSFWPolicyType - formValuesWatcher: Subscription - - constructor ( - protected formValidatorService: FormValidatorService, - private authService: AuthService, - private notifier: Notifier, - private userService: UserService, - private serverService: ServerService, - private i18n: I18n - ) { - super() - } - - ngOnInit () { - let oldForm: any - - this.buildForm({ - nsfwPolicy: null, - webTorrentEnabled: null, - autoPlayVideo: null, - autoPlayNextVideo: null, - videoLanguages: null - }) - - forkJoin([ - this.serverService.getVideoLanguages(), - this.serverService.getConfig(), - this.userInformationLoaded.pipe(first()) - ]).subscribe(([ languages, config ]) => { - this.languageItems = [ { label: this.i18n('Unknown language'), value: '_unknown' } ] - this.languageItems = this.languageItems - .concat(languages.map(l => ({ label: l.label, value: l.id }))) - - const videoLanguages = this.user.videoLanguages - ? this.user.videoLanguages - : this.languageItems.map(l => l.value) - - this.defaultNSFWPolicy = config.instance.defaultNSFWPolicy - - this.form.patchValue({ - nsfwPolicy: this.user.nsfwPolicy || this.defaultNSFWPolicy, - webTorrentEnabled: this.user.webTorrentEnabled, - autoPlayVideo: this.user.autoPlayVideo === true, - autoPlayNextVideo: this.user.autoPlayNextVideo, - videoLanguages - }) - - if (this.reactiveUpdate) { - oldForm = { ...this.form.value } - this.formValuesWatcher = this.form.valueChanges.subscribe((formValue: any) => { - const updatedKey = Object.keys(formValue).find(k => formValue[k] !== oldForm[k]) - oldForm = { ...this.form.value } - this.updateDetails([updatedKey]) - }) - } - }) - } - - ngOnDestroy () { - this.formValuesWatcher?.unsubscribe() - } - - updateDetails (onlyKeys?: string[]) { - const nsfwPolicy = this.form.value[ 'nsfwPolicy' ] - const webTorrentEnabled = this.form.value['webTorrentEnabled'] - const autoPlayVideo = this.form.value['autoPlayVideo'] - const autoPlayNextVideo = this.form.value['autoPlayNextVideo'] - - let videoLanguages: string[] = this.form.value['videoLanguages'] - if (Array.isArray(videoLanguages)) { - if (videoLanguages.length === this.languageItems.length) { - videoLanguages = null // null means "All" - } else if (videoLanguages.length > 20) { - this.notifier.error('Too many languages are enabled. Please enable them all or stay below 20 enabled languages.') - return - } else if (videoLanguages.length === 0) { - this.notifier.error('You need to enabled at least 1 video language.') - return - } - } - - let details: UserUpdateMe = { - nsfwPolicy, - webTorrentEnabled, - autoPlayVideo, - autoPlayNextVideo, - videoLanguages - } - - if (onlyKeys) details = pick(details, onlyKeys) - - if (this.authService.isLoggedIn()) { - this.userService.updateMyProfile(details).subscribe( - () => { - this.authService.refreshUserInformation() - - if (this.notifyOnUpdate) this.notifier.success(this.i18n('Video settings updated.')) - }, - - err => this.notifier.error(err.message) - ) - } else { - this.userService.updateMyAnonymousProfile(details) - if (this.notifyOnUpdate) this.notifier.success(this.i18n('Display/Video settings updated.')) - } - } - - getDefaultVideoLanguageLabel () { - return this.i18n('No language') - } - - getSelectedVideoLanguageLabel () { - return this.i18n('{{\'{0} languages selected') - } -} -- cgit v1.2.3