diff options
Diffstat (limited to 'client/src/app/account/account-videos/account-videos.component.ts')
-rw-r--r-- | client/src/app/account/account-videos/account-videos.component.ts | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/client/src/app/account/account-videos/account-videos.component.ts b/client/src/app/account/account-videos/account-videos.component.ts index bce135557..e9d044dbf 100644 --- a/client/src/app/account/account-videos/account-videos.component.ts +++ b/client/src/app/account/account-videos/account-videos.component.ts | |||
@@ -1,5 +1,7 @@ | |||
1 | import { Component, OnInit } from '@angular/core' | 1 | import { Component, OnInit } from '@angular/core' |
2 | import { ActivatedRoute, Router } from '@angular/router' | 2 | import { ActivatedRoute, Router } from '@angular/router' |
3 | import { immutableAssign } from '@app/shared/misc/utils' | ||
4 | import { ComponentPagination } from '@app/shared/rest/component-pagination.model' | ||
3 | import { NotificationsService } from 'angular2-notifications' | 5 | import { NotificationsService } from 'angular2-notifications' |
4 | import 'rxjs/add/observable/from' | 6 | import 'rxjs/add/observable/from' |
5 | import 'rxjs/add/operator/concatAll' | 7 | import 'rxjs/add/operator/concatAll' |
@@ -19,7 +21,9 @@ export class AccountVideosComponent extends AbstractVideoList implements OnInit | |||
19 | titlePage = 'My videos' | 21 | titlePage = 'My videos' |
20 | currentRoute = '/account/videos' | 22 | currentRoute = '/account/videos' |
21 | checkedVideos: { [ id: number ]: boolean } = {} | 23 | checkedVideos: { [ id: number ]: boolean } = {} |
22 | pagination = { | 24 | videoHeight = 155 |
25 | videoWidth = -1 | ||
26 | pagination: ComponentPagination = { | ||
23 | currentPage: 1, | 27 | currentPage: 1, |
24 | itemsPerPage: 10, | 28 | itemsPerPage: 10, |
25 | totalItems: null | 29 | totalItems: null |
@@ -46,8 +50,10 @@ export class AccountVideosComponent extends AbstractVideoList implements OnInit | |||
46 | return Object.keys(this.checkedVideos).some(k => this.checkedVideos[k] === true) | 50 | return Object.keys(this.checkedVideos).some(k => this.checkedVideos[k] === true) |
47 | } | 51 | } |
48 | 52 | ||
49 | getVideosObservable () { | 53 | getVideosObservable (page: number) { |
50 | return this.videoService.getMyVideos(this.pagination, this.sort) | 54 | const newPagination = immutableAssign(this.pagination, { currentPage: page }) |
55 | |||
56 | return this.videoService.getMyVideos(newPagination, this.sort) | ||
51 | } | 57 | } |
52 | 58 | ||
53 | deleteSelectedVideos () { | 59 | deleteSelectedVideos () { |
@@ -71,9 +77,12 @@ export class AccountVideosComponent extends AbstractVideoList implements OnInit | |||
71 | Observable.from(observables) | 77 | Observable.from(observables) |
72 | .concatAll() | 78 | .concatAll() |
73 | .subscribe( | 79 | .subscribe( |
74 | res => this.notificationsService.success('Success', `${toDeleteVideosIds.length} videos deleted.`), | 80 | res => { |
81 | this.notificationsService.success('Success', `${toDeleteVideosIds.length} videos deleted.`) | ||
82 | this.buildVideoPages() | ||
83 | }, | ||
75 | 84 | ||
76 | err => this.notificationsService.error('Error', err.message) | 85 | err => this.notificationsService.error('Error', err.message) |
77 | ) | 86 | ) |
78 | } | 87 | } |
79 | ) | 88 | ) |
@@ -89,6 +98,7 @@ export class AccountVideosComponent extends AbstractVideoList implements OnInit | |||
89 | status => { | 98 | status => { |
90 | this.notificationsService.success('Success', `Video ${video.name} deleted.`) | 99 | this.notificationsService.success('Success', `Video ${video.name} deleted.`) |
91 | this.spliceVideosById(video.id) | 100 | this.spliceVideosById(video.id) |
101 | this.buildVideoPages() | ||
92 | }, | 102 | }, |
93 | 103 | ||
94 | error => this.notificationsService.error('Error', error.message) | 104 | error => this.notificationsService.error('Error', error.message) |
@@ -98,7 +108,14 @@ export class AccountVideosComponent extends AbstractVideoList implements OnInit | |||
98 | } | 108 | } |
99 | 109 | ||
100 | private spliceVideosById (id: number) { | 110 | private spliceVideosById (id: number) { |
101 | const index = this.videos.findIndex(v => v.id === id) | 111 | for (const key of Object.keys(this.loadedPages)) { |
102 | this.videos.splice(index, 1) | 112 | const videos = this.loadedPages[key] |
113 | const index = videos.findIndex(v => v.id === id) | ||
114 | |||
115 | if (index !== -1) { | ||
116 | videos.splice(index, 1) | ||
117 | return | ||
118 | } | ||
119 | } | ||
103 | } | 120 | } |
104 | } | 121 | } |