@@ -53,69 +53,71 @@ export default class StorageMigrationCtrl {
53
53
} ;
54
54
55
55
vm . callServer = function ( tableState ) {
56
- $scope . ipLoading = true ;
57
- if ( vm . displayedIps . length == 0 ) {
58
- $scope . initLoad = true ;
59
- }
60
- if ( ! angular . isUndefined ( tableState ) ) {
61
- $scope . tableState = tableState ;
62
- var search = '' ;
63
- if ( tableState . search . predicateObject ) {
64
- var search = tableState . search . predicateObject [ '$' ] ;
65
- }
66
- let ordering = tableState . sort . predicate ;
67
- if ( tableState . sort . reverse ) {
68
- ordering = '-' + ordering ;
56
+ if ( vm . selectedMediums . length && vm . ipsVisible ) {
57
+ $scope . ipLoading = true ;
58
+ if ( vm . displayedIps . length == 0 ) {
59
+ $scope . initLoad = true ;
69
60
}
61
+ if ( ! angular . isUndefined ( tableState ) ) {
62
+ $scope . tableState = tableState ;
63
+ var search = '' ;
64
+ if ( tableState . search . predicateObject ) {
65
+ var search = tableState . search . predicateObject [ '$' ] ;
66
+ }
67
+ let ordering = tableState . sort . predicate ;
68
+ if ( tableState . sort . reverse ) {
69
+ ordering = '-' + ordering ;
70
+ }
70
71
71
- const paginationParams = listViewService . getPaginationParams ( tableState . pagination , vm . itemsPerPage ) ;
72
- $http ( {
73
- method : 'GET' ,
74
- url : appConfig . djangoUrl + 'information-packages/' ,
75
- params : angular . extend (
76
- {
77
- search,
78
- ordering,
79
- view_type : 'flat' ,
80
- page : paginationParams . pageNumber ,
81
- page_size : paginationParams . number ,
82
- pager : paginationParams . pager ,
83
- medium : vm . selectedMediums . length ? vm . selectedMediums . map ( ( x ) => x . id ) : null ,
84
- policy : vm . mediumFilterModel . policy ,
85
- migratable : true ,
86
- } ,
87
- vm . columnFilters
88
- ) ,
89
- } )
90
- . then ( function ( response ) {
91
- vm . displayedIps = response . data ;
92
- tableState . pagination . numberOfPages = Math . ceil ( response . headers ( 'Count' ) / paginationParams . number ) ; //set the number of pages so the pagination can update
93
- $scope . ipLoading = false ;
94
- $scope . initLoad = false ;
95
- ipExists ( ) ;
96
- SelectedIPUpdater . update ( vm . displayedIps , $scope . ips , $scope . ip ) ;
72
+ const paginationParams = listViewService . getPaginationParams ( tableState . pagination , vm . itemsPerPage ) ;
73
+ $http ( {
74
+ method : 'GET' ,
75
+ url : appConfig . djangoUrl + 'information-packages/' ,
76
+ params : angular . extend (
77
+ {
78
+ search,
79
+ ordering,
80
+ view_type : 'flat' ,
81
+ page : paginationParams . pageNumber ,
82
+ page_size : paginationParams . number ,
83
+ pager : paginationParams . pager ,
84
+ medium : vm . selectedMediums . length ? vm . selectedMediums . map ( ( x ) => x . id ) : null ,
85
+ policy : vm . mediumFilterModel . policy ,
86
+ migratable : true ,
87
+ } ,
88
+ vm . columnFilters
89
+ ) ,
97
90
} )
98
- . catch ( function ( response ) {
99
- if ( response . status == 404 ) {
100
- const filters = angular . extend (
101
- {
102
- state : ipSortString ,
103
- } ,
104
- vm . columnFilters
105
- ) ;
91
+ . then ( function ( response ) {
92
+ vm . displayedIps = response . data ;
93
+ tableState . pagination . numberOfPages = Math . ceil ( response . headers ( 'Count' ) / paginationParams . number ) ; //set the number of pages so the pagination can update
94
+ $scope . ipLoading = false ;
95
+ $scope . initLoad = false ;
96
+ ipExists ( ) ;
97
+ SelectedIPUpdater . update ( vm . displayedIps , $scope . ips , $scope . ip ) ;
98
+ } )
99
+ . catch ( function ( response ) {
100
+ if ( response . status == 404 ) {
101
+ const filters = angular . extend (
102
+ {
103
+ state : ipSortString ,
104
+ } ,
105
+ vm . columnFilters
106
+ ) ;
106
107
107
- if ( vm . workarea ) {
108
- filters . workarea = vm . workarea ;
109
- }
108
+ if ( vm . workarea ) {
109
+ filters . workarea = vm . workarea ;
110
+ }
110
111
111
- listViewService . checkPages ( 'ip' , paginationParams . number , filters ) . then ( function ( response ) {
112
- tableState . pagination . numberOfPages = response . numberOfPages ; //set the number of pages so the pagination can update
113
- tableState . pagination . start =
114
- response . numberOfPages * paginationParams . number - paginationParams . number ;
115
- vm . callServer ( tableState ) ;
116
- } ) ;
117
- }
118
- } ) ;
112
+ listViewService . checkPages ( 'ip' , paginationParams . number , filters ) . then ( function ( response ) {
113
+ tableState . pagination . numberOfPages = response . numberOfPages ; //set the number of pages so the pagination can update
114
+ tableState . pagination . start =
115
+ response . numberOfPages * paginationParams . number - paginationParams . number ;
116
+ vm . callServer ( tableState ) ;
117
+ } ) ;
118
+ }
119
+ } ) ;
120
+ }
119
121
}
120
122
} ;
121
123
0 commit comments