@@ -14,8 +14,10 @@ import { SortParams, OrderParams } from '../../shared/components/shared.interfac
14
14
import { IntervalObservable } from 'rxjs/observable/IntervalObservable' ;
15
15
import { StreamListParams } from '../components/streams.interface' ;
16
16
import { Subject } from 'rxjs/Subject' ;
17
- import { takeUntil } from 'rxjs/operators' ;
17
+ import { mergeMap , takeUntil } from 'rxjs/operators' ;
18
18
import { BusyService } from '../../shared/services/busy.service' ;
19
+ import { AppsService } from '../../apps/apps.service' ;
20
+ import { AppRegistration } from '../../shared/model/app-registration.model' ;
19
21
20
22
@Component ( {
21
23
selector : 'app-streams' ,
@@ -82,6 +84,11 @@ export class StreamsComponent implements OnInit, OnDestroy {
82
84
q : ''
83
85
} ;
84
86
87
+ /**
88
+ * State of application register empty
89
+ */
90
+ noApplicationRegister : boolean ;
91
+
85
92
/**
86
93
* Contain a key application of each selected application
87
94
* @type {Array }
@@ -104,12 +111,14 @@ export class StreamsComponent implements OnInit, OnDestroy {
104
111
*
105
112
* @param {StreamsService } streamsService
106
113
* @param {BsModalService } modalService
114
+ * @param {AppsService } appsService
107
115
* @param {BusyService } busyService
108
116
* @param {ToastyService } toastyService
109
117
* @param {Router } router
110
118
*/
111
119
constructor ( public streamsService : StreamsService ,
112
120
private modalService : BsModalService ,
121
+ private appsService : AppsService ,
113
122
private busyService : BusyService ,
114
123
private toastyService : ToastyService ,
115
124
private router : Router ) {
@@ -146,7 +155,8 @@ export class StreamsComponent implements OnInit, OnDestroy {
146
155
refresh ( ) {
147
156
console . log ( 'Loading Stream Definitions...' , this . params ) ;
148
157
const busy = this . streamsService
149
- . getDefinitions ( this . params ) . map ( ( page : Page < StreamDefinition > ) => {
158
+ . getDefinitions ( this . params )
159
+ . map ( ( page : Page < StreamDefinition > ) => {
150
160
this . form . checkboxes = page . items . map ( ( stream ) => {
151
161
return this . itemsSelected . indexOf ( stream . name ) > - 1 ;
152
162
} ) ;
@@ -155,14 +165,32 @@ export class StreamsComponent implements OnInit, OnDestroy {
155
165
} ) ;
156
166
return page ;
157
167
} )
168
+ . pipe (
169
+ mergeMap (
170
+ val => this . appsService . getApps ( {
171
+ q : '' ,
172
+ type : null ,
173
+ page : 0 ,
174
+ size : 1 ,
175
+ order : 'name' ,
176
+ sort : OrderParams . ASC
177
+ } ) ,
178
+ ( val1 , val2 ) => {
179
+ return {
180
+ streams : val1 ,
181
+ apps : val2 ,
182
+ } ;
183
+ } )
184
+ )
158
185
. pipe ( takeUntil ( this . ngUnsubscribe$ ) )
159
- . subscribe ( ( page : Page < StreamDefinition > ) => {
160
- if ( page . items . length === 0 && this . params . page > 0 ) {
186
+ . subscribe ( ( value : { streams : Page < StreamDefinition > , apps : Page < AppRegistration > } ) => {
187
+ if ( value . streams . items . length === 0 && this . params . page > 0 ) {
161
188
this . params . page = 0 ;
162
189
this . refresh ( ) ;
163
190
return ;
164
191
}
165
- this . streamDefinitions = page ;
192
+ this . noApplicationRegister = ! ( value . apps . totalElements > 0 ) ;
193
+ this . streamDefinitions = value . streams ;
166
194
this . changeExpand ( ) ;
167
195
this . changeCheckboxes ( ) ;
168
196
this . updateContext ( ) ;
@@ -229,7 +257,7 @@ export class StreamsComponent implements OnInit, OnDestroy {
229
257
/**
230
258
* Determine if there is no application
231
259
*/
232
- isAppsEmpty ( ) : boolean {
260
+ isStreamsEmpty ( ) : boolean {
233
261
if ( this . streamDefinitions ) {
234
262
if ( this . streamDefinitions . totalPages < 2 ) {
235
263
return ( this . params . q === '' && this . streamDefinitions . items . length === 0 ) ;
0 commit comments