Add progress bar for video upload
This commit is contained in:
parent
baeefe22ca
commit
c182778e26
|
@ -84,19 +84,19 @@ styles:
|
||||||
navs: true
|
navs: true
|
||||||
navbar: false
|
navbar: false
|
||||||
breadcrumbs: false
|
breadcrumbs: false
|
||||||
pagination: true
|
pagination: false
|
||||||
pager: false
|
pager: false
|
||||||
labels: true
|
labels: false
|
||||||
badges: false
|
badges: false
|
||||||
jumbotron: false
|
jumbotron: false
|
||||||
thumbnails: true
|
thumbnails: false
|
||||||
alerts: true
|
alerts: true
|
||||||
progress-bars: true
|
progress-bars: false
|
||||||
media: true
|
media: true
|
||||||
list-group: false
|
list-group: false
|
||||||
panels: true
|
panels: true
|
||||||
wells: false
|
wells: false
|
||||||
responsive-embed: true
|
responsive-embed: false
|
||||||
close: true
|
close: true
|
||||||
|
|
||||||
# Components w/ JavaScript
|
# Components w/ JavaScript
|
||||||
|
|
|
@ -6,7 +6,6 @@ import { RouterModule } from '@angular/router'
|
||||||
|
|
||||||
import { BsDropdownModule } from 'ngx-bootstrap/dropdown'
|
import { BsDropdownModule } from 'ngx-bootstrap/dropdown'
|
||||||
import { ModalModule } from 'ngx-bootstrap/modal'
|
import { ModalModule } from 'ngx-bootstrap/modal'
|
||||||
import { ProgressbarModule } from 'ngx-bootstrap/progressbar'
|
|
||||||
import { InfiniteScrollModule } from 'ngx-infinite-scroll'
|
import { InfiniteScrollModule } from 'ngx-infinite-scroll'
|
||||||
import { BytesPipe, KeysPipe, NgPipesModule } from 'ngx-pipes'
|
import { BytesPipe, KeysPipe, NgPipesModule } from 'ngx-pipes'
|
||||||
import { SharedModule as PrimeSharedModule } from 'primeng/components/common/shared'
|
import { SharedModule as PrimeSharedModule } from 'primeng/components/common/shared'
|
||||||
|
@ -34,7 +33,6 @@ import { VideoService } from './video/video.service'
|
||||||
|
|
||||||
BsDropdownModule.forRoot(),
|
BsDropdownModule.forRoot(),
|
||||||
ModalModule.forRoot(),
|
ModalModule.forRoot(),
|
||||||
ProgressbarModule.forRoot(),
|
|
||||||
|
|
||||||
DataTableModule,
|
DataTableModule,
|
||||||
PrimeSharedModule,
|
PrimeSharedModule,
|
||||||
|
@ -59,7 +57,6 @@ import { VideoService } from './video/video.service'
|
||||||
|
|
||||||
BsDropdownModule,
|
BsDropdownModule,
|
||||||
ModalModule,
|
ModalModule,
|
||||||
ProgressbarModule,
|
|
||||||
DataTableModule,
|
DataTableModule,
|
||||||
PrimeSharedModule,
|
PrimeSharedModule,
|
||||||
InfiniteScrollModule,
|
InfiniteScrollModule,
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<p-progressBar *ngIf="isUploadingVideo" [value]="videoUploadPercents"></p-progressBar>
|
||||||
|
|
||||||
<!-- Hidden because we need to load the component -->
|
<!-- Hidden because we need to load the component -->
|
||||||
<form [hidden]="!isUploadingVideo" novalidate [formGroup]="form">
|
<form [hidden]="!isUploadingVideo" novalidate [formGroup]="form">
|
||||||
<my-video-edit
|
<my-video-edit
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {
|
||||||
|
|
||||||
isUploadingVideo = false
|
isUploadingVideo = false
|
||||||
videoUploaded = false
|
videoUploaded = false
|
||||||
progressPercent = 0
|
videoUploadPercents = 0
|
||||||
|
|
||||||
error: string = null
|
error: string = null
|
||||||
form: FormGroup
|
form: FormGroup
|
||||||
|
@ -55,7 +55,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {
|
||||||
ngOnInit () {
|
ngOnInit () {
|
||||||
this.buildForm()
|
this.buildForm()
|
||||||
|
|
||||||
this.serverService.videoCategoriesLoaded
|
this.serverService.videoPrivaciesLoaded
|
||||||
.subscribe(
|
.subscribe(
|
||||||
() => {
|
() => {
|
||||||
this.videoPrivacies = this.serverService.getVideoPrivacies()
|
this.videoPrivacies = this.serverService.getVideoPrivacies()
|
||||||
|
@ -112,7 +112,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {
|
||||||
this.videoService.uploadVideo(formData).subscribe(
|
this.videoService.uploadVideo(formData).subscribe(
|
||||||
event => {
|
event => {
|
||||||
if (event.type === HttpEventType.UploadProgress) {
|
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) {
|
} else if (event instanceof HttpResponse) {
|
||||||
console.log('Video uploaded.')
|
console.log('Video uploaded.')
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {
|
||||||
|
|
||||||
err => {
|
err => {
|
||||||
// Reset progress
|
// Reset progress
|
||||||
this.progressPercent = 0
|
this.videoUploadPercents = 0
|
||||||
this.error = err.message
|
this.error = err.message
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { NgModule } from '@angular/core'
|
import { NgModule } from '@angular/core'
|
||||||
|
import { ProgressBarModule } from 'primeng/primeng'
|
||||||
import { SharedModule } from '../../shared'
|
import { SharedModule } from '../../shared'
|
||||||
import { VideoEditModule } from './shared/video-edit.module'
|
import { VideoEditModule } from './shared/video-edit.module'
|
||||||
import { VideoAddRoutingModule } from './video-add-routing.module'
|
import { VideoAddRoutingModule } from './video-add-routing.module'
|
||||||
|
@ -8,7 +9,8 @@ import { VideoAddComponent } from './video-add.component'
|
||||||
imports: [
|
imports: [
|
||||||
VideoAddRoutingModule,
|
VideoAddRoutingModule,
|
||||||
VideoEditModule,
|
VideoEditModule,
|
||||||
SharedModule
|
SharedModule,
|
||||||
|
ProgressBarModule
|
||||||
],
|
],
|
||||||
|
|
||||||
declarations: [
|
declarations: [
|
||||||
|
|
Loading…
Reference in New Issue