})
}
+function scrollToTop () {
+ window.scroll(0, 0)
+}
+
export {
sortBy,
durationToString,
immutableAssign,
objectToFormData,
lineFeedToHtml,
- removeElementFromArray
+ removeElementFromArray,
+ scrollToTop
}
</div>
</div>
-<div *ngIf="hasImportedVideo" class="alert alert-info" i18n>
+<div *ngIf="error" class="alert alert-danger">
+ <div i18n>Sorry, but something went wrong</div>
+ {{ error }}
+</div>
+
+<div *ngIf="hasImportedVideo && !error" class="alert alert-info" i18n>
Congratulations, the video will be imported with BitTorrent! You can already add information about this video.
</div>
@include peertube-select-container($width-size);
}
+.alert.alert-danger {
+ text-align: center;
+
+ & > div {
+ font-weight: $font-semibold;
+ }
+}
+
.import-video-torrent {
display: flex;
flex-direction: column;
import { FormValidatorService } from '@app/shared'
import { VideoCaptionService } from '@app/shared/video-caption'
import { VideoImportService } from '@app/shared/video-import'
+import { scrollToTop } from '@app/shared/misc/utils'
@Component({
selector: 'my-video-import-torrent',
})
export class VideoImportTorrentComponent extends VideoSend implements OnInit, CanComponentDeactivate {
@Output() firstStepDone = new EventEmitter<string>()
+ @Output() firstStepError = new EventEmitter<void>()
@ViewChild('torrentfileInput') torrentfileInput: ElementRef<HTMLInputElement>
- videoFileName: string
magnetUri = ''
isImportingVideo = false
isUpdatingVideo = false
video: VideoEdit
+ error: string
protected readonly DEFAULT_VIDEO_PRIVACY = VideoPrivacy.PUBLIC
err => {
this.loadingBar.complete()
this.isImportingVideo = false
+ this.firstStepError.emit()
this.notificationsService.error(this.i18n('Error'), err.message)
}
)
},
err => {
- this.isUpdatingVideo = false
- this.notificationsService.error(this.i18n('Error'), err.message)
+ this.error = err.message
+ scrollToTop()
console.error(err)
}
)
</div>
</div>
-<div *ngIf="hasImportedVideo" class="alert alert-info" i18n>
+
+<div *ngIf="error" class="alert alert-danger">
+ <div i18n>Sorry, but something went wrong</div>
+ {{ error }}
+</div>
+
+<div *ngIf="!error && hasImportedVideo" class="alert alert-info" i18n>
Congratulations, the video behind {{ targetUrl }} will be imported! You can already add information about this video.
</div>
@include peertube-select-container($width-size);
}
+.alert.alert-danger {
+ text-align: center;
+
+ & > div {
+ font-weight: $font-semibold;
+ }
+}
+
.import-video-url {
display: flex;
flex-direction: column;
import { FormValidatorService } from '@app/shared'
import { VideoCaptionService } from '@app/shared/video-caption'
import { VideoImportService } from '@app/shared/video-import'
+import { scrollToTop } from '@app/shared/misc/utils'
@Component({
selector: 'my-video-import-url',
})
export class VideoImportUrlComponent extends VideoSend implements OnInit, CanComponentDeactivate {
@Output() firstStepDone = new EventEmitter<string>()
+ @Output() firstStepError = new EventEmitter<void>()
targetUrl = ''
- videoFileName: string
isImportingVideo = false
hasImportedVideo = false
isUpdatingVideo = false
video: VideoEdit
+ error: string
protected readonly DEFAULT_VIDEO_PRIVACY = VideoPrivacy.PUBLIC
err => {
this.loadingBar.complete()
this.isImportingVideo = false
+ this.firstStepError.emit()
this.notificationsService.error(this.i18n('Error'), err.message)
}
)
},
err => {
- this.isUpdatingVideo = false
- this.notificationsService.error(this.i18n('Error'), err.message)
+ this.error = err.message
+ scrollToTop()
console.error(err)
}
)
firstStepChannelId = 0
abstract firstStepDone: EventEmitter<string>
+ abstract firstStepError: EventEmitter<void>
protected abstract readonly DEFAULT_VIDEO_PRIVACY: VideoPrivacy
protected loadingBar: LoadingBarService
</div>
</div>
-<div *ngIf="isUploadingVideo" class="upload-progress-cancel">
+<div *ngIf="isUploadingVideo && !error" class="upload-progress-cancel">
<p-progressBar
[value]="videoUploadPercents"
[ngClass]="{ processing: videoUploadPercents === 100 && videoUploaded === false }"
<input *ngIf="videoUploaded === false" type="button" value="Cancel" (click)="cancelUpload()" />
</div>
+<div *ngIf="error" class="alert alert-danger">
+ <div i18n>Sorry, but something went wrong</div>
+ {{ error }}
+</div>
+
<!-- Hidden because we want to load the component -->
<form [hidden]="!isUploadingVideo" novalidate [formGroup]="form">
<my-video-edit
<input [disabled]="isPublishingButtonDisabled()" type="button" i18n-value value="Publish" />
</div>
</div>
-</form>
\ No newline at end of file
+</form>
@include peertube-select-container(190px);
}
+.alert.alert-danger {
+ text-align: center;
+
+ & > div {
+ font-weight: $font-semibold;
+ }
+}
+
.upload-video {
display: flex;
flex-direction: column;
margin-left: 10px;
}
-}
\ No newline at end of file
+}
import { CanComponentDeactivate } from '@app/shared/guards/can-deactivate-guard.service'
import { FormValidatorService, UserService } from '@app/shared'
import { VideoCaptionService } from '@app/shared/video-caption'
+import { scrollToTop } from '@app/shared/misc/utils'
@Component({
selector: 'my-video-upload',
})
export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy, CanComponentDeactivate {
@Output() firstStepDone = new EventEmitter<string>()
+ @Output() firstStepError = new EventEmitter<void>()
@ViewChild('videofileInput') videofileInput: ElementRef<HTMLInputElement>
// So that it can be accessed in the template
uuid: ''
}
+ error: string
+
protected readonly DEFAULT_VIDEO_PRIVACY = VideoPrivacy.PUBLIC
constructor (
this.isUploadingVideo = false
this.videoUploadPercents = 0
this.videoUploadObservable = null
+ this.firstStepError.emit()
this.notificationsService.error(this.i18n('Error'), err.message)
}
)
},
err => {
- this.isUpdatingVideo = false
- this.notificationsService.error(this.i18n('Error'), err.message)
+ this.error = err.message
+ scrollToTop()
console.error(err)
}
)
<ngb-tabset class="video-add-tabset root-tabset bootstrap" [ngClass]="{ 'hide-nav': secondStepType !== undefined }">
- <ngb-tab i18n-title title="">
+ <ngb-tab>
<ng-template ngbTabTitle><span i18n>Upload a file</span></ng-template>
<ng-template ngbTabContent>
- <my-video-upload #videoUpload (firstStepDone)="onFirstStepDone('upload', $event)"></my-video-upload>
+ <my-video-upload #videoUpload (firstStepDone)="onFirstStepDone('upload', $event)" (firstStepError)="onError()"></my-video-upload>
</ng-template>
</ngb-tab>
<ngb-tab *ngIf="isVideoImportHttpEnabled()">
<ng-template ngbTabTitle><span i18n>Import with URL</span></ng-template>
<ng-template ngbTabContent>
- <my-video-import-url #videoImportUrl (firstStepDone)="onFirstStepDone('import-url', $event)"></my-video-import-url>
+ <my-video-import-url #videoImportUrl (firstStepDone)="onFirstStepDone('import-url', $event)" (firstStepError)="onError()"></my-video-import-url>
</ng-template>
</ngb-tab>
<ngb-tab *ngIf="isVideoImportTorrentEnabled()">
<ng-template ngbTabTitle><span i18n>Import with torrent</span></ng-template>
<ng-template ngbTabContent>
- <my-video-import-torrent #videoImportTorrent (firstStepDone)="onFirstStepDone('import-torrent', $event)"></my-video-import-torrent>
+ <my-video-import-torrent #videoImportTorrent (firstStepDone)="onFirstStepDone('import-torrent', $event)" (firstStepError)="onError()"></my-video-import-torrent>
</ng-template>
</ngb-tab>
</ngb-tabset>
this.videoName = videoName
}
+ onError () {
+ this.videoName = undefined
+ this.secondStepType = undefined
+ }
+
canDeactivate () {
if (this.secondStepType === 'upload') return this.videoUpload.canDeactivate()
if (this.secondStepType === 'import-url') return this.videoImportUrl.canDeactivate()
function areErrorsInScheduleUpdate (req: express.Request, res: express.Response) {
if (req.body.scheduleUpdate) {
if (!req.body.scheduleUpdate.updateAt) {
+ logger.warn('Invalid parameters: scheduleUpdate.updateAt is mandatory.')
+
res.status(400)
.json({ error: 'Schedule update at is mandatory.' })