X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2F%2Bvideos%2F%2Bvideo-edit%2Fvideo-add.component.ts;h=8606b82222c4c4e95009dc867d7ac2919b8311af;hb=2989628b7913383b39ac34c7db8666a21f8e5037;hp=016791d59dc76576c343ba767cbc3055fd9dc6ec;hpb=2e7f262724dd64a209e0bad5930ba29bb4f801c3;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 016791d59..8606b8222 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, User } from '@app/core' -import { ServerConfig } from '@shared/models' +import { ActivatedRoute, Router } from '@angular/router' +import { AuthService, AuthUser, CanComponentDeactivate, ServerService } from '@app/core' +import { HTMLServerConfig } 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,16 +17,22 @@ export class VideoAddComponent implements OnInit, CanComponentDeactivate { @ViewChild('videoUpload') videoUpload: VideoUploadComponent @ViewChild('videoImportUrl') videoImportUrl: VideoImportUrlComponent @ViewChild('videoImportTorrent') videoImportTorrent: VideoImportTorrentComponent + @ViewChild('videoGoLive') videoGoLive: VideoGoLiveComponent - user: User = null + user: AuthUser = null - secondStepType: 'upload' | 'import-url' | 'import-torrent' + secondStepType: VideoEditType videoName: string - serverConfig: ServerConfig + + activeNav: string + + private serverConfig: HTMLServerConfig constructor ( private auth: AuthService, - private serverService: ServerService + private serverService: ServerService, + private route: ActivatedRoute, + private router: Router ) {} get userInformationLoaded () { @@ -33,13 +42,22 @@ export class VideoAddComponent implements OnInit, CanComponentDeactivate { ngOnInit () { this.user = this.auth.getUser() - this.serverConfig = this.serverService.getTmpConfig() + this.serverConfig = this.serverService.getHTMLConfig() - this.serverService.getConfig() - .subscribe(config => this.serverConfig = config) + this.user = this.auth.getUser() + + if (this.route.snapshot.fragment) { + this.onNavChange(this.route.snapshot.fragment) + } } - onFirstStepDone (type: 'upload' | 'import-url' | 'import-torrent', videoName: string) { + onNavChange (newActiveNav: string) { + this.activeNav = newActiveNav + + this.router.navigate([], { fragment: this.activeNav }) + } + + onFirstStepDone (type: VideoEditType, videoName: string) { this.secondStepType = type this.videoName = videoName } @@ -60,9 +78,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 } } @@ -75,11 +93,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' } }