Add progress bar for video upload

pull/159/head
Chocobozzz 2017-12-07 17:56:59 +01:00
parent baeefe22ca
commit c182778e26
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
6 changed files with 37 additions and 13 deletions

View File

@ -84,19 +84,19 @@ styles:
navs: true
navbar: false
breadcrumbs: false
pagination: true
pagination: false
pager: false
labels: true
labels: false
badges: false
jumbotron: false
thumbnails: true
thumbnails: false
alerts: true
progress-bars: true
progress-bars: false
media: true
list-group: false
panels: true
wells: false
responsive-embed: true
responsive-embed: false
close: true
# Components w/ JavaScript

View File

@ -6,7 +6,6 @@ import { RouterModule } from '@angular/router'
import { BsDropdownModule } from 'ngx-bootstrap/dropdown'
import { ModalModule } from 'ngx-bootstrap/modal'
import { ProgressbarModule } from 'ngx-bootstrap/progressbar'
import { InfiniteScrollModule } from 'ngx-infinite-scroll'
import { BytesPipe, KeysPipe, NgPipesModule } from 'ngx-pipes'
import { SharedModule as PrimeSharedModule } from 'primeng/components/common/shared'
@ -34,7 +33,6 @@ import { VideoService } from './video/video.service'
BsDropdownModule.forRoot(),
ModalModule.forRoot(),
ProgressbarModule.forRoot(),
DataTableModule,
PrimeSharedModule,
@ -59,7 +57,6 @@ import { VideoService } from './video/video.service'
BsDropdownModule,
ModalModule,
ProgressbarModule,
DataTableModule,
PrimeSharedModule,
InfiniteScrollModule,

View File

@ -28,6 +28,8 @@
</div>
</div>
<p-progressBar *ngIf="isUploadingVideo" [value]="videoUploadPercents"></p-progressBar>
<!-- Hidden because we need to load the component -->
<form [hidden]="!isUploadingVideo" novalidate [formGroup]="form">
<my-video-edit

View File

@ -57,4 +57,27 @@
}
}
p-progressBar {
margin-top: 50px;
margin-bottom: 40px;
/deep/ .ui-progressbar {
font-size: 15px !important;
color: #fff !important;
height: 30px !important;
line-height: 30px !important;
border-radius: 3px !important;
background-color: rgba(11, 204, 41, 0.16) !important;
.ui-progressbar-value {
background-color: #0BCC29 !important;
}
.ui-progressbar-label {
text-align: left;
padding-left: 18px;
}
}
}

View File

@ -24,7 +24,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {
isUploadingVideo = false
videoUploaded = false
progressPercent = 0
videoUploadPercents = 0
error: string = null
form: FormGroup
@ -55,7 +55,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {
ngOnInit () {
this.buildForm()
this.serverService.videoCategoriesLoaded
this.serverService.videoPrivaciesLoaded
.subscribe(
() => {
this.videoPrivacies = this.serverService.getVideoPrivacies()
@ -112,7 +112,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {
this.videoService.uploadVideo(formData).subscribe(
event => {
if (event.type === HttpEventType.UploadProgress) {
this.progressPercent = Math.round(100 * event.loaded / event.total)
this.videoUploadPercents = Math.round(100 * event.loaded / event.total)
} else if (event instanceof HttpResponse) {
console.log('Video uploaded.')
@ -122,7 +122,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {
err => {
// Reset progress
this.progressPercent = 0
this.videoUploadPercents = 0
this.error = err.message
}
)

View File

@ -1,4 +1,5 @@
import { NgModule } from '@angular/core'
import { ProgressBarModule } from 'primeng/primeng'
import { SharedModule } from '../../shared'
import { VideoEditModule } from './shared/video-edit.module'
import { VideoAddRoutingModule } from './video-add-routing.module'
@ -8,7 +9,8 @@ import { VideoAddComponent } from './video-add.component'
imports: [
VideoAddRoutingModule,
VideoEditModule,
SharedModule
SharedModule,
ProgressBarModule
],
declarations: [