Skip to content

Commit

Permalink
correctly handle complex data in message headers; fixes #143
Browse files Browse the repository at this point in the history
  • Loading branch information
rikimaru0345 committed Nov 16, 2020
1 parent 2d24361 commit a898483
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 17 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Master / unreleased

## 1.2.1 / 2020-11-16
- [ENHANCEMENT] Message headers can be expanded/collapsed now
- [BUGFIX] Kowl now handles message headers containing structured data (JSON) correctly

## 1.2.0 / 2020-11-14

- **[FEATURE] Embed topic documentation using Markdown files from Git repositories ([/docs/features/topic-documentation.md](/docs/features/topic-documentation.md))**
Expand Down
2 changes: 1 addition & 1 deletion docs/local/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ services:
- zoo1

kowl:
image: quay.io/cloudhut/kowl:v1.2.0
image: quay.io/cloudhut/kowl:v1.2.1
restart: on-failure
hostname: kowl
volumes:
Expand Down
20 changes: 15 additions & 5 deletions frontend/src/components/pages/topics/Tab.Messages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ class MessagePreview extends Component<{ msg: TopicMessage, previewFields: () =>

function RenderExpandedMessage(msg: TopicMessage, shouldExpand?: ((x: CollapsedFieldProps) => boolean)) {
return <div>
{(msg.headers.length > 0) && RenderMessageHeaders(msg)}
{(msg.headers.length > 0) && <MessageHeaders msg={msg} />}
<div>{RenderMessageValue(msg, shouldExpand)}</div>
</div>
}
Expand Down Expand Up @@ -836,14 +836,24 @@ function RenderMessageValue(msg: TopicMessage, shouldExpand?: ((x: CollapsedFiel
}
}

function RenderMessageHeaders(msg: TopicMessage) {
const MessageHeaders = observer((props: { msg: TopicMessage }) => {
const headers = props.msg.headers
const jsonHeaders = headers.map(h => ({
key: ToJson(h.key),
value: ToJson(h.value),
valueEncoding: ToJson(h.valueEncoding)
}));
const showHeaders = uiState.topicSettings.showMessageHeaders;
const titleText = (showHeaders ? "Hide" : "Show") + " Message Headers";
return <div className='messageHeaders'>
<div className='title'>Message Headers</div>
{QuickTable(msg.headers, {
<div className='title'>
<span className='titleBtn' onClick={() => uiState.topicSettings.showMessageHeaders = !showHeaders}>{titleText}</span>
</div>
{showHeaders && QuickTable(jsonHeaders, {
tableStyle: { width: 'auto', paddingLeft: '1em' },
})}
</div>
}
});

@observer
class PreviewSettings extends Component<{ allCurrentKeys: string[], getShowDialog: () => boolean, setShowDialog: (show: boolean) => void }> {
Expand Down
29 changes: 25 additions & 4 deletions frontend/src/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1301,19 +1301,40 @@ svg {
}

.messageHeaders {
margin-bottom: 2em;
margin-bottom: 1.5em;
margin-top: .5em;
padding-bottom: 1em;
padding-bottom: .5em;
border-bottom: 1px solid #ddd;

.title {
padding-bottom: 8px;
padding-bottom: 6px;
font-family: "Open Sans", sans-serif;
font-size: 11px;
font-weight: 600;
// padding-left: 2px;
color: hsla(0, 0%, 50%, 1);
cursor: default;

.titleBtn {
border: 1px solid transparent;
padding: 3px 6px;
border-radius: 3px;

cursor: pointer;
user-select: none;

transition: background-color 80ms ease-out, border-color 80ms ease-out, color 80ms ease-out;

&:hover {
color: hsl(205, 100%, 50%);
background-color: hsla(0, 0%, 100%, 0.85);
border-color: hsla(205, 100%, 50%, 1);
}
}
}

.quickTable {
margin-bottom: .5rem;
margin-top: .5rem;
}

.keyCell {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/state/backendApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import {
GetTopicsResponse, TopicDetail, GetConsumerGroupsResponse, GroupDescription, UserData,
TopicConfigEntry, ClusterInfo, TopicMessage, TopicConfigResponse,
ClusterInfoResponse, GetPartitionsResponse, Partition, GetTopicConsumersResponse, TopicConsumer, AdminInfo, TopicPermissions, ClusterConfigResponse, ClusterConfig, TopicDocumentationResponse, AclRequest, AclResponse, AclResource, SchemaOverview, SchemaOverviewRequestError, SchemaOverviewResponse, SchemaDetailsResponse, SchemaDetails
ClusterInfoResponse, GetPartitionsResponse, Partition, GetTopicConsumersResponse, TopicConsumer, AdminInfo, TopicPermissions, ClusterConfigResponse, ClusterConfig, TopicDocumentationResponse, AclRequest, AclResponse, AclResource, SchemaOverview, SchemaOverviewRequestError, SchemaOverviewResponse, SchemaDetailsResponse, SchemaDetails
} from "./restInterfaces";
import { observable, autorun, computed, action, transaction, decorate, extendObservable } from "mobx";
import fetchWithTimeout from "../utils/fetchWithTimeout";
import { ToJson, LazyMap, TimeSince } from "../utils/utils";
import { ToJson, LazyMap, TimeSince, clone } from "../utils/utils";
import { IsDev, IsBusiness, basePathS } from "../utils/env";
import { appGlobal } from "./appGlobal";
import { uiState } from "./uiState";
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/state/restInterfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ export interface TopicMessage {
key: any, // base64 encoded key of the message

headers: {
key: string,
value: string,
key: string | object,
value: string | object,
valueEncoding: MessageDataType // for now: always text
}[]

Expand Down
7 changes: 4 additions & 3 deletions frontend/src/state/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ const settingsName = 'uiSettings-v3';


/*
todo:
- remember UI settings using local storage
- topic: message filter, display settings, ...
todo:
- remember UI settings using local storage
- topic: message filter, display settings, ...
*/

export interface PreviewTag {
Expand Down Expand Up @@ -81,6 +81,7 @@ export class TopicDetailsSettings {
@observable previewShowResultCount = false;
// @observable previewResultLimit: 3; // todo
@observable previewShowEmptyMessages = true; // todo: filter out messages that don't match
@observable showMessageHeaders = false;

@observable previewTimestamps = 'default' as TimestampDisplayFormat;
@observable previewColumnFields = [] as ColumnList[];
Expand Down

0 comments on commit a898483

Please sign in to comment.