Skip to content
This repository was archived by the owner on May 14, 2025. It is now read-only.

Commit 70e7da2

Browse files
oodamienghillert
authored andcommitted
Stream list: wording
Resole #706
1 parent 104d817 commit 70e7da2

File tree

3 files changed

+57
-13
lines changed

3 files changed

+57
-13
lines changed

ui/src/app/streams/streams/streams.component.html

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div id="streams-list">
22

33
<div class="heading">
4-
<div class="actions hidden visible-md-block visible-lg-block" *ngIf="!isAppsEmpty()" [appRoles]="['ROLE_CREATE']">
4+
<div class="actions hidden visible-md-block visible-lg-block" *ngIf="!isStreamsEmpty()" [appRoles]="['ROLE_CREATE']">
55
<a class="btn btn-primary" routerLink="create">Create Stream(s)</a>
66
</div>
77
<div class="description">
@@ -12,7 +12,7 @@ <h1 class="no-user-selection">Streams</h1>
1212
</div>
1313
</div>
1414

15-
<div id="filters" class="pui-filter" *ngIf="!isAppsEmpty()">
15+
<div id="filters" class="pui-filter" *ngIf="!isStreamsEmpty()">
1616
<form #registerAppsForm="ngForm" name="registerAppsForm" role="form" (ngSubmit)="search()" novalidate>
1717

1818
<div class="pui-filter-center">
@@ -178,20 +178,32 @@ <h1 class="no-user-selection">Streams</h1>
178178

179179
<div *ngIf="streamDefinitions" id="empty">
180180

181-
<div *ngIf="isAppsEmpty()" class="text-center">
182-
<div class="alert alert-warning" style="display:inline-block;margin:0 auto">
183-
<strong>No registered apps.</strong>
181+
<div *ngIf="isStreamsEmpty()" class="text-center">
182+
<div class="alert alert-warning" style="display:inline-block;margin:0 auto" *ngIf="!noApplicationRegister">
183+
<strong>No Streams exist, yet.</strong>
184184
<div [appRoles]="['ROLE_CREATE']">
185-
<p>You can register apps by clicking:</p>
185+
<p>You can create streams by clicking:</p>
186186
<a routerLink="create" class="btn btn-primary">
187187
Create a stream
188188
</a>
189189
</div>
190190
</div>
191+
<div class="alert alert-warning" style="display:inline-block;margin:0 auto" *ngIf="noApplicationRegister">
192+
<strong>No Streams exist and no registered apps.</strong>
193+
<div [appRoles]="['ROLE_CREATE']">
194+
<p>You can register apps by clicking:</p>
195+
<a routerLink="/apps/register-apps" class="btn btn-primary">
196+
Register Application(s)
197+
</a>
198+
<a routerLink="/apps/bulk-import-apps" class="btn btn-primary">
199+
Bulk Import Application(s)
200+
</a>
201+
</div>
202+
</div>
191203
</div>
192204

193205
<div id="no-result" class="row"
194-
*ngIf="!isAppsEmpty() && streamDefinitions.totalPages < 2 && streamDefinitions.items.length == 0">
206+
*ngIf="!isStreamsEmpty() && streamDefinitions.totalPages < 2 && streamDefinitions.items.length == 0">
195207
<div class="col-md-8"></div>
196208
<div class="col-md-8">
197209
<div class="alert alert-warning" style="border:0 none;padding: 1.5rem 2rem;">

ui/src/app/streams/streams/streams.component.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ import { StreamGraphDefinitionComponent } from '../components/stream-graph-defin
3535
import { TruncatePipe } from '../../shared/pipes/truncate.pipe';
3636
import { BusyService } from '../../shared/services/busy.service';
3737
import { MockModalService } from '../../tests/mocks/modal';
38+
import { AppsService } from '../../apps/apps.service';
39+
import { MockAppsService } from '../../tests/mocks/apps';
3840

