X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2F%2Bvideos%2F%2Bvideo-edit%2Fvideo-add-components%2Fvideo-send.ts;h=ce8de049d85d0b5a51c755ee36c76b3da758434c;hb=a3f45a2ab3cadf0946f06a0539993b828becd516;hp=2e658dfaecb6fdd76fdaf877f58c245d35300c63;hpb=a02b93ce756d646a59cef57b5e4ff53c2bb30bec;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-send.ts b/client/src/app/+videos/+video-edit/video-add-components/video-send.ts index 2e658dfae..ce8de049d 100644 --- a/client/src/app/+videos/+video-edit/video-add-components/video-send.ts +++ b/client/src/app/+videos/+video-edit/video-add-components/video-send.ts @@ -1,52 +1,60 @@ import { catchError, switchMap, tap } from 'rxjs/operators' +import { SelectChannelItem } from 'src/types/select-options-item.model' import { Directive, EventEmitter, OnInit } from '@angular/core' import { AuthService, CanComponentDeactivateResult, Notifier, ServerService } from '@app/core' -import { populateAsyncUserVideoChannels } from '@app/helpers' +import { listUserChannels } from '@app/helpers' import { FormReactive } from '@app/shared/shared-forms' import { VideoCaptionEdit, VideoCaptionService, VideoEdit, VideoService } from '@app/shared/shared-main' import { LoadingBarService } from '@ngx-loading-bar/core' -import { ServerConfig, VideoConstant, VideoPrivacy } from '@shared/models' +import { HTMLServerConfig, VideoConstant, VideoPrivacy } from '@shared/models' @Directive() // tslint:disable-next-line: directive-class-suffix export abstract class VideoSend extends FormReactive implements OnInit { - userVideoChannels: { id: number, label: string, support: string }[] = [] + userVideoChannels: SelectChannelItem[] = [] videoPrivacies: VideoConstant[] = [] videoCaptions: VideoCaptionEdit[] = [] - firstStepPrivacyId = 0 - firstStepChannelId = 0 + firstStepPrivacyId: VideoPrivacy + firstStepChannelId: number abstract firstStepDone: EventEmitter abstract firstStepError: EventEmitter - protected abstract readonly DEFAULT_VIDEO_PRIVACY: VideoPrivacy protected loadingBar: LoadingBarService protected notifier: Notifier protected authService: AuthService + protected serverService: ServerService protected videoService: VideoService protected videoCaptionService: VideoCaptionService - protected serverConfig: ServerConfig + + protected serverConfig: HTMLServerConfig + + protected highestPrivacy: VideoPrivacy abstract canDeactivate (): CanComponentDeactivateResult ngOnInit () { this.buildForm({}) - populateAsyncUserVideoChannels(this.authService, this.userVideoChannels) - .then(() => this.firstStepChannelId = this.userVideoChannels[ 0 ].id) + listUserChannels(this.authService) + .subscribe(channels => { + this.userVideoChannels = channels + this.firstStepChannelId = this.userVideoChannels[0].id + }) - this.serverConfig = this.serverService.getTmpConfig() - this.serverService.getConfig() - .subscribe(config => this.serverConfig = config) + this.serverConfig = this.serverService.getHTMLConfig() this.serverService.getVideoPrivacies() .subscribe( privacies => { - this.videoPrivacies = privacies + const { videoPrivacies, defaultPrivacyId } = this.videoService.explainedPrivacyLabels(privacies) + + this.videoPrivacies = videoPrivacies + this.firstStepPrivacyId = defaultPrivacyId - this.firstStepPrivacyId = this.DEFAULT_VIDEO_PRIVACY + this.highestPrivacy = this.videoService.getHighestAvailablePrivacy(privacies) }) }