X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fvideos%2F%2Bvideo-edit%2Fvideo-add.component.ts;h=5bd7688092020553001626b29f52321d9d606749;hb=67ed6552b831df66713bac9e672738796128d33f;hp=01fdfcb66742e3a9eb89b85a9fb0f8d0636f676e;hpb=88108880bbdba473cfe36ecbebc1c3c4f972e102;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 01fdfcb66..5bd768809 100644 --- a/client/src/app/videos/+video-edit/video-add.component.ts +++ b/client/src/app/videos/+video-edit/video-add.component.ts @@ -1,27 +1,36 @@ -import { Component, HostListener, ViewChild } from '@angular/core' -import { CanComponentDeactivate } from '@app/shared/guards/can-deactivate-guard.service' -import { VideoImportUrlComponent } from '@app/videos/+video-edit/video-add-components/video-import-url.component' -import { VideoUploadComponent } from '@app/videos/+video-edit/video-add-components/video-upload.component' -import { ServerService } from '@app/core' -import { VideoImportTorrentComponent } from '@app/videos/+video-edit/video-add-components/video-import-torrent.component' +import { Component, HostListener, OnInit, ViewChild } from '@angular/core' +import { AuthService, CanComponentDeactivate, ServerService } from '@app/core' +import { ServerConfig } from '@shared/models' +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' @Component({ selector: 'my-videos-add', templateUrl: './video-add.component.html', styleUrls: [ './video-add.component.scss' ] }) -export class VideoAddComponent implements CanComponentDeactivate { +export class VideoAddComponent implements OnInit, CanComponentDeactivate { @ViewChild('videoUpload') videoUpload: VideoUploadComponent @ViewChild('videoImportUrl') videoImportUrl: VideoImportUrlComponent @ViewChild('videoImportTorrent') videoImportTorrent: VideoImportTorrentComponent secondStepType: 'upload' | 'import-url' | 'import-torrent' videoName: string + serverConfig: ServerConfig constructor ( + private auth: AuthService, private serverService: ServerService ) {} + ngOnInit () { + this.serverConfig = this.serverService.getTmpConfig() + + this.serverService.getConfig() + .subscribe(config => this.serverConfig = config) + } + onFirstStepDone (type: 'upload' | 'import-url' | 'import-torrent', videoName: string) { this.secondStepType = type this.videoName = videoName @@ -51,10 +60,18 @@ export class VideoAddComponent implements CanComponentDeactivate { } isVideoImportHttpEnabled () { - return this.serverService.getConfig().import.videos.http.enabled + return this.serverConfig.import.videos.http.enabled } isVideoImportTorrentEnabled () { - return this.serverService.getConfig().import.videos.torrent.enabled + return this.serverConfig.import.videos.torrent.enabled + } + + isInSecondStep () { + return !!this.secondStepType + } + + isRootUser () { + return this.auth.getUser().username === 'root' } }