3941
/**
4042
* Test {@link StreamsComponent}.
@@ -49,6 +51,7 @@ describe('StreamsComponent', () => {
4951
const streamsService = new MockStreamsService();
5052
const authService = new MockAuthService();
5153
const modalService = new MockModalService();
54+
const appsService = new MockAppsService();
5255

5356
beforeEach(async(() => {
5457
const aboutService = new MocksSharedAboutService();
@@ -85,6 +88,7 @@ describe('StreamsComponent', () => {
8588
],
8689
providers: [
8790
{ provide: SharedAboutService, useValue: aboutService },
91+
{ provide: AppsService, useValue: appsService },
8892
{ provide: AuthService, useValue: authService },
8993
{ provide: BusyService, useValue: new BusyService() },
9094
{ provide: StreamsService, useValue: streamsService },

ui/src/app/streams/streams/streams.component.ts

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ import { SortParams, OrderParams } from '../../shared/components/shared.interfac
1414
import { IntervalObservable } from 'rxjs/observable/IntervalObservable';
1515
import { StreamListParams } from '../components/streams.interface';
1616
import { Subject } from 'rxjs/Subject';
17-
import { takeUntil } from 'rxjs/operators';
17+
import { mergeMap, takeUntil } from 'rxjs/operators';
1818
import { BusyService } from '../../shared/services/busy.service';
19+
import { AppsService } from '../../apps/apps.service';
20+
import { AppRegistration } from '../../shared/model/app-registration.model';
1921

2022
@Component({
2123
selector: 'app-streams',
@@ -82,6 +84,11 @@ export class StreamsComponent implements OnInit, OnDestroy {
8284
q: ''
8385
};
8486

87+
/**
88+
* State of application register empty
89+
*/
90+
noApplicationRegister: boolean;
91+
8592
/**
8693
* Contain a key application of each selected application
8794
* @type {Array}
@@ -104,12 +111,14 @@ export class StreamsComponent implements OnInit, OnDestroy {
104111
*
105112
* @param {StreamsService} streamsService
106113
* @param {BsModalService} modalService
114+
* @param {AppsService} appsService
107115
* @param {BusyService} busyService
108116
* @param {ToastyService} toastyService
109117
* @param {Router} router
110118
*/
111119
constructor(public streamsService: StreamsService,
112120
private modalService: BsModalService,
121+
private appsService: AppsService,
113122
private busyService: BusyService,
114123
private toastyService: ToastyService,
115124
private router: Router) {
@@ -146,7 +155,8 @@ export class StreamsComponent implements OnInit, OnDestroy {
146155
refresh() {
147156
console.log('Loading Stream Definitions...', this.params);
148157
const busy = this.streamsService
149-
.getDefinitions(this.params).map((page: Page<StreamDefinition>) => {
158+
.getDefinitions(this.params)
159+
.map((page: Page<StreamDefinition>) => {
150160
this.form.checkboxes = page.items.map((stream) => {
151161
return this.itemsSelected.indexOf(stream.name) > -1;
152162
});
@@ -155,14 +165,32 @@ export class StreamsComponent implements OnInit, OnDestroy {
155165
});
156166
return page;
157167
})
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+
)
158185
.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) {
161188
this.params.page = 0;
162189
this.refresh();
163190
return;
164191
}
165-
this.streamDefinitions = page;
192+
this.noApplicationRegister = !(value.apps.totalElements > 0);
193+
this.streamDefinitions = value.streams;
166194
this.changeExpand();
167195
this.changeCheckboxes();
168196
this.updateContext();
@@ -229,7 +257,7 @@ export class StreamsComponent implements OnInit, OnDestroy {
229257
/**
230258
* Determine if there is no application
231259
*/
232-
isAppsEmpty(): boolean {
260+
isStreamsEmpty(): boolean {
233261
if (this.streamDefinitions) {
234262
if (this.streamDefinitions.totalPages < 2) {
235263
return (this.params.q === '' && this.streamDefinitions.items.length === 0);

0 commit comments

Comments
 (0)