Skip to content

Commit 6ccb58f

Browse files
authored
Merge pull request #23 from NeoScript/view_attributes
Ability to view attributes
2 parents e74e777 + 61754f1 commit 6ccb58f

File tree

2 files changed

+47
-45
lines changed

2 files changed

+47
-45
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,40 @@
11
@if (this.details|async; as subscription) {
2-
<div class="content">
3-
<h3>Subscription Details</h3>
4-
<div class="header">
5-
<div id="path">path: {{subscription.name}}</div>
6-
<div id="topic">topic: {{subscription.topic}}</div>
7-
<button id="pullMessagesBtn" mat-raised-button color="primary" (click)="this.pullMessages()">
8-
Pull Messages
9-
<mat-icon matSuffix>download</mat-icon>
10-
</button>
11-
</div>
12-
<div class="message-pane">
13-
<div>Messages Received: {{this.messages.length}}</div>
14-
@if (this.messages) {
15-
<table class="message-table mat-table">
16-
<thead>
17-
<tr>
18-
<th>Timestamp</th>
19-
<th>Message</th>
20-
<th>Ack</th>
21-
</tr>
22-
</thead>
23-
<tbody>
24-
@for (msg of this.messages; track msg) {
25-
<tr class="pubsub-message">
26-
<td>{{msg.message.publishTime | date : "long"}}</td>
27-
<td>{{msg.message.data}}</td>
28-
<td>
29-
<button mat-button color="warn" (click)="this.ackMessage(msg.ackId)">Ack</button>
30-
</td>
31-
</tr>
32-
}
33-
</tbody>
34-
</table>
35-
}
36-
</div>
2+
<div class="content">
3+
<h3>Subscription Details</h3>
4+
<div class="header">
5+
<div id="path">path: {{subscription.name}}</div>
6+
<div id="topic">topic: {{subscription.topic}}</div>
7+
<button id="pullMessagesBtn" mat-raised-button color="primary" (click)="this.pullMessages()">
8+
Pull Messages
9+
<mat-icon matSuffix>download</mat-icon>
10+
</button>
3711
</div>
38-
}
12+
<div class="message-pane">
13+
<div>Messages Received: {{this.messages.length}}</div>
14+
@if (this.messages) {
15+
<table class="message-table mat-table">
16+
<thead>
17+
<tr>
18+
<th>Timestamp</th>
19+
<th>Message</th>
20+
<th>Attributes</th>
21+
<th>Ack</th>
22+
</tr>
23+
</thead>
24+
<tbody>
25+
@for (msg of this.messages; track msg) {
26+
<tr class="pubsub-message">
27+
<td>{{msg.message.publishTime | date : "long"}}</td>
28+
<td>{{msg.message.data}}</td>
29+
<td>{{msg.message.attributes | json}}</td>
30+
<td>
31+
<button mat-button color="warn" (click)="this.ackMessage(msg.ackId)">Ack</button>
32+
</td>
33+
</tr>
34+
}
35+
</tbody>
36+
</table>
37+
}
38+
</div>
39+
</div>
40+
}

webapp/src/app/components/subscription-details/subscription-details.component.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import { Component, Input, OnInit, inject } from '@angular/core';
22
import { EMPTY, firstValueFrom, map, Observable } from 'rxjs';
33
import { PubsubService, ReceivedMessage, Subscription } from 'src/app/services/pubsub.service';
4-
import { AsyncPipe, DatePipe } from '@angular/common';
4+
import { AsyncPipe, DatePipe, JsonPipe } from '@angular/common';
55
import { MatButton } from '@angular/material/button';
66
import { MatIcon } from '@angular/material/icon';
77
import { MatSuffix } from '@angular/material/form-field';
88

99
@Component({
10-
selector: 'app-subscription-details',
11-
templateUrl: './subscription-details.component.html',
12-
styleUrls: ['./subscription-details.component.scss'],
13-
standalone: true,
14-
imports: [MatButton, MatIcon, MatSuffix, AsyncPipe, DatePipe]
10+
selector: 'app-subscription-details',
11+
templateUrl: './subscription-details.component.html',
12+
styleUrls: ['./subscription-details.component.scss'],
13+
standalone: true,
14+
imports: [MatButton, MatIcon, MatSuffix, AsyncPipe, DatePipe, JsonPipe]
1515
})
1616
export class SubscriptionDetailsComponent implements OnInit {
1717
private pubsub = inject(PubsubService);
@@ -50,11 +50,11 @@ export class SubscriptionDetailsComponent implements OnInit {
5050
console.log('called with', data)
5151
}
5252

53-
async ackMessage(ackId: string){
53+
async ackMessage(ackId: string) {
5454
const result = await firstValueFrom(this.pubsub.ackMessage(this.subscriptionPath!, [ackId]))
5555
console.log("result", result)
56-
57-
if(Object.keys(result).length == 0){ // a valid response will be no content
56+
57+
if (Object.keys(result).length == 0) { // a valid response will be no content
5858
this.messages = this.messages.filter(msg => msg.ackId != ackId)
5959
}
6060
}

0 commit comments

Comments
 (0)