UI: Change ws command to new format and change API uri
This commit is contained in:
parent
31f95fbe62
commit
6b4c7c7ce4
@ -22,14 +22,12 @@ import {
|
||||
AlarmDataCmd,
|
||||
AlarmDataUnsubscribeCmd,
|
||||
AlarmDataUpdate,
|
||||
AttributesSubscriptionCmd,
|
||||
EntityCountCmd,
|
||||
EntityCountUnsubscribeCmd,
|
||||
EntityCountUpdate,
|
||||
EntityDataCmd,
|
||||
EntityDataUnsubscribeCmd,
|
||||
EntityDataUpdate,
|
||||
GetHistoryCmd,
|
||||
isAlarmCountUpdateMsg,
|
||||
isAlarmDataUpdateMsg,
|
||||
isEntityCountUpdateMsg,
|
||||
@ -38,10 +36,8 @@ import {
|
||||
NotificationsUpdate,
|
||||
SubscriptionCmd,
|
||||
SubscriptionUpdate,
|
||||
TelemetryFeature,
|
||||
TelemetryPluginCmdsWrapper,
|
||||
TelemetrySubscriber,
|
||||
TimeseriesSubscriptionCmd,
|
||||
WebsocketDataMsg
|
||||
} from '@app/shared/models/telemetry/telemetry.models';
|
||||
import { Store } from '@ngrx/store';
|
||||
@ -72,7 +68,7 @@ export class TelemetryWebsocketService extends WebsocketService<TelemetrySubscri
|
||||
protected authService: AuthService,
|
||||
protected ngZone: NgZone,
|
||||
@Inject(WINDOW) protected window: Window) {
|
||||
super(store, authService, ngZone, 'api/ws/plugins/telemetry', new TelemetryPluginCmdsWrapper(), window);
|
||||
super(store, authService, ngZone, 'api/ws', new TelemetryPluginCmdsWrapper(), window);
|
||||
}
|
||||
|
||||
public subscribe(subscriber: TelemetrySubscriber) {
|
||||
@ -80,35 +76,11 @@ export class TelemetryWebsocketService extends WebsocketService<TelemetrySubscri
|
||||
subscriber.subscriptionCommands.forEach(
|
||||
(subscriptionCommand) => {
|
||||
const cmdId = this.nextCmdId();
|
||||
if (!(subscriptionCommand instanceof MarkAsReadCmd) && !(subscriptionCommand instanceof MarkAllAsReadCmd)) {
|
||||
this.subscribersMap.set(cmdId, subscriber);
|
||||
}
|
||||
subscriptionCommand.cmdId = cmdId;
|
||||
if (subscriptionCommand instanceof SubscriptionCmd) {
|
||||
if (subscriptionCommand.getType() === TelemetryFeature.TIMESERIES) {
|
||||
this.cmdWrapper.tsSubCmds.push(subscriptionCommand as TimeseriesSubscriptionCmd);
|
||||
} else {
|
||||
this.cmdWrapper.attrSubCmds.push(subscriptionCommand as AttributesSubscriptionCmd);
|
||||
}
|
||||
} else if (subscriptionCommand instanceof GetHistoryCmd) {
|
||||
this.cmdWrapper.historyCmds.push(subscriptionCommand);
|
||||
} else if (subscriptionCommand instanceof EntityDataCmd) {
|
||||
this.cmdWrapper.entityDataCmds.push(subscriptionCommand);
|
||||
} else if (subscriptionCommand instanceof AlarmDataCmd) {
|
||||
this.cmdWrapper.alarmDataCmds.push(subscriptionCommand);
|
||||
} else if (subscriptionCommand instanceof EntityCountCmd) {
|
||||
this.cmdWrapper.entityCountCmds.push(subscriptionCommand);
|
||||
} else if (subscriptionCommand instanceof AlarmCountCmd) {
|
||||
this.cmdWrapper.alarmCountCmds.push(subscriptionCommand);
|
||||
} else if (subscriptionCommand instanceof UnreadCountSubCmd) {
|
||||
this.cmdWrapper.unreadNotificationsCountSubCmds.push(subscriptionCommand);
|
||||
} else if (subscriptionCommand instanceof UnreadSubCmd) {
|
||||
this.cmdWrapper.unreadNotificationsSubCmds.push(subscriptionCommand);
|
||||
} else if (subscriptionCommand instanceof MarkAsReadCmd) {
|
||||
this.cmdWrapper.markNotificationAsReadCmds.push(subscriptionCommand);
|
||||
this.subscribersMap.delete(cmdId);
|
||||
} else if (subscriptionCommand instanceof MarkAllAsReadCmd) {
|
||||
this.cmdWrapper.markAllNotificationsAsReadCmds.push(subscriptionCommand);
|
||||
this.subscribersMap.delete(cmdId);
|
||||
}
|
||||
this.cmdWrapper.cmds.push(subscriptionCommand);
|
||||
}
|
||||
);
|
||||
this.subscribersCount++;
|
||||
@ -119,10 +91,8 @@ export class TelemetryWebsocketService extends WebsocketService<TelemetrySubscri
|
||||
if (!this.isReconnect) {
|
||||
subscriber.subscriptionCommands.forEach(
|
||||
(subscriptionCommand) => {
|
||||
if (subscriptionCommand.cmdId && subscriptionCommand instanceof EntityDataCmd) {
|
||||
this.cmdWrapper.entityDataCmds.push(subscriptionCommand);
|
||||
} else if (subscriptionCommand.cmdId && subscriptionCommand instanceof UnreadSubCmd) {
|
||||
this.cmdWrapper.unreadNotificationsSubCmds.push(subscriptionCommand);
|
||||
if (subscriptionCommand.cmdId && (subscriptionCommand instanceof EntityDataCmd || subscriptionCommand instanceof UnreadSubCmd)) {
|
||||
this.cmdWrapper.cmds.push(subscriptionCommand);
|
||||
}
|
||||
}
|
||||
);
|
||||
@ -136,31 +106,27 @@ export class TelemetryWebsocketService extends WebsocketService<TelemetrySubscri
|
||||
(subscriptionCommand) => {
|
||||
if (subscriptionCommand instanceof SubscriptionCmd) {
|
||||
subscriptionCommand.unsubscribe = true;
|
||||
if (subscriptionCommand.getType() === TelemetryFeature.TIMESERIES) {
|
||||
this.cmdWrapper.tsSubCmds.push(subscriptionCommand as TimeseriesSubscriptionCmd);
|
||||
} else {
|
||||
this.cmdWrapper.attrSubCmds.push(subscriptionCommand as AttributesSubscriptionCmd);
|
||||
}
|
||||
this.cmdWrapper.cmds.push(subscriptionCommand);
|
||||
} else if (subscriptionCommand instanceof EntityDataCmd) {
|
||||
const entityDataUnsubscribeCmd = new EntityDataUnsubscribeCmd();
|
||||
entityDataUnsubscribeCmd.cmdId = subscriptionCommand.cmdId;
|
||||
this.cmdWrapper.entityDataUnsubscribeCmds.push(entityDataUnsubscribeCmd);
|
||||
this.cmdWrapper.cmds.push(entityDataUnsubscribeCmd);
|
||||
} else if (subscriptionCommand instanceof AlarmDataCmd) {
|
||||
const alarmDataUnsubscribeCmd = new AlarmDataUnsubscribeCmd();
|
||||
alarmDataUnsubscribeCmd.cmdId = subscriptionCommand.cmdId;
|
||||
this.cmdWrapper.alarmDataUnsubscribeCmds.push(alarmDataUnsubscribeCmd);
|
||||
this.cmdWrapper.cmds.push(alarmDataUnsubscribeCmd);
|
||||
} else if (subscriptionCommand instanceof EntityCountCmd) {
|
||||
const entityCountUnsubscribeCmd = new EntityCountUnsubscribeCmd();
|
||||
entityCountUnsubscribeCmd.cmdId = subscriptionCommand.cmdId;
|
||||
this.cmdWrapper.entityCountUnsubscribeCmds.push(entityCountUnsubscribeCmd);
|
||||
this.cmdWrapper.cmds.push(entityCountUnsubscribeCmd);
|
||||
} else if (subscriptionCommand instanceof AlarmCountCmd) {
|
||||
const alarmCountUnsubscribeCmd = new AlarmCountUnsubscribeCmd();
|
||||
alarmCountUnsubscribeCmd.cmdId = subscriptionCommand.cmdId;
|
||||
this.cmdWrapper.alarmCountUnsubscribeCmds.push(alarmCountUnsubscribeCmd);
|
||||
this.cmdWrapper.cmds.push(alarmCountUnsubscribeCmd);
|
||||
} else if (subscriptionCommand instanceof UnreadCountSubCmd || subscriptionCommand instanceof UnreadSubCmd) {
|
||||
const notificationsUnsubCmds = new UnsubscribeCmd();
|
||||
notificationsUnsubCmds.cmdId = subscriptionCommand.cmdId;
|
||||
this.cmdWrapper.notificationsUnsubCmds.push(notificationsUnsubCmds);
|
||||
this.cmdWrapper.cmds.push(notificationsUnsubCmds);
|
||||
}
|
||||
const cmdId = subscriptionCommand.cmdId;
|
||||
if (cmdId) {
|
||||
|
||||
@ -38,15 +38,7 @@ import { entityFields } from '@shared/models/entity.models';
|
||||
import { isUndefined } from '@core/utils';
|
||||
import { CmdWrapper, WsSubscriber } from '@shared/models/websocket/websocket.models';
|
||||
import { TelemetryWebsocketService } from '@core/ws/telemetry-websocket.service';
|
||||
import {
|
||||
MarkAllAsReadCmd,
|
||||
MarkAsReadCmd,
|
||||
NotificationCountUpdateMsg,
|
||||
NotificationsUpdateMsg,
|
||||
UnreadCountSubCmd,
|
||||
UnreadSubCmd,
|
||||
UnsubscribeCmd
|
||||
} from '@shared/models/websocket/notification-ws.models';
|
||||
import { NotificationCountUpdateMsg, NotificationsUpdateMsg } from '@shared/models/websocket/notification-ws.models';
|
||||
import { Notification } from '@shared/models/notification.models';
|
||||
|
||||
export const NOT_SUPPORTED = 'Not supported!';
|
||||
@ -70,11 +62,6 @@ export enum AttributeScope {
|
||||
SHARED_SCOPE = 'SHARED_SCOPE'
|
||||
}
|
||||
|
||||
export enum TelemetryFeature {
|
||||
ATTRIBUTES = 'ATTRIBUTES',
|
||||
TIMESERIES = 'TIMESERIES'
|
||||
}
|
||||
|
||||
export enum TimeseriesDeleteStrategy {
|
||||
DELETE_ALL_DATA = 'DELETE_ALL_DATA',
|
||||
DELETE_ALL_DATA_EXCEPT_LATEST_VALUE = 'DELETE_ALL_DATA_EXCEPT_LATEST_VALUE',
|
||||
@ -134,8 +121,30 @@ export enum DataSortOrder {
|
||||
DESC = 'DESC'
|
||||
}
|
||||
|
||||
export enum WsCmdType {
|
||||
ATTRIBUTES = 'ATTRIBUTES',
|
||||
TIMESERIES = 'TIMESERIES',
|
||||
TIMESERIES_HISTORY = 'TIMESERIES_HISTORY',
|
||||
ENTITY_DATA = 'ENTITY_DATA',
|
||||
ENTITY_COUNT = 'ENTITY_COUNT',
|
||||
ALARM_DATA = 'ALARM_DATA',
|
||||
ALARM_COUNT = 'ALARM_COUNT',
|
||||
|
||||
NOTIFICATIONS = 'NOTIFICATIONS',
|
||||
NOTIFICATIONS_COUNT = 'NOTIFICATIONS_COUNT',
|
||||
MARK_NOTIFICATIONS_AS_READ = 'MARK_NOTIFICATIONS_AS_READ',
|
||||
MARK_ALL_NOTIFICATIONS_AS_READ = 'MARK_ALL_NOTIFICATIONS_AS_READ',
|
||||
|
||||
ALARM_DATA_UNSUBSCRIBE = 'ALARM_DATA_UNSUBSCRIBE',
|
||||
ALARM_COUNT_UNSUBSCRIBE = 'ALARM_COUNT_UNSUBSCRIBE',
|
||||
ENTITY_DATA_UNSUBSCRIBE = 'ENTITY_DATA_UNSUBSCRIBE',
|
||||
ENTITY_COUNT_UNSUBSCRIBE = 'ENTITY_COUNT_UNSUBSCRIBE',
|
||||
NOTIFICATIONS_UNSUBSCRIBE = 'NOTIFICATIONS_UNSUBSCRIBE'
|
||||
}
|
||||
|
||||
export interface WebsocketCmd {
|
||||
cmdId: number;
|
||||
type: WsCmdType;
|
||||
}
|
||||
|
||||
export interface TelemetryPluginCmd extends WebsocketCmd {
|
||||
@ -149,13 +158,11 @@ export abstract class SubscriptionCmd implements TelemetryPluginCmd {
|
||||
entityId: string;
|
||||
scope?: AttributeScope;
|
||||
unsubscribe: boolean;
|
||||
abstract getType(): TelemetryFeature;
|
||||
abstract type: WsCmdType;
|
||||
}
|
||||
|
||||
export class AttributesSubscriptionCmd extends SubscriptionCmd {
|
||||
getType() {
|
||||
return TelemetryFeature.ATTRIBUTES;
|
||||
}
|
||||
type = WsCmdType.ATTRIBUTES;
|
||||
}
|
||||
|
||||
export class TimeseriesSubscriptionCmd extends SubscriptionCmd {
|
||||
@ -164,10 +171,7 @@ export class TimeseriesSubscriptionCmd extends SubscriptionCmd {
|
||||
interval: number;
|
||||
limit: number;
|
||||
agg: AggregationType;
|
||||
|
||||
getType() {
|
||||
return TelemetryFeature.TIMESERIES;
|
||||
}
|
||||
type = WsCmdType.TIMESERIES;
|
||||
}
|
||||
|
||||
export class GetHistoryCmd implements TelemetryPluginCmd {
|
||||
@ -180,6 +184,7 @@ export class GetHistoryCmd implements TelemetryPluginCmd {
|
||||
interval: number;
|
||||
limit: number;
|
||||
agg: AggregationType;
|
||||
type = WsCmdType.TIMESERIES_HISTORY;
|
||||
}
|
||||
|
||||
export interface EntityHistoryCmd {
|
||||
@ -235,6 +240,7 @@ export class EntityDataCmd implements WebsocketCmd {
|
||||
tsCmd?: TimeSeriesCmd;
|
||||
aggHistoryCmd?: AggEntityHistoryCmd;
|
||||
aggTsCmd?: AggTimeSeriesCmd;
|
||||
type = WsCmdType.ENTITY_DATA;
|
||||
|
||||
public isEmpty(): boolean {
|
||||
return !this.query && !this.historyCmd && !this.latestCmd && !this.tsCmd && !this.aggTsCmd && !this.aggHistoryCmd;
|
||||
@ -244,11 +250,13 @@ export class EntityDataCmd implements WebsocketCmd {
|
||||
export class EntityCountCmd implements WebsocketCmd {
|
||||
cmdId: number;
|
||||
query?: EntityCountQuery;
|
||||
type = WsCmdType.ENTITY_COUNT;
|
||||
}
|
||||
|
||||
export class AlarmDataCmd implements WebsocketCmd {
|
||||
cmdId: number;
|
||||
query?: AlarmDataQuery;
|
||||
type = WsCmdType.ALARM_DATA;
|
||||
|
||||
public isEmpty(): boolean {
|
||||
return !this.query;
|
||||
@ -258,60 +266,36 @@ export class AlarmDataCmd implements WebsocketCmd {
|
||||
export class AlarmCountCmd implements WebsocketCmd {
|
||||
cmdId: number;
|
||||
query?: AlarmCountQuery;
|
||||
type = WsCmdType.ALARM_COUNT;
|
||||
}
|
||||
|
||||
export class EntityDataUnsubscribeCmd implements WebsocketCmd {
|
||||
cmdId: number;
|
||||
type = WsCmdType.ENTITY_DATA_UNSUBSCRIBE;
|
||||
}
|
||||
|
||||
export class EntityCountUnsubscribeCmd implements WebsocketCmd {
|
||||
cmdId: number;
|
||||
type = WsCmdType.ENTITY_COUNT_UNSUBSCRIBE;
|
||||
}
|
||||
|
||||
export class AlarmDataUnsubscribeCmd implements WebsocketCmd {
|
||||
cmdId: number;
|
||||
type = WsCmdType.ALARM_DATA_UNSUBSCRIBE;
|
||||
}
|
||||
|
||||
export class AlarmCountUnsubscribeCmd implements WebsocketCmd {
|
||||
cmdId: number;
|
||||
type = WsCmdType.ALARM_COUNT_UNSUBSCRIBE;
|
||||
}
|
||||
|
||||
export class TelemetryPluginCmdsWrapper implements CmdWrapper {
|
||||
|
||||
constructor() {
|
||||
this.attrSubCmds = [];
|
||||
this.tsSubCmds = [];
|
||||
this.historyCmds = [];
|
||||
this.entityDataCmds = [];
|
||||
this.entityDataUnsubscribeCmds = [];
|
||||
this.alarmDataCmds = [];
|
||||
this.alarmDataUnsubscribeCmds = [];
|
||||
this.entityCountCmds = [];
|
||||
this.entityCountUnsubscribeCmds = [];
|
||||
this.alarmCountCmds = [];
|
||||
this.alarmCountUnsubscribeCmds = [];
|
||||
this.unreadNotificationsCountSubCmds = [];
|
||||
this.unreadNotificationsSubCmds = [];
|
||||
this.notificationsUnsubCmds = [];
|
||||
this.markNotificationAsReadCmds = [];
|
||||
this.markAllNotificationsAsReadCmds = [];
|
||||
this.cmds = [];
|
||||
}
|
||||
attrSubCmds: Array<AttributesSubscriptionCmd>;
|
||||
tsSubCmds: Array<TimeseriesSubscriptionCmd>;
|
||||
historyCmds: Array<GetHistoryCmd>;
|
||||
entityDataCmds: Array<EntityDataCmd>;
|
||||
entityDataUnsubscribeCmds: Array<EntityDataUnsubscribeCmd>;
|
||||
alarmDataCmds: Array<AlarmDataCmd>;
|
||||
alarmDataUnsubscribeCmds: Array<AlarmDataUnsubscribeCmd>;
|
||||
entityCountCmds: Array<EntityCountCmd>;
|
||||
entityCountUnsubscribeCmds: Array<EntityCountUnsubscribeCmd>;
|
||||
alarmCountCmds: Array<AlarmCountCmd>;
|
||||
alarmCountUnsubscribeCmds: Array<AlarmCountUnsubscribeCmd>;
|
||||
unreadNotificationsCountSubCmds: Array<UnreadCountSubCmd>;
|
||||
unreadNotificationsSubCmds: Array<UnreadSubCmd>;
|
||||
notificationsUnsubCmds: Array<UnsubscribeCmd>;
|
||||
markNotificationAsReadCmds: Array<MarkAsReadCmd>;
|
||||
markAllNotificationsAsReadCmds: Array<MarkAllAsReadCmd>;
|
||||
|
||||
cmds: Array<WebsocketCmd>;
|
||||
|
||||
private static popCmds<T>(cmds: Array<T>, leftCount: number): Array<T> {
|
||||
const toPublish = Math.min(cmds.length, leftCount);
|
||||
@ -323,77 +307,16 @@ export class TelemetryPluginCmdsWrapper implements CmdWrapper {
|
||||
}
|
||||
|
||||
public hasCommands(): boolean {
|
||||
return this.tsSubCmds.length > 0 ||
|
||||
this.historyCmds.length > 0 ||
|
||||
this.attrSubCmds.length > 0 ||
|
||||
this.entityDataCmds.length > 0 ||
|
||||
this.entityDataUnsubscribeCmds.length > 0 ||
|
||||
this.alarmDataCmds.length > 0 ||
|
||||
this.alarmDataUnsubscribeCmds.length > 0 ||
|
||||
this.entityCountCmds.length > 0 ||
|
||||
this.entityCountUnsubscribeCmds.length > 0 ||
|
||||
this.alarmCountCmds.length > 0 ||
|
||||
this.alarmCountUnsubscribeCmds.length > 0 ||
|
||||
this.unreadNotificationsCountSubCmds.length > 0 ||
|
||||
this.unreadNotificationsSubCmds.length > 0 ||
|
||||
this.notificationsUnsubCmds.length > 0 ||
|
||||
this.markNotificationAsReadCmds.length > 0 ||
|
||||
this.markAllNotificationsAsReadCmds.length > 0;
|
||||
return this.cmds.length > 0;
|
||||
}
|
||||
|
||||
public clear() {
|
||||
this.attrSubCmds.length = 0;
|
||||
this.tsSubCmds.length = 0;
|
||||
this.historyCmds.length = 0;
|
||||
this.entityDataCmds.length = 0;
|
||||
this.entityDataUnsubscribeCmds.length = 0;
|
||||
this.alarmDataCmds.length = 0;
|
||||
this.alarmDataUnsubscribeCmds.length = 0;
|
||||
this.entityCountCmds.length = 0;
|
||||
this.entityCountUnsubscribeCmds.length = 0;
|
||||
this.alarmCountCmds.length = 0;
|
||||
this.alarmCountUnsubscribeCmds.length = 0;
|
||||
this.unreadNotificationsSubCmds.length = 0;
|
||||
this.unreadNotificationsCountSubCmds.length = 0;
|
||||
this.notificationsUnsubCmds.length = 0;
|
||||
this.markNotificationAsReadCmds.length = 0;
|
||||
this.markAllNotificationsAsReadCmds.length = 0;
|
||||
this.cmds.length = 0;
|
||||
}
|
||||
|
||||
public preparePublishCommands(maxCommands: number): TelemetryPluginCmdsWrapper {
|
||||
const preparedWrapper = new TelemetryPluginCmdsWrapper();
|
||||
let leftCount = maxCommands;
|
||||
preparedWrapper.tsSubCmds = TelemetryPluginCmdsWrapper.popCmds(this.tsSubCmds, leftCount);
|
||||
leftCount -= preparedWrapper.tsSubCmds.length;
|
||||
preparedWrapper.historyCmds = TelemetryPluginCmdsWrapper.popCmds(this.historyCmds, leftCount);
|
||||
leftCount -= preparedWrapper.historyCmds.length;
|
||||
preparedWrapper.attrSubCmds = TelemetryPluginCmdsWrapper.popCmds(this.attrSubCmds, leftCount);
|
||||
leftCount -= preparedWrapper.attrSubCmds.length;
|
||||
preparedWrapper.entityDataCmds = TelemetryPluginCmdsWrapper.popCmds(this.entityDataCmds, leftCount);
|
||||
leftCount -= preparedWrapper.entityDataCmds.length;
|
||||
preparedWrapper.entityDataUnsubscribeCmds = TelemetryPluginCmdsWrapper.popCmds(this.entityDataUnsubscribeCmds, leftCount);
|
||||
leftCount -= preparedWrapper.entityDataUnsubscribeCmds.length;
|
||||
preparedWrapper.alarmDataCmds = TelemetryPluginCmdsWrapper.popCmds(this.alarmDataCmds, leftCount);
|
||||
leftCount -= preparedWrapper.alarmDataCmds.length;
|
||||
preparedWrapper.alarmDataUnsubscribeCmds = TelemetryPluginCmdsWrapper.popCmds(this.alarmDataUnsubscribeCmds, leftCount);
|
||||
leftCount -= preparedWrapper.alarmDataUnsubscribeCmds.length;
|
||||
preparedWrapper.entityCountCmds = TelemetryPluginCmdsWrapper.popCmds(this.entityCountCmds, leftCount);
|
||||
leftCount -= preparedWrapper.entityCountCmds.length;
|
||||
preparedWrapper.entityCountUnsubscribeCmds = TelemetryPluginCmdsWrapper.popCmds(this.entityCountUnsubscribeCmds, leftCount);
|
||||
leftCount -= preparedWrapper.entityCountUnsubscribeCmds.length;
|
||||
preparedWrapper.alarmCountCmds = TelemetryPluginCmdsWrapper.popCmds(this.alarmCountCmds, leftCount);
|
||||
leftCount -= preparedWrapper.alarmCountCmds.length;
|
||||
preparedWrapper.alarmCountUnsubscribeCmds = TelemetryPluginCmdsWrapper.popCmds(this.alarmCountUnsubscribeCmds, leftCount);
|
||||
leftCount -= preparedWrapper.unreadNotificationsSubCmds.length;
|
||||
preparedWrapper.unreadNotificationsSubCmds = TelemetryPluginCmdsWrapper.popCmds(this.unreadNotificationsSubCmds, leftCount);
|
||||
leftCount -= preparedWrapper.unreadNotificationsCountSubCmds.length;
|
||||
preparedWrapper.unreadNotificationsCountSubCmds = TelemetryPluginCmdsWrapper.popCmds(this.unreadNotificationsCountSubCmds, leftCount);
|
||||
leftCount -= preparedWrapper.notificationsUnsubCmds.length;
|
||||
preparedWrapper.notificationsUnsubCmds = TelemetryPluginCmdsWrapper.popCmds(this.notificationsUnsubCmds, leftCount);
|
||||
leftCount -= preparedWrapper.markNotificationAsReadCmds.length;
|
||||
preparedWrapper.markNotificationAsReadCmds = TelemetryPluginCmdsWrapper.popCmds(this.markNotificationAsReadCmds, leftCount);
|
||||
leftCount -= preparedWrapper.markAllNotificationsAsReadCmds.length;
|
||||
preparedWrapper.markAllNotificationsAsReadCmds = TelemetryPluginCmdsWrapper.popCmds(this.markAllNotificationsAsReadCmds, leftCount);
|
||||
preparedWrapper.cmds = TelemetryPluginCmdsWrapper.popCmds(this.cmds, maxCommands);
|
||||
return preparedWrapper;
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,7 +20,8 @@ import {
|
||||
NotificationCountUpdate,
|
||||
NotificationsUpdate,
|
||||
WebsocketCmd,
|
||||
WebsocketDataMsg
|
||||
WebsocketDataMsg,
|
||||
WsCmdType
|
||||
} from '@shared/models/telemetry/telemetry.models';
|
||||
import { NgZone } from '@angular/core';
|
||||
import { isDefinedAndNotNull } from '@core/utils';
|
||||
@ -127,11 +128,13 @@ export class NotificationSubscriber extends WsSubscriber {
|
||||
|
||||
export class UnreadCountSubCmd implements WebsocketCmd {
|
||||
cmdId: number;
|
||||
type = WsCmdType.NOTIFICATIONS_COUNT;
|
||||
}
|
||||
|
||||
export class UnreadSubCmd implements WebsocketCmd {
|
||||
limit: number;
|
||||
cmdId: number;
|
||||
type = WsCmdType.NOTIFICATIONS;
|
||||
|
||||
constructor(limit = 10) {
|
||||
this.limit = limit;
|
||||
@ -140,12 +143,14 @@ export class UnreadSubCmd implements WebsocketCmd {
|
||||
|
||||
export class UnsubscribeCmd implements WebsocketCmd {
|
||||
cmdId: number;
|
||||
type = WsCmdType.NOTIFICATIONS_UNSUBSCRIBE;
|
||||
}
|
||||
|
||||
export class MarkAsReadCmd implements WebsocketCmd {
|
||||
|
||||
cmdId: number;
|
||||
notifications: string[];
|
||||
type = WsCmdType.MARK_NOTIFICATIONS_AS_READ;
|
||||
|
||||
constructor(ids: string[]) {
|
||||
this.notifications = ids;
|
||||
@ -154,6 +159,7 @@ export class MarkAsReadCmd implements WebsocketCmd {
|
||||
|
||||
export class MarkAllAsReadCmd implements WebsocketCmd {
|
||||
cmdId: number;
|
||||
type = WsCmdType.MARK_ALL_NOTIFICATIONS_AS_READ;
|
||||
}
|
||||
|
||||
export interface NotificationCountUpdateMsg extends CmdUpdateMsg {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user