Put presentation logic in the components

pull/10/head
Chocobozzz 2016-05-27 17:52:41 +02:00
parent 4fd8aa3270
commit 9bfe96e19f
3 changed files with 8 additions and 4 deletions

View File

@ -25,9 +25,9 @@ export class VideoAddComponent implements OnInit {
private form: any;
constructor(
private router: Router,
private authService: AuthService,
private elementRef: ElementRef,
private authService: AuthService
private router: Router
) {}
ngOnInit() {
@ -62,8 +62,8 @@ export class VideoAddComponent implements OnInit {
}
uploadFile() {
this.form.headers = this.authService.getRequestHeader().toJSON();
this.form.formData = jQuery(this.elementRef.nativeElement).find('form').serializeArray();
this.form.headers = this.authService.getRequestHeader().toJSON();
this.form.submit();
}
}

View File

@ -6,7 +6,7 @@
<div class="videos-miniatures">
<my-loader [loading]="loading"></my-loader>
<div class="col-md-12 no-video" *ngIf="!loading && videos.length === 0">There is no video.</div>
<div class="col-md-12 no-video" *ngIf="noVideo()">There is no video.</div>
<my-video-miniature *ngFor="let video of videos" [video]="video" [user]="user" (removed)="onRemoved(video)">
</my-video-miniature>

View File

@ -80,6 +80,10 @@ export class VideoListComponent implements OnInit {
);
}
noVideo() {
return !this.loading && this.videos.length === 0;
}
onRemoved(video: Video) {
this.videos.splice(this.videos.indexOf(video), 1);
}