X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2F%2Bvideos%2F%2Bvideo-edit%2Fvideo-add.component.ts;h=d735c936c2b4cc44ed8d03a4e627bc0e8a7c226a;hb=5b1a6d45b5d6e50102e1c7c8c845401b76b11b4d;hp=5bd7688092020553001626b29f52321d9d606749;hpb=1942f11d5ee6926ad93dc1b79fae18325ba5de18;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/+videos/+video-edit/video-add.component.ts b/client/src/app/+videos/+video-edit/video-add.component.ts index 5bd768809..d735c936c 100644 --- a/client/src/app/+videos/+video-edit/video-add.component.ts +++ b/client/src/app/+videos/+video-edit/video-add.component.ts @@ -1,6 +1,9 @@ import { Component, HostListener, OnInit, ViewChild } from '@angular/core' -import { AuthService, CanComponentDeactivate, ServerService } from '@app/core' +import { ActivatedRoute, Router } from '@angular/router' +import { AuthService, AuthUser, CanComponentDeactivate, ServerService } from '@app/core' import { ServerConfig } from '@shared/models' +import { VideoEditType } from './shared/video-edit.type' +import { VideoGoLiveComponent } from './video-add-components/video-go-live.component' import { VideoImportTorrentComponent } from './video-add-components/video-import-torrent.component' import { VideoImportUrlComponent } from './video-add-components/video-import-url.component' import { VideoUploadComponent } from './video-add-components/video-upload.component' @@ -14,24 +17,50 @@ export class VideoAddComponent implements OnInit, CanComponentDeactivate { @ViewChild('videoUpload') videoUpload: VideoUploadComponent @ViewChild('videoImportUrl') videoImportUrl: VideoImportUrlComponent @ViewChild('videoImportTorrent') videoImportTorrent: VideoImportTorrentComponent + @ViewChild('videoGoLive') videoGoLive: VideoGoLiveComponent - secondStepType: 'upload' | 'import-url' | 'import-torrent' + user: AuthUser = null + + secondStepType: VideoEditType videoName: string - serverConfig: ServerConfig + + activeNav: string + + private serverConfig: ServerConfig constructor ( private auth: AuthService, - private serverService: ServerService + private serverService: ServerService, + private route: ActivatedRoute, + private router: Router ) {} + get userInformationLoaded () { + return this.auth.userInformationLoaded + } + ngOnInit () { + this.user = this.auth.getUser() + this.serverConfig = this.serverService.getTmpConfig() this.serverService.getConfig() .subscribe(config => this.serverConfig = config) + + this.user = this.auth.getUser() + + if (this.route.snapshot.fragment) { + this.onNavChange(this.route.snapshot.fragment) + } + } + + onNavChange (newActiveNav: string) { + this.activeNav = newActiveNav + + this.router.navigate([], { fragment: this.activeNav }) } - onFirstStepDone (type: 'upload' | 'import-url' | 'import-torrent', videoName: string) { + onFirstStepDone (type: VideoEditType, videoName: string) { this.secondStepType = type this.videoName = videoName } @@ -52,9 +81,9 @@ export class VideoAddComponent implements OnInit, CanComponentDeactivate { } canDeactivate (): { canDeactivate: boolean, text?: string} { - if (this.secondStepType === 'upload') return this.videoUpload.canDeactivate() if (this.secondStepType === 'import-url') return this.videoImportUrl.canDeactivate() if (this.secondStepType === 'import-torrent') return this.videoImportTorrent.canDeactivate() + if (this.secondStepType === 'go-live') return this.videoGoLive.canDeactivate() return { canDeactivate: true } } @@ -67,11 +96,15 @@ export class VideoAddComponent implements OnInit, CanComponentDeactivate { return this.serverConfig.import.videos.torrent.enabled } + isVideoLiveEnabled () { + return this.serverConfig.live.enabled + } + isInSecondStep () { return !!this.secondStepType } isRootUser () { - return this.auth.getUser().username === 'root' + return this.user.username === 'root' } }