1
1
import { HttpResponse } from '@angular/common/http' ;
2
- import { AfterViewInit , ChangeDetectionStrategy , Component , OnDestroy , OnInit } from '@angular/core' ;
2
+ import { ChangeDetectionStrategy , Component , OnDestroy , OnInit } from '@angular/core' ;
3
3
import { Router } from '@angular/router' ;
4
4
import { NgbModal } from '@ng-bootstrap/ng-bootstrap' ;
5
5
import { ResizeEvent } from 'angular-resizable-element' ;
@@ -42,7 +42,7 @@ import {SourceDataTypeConfigComponent} from '../source-data-type-config/source-d
42
42
styleUrls : [ './assets-view.component.scss' ] ,
43
43
changeDetection : ChangeDetectionStrategy . OnPush
44
44
} )
45
- export class AssetsViewComponent implements OnInit , AfterViewInit , OnDestroy {
45
+ export class AssetsViewComponent implements OnInit , OnDestroy {
46
46
assets$ : Observable < NetScanType [ ] > ;
47
47
assets : NetScanType [ ] ;
48
48
// defaultTime: ElasticFilterDefaultTime = new ElasticFilterDefaultTime('now-30d', 'now');
@@ -98,7 +98,7 @@ export class AssetsViewComponent implements OnInit, AfterViewInit, OnDestroy {
98
98
99
99
ngOnInit ( ) {
100
100
this . setInitialWidth ( ) ;
101
- this . starInterval ( ) ;
101
+
102
102
this . accountService . identity ( ) . then ( account => {
103
103
this . reasonRun = {
104
104
command : '' ,
@@ -130,10 +130,9 @@ export class AssetsViewComponent implements OnInit, AfterViewInit, OnDestroy {
130
130
} ) ;
131
131
} )
132
132
) ;
133
- }
134
133
135
- ngAfterViewInit ( ) {
136
- this . getAssets ( ) ;
134
+ this . utmNetScanService . notifyRefresh ( true ) ;
135
+ this . starInterval ( ) ;
137
136
}
138
137
139
138
setInitialWidth ( ) {
@@ -145,10 +144,6 @@ export class AssetsViewComponent implements OnInit, AfterViewInit, OnDestroy {
145
144
loadPage ( page : number ) {
146
145
this . page = page - 1 ;
147
146
this . requestParam . page = page ;
148
- this . getAssets ( ) ;
149
- }
150
-
151
- getAssets ( ) {
152
147
this . utmNetScanService . notifyRefresh ( true ) ;
153
148
}
154
149
@@ -163,13 +158,13 @@ export class AssetsViewComponent implements OnInit, AfterViewInit, OnDestroy {
163
158
onItemsPerPageChange ( $event : number ) {
164
159
this . itemsPerPage = $event ;
165
160
this . requestParam . size = $event ;
166
- this . getAssets ( ) ;
161
+ this . utmNetScanService . notifyRefresh ( true ) ;
167
162
}
168
163
169
164
onTimeFilterChange ( $event : TimeFilterType ) {
170
165
this . requestParam . discoveredInitDate = $event . timeFrom ;
171
166
this . requestParam . discoveredEndDate = $event . timeTo ;
172
- this . getAssets ( ) ;
167
+ this . utmNetScanService . notifyRefresh ( true ) ;
173
168
}
174
169
175
170
onResize ( $event : ResizeEvent ) {
@@ -186,7 +181,7 @@ export class AssetsViewComponent implements OnInit, AfterViewInit, OnDestroy {
186
181
187
182
onSortBy ( $event : SortEvent ) {
188
183
this . requestParam . sort = $event . column + ',' + $event . direction ;
189
- this . getAssets ( ) ;
184
+ this . utmNetScanService . notifyRefresh ( true ) ;
190
185
}
191
186
192
187
toggleCheck ( ) {
@@ -230,7 +225,7 @@ export class AssetsViewComponent implements OnInit, AfterViewInit, OnDestroy {
230
225
}
231
226
}
232
227
this . assetFiltersBehavior . $assetFilter . next ( this . requestParam ) ;
233
- this . getAssets ( ) ;
228
+ this . utmNetScanService . notifyRefresh ( true ) ;
234
229
}
235
230
236
231
onFilterChange ( $event : { prop : AssetFieldFilterEnum , values : any } ) {
@@ -268,13 +263,13 @@ export class AssetsViewComponent implements OnInit, AfterViewInit, OnDestroy {
268
263
}
269
264
this . assetFiltersBehavior . $assetAppliedFilter . next ( this . requestParam ) ;
270
265
this . assetFiltersBehavior . $assetFilter . next ( this . requestParam ) ;
271
- this . getAssets ( ) ;
266
+ this . utmNetScanService . notifyRefresh ( true ) ;
272
267
}
273
268
274
269
onSearch ( $event : string ) {
275
270
this . requestParam . assetIpMacName = $event ;
276
271
this . requestParam . page = 0 ;
277
- this . getAssets ( ) ;
272
+ this . utmNetScanService . notifyRefresh ( true ) ;
278
273
}
279
274
280
275
deleteAsset ( event : Event , asset : NetScanType ) {
@@ -293,7 +288,7 @@ export class AssetsViewComponent implements OnInit, AfterViewInit, OnDestroy {
293
288
delete ( asset : NetScanType ) {
294
289
this . utmNetScanService . deleteCustomAsset ( asset . id ) . subscribe ( ( ) => {
295
290
this . utmToastService . showSuccessBottom ( 'Asset deleted successfully' ) ;
296
- this . getAssets ( ) ;
291
+ this . utmNetScanService . notifyRefresh ( true ) ;
297
292
} , ( ) => {
298
293
this . utmToastService . showError ( 'Error deleting asset' ,
299
294
'Error while trying to delete asset, please try again' ) ;
@@ -305,7 +300,7 @@ export class AssetsViewComponent implements OnInit, AfterViewInit, OnDestroy {
305
300
event . stopPropagation ( ) ;
306
301
this . deleting . push ( dat . id ) ;
307
302
this . dataSourceInputService . delete ( dat . id ) . subscribe ( ( ) => {
308
- this . getAssets ( ) ;
303
+ this . utmNetScanService . notifyRefresh ( true ) ;
309
304
const indexDelete = this . deleting . indexOf ( dat . id ) ;
310
305
if ( indexDelete !== - 1 ) {
311
306
this . deleting . splice ( indexDelete , 1 ) ;
@@ -382,7 +377,7 @@ export class AssetsViewComponent implements OnInit, AfterViewInit, OnDestroy {
382
377
showDataTypeModal ( ) {
383
378
const modalSource = this . modalService . open ( SourceDataTypeConfigComponent , { centered : true , size : 'lg' } ) ;
384
379
modalSource . componentInstance . refreshDataInput . subscribe ( ( ) => {
385
- this . getAssets ( ) ;
380
+ this . utmNetScanService . notifyRefresh ( true ) ;
386
381
} ) ;
387
382
}
388
383
@@ -407,8 +402,8 @@ export class AssetsViewComponent implements OnInit, AfterViewInit, OnDestroy {
407
402
starInterval ( ) {
408
403
if ( ! this . interval ) {
409
404
this . interval = setInterval ( ( ) => {
410
- this . getAssets ( ) ;
411
- } , 10000 ) ;
405
+ this . utmNetScanService . notifyRefresh ( true ) ;
406
+ } , 30000 ) ;
412
407
}
413
408
}
414
409
0 commit comments