Skip to content

Commit

Permalink
ws-client update messages cols width + counter of published props
Browse files Browse the repository at this point in the history
  • Loading branch information
deaflynx committed Mar 29, 2024
1 parent c3954dc commit 244c2a6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ import { ContentType, MediaBreakpoints } from '@shared/models/constants';
import { MatDialog } from '@angular/material/dialog';
import { WsQoSTranslationMap } from '@shared/models/session.model';
import { isDefinedAndNotNull } from '@core/utils';
import { PublishMessageProperties, WsClientMessageTypeTranslationMap, WsTableMessage } from '@shared/models/ws-client.model';
import {
isDefinedProps,
PublishMessageProperties,
WsClientMessageTypeTranslationMap,
WsTableMessage
} from '@shared/models/ws-client.model';
import { MqttJsClientService } from '@core/http/mqtt-js-client.service';
import {
WsMessageContentDialogComponentDialogData,
Expand Down Expand Up @@ -78,11 +83,11 @@ export class MessagesTableConfig extends EntityTableConfig<WsTableMessage> {
return this.translate.instant(WsClientMessageTypeTranslationMap.get(messageReceived));
}),
new DateEntityTableColumn<WsTableMessage>('createdTime', 'common.time', this.datePipe, '150px'),
new EntityTableColumn<WsTableMessage>('topic', 'retained-message.topic', this.colWidth(), entity => entity.topic,
new EntityTableColumn<WsTableMessage>('topic', 'retained-message.topic', '100%', entity => entity.topic,
undefined, undefined, undefined, (entity) => entity.topic),
new EntityTableColumn<WsTableMessage>('qos', 'retained-message.qos', '50%', entity => entity.qos.toString(),
new EntityTableColumn<WsTableMessage>('qos', 'retained-message.qos', '50px', entity => entity.qos.toString(),
undefined, undefined, undefined, (entity) => this.translate.instant(WsQoSTranslationMap.get(entity.qos))),
new EntityTableColumn<WsTableMessage>('retain', 'ws-client.messages.retained', '50%',
new EntityTableColumn<WsTableMessage>('retain', 'ws-client.messages.retained', '50px',
entity => entity.retain ? cellWithBackground('True', 'rgba(0, 0, 0, 0.08)') : ''
),
new EntityTableColumn<WsTableMessage>('payload', 'retained-message.payload', this.colWidth(), (entity) => {
Expand Down Expand Up @@ -115,7 +120,7 @@ export class MessagesTableConfig extends EntityTableConfig<WsTableMessage> {
{
name: this.translate.instant('ws-client.connections.properties'),
icon: 'mdi:information-outline',
isEnabled: (entity) => isDefinedAndNotNull(entity.properties),
isEnabled: (entity) => isDefinedProps(entity.properties),
onAction: ($event, entity) => this.showPayloadProperties($event, entity.properties)
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
TimeUnitTypeTranslationMap,
WebSocketConnection,
AboveSecWebSocketTimeUnit,
countNonNullProps
isDefinedProps
} from '@shared/models/ws-client.model';
import { MqttJsClientService } from '@core/http/mqtt-js-client.service';

Expand Down Expand Up @@ -104,7 +104,7 @@ export class WsPublishMessagePropertiesDialogComponent extends DialogComponent<W

onSave() {
const properties = this.formGroup.getRawValue();
properties.changed = countNonNullProps(properties) > 1;
properties.changed = isDefinedProps(properties);
this.dialogRef.close(properties);
}

Expand Down
6 changes: 3 additions & 3 deletions ui-ngx/src/app/shared/models/ws-client.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,14 +300,14 @@ export const colorRandom = () => {
const randomIndex = Math.floor(Math.random() * colorPresetsHex.length);
return colorPresetsHex[randomIndex];
}
export const countNonNullProps = (obj: any): number => {
export const isDefinedProps = (obj: any): boolean => {
let count = 0;
for (let key in obj) {
if (obj[key] !== null && obj[key] !== '') {
if (obj[key] !== null && obj[key] !== '' && key !== 'messageExpiryIntervalUnit') {
count++;
}
}
return count;
return count > 0;
}

export const MessageFilterDefaultConfigAll: MessageFilterConfig = {
Expand Down

0 comments on commit 244c2a6

Please sign in to comment.