From 2989628b7913383b39ac34c7db8666a21f8e5037 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 4 Jun 2021 13:31:41 +0200 Subject: Use HTML config when possible --- .../actor-avatar-edit.component.ts | 15 +++++++-------- .../actor-banner-edit.component.ts | 15 +++++++-------- .../app/shared/shared-forms/preview-upload.component.ts | 8 +++----- .../instance-features-table.component.html | 2 +- .../shared-instance/instance-features-table.component.ts | 1 - client/src/app/shared/shared-main/video/video.model.ts | 6 ++---- .../user-moderation-dropdown.component.ts | 13 ++++--------- .../user-interface-settings.component.ts | 8 +++----- .../shared-user-settings/user-video-settings.component.ts | 6 +++--- .../shared/shared-video-miniature/abstract-video-list.ts | 8 +++----- .../shared-video-miniature/video-miniature.component.ts | 12 ++++-------- .../video-playlist-element-miniature.component.ts | 11 +++-------- 12 files changed, 40 insertions(+), 65 deletions(-) (limited to 'client/src/app/shared') diff --git a/client/src/app/shared/shared-actor-image-edit/actor-avatar-edit.component.ts b/client/src/app/shared/shared-actor-image-edit/actor-avatar-edit.component.ts index 840946690..dc9b72ddb 100644 --- a/client/src/app/shared/shared-actor-image-edit/actor-avatar-edit.component.ts +++ b/client/src/app/shared/shared-actor-image-edit/actor-avatar-edit.component.ts @@ -39,14 +39,13 @@ export class ActorAvatarEditComponent implements OnInit { ) { } ngOnInit (): void { - this.serverService.getConfig() - .subscribe(config => { - this.maxAvatarSize = config.avatar.file.size.max - this.avatarExtensions = config.avatar.file.extensions.join(', ') - - this.avatarFormat = `${$localize`max size`}: 192*192px, ` + - `${getBytes(this.maxAvatarSize)} ${$localize`extensions`}: ${this.avatarExtensions}` - }) + const config = this.serverService.getHTMLConfig() + + this.maxAvatarSize = config.avatar.file.size.max + this.avatarExtensions = config.avatar.file.extensions.join(', ') + + this.avatarFormat = `${$localize`max size`}: 192*192px, ` + + `${getBytes(this.maxAvatarSize)} ${$localize`extensions`}: ${this.avatarExtensions}` } onAvatarChange (input: HTMLInputElement) { diff --git a/client/src/app/shared/shared-actor-image-edit/actor-banner-edit.component.ts b/client/src/app/shared/shared-actor-image-edit/actor-banner-edit.component.ts index 08372d8ad..eec325a61 100644 --- a/client/src/app/shared/shared-actor-image-edit/actor-banner-edit.component.ts +++ b/client/src/app/shared/shared-actor-image-edit/actor-banner-edit.component.ts @@ -1,4 +1,4 @@ -import { Component, ElementRef, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, ViewChild } from '@angular/core' +import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core' import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser' import { Notifier, ServerService } from '@app/core' import { VideoChannel } from '@app/shared/shared-main' @@ -36,16 +36,15 @@ export class ActorBannerEditComponent implements OnInit { ) { } ngOnInit (): void { - this.serverService.getConfig() - .subscribe(config => { - this.maxBannerSize = config.banner.file.size.max - this.bannerExtensions = config.banner.file.extensions.join(', ') + const config = this.serverService.getHTMLConfig() + this.maxBannerSize = config.banner.file.size.max + this.bannerExtensions = config.banner.file.extensions.join(', ') - // tslint:disable:max-line-length - this.bannerFormat = $localize`ratio 6/1, recommended size: 1920x317, max size: ${getBytes(this.maxBannerSize)}, extensions: ${this.bannerExtensions}` - }) + // tslint:disable:max-line-length + this.bannerFormat = $localize`ratio 6/1, recommended size: 1920x317, max size: ${getBytes(this.maxBannerSize)}, extensions: ${this.bannerExtensions}` } + onBannerChange (input: HTMLInputElement) { this.bannerfileInput = new ElementRef(input) diff --git a/client/src/app/shared/shared-forms/preview-upload.component.ts b/client/src/app/shared/shared-forms/preview-upload.component.ts index a55dcdd9a..edee6786d 100644 --- a/client/src/app/shared/shared-forms/preview-upload.component.ts +++ b/client/src/app/shared/shared-forms/preview-upload.component.ts @@ -2,7 +2,7 @@ import { Component, forwardRef, Input, OnInit } from '@angular/core' import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser' import { ServerService } from '@app/core' -import { ServerConfig } from '@shared/models' +import { HTMLServerConfig } from '@shared/models' import { BytesPipe } from '../shared-main' @Component({ @@ -27,7 +27,7 @@ export class PreviewUploadComponent implements OnInit, ControlValueAccessor { allowedExtensionsMessage = '' maxSizeText: string - private serverConfig: ServerConfig + private serverConfig: HTMLServerConfig private bytesPipe: BytesPipe private file: Blob @@ -52,9 +52,7 @@ export class PreviewUploadComponent implements OnInit, ControlValueAccessor { } ngOnInit () { - this.serverConfig = this.serverService.getTmpConfig() - this.serverService.getConfig() - .subscribe(config => this.serverConfig = config) + this.serverConfig = this.serverService.getHTMLConfig() this.allowedExtensionsMessage = this.videoImageExtensions.join(', ') } diff --git a/client/src/app/shared/shared-instance/instance-features-table.component.html b/client/src/app/shared/shared-instance/instance-features-table.component.html index d505b6739..3fc5920b5 100644 --- a/client/src/app/shared/shared-instance/instance-features-table.component.html +++ b/client/src/app/shared/shared-instance/instance-features-table.component.html @@ -1,4 +1,4 @@ -
+
diff --git a/client/src/app/shared/shared-instance/instance-features-table.component.ts b/client/src/app/shared/shared-instance/instance-features-table.component.ts index c3b3dfdfd..6335de450 100644 --- a/client/src/app/shared/shared-instance/instance-features-table.component.ts +++ b/client/src/app/shared/shared-instance/instance-features-table.component.ts @@ -40,7 +40,6 @@ export class InstanceFeaturesTableComponent implements OnInit { } ngOnInit () { - this.serverConfig = this.serverService.getTmpConfig() this.serverService.getConfig() .subscribe(config => { this.serverConfig = config diff --git a/client/src/app/shared/shared-main/video/video.model.ts b/client/src/app/shared/shared-main/video/video.model.ts index e7f739bfe..ab8ed9051 100644 --- a/client/src/app/shared/shared-main/video/video.model.ts +++ b/client/src/app/shared/shared-main/video/video.model.ts @@ -1,13 +1,11 @@ import { AuthUser } from '@app/core' import { User } from '@app/core/users/user.model' import { durationToString, getAbsoluteAPIUrl, getAbsoluteEmbedUrl } from '@app/helpers' -import { Account } from '@app/shared/shared-main/account/account.model' import { Actor } from '@app/shared/shared-main/account/actor.model' -import { VideoChannel } from '@app/shared/shared-main/video-channel/video-channel.model' import { peertubeTranslate } from '@shared/core-utils/i18n' import { ActorImage, - ServerConfig, + HTMLServerConfig, UserRight, Video as VideoServerModel, VideoConstant, @@ -163,7 +161,7 @@ export class Video implements VideoServerModel { this.pluginData = hash.pluginData } - isVideoNSFWForUser (user: User, serverConfig: ServerConfig) { + isVideoNSFWForUser (user: User, serverConfig: HTMLServerConfig) { // Video is not NSFW, skip if (this.nsfw === false) return false diff --git a/client/src/app/shared/shared-moderation/user-moderation-dropdown.component.ts b/client/src/app/shared/shared-moderation/user-moderation-dropdown.component.ts index f510a82f9..8c5a48d42 100644 --- a/client/src/app/shared/shared-moderation/user-moderation-dropdown.component.ts +++ b/client/src/app/shared/shared-moderation/user-moderation-dropdown.component.ts @@ -1,7 +1,7 @@ import { Component, EventEmitter, Input, OnChanges, OnInit, Output, ViewChild } from '@angular/core' import { AuthService, ConfirmService, Notifier, ServerService, UserService } from '@app/core' import { Account, DropdownAction } from '@app/shared/shared-main' -import { BulkRemoveCommentsOfBody, ServerConfig, User, UserRight } from '@shared/models' +import { BulkRemoveCommentsOfBody, User, UserRight } from '@shared/models' import { BlocklistService } from './blocklist.service' import { BulkService } from './bulk.service' import { UserBanModalComponent } from './user-ban-modal.component' @@ -28,7 +28,7 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges { userActions: DropdownAction<{ user: User, account: Account }>[][] = [] - private serverConfig: ServerConfig + requiresEmailVerification = false constructor ( private authService: AuthService, @@ -40,14 +40,9 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges { private bulkService: BulkService ) { } - get requiresEmailVerification () { - return this.serverConfig.signup.requiresEmailVerification - } - - ngOnInit (): void { - this.serverConfig = this.serverService.getTmpConfig() + ngOnInit () { this.serverService.getConfig() - .subscribe(config => this.serverConfig = config) + .subscribe(config => this.requiresEmailVerification = config.signup.requiresEmailVerification) } ngOnChanges () { diff --git a/client/src/app/shared/shared-user-settings/user-interface-settings.component.ts b/client/src/app/shared/shared-user-settings/user-interface-settings.component.ts index 80b88c129..b721604e5 100644 --- a/client/src/app/shared/shared-user-settings/user-interface-settings.component.ts +++ b/client/src/app/shared/shared-user-settings/user-interface-settings.component.ts @@ -2,7 +2,7 @@ import { Subject, Subscription } from 'rxjs' import { Component, Input, OnDestroy, OnInit } from '@angular/core' import { AuthService, Notifier, ServerService, UserService } from '@app/core' import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' -import { ServerConfig, User, UserUpdateMe } from '@shared/models' +import { HTMLServerConfig, User, UserUpdateMe } from '@shared/models' @Component({ selector: 'my-user-interface-settings', @@ -17,7 +17,7 @@ export class UserInterfaceSettingsComponent extends FormReactive implements OnIn formValuesWatcher: Subscription - private serverConfig: ServerConfig + private serverConfig: HTMLServerConfig constructor ( protected formValidatorService: FormValidatorService, @@ -35,9 +35,7 @@ export class UserInterfaceSettingsComponent extends FormReactive implements OnIn } ngOnInit () { - this.serverConfig = this.serverService.getTmpConfig() - this.serverService.getConfig() - .subscribe(config => this.serverConfig = config) + this.serverConfig = this.serverService.getHTMLConfig() this.buildForm({ theme: null diff --git a/client/src/app/shared/shared-user-settings/user-video-settings.component.ts b/client/src/app/shared/shared-user-settings/user-video-settings.component.ts index ae95030c7..8b0eaea4f 100644 --- a/client/src/app/shared/shared-user-settings/user-video-settings.component.ts +++ b/client/src/app/shared/shared-user-settings/user-video-settings.component.ts @@ -48,9 +48,8 @@ export class UserVideoSettingsComponent extends FormReactive implements OnInit, forkJoin([ this.serverService.getVideoLanguages(), - this.serverService.getConfig(), this.userInformationLoaded.pipe(first()) - ]).subscribe(([ languages, config ]) => { + ]).subscribe(([ languages ]) => { const group = this.allLanguagesGroup this.languageItems = [ { label: $localize`Unknown language`, id: '_unknown', group } ] @@ -61,7 +60,8 @@ export class UserVideoSettingsComponent extends FormReactive implements OnInit, ? this.user.videoLanguages.map(l => ({ id: l })) : [ { group } ] - this.defaultNSFWPolicy = config.instance.defaultNSFWPolicy + const serverConfig = this.serverService.getHTMLConfig() + this.defaultNSFWPolicy = serverConfig.instance.defaultNSFWPolicy this.form.patchValue({ nsfwPolicy: this.user.nsfwPolicy || this.defaultNSFWPolicy, diff --git a/client/src/app/shared/shared-video-miniature/abstract-video-list.ts b/client/src/app/shared/shared-video-miniature/abstract-video-list.ts index f83380513..bf433aabd 100644 --- a/client/src/app/shared/shared-video-miniature/abstract-video-list.ts +++ b/client/src/app/shared/shared-video-miniature/abstract-video-list.ts @@ -25,7 +25,7 @@ import { import { DisableForReuseHook } from '@app/core/routing/disable-for-reuse-hook' import { GlobalIconName } from '@app/shared/shared-icons' import { isLastMonth, isLastWeek, isThisMonth, isToday, isYesterday } from '@shared/core-utils/miscs/date' -import { ServerConfig, UserRight, VideoFilter, VideoSortField } from '@shared/models' +import { HTMLServerConfig, UserRight, VideoFilter, VideoSortField } from '@shared/models' import { NSFWPolicyType } from '@shared/models/videos/nsfw-policy.type' import { Syndication, Video } from '../shared-main' import { GenericHeaderComponent, VideoListHeaderComponent } from './video-list-header.component' @@ -100,7 +100,7 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy, AfterConte protected onUserLoadedSubject = new ReplaySubject(1) - protected serverConfig: ServerConfig + protected serverConfig: HTMLServerConfig protected abstract notifier: Notifier protected abstract authService: AuthService @@ -126,9 +126,7 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy, AfterConte abstract generateSyndicationList (): void ngOnInit () { - this.serverConfig = this.serverService.getTmpConfig() - this.serverService.getConfig() - .subscribe(config => this.serverConfig = config) + this.serverConfig = this.serverService.getHTMLConfig() this.groupedDateLabels = { [GroupDate.UNKNOWN]: null, diff --git a/client/src/app/shared/shared-video-miniature/video-miniature.component.ts b/client/src/app/shared/shared-video-miniature/video-miniature.component.ts index aac55a6e9..fc066846a 100644 --- a/client/src/app/shared/shared-video-miniature/video-miniature.component.ts +++ b/client/src/app/shared/shared-video-miniature/video-miniature.component.ts @@ -11,7 +11,7 @@ import { Output } from '@angular/core' import { AuthService, ScreenService, ServerService, User } from '@app/core' -import { ServerConfig, VideoPlaylistType, VideoPrivacy, VideoState } from '@shared/models' +import { HTMLServerConfig, VideoPlaylistType, VideoPrivacy, VideoState } from '@shared/models' import { ActorAvatarSize } from '../shared-actor-image/actor-avatar.component' import { Video } from '../shared-main' import { VideoPlaylistService } from '../shared-video-playlist' @@ -74,7 +74,7 @@ export class VideoMiniatureComponent implements OnInit { mute: true } showActions = false - serverConfig: ServerConfig + serverConfig: HTMLServerConfig addToWatchLaterText: string addedToWatchLaterText: string @@ -106,12 +106,8 @@ export class VideoMiniatureComponent implements OnInit { } ngOnInit () { - this.serverConfig = this.serverService.getTmpConfig() - this.serverService.getConfig() - .subscribe(config => { - this.serverConfig = config - this.buildVideoLink() - }) + this.serverConfig = this.serverService.getHTMLConfig() + this.buildVideoLink() this.setUpBy() diff --git a/client/src/app/shared/shared-video-playlist/video-playlist-element-miniature.component.ts b/client/src/app/shared/shared-video-playlist/video-playlist-element-miniature.component.ts index 86c281a1e..57eab4dfd 100644 --- a/client/src/app/shared/shared-video-playlist/video-playlist-element-miniature.component.ts +++ b/client/src/app/shared/shared-video-playlist/video-playlist-element-miniature.component.ts @@ -2,7 +2,7 @@ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, In import { AuthService, Notifier, ServerService } from '@app/core' import { Video } from '@app/shared/shared-main' import { NgbDropdown } from '@ng-bootstrap/ng-bootstrap' -import { ServerConfig, VideoPlaylistElementType, VideoPlaylistElementUpdate } from '@shared/models' +import { HTMLServerConfig, VideoPlaylistElementType, VideoPlaylistElementUpdate } from '@shared/models' import { secondsToTime } from '../../../assets/player/utils' import { VideoPlaylistElement } from './video-playlist-element.model' import { VideoPlaylist } from './video-playlist.model' @@ -37,7 +37,7 @@ export class VideoPlaylistElementMiniatureComponent implements OnInit { stopTimestamp: number } = {} as any - private serverConfig: ServerConfig + private serverConfig: HTMLServerConfig constructor ( private authService: AuthService, @@ -48,12 +48,7 @@ export class VideoPlaylistElementMiniatureComponent implements OnInit { ) {} ngOnInit (): void { - this.serverConfig = this.serverService.getTmpConfig() - this.serverService.getConfig() - .subscribe(config => { - this.serverConfig = config - this.cdr.detectChanges() - }) + this.serverConfig = this.serverService.getHTMLConfig() } isUnavailable (e: VideoPlaylistElement) { -- cgit v1.2.3
Features found on this instance