diff --git a/.dprint.json b/.dprint.json index 503010f3a..6bd8acb84 100644 --- a/.dprint.json +++ b/.dprint.json @@ -38,8 +38,8 @@ "forStatement.spaceAfterForKeyword": true, "forStatement.spaceAfterSemiColons": true, "functionDeclaration.spaceBeforeParentheses": true, - "functionExpression.spaceBeforeParentheses": false, - "functionExpression.spaceAfterFunctionKeyword": false, + "functionExpression.spaceBeforeParentheses": true, + "functionExpression.spaceAfterFunctionKeyword": true, "getAccessor.spaceBeforeParentheses": true, "ifStatement.spaceAfterIfKeyword": true, "importDeclaration.spaceSurroundingNamedImports": true, diff --git a/.eslintrc.json b/.eslintrc.json index 17afd1b83..6e484c197 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -50,7 +50,7 @@ "SwitchCase": 1, "MemberExpression": "off", // https://github.com/eslint/eslint/issues/15299 - "ignoredNodes": ["PropertyDefinition"] + "ignoredNodes": ["PropertyDefinition", "TSTypeParameterInstantiation"] } ], "@typescript-eslint/consistent-type-assertions": [ diff --git a/client/src/app/+about/about-contact/about-contact.component.ts b/client/src/app/+about/about-contact/about-contact.component.ts index f8985f098..fccceebb5 100644 --- a/client/src/app/+about/about-contact/about-contact.component.ts +++ b/client/src/app/+about/about-contact/about-contact.component.ts @@ -1,5 +1,5 @@ import { NgClass, NgIf } from '@angular/common' -import { Component, OnInit } from '@angular/core' +import { Component, OnInit, inject } from '@angular/core' import { FormsModule, ReactiveFormsModule } from '@angular/forms' import { ActivatedRoute } from '@angular/router' import { ServerService } from '@app/core' @@ -26,20 +26,16 @@ type Prefill = { imports: [ NgIf, FormsModule, ReactiveFormsModule, NgClass, AlertComponent ] }) export class AboutContactComponent extends FormReactive implements OnInit { + protected formReactiveService = inject(FormReactiveService) + private route = inject(ActivatedRoute) + private instanceService = inject(InstanceService) + private serverService = inject(ServerService) + error: string success: string private serverConfig: HTMLServerConfig - constructor ( - protected formReactiveService: FormReactiveService, - private route: ActivatedRoute, - private instanceService: InstanceService, - private serverService: ServerService - ) { - super() - } - get instanceName () { return this.serverConfig.instance.name } @@ -68,17 +64,17 @@ export class AboutContactComponent extends FormReactive implements OnInit { const body = this.form.value['body'] this.instanceService.contactAdministrator(fromEmail, fromName, subject, body) - .subscribe({ - next: () => { - this.success = $localize`Your message has been sent.` - }, + .subscribe({ + next: () => { + this.success = $localize`Your message has been sent.` + }, - error: err => { - this.error = err.status === HttpStatusCode.FORBIDDEN_403 - ? $localize`You already sent this form recently` - : err.message - } - }) + error: err => { + this.error = err.status === HttpStatusCode.FORBIDDEN_403 + ? $localize`You already sent this form recently` + : err.message + } + }) } private prefillForm (prefill: Prefill) { diff --git a/client/src/app/+about/about-follows/about-follows.component.ts b/client/src/app/+about/about-follows/about-follows.component.ts index fd677fdc2..f2696d14a 100644 --- a/client/src/app/+about/about-follows/about-follows.component.ts +++ b/client/src/app/+about/about-follows/about-follows.component.ts @@ -1,5 +1,5 @@ import { DecimalPipe, NgFor, NgIf } from '@angular/common' -import { Component, OnInit } from '@angular/core' +import { Component, OnInit, inject } from '@angular/core' import { RouterLink } from '@angular/router' import { ComponentPagination, hasMoreItems, Notifier, RestService, ServerService } from '@app/core' import { ActorAvatarComponent } from '@app/shared/shared-actor-image/actor-avatar.component' @@ -29,8 +29,12 @@ import { SubscriptionImageComponent } from './subscription-image.component' FollowerImageComponent ] }) - export class AboutFollowsComponent implements OnInit { + private server = inject(ServerService) + private restService = inject(RestService) + private notifier = inject(Notifier) + private followService = inject(InstanceFollowService) + instanceName: string followers: Actor[] = [] @@ -58,13 +62,6 @@ export class AboutFollowsComponent implements OnInit { order: -1 } - constructor ( - private server: ServerService, - private restService: RestService, - private notifier: Notifier, - private followService: InstanceFollowService - ) { } - ngOnInit () { this.loadMoreFollowers(true) this.loadMoreSubscriptions(true) @@ -96,20 +93,20 @@ export class AboutFollowsComponent implements OnInit { const pagination = this.restService.componentToRestPagination(this.followersPagination) this.followService.getFollowers({ pagination, sort: this.sort, state: 'accepted' }) - .subscribe({ - next: resultList => { - if (reset) this.followers = [] + .subscribe({ + next: resultList => { + if (reset) this.followers = [] - const newFollowers = resultList.data.map(r => this.formatFollow(r.follower)) - this.followers = this.followers.concat(newFollowers) + const newFollowers = resultList.data.map(r => this.formatFollow(r.follower)) + this.followers = this.followers.concat(newFollowers) - this.followersPagination.totalItems = resultList.total - }, + this.followersPagination.totalItems = resultList.total + }, - error: err => this.notifier.error(err.message), + error: err => this.notifier.error(err.message), - complete: () => this.loadingFollowers = false - }) + complete: () => this.loadingFollowers = false + }) } loadMoreSubscriptions (reset = false) { @@ -122,20 +119,20 @@ export class AboutFollowsComponent implements OnInit { const pagination = this.restService.componentToRestPagination(this.subscriptionsPagination) this.followService.getFollowing({ pagination, sort: this.sort, state: 'accepted' }) - .subscribe({ - next: resultList => { - if (reset) this.subscriptions = [] + .subscribe({ + next: resultList => { + if (reset) this.subscriptions = [] - const newFollowings = resultList.data.map(r => this.formatFollow(r.following)) - this.subscriptions = this.subscriptions.concat(newFollowings) + const newFollowings = resultList.data.map(r => this.formatFollow(r.following)) + this.subscriptions = this.subscriptions.concat(newFollowings) - this.subscriptionsPagination.totalItems = resultList.total - }, + this.subscriptionsPagination.totalItems = resultList.total + }, - error: err => this.notifier.error(err.message), + error: err => this.notifier.error(err.message), - complete: () => this.loadingSubscriptions = false - }) + complete: () => this.loadingSubscriptions = false + }) } private formatFollow (actor: Actor) { diff --git a/client/src/app/+about/about-follows/follower-image.component.ts b/client/src/app/+about/about-follows/follower-image.component.ts index 2920402a0..4bbeabf71 100644 --- a/client/src/app/+about/about-follows/follower-image.component.ts +++ b/client/src/app/+about/about-follows/follower-image.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core' +import { Component, OnInit, inject } from '@angular/core' import { ServerService } from '@app/core' import { Actor } from '@app/shared/shared-main/account/actor.model' @@ -9,9 +9,9 @@ import { Actor } from '@app/shared/shared-main/account/actor.model' standalone: true }) export class FollowerImageComponent implements OnInit { - avatarUrl: string + private server = inject(ServerService) - constructor (private server: ServerService) {} + avatarUrl: string ngOnInit () { this.avatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.server.getHTMLConfig().instance, 30) diff --git a/client/src/app/+about/about-follows/subscription-image.component.ts b/client/src/app/+about/about-follows/subscription-image.component.ts index 738b32c7f..e5a99279c 100644 --- a/client/src/app/+about/about-follows/subscription-image.component.ts +++ b/client/src/app/+about/about-follows/subscription-image.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core' +import { Component, OnInit, inject } from '@angular/core' import { ServerService } from '@app/core' import { Actor } from '@app/shared/shared-main/account/actor.model' @@ -9,9 +9,9 @@ import { Actor } from '@app/shared/shared-main/account/actor.model' standalone: true }) export class SubscriptionImageComponent implements OnInit { - avatarUrl: string + private server = inject(ServerService) - constructor (private server: ServerService) {} + avatarUrl: string ngOnInit () { this.avatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.server.getHTMLConfig().instance, 30) diff --git a/client/src/app/+about/about-instance/about-instance.component.ts b/client/src/app/+about/about-instance/about-instance.component.ts index dd734743d..6cfcf22cf 100644 --- a/client/src/app/+about/about-instance/about-instance.component.ts +++ b/client/src/app/+about/about-instance/about-instance.component.ts @@ -1,4 +1,4 @@ -import { Component, ElementRef, OnInit, ViewChild } from '@angular/core' +import { Component, ElementRef, OnInit, inject, viewChild } from '@angular/core' import { ActivatedRoute, RouterOutlet } from '@angular/router' import { AboutHTML } from '@app/shared/shared-main/instance/instance.service' import { ServerConfig, ServerStats } from '@peertube/peertube-models' @@ -17,17 +17,15 @@ import { HorizontalMenuComponent, HorizontalMenuEntry } from '@app/shared/shared ] }) export class AboutInstanceComponent implements OnInit { - @ViewChild('descriptionWrapper') descriptionWrapper: ElementRef + private route = inject(ActivatedRoute) + + readonly descriptionWrapper = viewChild>('descriptionWrapper') aboutHTML: AboutHTML serverStats: ServerStats serverConfig: ServerConfig menuEntries: HorizontalMenuEntry[] = [] - constructor ( - private route: ActivatedRoute - ) {} - ngOnInit () { const { aboutHTML, diff --git a/client/src/app/+about/about-instance/about-instance.resolver.ts b/client/src/app/+about/about-instance/about-instance.resolver.ts index ed1054c3c..cb96b2f76 100644 --- a/client/src/app/+about/about-instance/about-instance.resolver.ts +++ b/client/src/app/+about/about-instance/about-instance.resolver.ts @@ -1,6 +1,6 @@ import { forkJoin, Observable } from 'rxjs' import { map, switchMap } from 'rxjs/operators' -import { Injectable } from '@angular/core' +import { Injectable, inject } from '@angular/core' import { ServerService } from '@app/core' import { About, ServerConfig, ServerStats } from '@peertube/peertube-models' import { AboutHTML, InstanceService } from '@app/shared/shared-main/instance/instance.service' @@ -18,12 +18,9 @@ export type ResolverData = { @Injectable() export class AboutInstanceResolver { - - constructor ( - private instanceService: InstanceService, - private customMarkupService: CustomMarkupService, - private serverService: ServerService - ) {} + private instanceService = inject(InstanceService) + private customMarkupService = inject(CustomMarkupService) + private serverService = inject(ServerService) resolve (): Observable { return forkJoin([ diff --git a/client/src/app/+about/about-instance/children/about-instance-home.component.ts b/client/src/app/+about/about-instance/children/about-instance-home.component.ts index 33abd13c8..077134210 100644 --- a/client/src/app/+about/about-instance/children/about-instance-home.component.ts +++ b/client/src/app/+about/about-instance/children/about-instance-home.component.ts @@ -1,5 +1,5 @@ import { NgFor, NgIf } from '@angular/common' -import { Component, OnInit, ViewChild } from '@angular/core' +import { Component, OnInit, inject, viewChild } from '@angular/core' import { ActivatedRoute, Router } from '@angular/router' import { ServerService } from '@app/core' import { AboutHTML } from '@app/shared/shared-main/instance/instance.service' @@ -19,7 +19,11 @@ import { ResolverData } from '../about-instance.resolver' ] }) export class AboutInstanceHomeComponent implements OnInit { - @ViewChild('supportModal') supportModal: SupportModalComponent + private router = inject(Router) + private route = inject(ActivatedRoute) + private serverService = inject(ServerService) + + readonly supportModal = viewChild('supportModal') aboutHTML: AboutHTML descriptionElement: HTMLDivElement @@ -29,12 +33,6 @@ export class AboutInstanceHomeComponent implements OnInit { config: HTMLServerConfig - constructor ( - private router: Router, - private route: ActivatedRoute, - private serverService: ServerService - ) {} - ngOnInit () { this.config = this.serverService.getHTMLConfig() @@ -55,7 +53,7 @@ export class AboutInstanceHomeComponent implements OnInit { if (!data?.isSupport) return setTimeout(() => { - const modal = this.supportModal.show() + const modal = this.supportModal().show() modal.hidden.subscribe(() => this.router.navigateByUrl('/about/instance/home')) }, 0) diff --git a/client/src/app/+about/about-instance/children/about-instance-moderation.component.ts b/client/src/app/+about/about-instance/children/about-instance-moderation.component.ts index ef0e8a391..5d8e71bc8 100644 --- a/client/src/app/+about/about-instance/children/about-instance-moderation.component.ts +++ b/client/src/app/+about/about-instance/children/about-instance-moderation.component.ts @@ -1,5 +1,5 @@ import { CommonModule } from '@angular/common' -import { Component, OnInit } from '@angular/core' +import { Component, OnInit, inject } from '@angular/core' import { ActivatedRoute } from '@angular/router' import { ServerService } from '@app/core' import { AboutHTML } from '@app/shared/shared-main/instance/instance.service' @@ -12,12 +12,10 @@ import { PluginSelectorDirective } from '@app/shared/shared-main/plugins/plugin- imports: [ CommonModule, PluginSelectorDirective ] }) export class AboutInstanceModerationComponent implements OnInit { - aboutHTML: AboutHTML + private route = inject(ActivatedRoute) + private serverService = inject(ServerService) - constructor ( - private route: ActivatedRoute, - private serverService: ServerService - ) {} + aboutHTML: AboutHTML get instanceName () { return this.serverService.getHTMLConfig().instance.name diff --git a/client/src/app/+about/about-instance/children/about-instance-team.component.ts b/client/src/app/+about/about-instance/children/about-instance-team.component.ts index 6a8f7995f..5aa4296c6 100644 --- a/client/src/app/+about/about-instance/children/about-instance-team.component.ts +++ b/client/src/app/+about/about-instance/children/about-instance-team.component.ts @@ -1,5 +1,5 @@ import { CommonModule } from '@angular/common' -import { Component, OnInit } from '@angular/core' +import { Component, OnInit, inject } from '@angular/core' import { ActivatedRoute } from '@angular/router' import { ServerService } from '@app/core' import { AboutHTML } from '@app/shared/shared-main/instance/instance.service' @@ -11,12 +11,10 @@ import { ResolverData } from '../about-instance.resolver' imports: [ CommonModule ] }) export class AboutInstanceTeamComponent implements OnInit { - aboutHTML: AboutHTML + private route = inject(ActivatedRoute) + private serverService = inject(ServerService) - constructor ( - private route: ActivatedRoute, - private serverService: ServerService - ) {} + aboutHTML: AboutHTML get instanceName () { return this.serverService.getHTMLConfig().instance.name diff --git a/client/src/app/+about/about-instance/children/about-instance-tech.component.ts b/client/src/app/+about/about-instance/children/about-instance-tech.component.ts index 4e5ba3bd9..3e63b6e24 100644 --- a/client/src/app/+about/about-instance/children/about-instance-tech.component.ts +++ b/client/src/app/+about/about-instance/children/about-instance-tech.component.ts @@ -1,5 +1,5 @@ import { CommonModule } from '@angular/common' -import { Component, OnInit } from '@angular/core' +import { Component, OnInit, inject } from '@angular/core' import { ActivatedRoute } from '@angular/router' import { ServerService } from '@app/core' import { AboutHTML } from '@app/shared/shared-main/instance/instance.service' @@ -13,12 +13,10 @@ import { InstanceFeaturesTableComponent } from '@app/shared/shared-instance/inst imports: [ CommonModule, PluginSelectorDirective, InstanceFeaturesTableComponent ] }) export class AboutInstanceTechComponent implements OnInit { - aboutHTML: AboutHTML + private route = inject(ActivatedRoute) + private serverService = inject(ServerService) - constructor ( - private route: ActivatedRoute, - private serverService: ServerService - ) {} + aboutHTML: AboutHTML get instanceName () { return this.serverService.getHTMLConfig().instance.name diff --git a/client/src/app/+about/about-instance/instance-stat-rules.component.html b/client/src/app/+about/about-instance/instance-stat-rules.component.html index 156e2523d..868fbf9ef 100644 --- a/client/src/app/+about/about-instance/instance-stat-rules.component.html +++ b/client/src/app/+about/about-instance/instance-stat-rules.component.html @@ -5,37 +5,37 @@
- {{ stats.totalModerators + stats.totalAdmins | number }} + {{ stats().totalModerators + stats().totalAdmins | number }}
moderators
- {{ stats.totalUsers | number }} + {{ stats().totalUsers | number }}
users
- {{ stats.totalLocalVideos | number }} + {{ stats().totalLocalVideos | number }} videos
- {{ stats.totalLocalVideoViews | number }} + {{ stats().totalLocalVideoViews | number }}
views
- {{ stats.totalLocalVideoComments | number }} + {{ stats().totalLocalVideoComments | number }}
comments
- {{ stats.totalLocalVideoFilesSize | bytes:1 }} + {{ stats().totalLocalVideoFilesSize | bytes:1 }}
hosted videos
@@ -47,7 +47,7 @@
-
+
@@ -57,10 +57,10 @@
- This platform has been created in {{ config.instance.serverCountry }} + This platform has been created in {{ config().instance.serverCountry }}
Your content (comments, videos...) must comply with the legislation in force in this country. - You must also follow our code of conduct. + You must also follow our code of conduct.
@@ -69,7 +69,7 @@
- @if (config.signup.allowed && config.signup.allowedForCurrentIP) { + @if (config().signup.allowed && config().signup.allowedForCurrentIP) {
@@ -81,12 +81,12 @@
- @if (config.signup.allowed && config.signup.allowedForCurrentIP) { - @if (config.signup.requiresApproval) { + @if (config().signup.allowed && config().signup.allowedForCurrentIP) { + @if (config().signup.requiresApproval) { You can request an account on our platform - @if (stats.averageRegistrationRequestResponseTimeMs) { -
Our moderator will validate it within a {{ stats.averageRegistrationRequestResponseTimeMs | myDaysDurationFormatter }}.
+ @if (stats().averageRegistrationRequestResponseTimeMs) { +
Our moderator will validate it within a {{ stats().averageRegistrationRequestResponseTimeMs | myDaysDurationFormatter }}.
} @else {
Our moderator will validate it within a few days.
} @@ -99,7 +99,7 @@
-
+
diff --git a/client/src/app/+about/about-instance/instance-stat-rules.component.ts b/client/src/app/+about/about-instance/instance-stat-rules.component.ts index 0bc499705..91bd8ffbf 100644 --- a/client/src/app/+about/about-instance/instance-stat-rules.component.ts +++ b/client/src/app/+about/about-instance/instance-stat-rules.component.ts @@ -1,5 +1,5 @@ import { CommonModule, DecimalPipe, NgIf } from '@angular/common' -import { Component, Input } from '@angular/core' +import { Component, inject, input } from '@angular/core' import { RouterLink } from '@angular/router' import { BytesPipe } from '@app/shared/shared-main/common/bytes.pipe' import { DaysDurationFormatterPipe } from '@app/shared/shared-main/date/days-duration-formatter.pipe' @@ -25,13 +25,11 @@ import { AuthService } from '@app/core' ] }) export class InstanceStatRulesComponent { - @Input({ required: true }) stats: ServerStats - @Input({ required: true }) config: ServerConfig - @Input({ required: true }) aboutHTML: AboutHTML + private auth = inject(AuthService) - constructor (private auth: AuthService) { - - } + readonly stats = input.required() + readonly config = input.required() + readonly aboutHTML = input.required() canUpload () { const user = this.auth.getUser() @@ -42,14 +40,16 @@ export class InstanceStatRulesComponent { return true } - return this.config.user.videoQuota !== 0 && this.config.user.videoQuotaDaily !== 0 + const config = this.config() + return config.user.videoQuota !== 0 && config.user.videoQuotaDaily !== 0 } canPublishLive () { - return this.config.live.enabled + return this.config().live.enabled } isContactFormEnabled () { - return this.config.email.enabled && this.config.contactForm.enabled + const config = this.config() + return config.email.enabled && config.contactForm.enabled } } diff --git a/client/src/app/+about/about-peertube/about-peertube.component.ts b/client/src/app/+about/about-peertube/about-peertube.component.ts index 729034dc8..08bfc6b66 100644 --- a/client/src/app/+about/about-peertube/about-peertube.component.ts +++ b/client/src/app/+about/about-peertube/about-peertube.component.ts @@ -1,4 +1,4 @@ -import { Component, AfterViewChecked } from '@angular/core' +import { Component, AfterViewChecked, inject } from '@angular/core' import { ViewportScroller } from '@angular/common' @Component({ @@ -7,13 +7,10 @@ import { ViewportScroller } from '@angular/common' styleUrls: [ './about-peertube.component.scss' ], standalone: true }) - export class AboutPeertubeComponent implements AfterViewChecked { - private lastScrollHash: string + private viewportScroller = inject(ViewportScroller) - constructor ( - private viewportScroller: ViewportScroller - ) {} + private lastScrollHash: string ngAfterViewChecked () { if (window.location.hash && window.location.hash !== this.lastScrollHash) { diff --git a/client/src/app/+about/about.component.ts b/client/src/app/+about/about.component.ts index 86cac1bf5..b09b54660 100644 --- a/client/src/app/+about/about.component.ts +++ b/client/src/app/+about/about.component.ts @@ -1,5 +1,5 @@ import { CommonModule } from '@angular/common' -import { Component, OnInit, ViewChild } from '@angular/core' +import { Component, OnInit, inject, viewChild } from '@angular/core' import { RouterOutlet } from '@angular/router' import { ServerService } from '@app/core' import { GlobalIconComponent } from '@app/shared/shared-icons/global-icon.component' @@ -14,11 +14,12 @@ import { HTMLServerConfig } from '@peertube/peertube-models' selector: 'my-about', templateUrl: './about.component.html', styleUrls: [ './about.component.scss' ], - imports: [ CommonModule, RouterOutlet, HorizontalMenuComponent, GlobalIconComponent, ButtonComponent, SupportModalComponent ] + imports: [ CommonModule, RouterOutlet, HorizontalMenuComponent, GlobalIconComponent, ButtonComponent ] }) - export class AboutComponent implements OnInit { - @ViewChild('supportModal') supportModal: SupportModalComponent + private server = inject(ServerService) + + readonly supportModal = viewChild('supportModal') bannerUrl: string avatarUrl: string @@ -27,12 +28,6 @@ export class AboutComponent implements OnInit { config: HTMLServerConfig - constructor ( - private server: ServerService - ) { - - } - ngOnInit () { this.config = this.server.getHTMLConfig() diff --git a/client/src/app/+accounts/account-video-channels/account-video-channels.component.ts b/client/src/app/+accounts/account-video-channels/account-video-channels.component.ts index 10132a6c8..e185c8372 100644 --- a/client/src/app/+accounts/account-video-channels/account-video-channels.component.ts +++ b/client/src/app/+accounts/account-video-channels/account-video-channels.component.ts @@ -1,6 +1,6 @@ import { from, Subject, Subscription } from 'rxjs' import { concatMap, map, switchMap, tap } from 'rxjs/operators' -import { Component, OnDestroy, OnInit } from '@angular/core' +import { Component, OnDestroy, OnInit, inject } from '@angular/core' import { ComponentPagination, hasMoreItems, MarkdownService, User, UserService } from '@app/core' import { SimpleMemoize } from '@app/helpers' import { NSFWPolicyType, VideoSortField } from '@peertube/peertube-models' @@ -24,12 +24,18 @@ import { Video } from '@app/shared/shared-main/video/video.model' imports: [ NgIf, InfiniteScrollerDirective, NgFor, ActorAvatarComponent, RouterLink, SubscribeButtonComponent, VideoMiniatureComponent ] }) export class AccountVideoChannelsComponent implements OnInit, OnDestroy { + private accountService = inject(AccountService) + private videoChannelService = inject(VideoChannelService) + private videoService = inject(VideoService) + private markdown = inject(MarkdownService) + private userService = inject(UserService) + account: Account videoChannels: VideoChannel[] = [] videos: { [id: number]: { total: number, videos: Video[] } } = {} - channelsDescriptionHTML: { [ id: number ]: string } = {} + channelsDescriptionHTML: { [id: number]: string } = {} channelPagination: ComponentPagination = { currentPage: 1, @@ -61,23 +67,15 @@ export class AccountVideoChannelsComponent implements OnInit, OnDestroy { private accountSub: Subscription - constructor ( - private accountService: AccountService, - private videoChannelService: VideoChannelService, - private videoService: VideoService, - private markdown: MarkdownService, - private userService: UserService - ) { } - ngOnInit () { // Parent get the account for us this.accountSub = this.accountService.accountLoaded - .subscribe(account => { - this.account = account - this.videoChannels = [] + .subscribe(account => { + this.account = account + this.videoChannels = [] - this.loadMoreChannels() - }) + this.loadMoreChannels() + }) this.userService.getAnonymousOrLoggedUser() .subscribe(user => { diff --git a/client/src/app/+accounts/account-videos/account-videos.component.ts b/client/src/app/+accounts/account-videos/account-videos.component.ts index 09051ef82..0a6013bea 100644 --- a/client/src/app/+accounts/account-videos/account-videos.component.ts +++ b/client/src/app/+accounts/account-videos/account-videos.component.ts @@ -1,5 +1,5 @@ import { NgIf } from '@angular/common' -import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core' +import { Component, OnDestroy, OnInit, inject, viewChild } from '@angular/core' import { ComponentPaginationLight, DisableForReuseHook, ScreenService } from '@app/core' import { Account } from '@app/shared/shared-main/account/account.model' import { AccountService } from '@app/shared/shared-main/account/account.service' @@ -15,7 +15,11 @@ import { VideosListComponent } from '../../shared/shared-video-miniature/videos- imports: [ NgIf, VideosListComponent ] }) export class AccountVideosComponent implements OnInit, OnDestroy, DisableForReuseHook { - @ViewChild('videosList') videosList: VideosListComponent + private screenService = inject(ScreenService) + private accountService = inject(AccountService) + private videoService = inject(VideoService) + + readonly videosList = viewChild('videosList') getVideosObservableFunction = this.getVideosObservable.bind(this) getSyndicationItemsFunction = this.getSyndicationItems.bind(this) @@ -29,19 +33,12 @@ export class AccountVideosComponent implements OnInit, OnDestroy, DisableForReus private accountSub: Subscription - constructor ( - private screenService: ScreenService, - private accountService: AccountService, - private videoService: VideoService - ) { - } - ngOnInit () { // Parent get the account for us this.accountSub = this.accountService.accountLoaded .subscribe(account => { this.account = account - if (this.alreadyLoaded) this.videosList.reloadVideos() + if (this.alreadyLoaded) this.videosList().reloadVideos() this.alreadyLoaded = true }) diff --git a/client/src/app/+accounts/accounts.component.ts b/client/src/app/+accounts/accounts.component.ts index f06f2915b..55b9fd5ff 100644 --- a/client/src/app/+accounts/accounts.component.ts +++ b/client/src/app/+accounts/accounts.component.ts @@ -1,5 +1,5 @@ import { NgClass, NgIf } from '@angular/common' -import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core' +import { Component, OnDestroy, OnInit, inject, viewChild } from '@angular/core' import { ActivatedRoute, Router, RouterLink, RouterLinkActive, RouterOutlet } from '@angular/router' import { AuthService, MarkdownService, MetaService, Notifier, RedirectService, RestExtractor, ScreenService, UserService } from '@app/core' import { Account } from '@app/shared/shared-main/account/account.model' @@ -44,7 +44,22 @@ import { SubscribeButtonComponent } from '../shared/shared-user-subscription/sub ] }) export class AccountsComponent implements OnInit, OnDestroy { - @ViewChild('accountReportModal') accountReportModal: AccountReportComponent + private route = inject(ActivatedRoute) + private router = inject(Router) + private userService = inject(UserService) + private accountService = inject(AccountService) + private videoChannelService = inject(VideoChannelService) + private notifier = inject(Notifier) + private restExtractor = inject(RestExtractor) + private redirectService = inject(RedirectService) + private authService = inject(AuthService) + private videoService = inject(VideoService) + private markdown = inject(MarkdownService) + private blocklist = inject(BlocklistService) + private screenService = inject(ScreenService) + private metaService = inject(MetaService) + + readonly accountReportModal = viewChild('accountReportModal') account: Account accountUser: User @@ -62,24 +77,6 @@ export class AccountsComponent implements OnInit, OnDestroy { private routeSub: Subscription - constructor ( - private route: ActivatedRoute, - private router: Router, - private userService: UserService, - private accountService: AccountService, - private videoChannelService: VideoChannelService, - private notifier: Notifier, - private restExtractor: RestExtractor, - private redirectService: RedirectService, - private authService: AuthService, - private videoService: VideoService, - private markdown: MarkdownService, - private blocklist: BlocklistService, - private screenService: ScreenService, - private metaService: MetaService - ) { - } - ngOnInit () { this.routeSub = this.route.params .pipe( @@ -88,10 +85,12 @@ export class AccountsComponent implements OnInit, OnDestroy { switchMap(accountId => this.accountService.getAccount(accountId)), tap(account => this.onAccount(account)), switchMap(account => this.videoChannelService.listAccountVideoChannels({ account })), - catchError(err => this.restExtractor.redirectTo404IfNotFound(err, 'other', [ - HttpStatusCode.BAD_REQUEST_400, - HttpStatusCode.NOT_FOUND_404 - ])) + catchError(err => + this.restExtractor.redirectTo404IfNotFound(err, 'other', [ + HttpStatusCode.BAD_REQUEST_400, + HttpStatusCode.NOT_FOUND_404 + ]) + ) ) .subscribe({ next: videoChannels => { @@ -187,7 +186,7 @@ export class AccountsComponent implements OnInit, OnDestroy { } private showReportModal () { - this.accountReportModal.show(this.account) + this.accountReportModal().show(this.account) } private loadUserIfNeeded (account: Account) { diff --git a/client/src/app/+admin/admin-moderation.component.ts b/client/src/app/+admin/admin-moderation.component.ts index 4ad157720..1e0e66c77 100644 --- a/client/src/app/+admin/admin-moderation.component.ts +++ b/client/src/app/+admin/admin-moderation.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core' +import { Component, OnInit, inject } from '@angular/core' import { RouterOutlet } from '@angular/router' import { AuthService, ServerService } from '@app/core' import { HorizontalMenuComponent, HorizontalMenuEntry } from '@app/shared/shared-main/menu/horizontal-menu.component' @@ -9,12 +9,10 @@ import { UserRight, UserRightType } from '@peertube/peertube-models' imports: [ HorizontalMenuComponent, RouterOutlet ] }) export class AdminModerationComponent implements OnInit { - menuEntries: HorizontalMenuEntry[] = [] + private auth = inject(AuthService) + private server = inject(ServerService) - constructor ( - private auth: AuthService, - private server: ServerService - ) { } + menuEntries: HorizontalMenuEntry[] = [] ngOnInit () { this.server.configReloaded.subscribe(() => this.buildMenu()) diff --git a/client/src/app/+admin/admin-overview.component.ts b/client/src/app/+admin/admin-overview.component.ts index 92600e0ee..2b73f8f3d 100644 --- a/client/src/app/+admin/admin-overview.component.ts +++ b/client/src/app/+admin/admin-overview.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core' +import { Component, OnInit, inject } from '@angular/core' import { RouterOutlet } from '@angular/router' import { AuthService } from '@app/core' import { HorizontalMenuComponent, HorizontalMenuEntry } from '@app/shared/shared-main/menu/horizontal-menu.component' @@ -9,11 +9,9 @@ import { UserRight, UserRightType } from '@peertube/peertube-models' imports: [ HorizontalMenuComponent, RouterOutlet ] }) export class AdminOverviewComponent implements OnInit { - menuEntries: HorizontalMenuEntry[] = [] + private auth = inject(AuthService) - constructor ( - private auth: AuthService - ) { } + menuEntries: HorizontalMenuEntry[] = [] ngOnInit () { this.buildMenu() diff --git a/client/src/app/+admin/admin-settings.component.ts b/client/src/app/+admin/admin-settings.component.ts index b4318a54c..955b9ff12 100644 --- a/client/src/app/+admin/admin-settings.component.ts +++ b/client/src/app/+admin/admin-settings.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core' +import { Component, OnInit, inject } from '@angular/core' import { RouterOutlet } from '@angular/router' import { AuthService, ServerService } from '@app/core' import { HorizontalMenuComponent, HorizontalMenuEntry } from '@app/shared/shared-main/menu/horizontal-menu.component' @@ -9,12 +9,10 @@ import { PluginType, UserRight, UserRightType } from '@peertube/peertube-models' imports: [ HorizontalMenuComponent, RouterOutlet ] }) export class AdminSettingsComponent implements OnInit { - menuEntries: HorizontalMenuEntry[] = [] + private auth = inject(AuthService) + private server = inject(ServerService) - constructor ( - private auth: AuthService, - private server: ServerService - ) { } + menuEntries: HorizontalMenuEntry[] = [] ngOnInit () { this.server.configReloaded.subscribe(() => this.buildMenu()) diff --git a/client/src/app/+admin/config/edit-custom-config/edit-advanced-configuration.component.html b/client/src/app/+admin/config/edit-custom-config/edit-advanced-configuration.component.html index 8e5d62b8e..d5e6510c9 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-advanced-configuration.component.html +++ b/client/src/app/+admin/config/edit-custom-config/edit-advanced-configuration.component.html @@ -1,4 +1,4 @@ - +
@@ -17,12 +17,12 @@
{getCacheSize('previews'), plural, =1 {cached image} other {cached images}}
- +
@@ -31,12 +31,12 @@
{getCacheSize('captions'), plural, =1 {cached caption} other {cached captions}}
- +
@@ -45,12 +45,12 @@
{getCacheSize('torrents'), plural, =1 {cached torrent} other {cached torrents}}
- +
@@ -59,12 +59,12 @@
{getCacheSize('storyboards'), plural, =1 {cached storyboard} other {cached storyboards}}
- +
@@ -96,10 +96,10 @@ - +
@@ -126,9 +126,9 @@ - +
diff --git a/client/src/app/+admin/config/edit-custom-config/edit-advanced-configuration.component.ts b/client/src/app/+admin/config/edit-custom-config/edit-advanced-configuration.component.ts index 1a4d2bd41..5a577a3d8 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-advanced-configuration.component.ts +++ b/client/src/app/+admin/config/edit-custom-config/edit-advanced-configuration.component.ts @@ -1,4 +1,4 @@ -import { Component, Input } from '@angular/core' +import { Component, input } from '@angular/core' import { FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms' import { PeerTubeTemplateDirective } from '../../../shared/shared-main/common/peertube-template.directive' import { HelpComponent } from '../../../shared/shared-main/buttons/help.component' @@ -11,10 +11,10 @@ import { NgClass, NgIf } from '@angular/common' imports: [ FormsModule, ReactiveFormsModule, NgClass, NgIf, HelpComponent, PeerTubeTemplateDirective ] }) export class EditAdvancedConfigurationComponent { - @Input() form: FormGroup - @Input() formErrors: any + readonly form = input(undefined) + readonly formErrors = input(undefined) getCacheSize (type: 'captions' | 'previews' | 'torrents' | 'storyboards') { - return this.form.value['cache'][type]['size'] + return this.form().value['cache'][type]['size'] } } diff --git a/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.html b/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.html index a557be07e..6ccb2e6e4 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.html +++ b/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.html @@ -1,4 +1,4 @@ - +

APPEARANCE

@@ -30,7 +30,7 @@ [clearable]="false" > - +
@@ -47,7 +47,7 @@
- +
@@ -122,7 +122,7 @@
- +
@@ -130,10 +130,10 @@ - +
@@ -185,12 +185,12 @@
- {form.value['signup']['limit'], plural, =1 {user} other {users}} + {form().value['signup']['limit'], plural, =1 {user} other {users}}
- + Signup won't be limited to a fixed number of users.
@@ -201,12 +201,12 @@
- {form.value['signup']['minimumAge'], plural, =1 {year old} other {years old}} + {form().value['signup']['minimumAge'], plural, =1 {year old} other {years old}}
- +
@@ -228,7 +228,7 @@ - +
@@ -243,7 +243,7 @@ [clearable]="false" > - +
@@ -281,7 +281,7 @@ jobs in parallel
- +
@@ -328,12 +328,12 @@
- {form.value['import']['videoChannelSynchronization']['maxPerUser'], plural, =1 {sync} other {syncs}} + {form().value['import']['videoChannelSynchronization']['maxPerUser'], plural, =1 {sync} other {syncs}}
- +
@@ -426,12 +426,12 @@
- {form.value['videoChannels']['maxPerUser'], plural, =1 {channel} other {channels}} + {form().value['videoChannels']['maxPerUser'], plural, =1 {channel} other {channels}}
- + @@ -490,10 +490,10 @@ - +
@@ -577,7 +577,7 @@ [clearable]="false" > - +
@@ -587,7 +587,7 @@
The archive file is deleted after this period.
- +
@@ -663,9 +663,9 @@ - + @@ -690,10 +690,10 @@ - +
@@ -731,10 +731,10 @@ - +
diff --git a/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.ts b/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.ts index 939a224fc..50e01d705 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.ts +++ b/client/src/app/+admin/config/edit-custom-config/edit-basic-configuration.component.ts @@ -1,5 +1,5 @@ -import { NgClass, NgFor, NgIf } from '@angular/common' -import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core' +import { NgClass, NgIf } from '@angular/common' +import { Component, OnChanges, OnInit, SimpleChanges, inject, input } from '@angular/core' import { FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms' import { RouterLink } from '@angular/router' import { ThemeService } from '@app/core' @@ -23,7 +23,6 @@ import { ConfigService } from '../shared/config.service' FormsModule, ReactiveFormsModule, RouterLink, - NgFor, SelectCustomValueComponent, NgIf, PeertubeCheckboxComponent, @@ -36,10 +35,13 @@ import { ConfigService } from '../shared/config.service' ] }) export class EditBasicConfigurationComponent implements OnInit, OnChanges { - @Input() form: FormGroup - @Input() formErrors: any + private configService = inject(ConfigService) + private themeService = inject(ThemeService) - @Input() serverConfig: HTMLServerConfig + readonly form = input(undefined) + readonly formErrors = input(undefined) + + readonly serverConfig = input(undefined) signupAlertMessage: string defaultLandingPageOptions: SelectOptionsItem[] = [] @@ -48,11 +50,6 @@ export class EditBasicConfigurationComponent implements OnInit, OnChanges { exportExpirationOptions: SelectOptionsItem[] = [] exportMaxUserVideoQuotaOptions: SelectOptionsItem[] = [] - constructor ( - private configService: ConfigService, - private themeService: ThemeService - ) {} - ngOnInit () { this.buildLandingPageOptions() this.checkSignupField() @@ -81,7 +78,7 @@ export class EditBasicConfigurationComponent implements OnInit, OnChanges { } countExternalAuth () { - return this.serverConfig.plugin.registeredExternalAuths.length + return this.serverConfig().plugin.registeredExternalAuths.length } getVideoQuotaOptions () { @@ -93,18 +90,18 @@ export class EditBasicConfigurationComponent implements OnInit, OnChanges { } doesTrendingVideosAlgorithmsEnabledInclude (algorithm: string) { - const enabled = this.form.value['trending']['videos']['algorithms']['enabled'] + const enabled = this.form().value['trending']['videos']['algorithms']['enabled'] if (!Array.isArray(enabled)) return false return !!enabled.find((e: string) => e === algorithm) } getUserVideoQuota () { - return this.form.value['user']['videoQuota'] + return this.form().value['user']['videoQuota'] } isExportUsersEnabled () { - return this.form.value['export']['users']['enabled'] === true + return this.form().value['export']['users']['enabled'] === true } getDisabledExportUsersClass () { @@ -112,7 +109,7 @@ export class EditBasicConfigurationComponent implements OnInit, OnChanges { } isSignupEnabled () { - return this.form.value['signup']['enabled'] === true + return this.form().value['signup']['enabled'] === true } getDisabledSignupClass () { @@ -120,19 +117,19 @@ export class EditBasicConfigurationComponent implements OnInit, OnChanges { } isImportVideosHttpEnabled (): boolean { - return this.form.value['import']['videos']['http']['enabled'] === true + return this.form().value['import']['videos']['http']['enabled'] === true } importSynchronizationChecked () { - return this.isImportVideosHttpEnabled() && this.form.value['import']['videoChannelSynchronization']['enabled'] + return this.isImportVideosHttpEnabled() && this.form().value['import']['videoChannelSynchronization']['enabled'] } hasUnlimitedSignup () { - return this.form.value['signup']['limit'] === -1 + return this.form().value['signup']['limit'] === -1 } isSearchIndexEnabled () { - return this.form.value['search']['searchIndex']['enabled'] === true + return this.form().value['search']['searchIndex']['enabled'] === true } getDisabledSearchIndexClass () { @@ -142,7 +139,7 @@ export class EditBasicConfigurationComponent implements OnInit, OnChanges { // --------------------------------------------------------------------------- isTranscriptionEnabled () { - return this.form.value['videoTranscription']['enabled'] === true + return this.form().value['videoTranscription']['enabled'] === true } getTranscriptionRunnerDisabledClass () { @@ -152,13 +149,13 @@ export class EditBasicConfigurationComponent implements OnInit, OnChanges { // --------------------------------------------------------------------------- isAutoFollowIndexEnabled () { - return this.form.value['followings']['instance']['autoFollowIndex']['enabled'] === true + return this.form().value['followings']['instance']['autoFollowIndex']['enabled'] === true } buildLandingPageOptions () { let links: { label: string, path: string }[] = [] - if (this.serverConfig.homepage.enabled) { + if (this.serverConfig().homepage.enabled) { links.push({ label: $localize`Home`, path: '/home' }) } @@ -176,11 +173,11 @@ export class EditBasicConfigurationComponent implements OnInit, OnChanges { } private checkImportSyncField () { - const importSyncControl = this.form.get('import.videoChannelSynchronization.enabled') - const importVideosHttpControl = this.form.get('import.videos.http.enabled') + const importSyncControl = this.form().get('import.videoChannelSynchronization.enabled') + const importVideosHttpControl = this.form().get('import.videos.http.enabled') importVideosHttpControl.valueChanges - .subscribe((httpImportEnabled) => { + .subscribe(httpImportEnabled => { importSyncControl.setValue(httpImportEnabled && importSyncControl.value) if (httpImportEnabled) { importSyncControl.enable() @@ -191,16 +188,17 @@ export class EditBasicConfigurationComponent implements OnInit, OnChanges { } private checkSignupField () { - const signupControl = this.form.get('signup.enabled') + const signupControl = this.form().get('signup.enabled') signupControl.valueChanges .pipe(pairwise()) .subscribe(([ oldValue, newValue ]) => { if (oldValue === false && newValue === true) { /* eslint-disable max-len */ - this.signupAlertMessage = $localize`You enabled signup: we automatically enabled the "Block new videos automatically" checkbox of the "Videos" section just below.` + this.signupAlertMessage = + $localize`You enabled signup: we automatically enabled the "Block new videos automatically" checkbox of the "Videos" section just below.` - this.form.patchValue({ + this.form().patchValue({ autoBlacklist: { videos: { ofUsers: { diff --git a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts index 71d2e1930..b28d2e7e0 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts +++ b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts @@ -1,5 +1,5 @@ import { NgFor, NgIf } from '@angular/common' -import { Component, OnInit } from '@angular/core' +import { Component, OnInit, inject } from '@angular/core' import { FormsModule, ReactiveFormsModule } from '@angular/forms' import { ActivatedRoute, Router } from '@angular/router' import { ConfigService } from '@app/+admin/config/shared/config.service' @@ -73,6 +73,15 @@ type ComponentCustomConfig = CustomConfig & { ] }) export class EditCustomConfigComponent extends FormReactive implements OnInit { + protected formReactiveService = inject(FormReactiveService) + private router = inject(Router) + private route = inject(ActivatedRoute) + private notifier = inject(Notifier) + private configService = inject(ConfigService) + private customPage = inject(CustomPageService) + private serverService = inject(ServerService) + private editConfigurationService = inject(EditConfigurationService) + activeNav: string customConfig: ComponentCustomConfig @@ -83,23 +92,10 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { languageItems: SelectOptionsItem[] = [] categoryItems: SelectOptionsItem[] = [] - constructor ( - protected formReactiveService: FormReactiveService, - private router: Router, - private route: ActivatedRoute, - private notifier: Notifier, - private configService: ConfigService, - private customPage: CustomPageService, - private serverService: ServerService, - private editConfigurationService: EditConfigurationService - ) { - super() - } - ngOnInit () { this.serverConfig = this.serverService.getHTMLConfig() - const formGroupData: { [key in keyof ComponentCustomConfig ]: any } = { + const formGroupData: { [key in keyof ComponentCustomConfig]: any } = { instance: { name: INSTANCE_NAME_VALIDATOR, shortDescription: INSTANCE_SHORT_DESCRIPTION_VALIDATOR, @@ -193,7 +189,6 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { videoChannelSynchronization: { enabled: null, maxPerUser: MAX_SYNC_PER_USER - }, users: { enabled: null diff --git a/client/src/app/+admin/config/edit-custom-config/edit-homepage.component.html b/client/src/app/+admin/config/edit-custom-config/edit-homepage.component.html index 7a8fcb3fe..7f694bfef 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-homepage.component.html +++ b/client/src/app/+admin/config/edit-custom-config/edit-homepage.component.html @@ -1,4 +1,4 @@ - + @@ -18,11 +18,11 @@ - + diff --git a/client/src/app/+admin/config/edit-custom-config/edit-homepage.component.ts b/client/src/app/+admin/config/edit-custom-config/edit-homepage.component.ts index fec8ee291..82ec7ff6f 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-homepage.component.ts +++ b/client/src/app/+admin/config/edit-custom-config/edit-homepage.component.ts @@ -1,4 +1,4 @@ -import { Component, Input } from '@angular/core' +import { Component, inject, input } from '@angular/core' import { FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms' import { NgIf } from '@angular/common' import { MarkdownTextareaComponent } from '../../../shared/shared-forms/markdown-textarea.component' @@ -12,15 +12,13 @@ import { CustomMarkupService } from '@app/shared/shared-custom-markup/custom-mar imports: [ FormsModule, ReactiveFormsModule, CustomMarkupHelpComponent, MarkdownTextareaComponent, NgIf ] }) export class EditHomepageComponent { - @Input() form: FormGroup - @Input() formErrors: any + private customMarkup = inject(CustomMarkupService) + + readonly form = input(undefined) + readonly formErrors = input(undefined) customMarkdownRenderer: (text: string) => Promise - constructor (private customMarkup: CustomMarkupService) { - - } - getCustomMarkdownRenderer () { return this.customMarkup.getCustomMarkdownRenderer() } diff --git a/client/src/app/+admin/config/edit-custom-config/edit-instance-information.component.html b/client/src/app/+admin/config/edit-custom-config/edit-instance-information.component.html index 470bee56a..cc4c0f2f2 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-instance-information.component.html +++ b/client/src/app/+admin/config/edit-custom-config/edit-instance-information.component.html @@ -1,4 +1,4 @@ - + @@ -41,10 +41,10 @@ - +
@@ -52,10 +52,10 @@ - +
@@ -67,7 +67,7 @@
@@ -77,7 +77,7 @@
@@ -91,7 +91,7 @@
@@ -105,10 +105,10 @@ - +
@@ -130,7 +130,7 @@ @@ -141,10 +141,10 @@ - +
@@ -152,10 +152,10 @@ - +
@@ -163,10 +163,10 @@ - +
@@ -217,7 +217,7 @@ - +
@@ -225,7 +225,7 @@
@@ -234,7 +234,7 @@ @@ -244,7 +244,7 @@ @@ -264,7 +264,7 @@ @@ -274,7 +274,7 @@ @@ -284,7 +284,7 @@ @@ -294,7 +294,7 @@ @@ -314,7 +314,7 @@ diff --git a/client/src/app/+admin/config/edit-custom-config/edit-instance-information.component.ts b/client/src/app/+admin/config/edit-custom-config/edit-instance-information.component.ts index 366259282..df574077e 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-instance-information.component.ts +++ b/client/src/app/+admin/config/edit-custom-config/edit-instance-information.component.ts @@ -1,6 +1,6 @@ import { NgClass, NgIf } from '@angular/common' import { HttpErrorResponse } from '@angular/common/http' -import { Component, Input, OnInit } from '@angular/core' +import { Component, OnInit, inject, input } from '@angular/core' import { FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms' import { RouterLink } from '@angular/router' import { Notifier, ServerService } from '@app/core' @@ -40,26 +40,22 @@ import { HelpComponent } from '../../../shared/shared-main/buttons/help.componen ] }) export class EditInstanceInformationComponent implements OnInit { - @Input() form: FormGroup - @Input() formErrors: any + private customMarkup = inject(CustomMarkupService) + private notifier = inject(Notifier) + private instanceService = inject(InstanceService) + private server = inject(ServerService) - @Input() languageItems: SelectOptionsItem[] = [] - @Input() categoryItems: SelectOptionsItem[] = [] + readonly form = input(undefined) + readonly formErrors = input(undefined) + + readonly languageItems = input([]) + readonly categoryItems = input([]) instanceBannerUrl: string instanceAvatars: ActorImage[] = [] private serverConfig: HTMLServerConfig - constructor ( - private customMarkup: CustomMarkupService, - private notifier: Notifier, - private instanceService: InstanceService, - private server: ServerService - ) { - - } - get instanceName () { return this.server.getHTMLConfig().instance.name } @@ -139,5 +135,4 @@ export class EditInstanceInformationComponent implements OnInit { this.updateActorImages() }) } - } diff --git a/client/src/app/+admin/config/edit-custom-config/edit-live-configuration.component.html b/client/src/app/+admin/config/edit-custom-config/edit-live-configuration.component.html index a60372dd1..8e5c1a1e1 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-live-configuration.component.html +++ b/client/src/app/+admin/config/edit-custom-config/edit-live-configuration.component.html @@ -1,4 +1,4 @@ - +
@@ -52,10 +52,10 @@
- {form.value['live']['maxInstanceLives'], plural, =1 {live} other {lives}} + {form().value['live']['maxInstanceLives'], plural, =1 {live} other {lives}}
- +
@@ -64,10 +64,10 @@
- {form.value['live']['maxUserLives'], plural, =1 {live} other {lives}} + {form().value['live']['maxUserLives'], plural, =1 {live} other {lives}}
- +
@@ -75,7 +75,7 @@ - +
@@ -123,7 +123,7 @@ FPS
- +
@@ -193,7 +193,7 @@ formControlName="threads" [clearable]="false" > - +
@@ -202,7 +202,7 @@ - +
diff --git a/client/src/app/+admin/config/edit-custom-config/edit-live-configuration.component.ts b/client/src/app/+admin/config/edit-custom-config/edit-live-configuration.component.ts index 93be7a300..fb5820f96 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-live-configuration.component.ts +++ b/client/src/app/+admin/config/edit-custom-config/edit-live-configuration.component.ts @@ -1,5 +1,5 @@ import { SelectOptionsItem } from 'src/types/select-options-item.model' -import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core' +import { Component, OnChanges, OnInit, SimpleChanges, inject, input } from '@angular/core' import { FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms' import { HTMLServerConfig } from '@peertube/peertube-models' import { ConfigService } from '../shared/config.service' @@ -29,9 +29,12 @@ import { PeertubeCheckboxComponent } from '../../../shared/shared-forms/peertube ] }) export class EditLiveConfigurationComponent implements OnInit, OnChanges { - @Input() form: FormGroup - @Input() formErrors: any - @Input() serverConfig: HTMLServerConfig + private configService = inject(ConfigService) + private editConfigurationService = inject(EditConfigurationService) + + readonly form = input(undefined) + readonly formErrors = input(undefined) + readonly serverConfig = input(undefined) transcodingThreadOptions: SelectOptionsItem[] = [] transcodingProfiles: SelectOptionsItem[] = [] @@ -39,11 +42,6 @@ export class EditLiveConfigurationComponent implements OnInit, OnChanges { liveMaxDurationOptions: SelectOptionsItem[] = [] liveResolutions: ResolutionOption[] = [] - constructor ( - private configService: ConfigService, - private editConfigurationService: EditConfigurationService - ) { } - ngOnInit () { this.transcodingThreadOptions = this.configService.transcodingThreadOptions @@ -65,7 +63,7 @@ export class EditLiveConfigurationComponent implements OnInit, OnChanges { } buildAvailableTranscodingProfile () { - const profiles = this.serverConfig.live.transcoding.availableProfiles + const profiles = this.serverConfig().live.transcoding.availableProfiles return profiles.map(p => { if (p === 'default') { @@ -81,15 +79,15 @@ export class EditLiveConfigurationComponent implements OnInit, OnChanges { } getLiveRTMPPort () { - return this.serverConfig.live.rtmp.port + return this.serverConfig().live.rtmp.port } isLiveEnabled () { - return this.editConfigurationService.isLiveEnabled(this.form) + return this.editConfigurationService.isLiveEnabled(this.form()) } isRemoteRunnerLiveEnabled () { - return this.editConfigurationService.isRemoteRunnerLiveEnabled(this.form) + return this.editConfigurationService.isRemoteRunnerLiveEnabled(this.form()) } getDisabledLiveClass () { @@ -105,10 +103,10 @@ export class EditLiveConfigurationComponent implements OnInit, OnChanges { } isLiveTranscodingEnabled () { - return this.editConfigurationService.isLiveTranscodingEnabled(this.form) + return this.editConfigurationService.isLiveTranscodingEnabled(this.form()) } getTotalTranscodingThreads () { - return this.editConfigurationService.getTotalTranscodingThreads(this.form) + return this.editConfigurationService.getTotalTranscodingThreads(this.form()) } } diff --git a/client/src/app/+admin/config/edit-custom-config/edit-vod-transcoding.component.html b/client/src/app/+admin/config/edit-custom-config/edit-vod-transcoding.component.html index 3c804f0cc..4dd5472be 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-vod-transcoding.component.html +++ b/client/src/app/+admin/config/edit-custom-config/edit-vod-transcoding.component.html @@ -1,4 +1,4 @@ - +
@@ -151,7 +151,7 @@ FPS
- +
@@ -220,7 +220,7 @@ [clearable]="false" > - +
@@ -232,7 +232,7 @@ jobs in parallel
- +
@@ -241,7 +241,7 @@ - +
diff --git a/client/src/app/+admin/config/edit-custom-config/edit-vod-transcoding.component.ts b/client/src/app/+admin/config/edit-custom-config/edit-vod-transcoding.component.ts index b75094ffe..7c5640965 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-vod-transcoding.component.ts +++ b/client/src/app/+admin/config/edit-custom-config/edit-vod-transcoding.component.ts @@ -1,5 +1,5 @@ import { NgClass, NgFor, NgIf } from '@angular/common' -import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core' +import { Component, OnChanges, OnInit, SimpleChanges, inject, input } from '@angular/core' import { FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms' import { RouterLink } from '@angular/router' import { Notifier } from '@app/core' @@ -30,9 +30,13 @@ import { EditConfigurationService, ResolutionOption } from './edit-configuration ] }) export class EditVODTranscodingComponent implements OnInit, OnChanges { - @Input() form: FormGroup - @Input() formErrors: any - @Input() serverConfig: HTMLServerConfig + private configService = inject(ConfigService) + private editConfigurationService = inject(EditConfigurationService) + private notifier = inject(Notifier) + + readonly form = input(undefined) + readonly formErrors = input(undefined) + readonly serverConfig = input(undefined) transcodingThreadOptions: SelectOptionsItem[] = [] transcodingProfiles: SelectOptionsItem[] = [] @@ -40,12 +44,6 @@ export class EditVODTranscodingComponent implements OnInit, OnChanges { additionalVideoExtensions = '' - constructor ( - private configService: ConfigService, - private editConfigurationService: EditConfigurationService, - private notifier: Notifier - ) { } - ngOnInit () { this.transcodingThreadOptions = this.configService.transcodingThreadOptions this.resolutions = this.editConfigurationService.getTranscodingResolutions() @@ -57,12 +55,12 @@ export class EditVODTranscodingComponent implements OnInit, OnChanges { if (changes['serverConfig']) { this.transcodingProfiles = this.buildAvailableTranscodingProfile() - this.additionalVideoExtensions = this.serverConfig.video.file.extensions.join(' ') + this.additionalVideoExtensions = this.serverConfig().video.file.extensions.join(' ') } } buildAvailableTranscodingProfile () { - const profiles = this.serverConfig.transcoding.availableProfiles + const profiles = this.serverConfig().transcoding.availableProfiles return profiles.map(p => { if (p === 'default') { @@ -78,19 +76,19 @@ export class EditVODTranscodingComponent implements OnInit, OnChanges { } isRemoteRunnerVODEnabled () { - return this.editConfigurationService.isRemoteRunnerVODEnabled(this.form) + return this.editConfigurationService.isRemoteRunnerVODEnabled(this.form()) } isTranscodingEnabled () { - return this.editConfigurationService.isTranscodingEnabled(this.form) + return this.editConfigurationService.isTranscodingEnabled(this.form()) } isHLSEnabled () { - return this.editConfigurationService.isHLSEnabled(this.form) + return this.editConfigurationService.isHLSEnabled(this.form()) } isStudioEnabled () { - return this.editConfigurationService.isStudioEnabled(this.form) + return this.editConfigurationService.isStudioEnabled(this.form()) } getTranscodingDisabledClass () { @@ -110,14 +108,14 @@ export class EditVODTranscodingComponent implements OnInit, OnChanges { } getTotalTranscodingThreads () { - return this.editConfigurationService.getTotalTranscodingThreads(this.form) + return this.editConfigurationService.getTotalTranscodingThreads(this.form()) } private checkTranscodingFields () { - const transcodingControl = this.form.get('transcoding.enabled') - const videoStudioControl = this.form.get('videoStudio.enabled') - const hlsControl = this.form.get('transcoding.hls.enabled') - const webVideosControl = this.form.get('transcoding.webVideos.enabled') + const transcodingControl = this.form().get('transcoding.enabled') + const videoStudioControl = this.form().get('videoStudio.enabled') + const hlsControl = this.form().get('transcoding.hls.enabled') + const webVideosControl = this.form().get('transcoding.webVideos.enabled') webVideosControl.valueChanges .subscribe(newValue => { @@ -125,7 +123,11 @@ export class EditVODTranscodingComponent implements OnInit, OnChanges { hlsControl.setValue(true) // eslint-disable-next-line max-len - this.notifier.info($localize`Automatically enable HLS transcoding because at least 1 output format must be enabled when transcoding is enabled`, '', 10000) + this.notifier.info( + $localize`Automatically enable HLS transcoding because at least 1 output format must be enabled when transcoding is enabled`, + '', + 10000 + ) } }) @@ -134,8 +136,12 @@ export class EditVODTranscodingComponent implements OnInit, OnChanges { if (newValue === false && webVideosControl.value === false) { webVideosControl.setValue(true) - // eslint-disable-next-line max-len - this.notifier.info($localize`Automatically enable Web Videos transcoding because at least 1 output format must be enabled when transcoding is enabled`, '', 10000) + this.notifier.info( + // eslint-disable-next-line max-len + $localize`Automatically enable Web Videos transcoding because at least 1 output format must be enabled when transcoding is enabled`, + '', + 10000 + ) } }) diff --git a/client/src/app/+admin/config/shared/config.service.ts b/client/src/app/+admin/config/shared/config.service.ts index 3c3894945..2f500664e 100644 --- a/client/src/app/+admin/config/shared/config.service.ts +++ b/client/src/app/+admin/config/shared/config.service.ts @@ -1,6 +1,6 @@ import { catchError } from 'rxjs/operators' import { HttpClient } from '@angular/common/http' -import { Injectable } from '@angular/core' +import { Injectable, inject } from '@angular/core' import { RestExtractor } from '@app/core' import { CustomConfig } from '@peertube/peertube-models' import { SelectOptionsItem } from '../../../../types/select-options-item.model' @@ -8,16 +8,16 @@ import { environment } from '../../../../environments/environment' @Injectable() export class ConfigService { + private authHttp = inject(HttpClient) + private restExtractor = inject(RestExtractor) + private static BASE_APPLICATION_URL = environment.apiUrl + '/api/v1/config' videoQuotaOptions: SelectOptionsItem[] = [] videoQuotaDailyOptions: SelectOptionsItem[] = [] transcodingThreadOptions: SelectOptionsItem[] = [] - constructor ( - private authHttp: HttpClient, - private restExtractor: RestExtractor - ) { + constructor () { this.videoQuotaOptions = [ { id: -1, label: $localize`Unlimited` }, { id: 0, label: $localize`None - no upload possible` }, @@ -60,11 +60,11 @@ export class ConfigService { getCustomConfig () { return this.authHttp.get(ConfigService.BASE_APPLICATION_URL + '/custom') - .pipe(catchError(res => this.restExtractor.handleError(res))) + .pipe(catchError(res => this.restExtractor.handleError(res))) } updateCustomConfig (data: CustomConfig) { return this.authHttp.put(ConfigService.BASE_APPLICATION_URL + '/custom', data) - .pipe(catchError(res => this.restExtractor.handleError(res))) + .pipe(catchError(res => this.restExtractor.handleError(res))) } } diff --git a/client/src/app/+admin/follows/followers-list/followers-list.component.ts b/client/src/app/+admin/follows/followers-list/followers-list.component.ts index 0bd861a23..e2248fc7a 100644 --- a/client/src/app/+admin/follows/followers-list/followers-list.component.ts +++ b/client/src/app/+admin/follows/followers-list/followers-list.component.ts @@ -1,5 +1,5 @@ import { NgIf } from '@angular/common' -import { Component, OnInit } from '@angular/core' +import { Component, OnInit, inject } from '@angular/core' import { ConfirmService, Notifier, RestPagination, RestTable } from '@app/core' import { formatICU } from '@app/helpers' import { InstanceFollowService } from '@app/shared/shared-instance/instance-follow.service' @@ -33,7 +33,11 @@ import { AutoColspanDirective } from '../../../shared/shared-main/common/auto-co PTDatePipe ] }) -export class FollowersListComponent extends RestTable implements OnInit { +export class FollowersListComponent extends RestTable implements OnInit { + private confirmService = inject(ConfirmService) + private notifier = inject(Notifier) + private followService = inject(InstanceFollowService) + followers: ActorFollow[] = [] totalRecords = 0 sort: SortMeta = { field: 'createdAt', order: -1 } @@ -43,14 +47,6 @@ export class FollowersListComponent extends RestTable implements O bulkActions: DropdownAction[] = [] - constructor ( - private confirmService: ConfirmService, - private notifier: Notifier, - private followService: InstanceFollowService - ) { - super() - } - ngOnInit () { this.initialize() @@ -108,20 +104,20 @@ export class FollowersListComponent extends RestTable implements O if (res === false) return this.followService.rejectFollower(follows) - .subscribe({ - next: () => { - // eslint-disable-next-line max-len - const message = formatICU( - $localize`Rejected {count, plural, =1 {{followerName} follow request} other {{count} follow requests}}`, - { count: follows.length, followerName: this.buildFollowerName(follows[0]) } - ) - this.notifier.success(message) + .subscribe({ + next: () => { + // eslint-disable-next-line max-len + const message = formatICU( + $localize`Rejected {count, plural, =1 {{followerName} follow request} other {{count} follow requests}}`, + { count: follows.length, followerName: this.buildFollowerName(follows[0]) } + ) + this.notifier.success(message) - this.reloadData() - }, + this.reloadData() + }, - error: err => this.notifier.error(err.message) - }) + error: err => this.notifier.error(err.message) + }) } async deleteFollowers (follows: ActorFollow[]) { @@ -140,21 +136,21 @@ export class FollowersListComponent extends RestTable implements O if (res === false) return this.followService.removeFollower(follows) - .subscribe({ - next: () => { - // eslint-disable-next-line max-len - const message = formatICU( - $localize`Removed {count, plural, =1 {{followerName} follow request} other {{count} follow requests}}`, - icuParams - ) + .subscribe({ + next: () => { + // eslint-disable-next-line max-len + const message = formatICU( + $localize`Removed {count, plural, =1 {{followerName} follow request} other {{count} follow requests}}`, + icuParams + ) - this.notifier.success(message) + this.notifier.success(message) - this.reloadData() - }, + this.reloadData() + }, - error: err => this.notifier.error(err.message) - }) + error: err => this.notifier.error(err.message) + }) } buildFollowerName (follow: ActorFollow) { @@ -163,13 +159,13 @@ export class FollowersListComponent extends RestTable implements O protected reloadDataInternal () { this.followService.getFollowers({ pagination: this.pagination, sort: this.sort, search: this.search }) - .subscribe({ - next: resultList => { - this.followers = resultList.data - this.totalRecords = resultList.total - }, + .subscribe({ + next: resultList => { + this.followers = resultList.data + this.totalRecords = resultList.total + }, - error: err => this.notifier.error(err.message) - }) + error: err => this.notifier.error(err.message) + }) } } diff --git a/client/src/app/+admin/follows/following-list/follow-modal.component.ts b/client/src/app/+admin/follows/following-list/follow-modal.component.ts index c144e35e4..df8032aaa 100644 --- a/client/src/app/+admin/follows/following-list/follow-modal.component.ts +++ b/client/src/app/+admin/follows/following-list/follow-modal.component.ts @@ -1,5 +1,5 @@ import { NgClass, NgIf } from '@angular/common' -import { Component, EventEmitter, OnInit, Output, ViewChild } from '@angular/core' +import { Component, OnInit, inject, output, viewChild } from '@angular/core' import { FormsModule, ReactiveFormsModule } from '@angular/forms' import { Notifier } from '@app/core' import { formatICU } from '@app/helpers' @@ -20,23 +20,19 @@ import { GlobalIconComponent } from '../../../shared/shared-icons/global-icon.co imports: [ GlobalIconComponent, FormsModule, ReactiveFormsModule, NgClass, NgIf, AlertComponent ] }) export class FollowModalComponent extends FormReactive implements OnInit { - @ViewChild('modal', { static: true }) modal: NgbModal + protected formReactiveService = inject(FormReactiveService) + private modalService = inject(NgbModal) + private followService = inject(InstanceFollowService) + private notifier = inject(Notifier) - @Output() newFollow = new EventEmitter() + readonly modal = viewChild('modal') + + readonly newFollow = output() placeholder = 'example.com\nchocobozzz@example.com\nchocobozzz_channel@example.com' private openedModal: NgbModalRef - constructor ( - protected formReactiveService: FormReactiveService, - private modalService: NgbModal, - private followService: InstanceFollowService, - private notifier: Notifier - ) { - super() - } - ngOnInit () { this.buildForm({ hostsOrHandles: UNIQUE_HOSTS_OR_HANDLE_VALIDATOR @@ -44,7 +40,7 @@ export class FollowModalComponent extends FormReactive implements OnInit { } openModal () { - this.openedModal = this.modalService.open(this.modal, { centered: true }) + this.openedModal = this.modalService.open(this.modal(), { centered: true }) } hide () { diff --git a/client/src/app/+admin/follows/following-list/following-list.component.ts b/client/src/app/+admin/follows/following-list/following-list.component.ts index e3ea405ec..e80488143 100644 --- a/client/src/app/+admin/follows/following-list/following-list.component.ts +++ b/client/src/app/+admin/follows/following-list/following-list.component.ts @@ -1,5 +1,5 @@ import { NgIf } from '@angular/common' -import { Component, OnInit, ViewChild } from '@angular/core' +import { Component, OnInit, inject, viewChild } from '@angular/core' import { ConfirmService, Notifier, RestPagination, RestTable } from '@app/core' import { formatICU } from '@app/helpers' import { InstanceFollowService } from '@app/shared/shared-instance/instance-follow.service' @@ -34,8 +34,12 @@ import { FollowModalComponent } from './follow-modal.component' ButtonComponent ] }) -export class FollowingListComponent extends RestTable implements OnInit { - @ViewChild('followModal') followModal: FollowModalComponent +export class FollowingListComponent extends RestTable implements OnInit { + private notifier = inject(Notifier) + private confirmService = inject(ConfirmService) + private followService = inject(InstanceFollowService) + + readonly followModal = viewChild('followModal') following: ActorFollow[] = [] totalRecords = 0 @@ -46,14 +50,6 @@ export class FollowingListComponent extends RestTable implements O bulkActions: DropdownAction[] = [] - constructor ( - private notifier: Notifier, - private confirmService: ConfirmService, - private followService: InstanceFollowService - ) { - super() - } - ngOnInit () { this.initialize() @@ -72,7 +68,7 @@ export class FollowingListComponent extends RestTable implements O } openFollowModal () { - this.followModal.openModal() + this.followModal().openModal() } isInstanceFollowing (follow: ActorFollow) { @@ -113,13 +109,13 @@ export class FollowingListComponent extends RestTable implements O protected reloadDataInternal () { this.followService.getFollowing({ pagination: this.pagination, sort: this.sort, search: this.search }) - .subscribe({ - next: resultList => { - this.following = resultList.data - this.totalRecords = resultList.total - }, + .subscribe({ + next: resultList => { + this.following = resultList.data + this.totalRecords = resultList.total + }, - error: err => this.notifier.error(err.message) - }) + error: err => this.notifier.error(err.message) + }) } } diff --git a/client/src/app/+admin/follows/shared/redundancy-checkbox.component.html b/client/src/app/+admin/follows/shared/redundancy-checkbox.component.html index 8a57d65f0..e4a466c8e 100644 --- a/client/src/app/+admin/follows/shared/redundancy-checkbox.component.html +++ b/client/src/app/+admin/follows/shared/redundancy-checkbox.component.html @@ -1,3 +1,3 @@ \ No newline at end of file + [inputName]="host() + '-redundancy-allowed'" [(ngModel)]="redundancyAllowed" (ngModelChange)="updateRedundancyState()" +> diff --git a/client/src/app/+admin/follows/shared/redundancy-checkbox.component.ts b/client/src/app/+admin/follows/shared/redundancy-checkbox.component.ts index 6f32ea0ea..39af37658 100644 --- a/client/src/app/+admin/follows/shared/redundancy-checkbox.component.ts +++ b/client/src/app/+admin/follows/shared/redundancy-checkbox.component.ts @@ -1,4 +1,4 @@ -import { Component, Input } from '@angular/core' +import { Component, inject, input } from '@angular/core' import { Notifier } from '@app/core' import { FormsModule } from '@angular/forms' import { PeertubeCheckboxComponent } from '../../../shared/shared-forms/peertube-checkbox.component' @@ -10,24 +10,22 @@ import { RedundancyService } from '@app/shared/shared-main/video/redundancy.serv imports: [ PeertubeCheckboxComponent, FormsModule ] }) export class RedundancyCheckboxComponent { - @Input() redundancyAllowed: boolean - @Input() host: string + private notifier = inject(Notifier) + private redundancyService = inject(RedundancyService) - constructor ( - private notifier: Notifier, - private redundancyService: RedundancyService - ) { } + readonly redundancyAllowed = input(undefined) + readonly host = input(undefined) updateRedundancyState () { - this.redundancyService.updateRedundancy(this.host, this.redundancyAllowed) - .subscribe({ - next: () => { - const stateLabel = this.redundancyAllowed ? $localize`enabled` : $localize`disabled` + this.redundancyService.updateRedundancy(this.host(), this.redundancyAllowed()) + .subscribe({ + next: () => { + const stateLabel = this.redundancyAllowed() ? $localize`enabled` : $localize`disabled` - this.notifier.success($localize`Redundancy for ${this.host} is ${stateLabel}`) - }, + this.notifier.success($localize`Redundancy for ${this.host()} is ${stateLabel}`) + }, - error: err => this.notifier.error(err.message) - }) + error: err => this.notifier.error(err.message) + }) } } diff --git a/client/src/app/+admin/follows/video-redundancies-list/video-redundancies-list.component.ts b/client/src/app/+admin/follows/video-redundancies-list/video-redundancies-list.component.ts index b5347db95..33daeea0b 100644 --- a/client/src/app/+admin/follows/video-redundancies-list/video-redundancies-list.component.ts +++ b/client/src/app/+admin/follows/video-redundancies-list/video-redundancies-list.component.ts @@ -1,5 +1,5 @@ import { NgFor, NgIf } from '@angular/common' -import { Component, OnInit } from '@angular/core' +import { Component, OnInit, inject } from '@angular/core' import { FormsModule } from '@angular/forms' import { ConfirmService, Notifier, RestPagination, RestTable, ServerService } from '@app/core' import { BytesPipe } from '@app/shared/shared-main/common/bytes.pipe' @@ -38,6 +38,11 @@ import { VideoRedundancyInformationComponent } from './video-redundancy-informat ] }) export class VideoRedundanciesListComponent extends RestTable implements OnInit { + private notifier = inject(Notifier) + private confirmService = inject(ConfirmService) + private redundancyService = inject(RedundancyService) + private serverService = inject(ServerService) + private static LS_DISPLAY_TYPE = 'video-redundancies-list-display-type' videoRedundancies: VideoRedundancy[] = [] @@ -56,12 +61,7 @@ export class VideoRedundanciesListComponent extends RestTable implements OnInit private bytesPipe: BytesPipe - constructor ( - private notifier: Notifier, - private confirmService: ConfirmService, - private redundancyService: RedundancyService, - private serverService: ServerService - ) { + constructor () { super() this.bytesPipe = new BytesPipe() @@ -77,15 +77,15 @@ export class VideoRedundanciesListComponent extends RestTable implements OnInit this.initialize() this.serverService.getServerStats() - .subscribe(res => { - const redundancies = res.videosRedundancy + .subscribe(res => { + const redundancies = res.videosRedundancy - if (redundancies.length === 0) this.noRedundancies = true + if (redundancies.length === 0) this.noRedundancies = true - for (const r of redundancies) { - this.buildPieData(r) - } - }) + for (const r of redundancies) { + this.buildPieData(r) + } + }) } isDisplayingRemoteVideos () { @@ -184,7 +184,6 @@ export class VideoRedundanciesListComponent extends RestTable implements OnInit error: err => this.notifier.error(err.message) }) - } protected reloadDataInternal () { @@ -197,16 +196,16 @@ export class VideoRedundanciesListComponent extends RestTable implements OnInit } this.redundancyService.listVideoRedundancies(options) - .subscribe({ - next: resultList => { - this.videoRedundancies = resultList.data - this.totalRecords = resultList.total + .subscribe({ + next: resultList => { + this.videoRedundancies = resultList.data + this.totalRecords = resultList.total - this.dataLoaded = true - }, + this.dataLoaded = true + }, - error: err => this.notifier.error(err.message) - }) + error: err => this.notifier.error(err.message) + }) } private loadSelectLocalStorage () { diff --git a/client/src/app/+admin/follows/video-redundancies-list/video-redundancy-information.component.html b/client/src/app/+admin/follows/video-redundancies-list/video-redundancy-information.component.html index 4976cf38c..2b94ae2e0 100644 --- a/client/src/app/+admin/follows/video-redundancies-list/video-redundancy-information.component.html +++ b/client/src/app/+admin/follows/video-redundancies-list/video-redundancy-information.component.html @@ -1,19 +1,19 @@
Created on - {{ redundancyElement.createdAt | ptDate: 'medium' }} + {{ redundancyElement().createdAt | ptDate: 'medium' }}
Expires on - {{ redundancyElement.expiresOn | ptDate: 'medium' }} + {{ redundancyElement().expiresOn | ptDate: 'medium' }}
Size - {{ redundancyElement.size | bytes: 1 }} + {{ redundancyElement().size | bytes: 1 }}
diff --git a/client/src/app/+admin/follows/video-redundancies-list/video-redundancy-information.component.ts b/client/src/app/+admin/follows/video-redundancies-list/video-redundancy-information.component.ts index d185523cb..7fce055b0 100644 --- a/client/src/app/+admin/follows/video-redundancies-list/video-redundancy-information.component.ts +++ b/client/src/app/+admin/follows/video-redundancies-list/video-redundancy-information.component.ts @@ -1,4 +1,4 @@ -import { Component, Input } from '@angular/core' +import { Component, input } from '@angular/core' import { PTDatePipe } from '@app/shared/shared-main/common/date.pipe' import { RedundancyInformation } from '@peertube/peertube-models' import { BytesPipe } from '../../../shared/shared-main/common/bytes.pipe' @@ -10,5 +10,5 @@ import { BytesPipe } from '../../../shared/shared-main/common/bytes.pipe' imports: [ PTDatePipe, BytesPipe ] }) export class VideoRedundancyInformationComponent { - @Input() redundancyElement: RedundancyInformation + readonly redundancyElement = input(undefined) } diff --git a/client/src/app/+admin/moderation/abuse-list/abuse-list.component.ts b/client/src/app/+admin/moderation/abuse-list/abuse-list.component.ts index afb1a4427..ddcc69534 100644 --- a/client/src/app/+admin/moderation/abuse-list/abuse-list.component.ts +++ b/client/src/app/+admin/moderation/abuse-list/abuse-list.component.ts @@ -1,13 +1,11 @@ import { Component } from '@angular/core' import { AbuseListTableComponent } from '../../../shared/shared-abuse-list/abuse-list-table.component' -import { GlobalIconComponent } from '../../../shared/shared-icons/global-icon.component' @Component({ selector: 'my-abuse-list', templateUrl: './abuse-list.component.html', styleUrls: [], - imports: [ GlobalIconComponent, AbuseListTableComponent ] + imports: [ AbuseListTableComponent ] }) export class AbuseListComponent { - } diff --git a/client/src/app/+admin/moderation/registration-list/admin-registration.service.ts b/client/src/app/+admin/moderation/registration-list/admin-registration.service.ts index f8ab04c71..b43bd5383 100644 --- a/client/src/app/+admin/moderation/registration-list/admin-registration.service.ts +++ b/client/src/app/+admin/moderation/registration-list/admin-registration.service.ts @@ -2,7 +2,7 @@ import { SortMeta } from 'primeng/api' import { from } from 'rxjs' import { catchError, concatMap, toArray } from 'rxjs/operators' import { HttpClient, HttpParams } from '@angular/common/http' -import { Injectable } from '@angular/core' +import { Injectable, inject } from '@angular/core' import { RestExtractor, RestPagination, RestService } from '@app/core' import { arrayify } from '@peertube/peertube-core-utils' import { ResultList, UserRegistration, UserRegistrationUpdateState } from '@peertube/peertube-models' @@ -10,13 +10,11 @@ import { environment } from '../../../../environments/environment' @Injectable() export class AdminRegistrationService { - private static BASE_REGISTRATION_URL = environment.apiUrl + '/api/v1/users/registrations' + private authHttp = inject(HttpClient) + private restExtractor = inject(RestExtractor) + private restService = inject(RestService) - constructor ( - private authHttp: HttpClient, - private restExtractor: RestExtractor, - private restService: RestService - ) { } + private static BASE_REGISTRATION_URL = environment.apiUrl + '/api/v1/users/registrations' listRegistrations (options: { pagination: RestPagination diff --git a/client/src/app/+admin/moderation/registration-list/process-registration-modal.component.ts b/client/src/app/+admin/moderation/registration-list/process-registration-modal.component.ts index 8b811b2ec..d94e4d527 100644 --- a/client/src/app/+admin/moderation/registration-list/process-registration-modal.component.ts +++ b/client/src/app/+admin/moderation/registration-list/process-registration-modal.component.ts @@ -1,5 +1,5 @@ import { NgClass, NgIf } from '@angular/common' -import { Component, EventEmitter, OnInit, Output, ViewChild } from '@angular/core' +import { Component, OnInit, inject, output, viewChild } from '@angular/core' import { FormsModule, ReactiveFormsModule } from '@angular/forms' import { Notifier, ServerService } from '@app/core' import { FormReactive } from '@app/shared/shared-forms/form-reactive' @@ -19,25 +19,21 @@ import { REGISTRATION_MODERATION_RESPONSE_VALIDATOR } from './process-registrati imports: [ NgIf, GlobalIconComponent, FormsModule, ReactiveFormsModule, NgClass, PeertubeCheckboxComponent, AlertComponent ] }) export class ProcessRegistrationModalComponent extends FormReactive implements OnInit { - @ViewChild('modal', { static: true }) modal: NgbModal + protected formReactiveService = inject(FormReactiveService) + private server = inject(ServerService) + private modalService = inject(NgbModal) + private notifier = inject(Notifier) + private registrationService = inject(AdminRegistrationService) - @Output() registrationProcessed = new EventEmitter() + readonly modal = viewChild('modal') + + readonly registrationProcessed = output() registration: UserRegistration private openedModal: NgbModalRef private processMode: 'accept' | 'reject' - constructor ( - protected formReactiveService: FormReactiveService, - private server: ServerService, - private modalService: NgbModal, - private notifier: Notifier, - private registrationService: AdminRegistrationService - ) { - super() - } - ngOnInit () { this.buildForm({ moderationResponse: REGISTRATION_MODERATION_RESPONSE_VALIDATOR, @@ -61,7 +57,7 @@ export class ProcessRegistrationModalComponent extends FormReactive implements O preventEmailDelivery: !this.isEmailEnabled() || registration.emailVerified !== true }) - this.openedModal = this.modalService.open(this.modal, { centered: true }) + this.openedModal = this.modalService.open(this.modal(), { centered: true }) } hide () { diff --git a/client/src/app/+admin/moderation/registration-list/registration-list.component.ts b/client/src/app/+admin/moderation/registration-list/registration-list.component.ts index 1d579e6db..8da1f5998 100644 --- a/client/src/app/+admin/moderation/registration-list/registration-list.component.ts +++ b/client/src/app/+admin/moderation/registration-list/registration-list.component.ts @@ -1,5 +1,5 @@ import { NgClass, NgIf } from '@angular/common' -import { Component, OnInit, ViewChild } from '@angular/core' +import { Component, OnInit, inject, viewChild } from '@angular/core' import { ActivatedRoute, Router } from '@angular/router' import { ConfirmService, MarkdownService, Notifier, RestPagination, RestTable, ServerService } from '@app/core' import { formatICU } from '@app/helpers' @@ -37,8 +37,16 @@ import { ProcessRegistrationModalComponent } from './process-registration-modal. PTDatePipe ] }) -export class RegistrationListComponent extends RestTable implements OnInit { - @ViewChild('processRegistrationModal', { static: true }) processRegistrationModal: ProcessRegistrationModalComponent +export class RegistrationListComponent extends RestTable implements OnInit { + protected route = inject(ActivatedRoute) + protected router = inject(Router) + private server = inject(ServerService) + private notifier = inject(Notifier) + private markdownRenderer = inject(MarkdownService) + private confirmService = inject(ConfirmService) + private adminRegistrationService = inject(AdminRegistrationService) + + readonly processRegistrationModal = viewChild('processRegistrationModal') registrations: (UserRegistration & { registrationReasonHTML?: string, moderationResponseHTML?: string })[] = [] totalRecords = 0 @@ -52,15 +60,7 @@ export class RegistrationListComponent extends RestTable impl requiresEmailVerification: boolean - constructor ( - protected route: ActivatedRoute, - protected router: Router, - private server: ServerService, - private notifier: Notifier, - private markdownRenderer: MarkdownService, - private confirmService: ConfirmService, - private adminRegistrationService: AdminRegistrationService - ) { + constructor () { super() this.registrationActions = [ @@ -137,7 +137,7 @@ export class RegistrationListComponent extends RestTable impl } private openRegistrationRequestProcessModal (registration: UserRegistration, mode: 'accept' | 'reject') { - this.processRegistrationModal.openModal(registration, mode) + this.processRegistrationModal().openModal(registration, mode) } private async removeRegistrations (registrations: UserRegistration[]) { diff --git a/client/src/app/+admin/moderation/video-block-list/video-block-list.component.ts b/client/src/app/+admin/moderation/video-block-list/video-block-list.component.ts index 0e18972b8..b9300a45d 100644 --- a/client/src/app/+admin/moderation/video-block-list/video-block-list.component.ts +++ b/client/src/app/+admin/moderation/video-block-list/video-block-list.component.ts @@ -1,5 +1,5 @@ import { NgClass, NgIf } from '@angular/common' -import { Component, OnInit } from '@angular/core' +import { Component, OnInit, inject } from '@angular/core' import { ActivatedRoute, Router } from '@angular/router' import { ConfirmService, MarkdownService, Notifier, RestPagination, RestTable, ServerService } from '@app/core' import { PTDatePipe } from '@app/shared/shared-main/common/date.pipe' @@ -42,6 +42,15 @@ import { VideoCellComponent } from '../../../shared/shared-tables/video-cell.com ] }) export class VideoBlockListComponent extends RestTable implements OnInit { + protected route = inject(ActivatedRoute) + protected router = inject(Router) + private notifier = inject(Notifier) + private serverService = inject(ServerService) + private confirmService = inject(ConfirmService) + private videoBlocklistService = inject(VideoBlockService) + private markdownRenderer = inject(MarkdownService) + private videoService = inject(VideoService) + blocklist: (VideoBlacklist & { reasonHtml?: string })[] = [] totalRecords = 0 sort: SortMeta = { field: 'createdAt', order: -1 } @@ -66,16 +75,7 @@ export class VideoBlockListComponent extends RestTable implements OnInit { } ] - constructor ( - protected route: ActivatedRoute, - protected router: Router, - private notifier: Notifier, - private serverService: ServerService, - private confirmService: ConfirmService, - private videoBlocklistService: VideoBlockService, - private markdownRenderer: MarkdownService, - private videoService: VideoService - ) { + constructor () { super() this.videoBlocklistActions = [ diff --git a/client/src/app/+admin/moderation/watched-words-list/watched-words-list-admin.component.ts b/client/src/app/+admin/moderation/watched-words-list/watched-words-list-admin.component.ts index a0696b408..7d1ccb1d4 100644 --- a/client/src/app/+admin/moderation/watched-words-list/watched-words-list-admin.component.ts +++ b/client/src/app/+admin/moderation/watched-words-list/watched-words-list-admin.component.ts @@ -1,12 +1,11 @@ import { Component } from '@angular/core' -import { GlobalIconComponent } from '@app/shared/shared-icons/global-icon.component' + import { WatchedWordsListAdminOwnerComponent } from '@app/shared/standalone-watched-words/watched-words-list-admin-owner.component' @Component({ templateUrl: './watched-words-list-admin.component.html', imports: [ - GlobalIconComponent, WatchedWordsListAdminOwnerComponent ] }) -export class WatchedWordsListAdminComponent { } +export class WatchedWordsListAdminComponent {} diff --git a/client/src/app/+admin/overview/comments/video-comment-list.component.ts b/client/src/app/+admin/overview/comments/video-comment-list.component.ts index 415428ea1..001db1393 100644 --- a/client/src/app/+admin/overview/comments/video-comment-list.component.ts +++ b/client/src/app/+admin/overview/comments/video-comment-list.component.ts @@ -1,16 +1,13 @@ import { Component } from '@angular/core' import { VideoCommentService } from '@app/shared/shared-video-comment/video-comment.service' import { FeedFormat } from '@peertube/peertube-models' -import { GlobalIconComponent } from '../../../shared/shared-icons/global-icon.component' -import { FeedComponent } from '../../../shared/shared-main/feeds/feed.component' + import { VideoCommentListAdminOwnerComponent } from '../../../shared/shared-video-comment/video-comment-list-admin-owner.component' @Component({ selector: 'my-video-comment-list', templateUrl: './video-comment-list.component.html', imports: [ - GlobalIconComponent, - FeedComponent, VideoCommentListAdminOwnerComponent ] }) diff --git a/client/src/app/+admin/overview/users/user-edit/user-create.component.ts b/client/src/app/+admin/overview/users/user-edit/user-create.component.ts index f62f62eba..af0d364c7 100644 --- a/client/src/app/+admin/overview/users/user-edit/user-create.component.ts +++ b/client/src/app/+admin/overview/users/user-edit/user-create.component.ts @@ -1,5 +1,5 @@ import { NgClass, NgFor, NgIf, NgTemplateOutlet } from '@angular/common' -import { Component, OnInit } from '@angular/core' +import { Component, OnInit, inject } from '@angular/core' import { FormsModule, ReactiveFormsModule } from '@angular/forms' import { Router, RouterLink } from '@angular/router' import { ConfigService } from '@app/+admin/config/shared/config.service' @@ -54,18 +54,18 @@ import { UserPasswordComponent } from './user-password.component' ] }) export class UserCreateComponent extends UserEdit implements OnInit { + protected serverService = inject(ServerService) + protected formReactiveService = inject(FormReactiveService) + protected configService = inject(ConfigService) + protected screenService = inject(ScreenService) + protected auth = inject(AuthService) + private router = inject(Router) + private notifier = inject(Notifier) + private userAdminService = inject(UserAdminService) + error: string - constructor ( - protected serverService: ServerService, - protected formReactiveService: FormReactiveService, - protected configService: ConfigService, - protected screenService: ScreenService, - protected auth: AuthService, - private router: Router, - private notifier: Notifier, - private userAdminService: UserAdminService - ) { + constructor () { super() this.buildQuotaOptions() diff --git a/client/src/app/+admin/overview/users/user-edit/user-password.component.ts b/client/src/app/+admin/overview/users/user-edit/user-password.component.ts index f0b09e964..92329211c 100644 --- a/client/src/app/+admin/overview/users/user-edit/user-password.component.ts +++ b/client/src/app/+admin/overview/users/user-edit/user-password.component.ts @@ -1,4 +1,4 @@ -import { Component, Input, OnInit } from '@angular/core' +import { Component, OnInit, inject, input } from '@angular/core' import { Notifier } from '@app/core' import { USER_PASSWORD_VALIDATOR } from '@app/shared/form-validators/user-validators' import { FormReactive } from '@app/shared/shared-forms/form-reactive' @@ -15,20 +15,16 @@ import { UserAdminService } from '@app/shared/shared-users/user-admin.service' imports: [ FormsModule, ReactiveFormsModule, NgClass, NgIf ] }) export class UserPasswordComponent extends FormReactive implements OnInit { - @Input() userId: number - @Input() username: string + protected formReactiveService = inject(FormReactiveService) + private notifier = inject(Notifier) + private userAdminService = inject(UserAdminService) + + readonly userId = input(undefined) + readonly username = input(undefined) error: string showPassword = false - constructor ( - protected formReactiveService: FormReactiveService, - private notifier: Notifier, - private userAdminService: UserAdminService - ) { - super() - } - ngOnInit () { this.buildForm({ password: USER_PASSWORD_VALIDATOR @@ -40,9 +36,9 @@ export class UserPasswordComponent extends FormReactive implements OnInit { const userUpdate: UserUpdate = this.form.value - this.userAdminService.updateUser(this.userId, userUpdate) + this.userAdminService.updateUser(this.userId(), userUpdate) .subscribe({ - next: () => this.notifier.success($localize`Password changed for user ${this.username}.`), + next: () => this.notifier.success($localize`Password changed for user ${this.username()}.`), error: err => { this.error = err.message diff --git a/client/src/app/+admin/overview/users/user-edit/user-update.component.ts b/client/src/app/+admin/overview/users/user-edit/user-update.component.ts index edf2b4404..f77848b79 100644 --- a/client/src/app/+admin/overview/users/user-edit/user-update.component.ts +++ b/client/src/app/+admin/overview/users/user-edit/user-update.component.ts @@ -1,5 +1,5 @@ import { NgClass, NgFor, NgIf, NgTemplateOutlet } from '@angular/common' -import { Component, OnDestroy, OnInit } from '@angular/core' +import { Component, OnDestroy, OnInit, inject } from '@angular/core' import { FormsModule, ReactiveFormsModule } from '@angular/forms' import { ActivatedRoute, Router, RouterLink } from '@angular/router' import { ConfigService } from '@app/+admin/config/shared/config.service' @@ -52,23 +52,23 @@ import { UserPasswordComponent } from './user-password.component' ] }) export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy { + protected formReactiveService = inject(FormReactiveService) + protected serverService = inject(ServerService) + protected configService = inject(ConfigService) + protected screenService = inject(ScreenService) + protected auth = inject(AuthService) + private route = inject(ActivatedRoute) + private router = inject(Router) + private notifier = inject(Notifier) + private userService = inject(UserService) + private twoFactorService = inject(TwoFactorService) + private userAdminService = inject(UserAdminService) + error: string private paramsSub: Subscription - constructor ( - protected formReactiveService: FormReactiveService, - protected serverService: ServerService, - protected configService: ConfigService, - protected screenService: ScreenService, - protected auth: AuthService, - private route: ActivatedRoute, - private router: Router, - private notifier: Notifier, - private userService: UserService, - private twoFactorService: TwoFactorService, - private userAdminService: UserAdminService - ) { + constructor () { super() this.buildQuotaOptions() @@ -168,7 +168,6 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy { error: err => this.notifier.error(err.message) }) - } private onUserFetched (userJson: UserType) { diff --git a/client/src/app/+admin/overview/users/user-list/user-list.component.ts b/client/src/app/+admin/overview/users/user-list/user-list.component.ts index 3bb5f20ab..9c7351492 100644 --- a/client/src/app/+admin/overview/users/user-list/user-list.component.ts +++ b/client/src/app/+admin/overview/users/user-list/user-list.component.ts @@ -1,5 +1,5 @@ import { NgClass, NgIf } from '@angular/common' -import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core' +import { Component, OnDestroy, OnInit, inject, viewChild } from '@angular/core' import { FormsModule } from '@angular/forms' import { ActivatedRoute, Router, RouterLink } from '@angular/router' import { @@ -79,10 +79,21 @@ type UserForList = User & { ProgressBarComponent ] }) -export class UserListComponent extends RestTable implements OnInit, OnDestroy { +export class UserListComponent extends RestTable implements OnInit, OnDestroy { + protected route = inject(ActivatedRoute) + protected router = inject(Router) + private notifier = inject(Notifier) + private confirmService = inject(ConfirmService) + private auth = inject(AuthService) + private blocklist = inject(BlocklistService) + private userAdminService = inject(UserAdminService) + private peertubeLocalStorage = inject(LocalStorageService) + private hooks = inject(HooksService) + private pluginService = inject(PluginService) + private static readonly LS_SELECTED_COLUMNS_KEY = 'admin-user-list-selected-columns' - @ViewChild('userBanModal', { static: true }) userBanModal: UserBanModalComponent + readonly userBanModal = viewChild('userBanModal') users: (User & { accountMutedStatus: AccountMutedStatus })[] = [] @@ -115,21 +126,6 @@ export class UserListComponent extends RestTable implements OnInit, OnDes private _selectedColumns: string[] = [] - constructor ( - protected route: ActivatedRoute, - protected router: Router, - private notifier: Notifier, - private confirmService: ConfirmService, - private auth: AuthService, - private blocklist: BlocklistService, - private userAdminService: UserAdminService, - private peertubeLocalStorage: LocalStorageService, - private hooks: HooksService, - private pluginService: PluginService - ) { - super() - } - get authUser () { return this.auth.getUser() } @@ -262,7 +258,7 @@ export class UserListComponent extends RestTable implements OnInit, OnDes } } - this.userBanModal.openModal(users) + this.userBanModal().openModal(users) } onUserChanged () { @@ -281,19 +277,19 @@ export class UserListComponent extends RestTable implements OnInit, OnDes if (res === false) return this.userAdminService.unbanUsers(users) - .subscribe({ - next: () => { - this.notifier.success( - formatICU( - $localize`{count, plural, =1 {1 user unbanned.} other {{count} users unbanned.}}`, - { count: users.length } - ) + .subscribe({ + next: () => { + this.notifier.success( + formatICU( + $localize`{count, plural, =1 {1 user unbanned.} other {{count} users unbanned.}}`, + { count: users.length } ) - this.reloadData() - }, + ) + this.reloadData() + }, - error: err => this.notifier.error(err.message) - }) + error: err => this.notifier.error(err.message) + }) } async removeUsers (users: User[]) { diff --git a/client/src/app/+admin/overview/videos/video-admin.service.ts b/client/src/app/+admin/overview/videos/video-admin.service.ts index 166b1fe04..63aae2caf 100644 --- a/client/src/app/+admin/overview/videos/video-admin.service.ts +++ b/client/src/app/+admin/overview/videos/video-admin.service.ts @@ -1,5 +1,5 @@ import { HttpClient, HttpParams } from '@angular/common/http' -import { Injectable } from '@angular/core' +import { Injectable, inject } from '@angular/core' import { RestExtractor, RestPagination, RestService } from '@app/core' import { AdvancedInputFilter } from '@app/shared/shared-forms/advanced-input-filter.component' import { Video } from '@app/shared/shared-main/video/video.model' @@ -11,13 +11,10 @@ import { catchError, switchMap } from 'rxjs/operators' @Injectable() export class VideoAdminService { - - constructor ( - private videoService: VideoService, - private authHttp: HttpClient, - private restExtractor: RestExtractor, - private restService: RestService - ) {} + private videoService = inject(VideoService) + private authHttp = inject(HttpClient) + private restExtractor = inject(RestExtractor) + private restService = inject(RestService) getAdminVideos ( options: CommonVideoParams & { pagination: RestPagination, search?: string } @@ -28,16 +25,16 @@ export class VideoAdminService { params = this.videoService.buildCommonVideosParams({ params, ...omit(options, [ 'search', 'pagination' ]) }) params = params.set('start', pagination.start.toString()) - .set('count', pagination.count.toString()) + .set('count', pagination.count.toString()) params = this.buildAdminParamsFromSearch(search, params) return this.authHttp - .get>(VideoService.BASE_VIDEO_URL, { params }) - .pipe( - switchMap(res => this.videoService.extractVideos(res)), - catchError(err => this.restExtractor.handleError(err)) - ) + .get>(VideoService.BASE_VIDEO_URL, { params }) + .pipe( + switchMap(res => this.videoService.extractVideos(res)), + catchError(err => this.restExtractor.handleError(err)) + ) } buildAdminInputFilter (): AdvancedInputFilter[] { diff --git a/client/src/app/+admin/overview/videos/video-list.component.ts b/client/src/app/+admin/overview/videos/video-list.component.ts index 1ab24baab..347015fec 100644 --- a/client/src/app/+admin/overview/videos/video-list.component.ts +++ b/client/src/app/+admin/overview/videos/video-list.component.ts @@ -1,5 +1,5 @@ import { NgClass, NgFor, NgIf } from '@angular/common' -import { Component, OnInit, ViewChild } from '@angular/core' +import { Component, OnInit, inject, viewChild } from '@angular/core' import { ActivatedRoute, Router, RouterLink } from '@angular/router' import { AuthService, ConfirmService, Notifier, RestPagination, RestTable, ServerService } from '@app/core' import { formatICU } from '@app/helpers' @@ -59,8 +59,20 @@ import { VideoAdminService } from './video-admin.service' BytesPipe ] }) -export class VideoListComponent extends RestTable