UNPKG

@microsoft/windows-admin-center-sdk

Version:

Microsoft - Windows Admin Center Shell

1 lines 5.5 kB
{"version":3,"sources":["../../../packages/core/notification/notification-connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,UAAU,EAAE,MAAM,MAAM,CAAC;AAGxC,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAA0B,MAAM,uBAAuB,CAAC;AACnF,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD;;GAEG;AACH,qBAAa,sBAAsB;IAQnB,OAAO,CAAC,GAAG;IAPhB,mBAAmB,EAAE,mBAAmB,CAAC;IAEhD;;;;OAIG;gBACiB,GAAG,EAAE,GAAG;IAO5B;;;;;OAKG;IACI,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,0BAA0B;IAI3D;;;;;OAKG;IACI,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,kBAAkB,GAAG,UAAU,CAAC,GAAG,CAAC;IAgBlF;;;;;;OAMG;IACI,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,kBAAkB,EAAE,KAAK,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM;IAMvH;;;;;;;;;;;;;OAaG;IACI,KAAK,CACR,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,iBAAiB,EACxB,OAAO,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC;CA0BvC","file":"notification-connection.d.ts","sourcesContent":["import { from, Observable } from 'rxjs';\r\nimport { RpcNotificationClient } from '../rpc/notification/rpc-notification-client';\r\nimport { RpcNotification } from '../rpc/notification/rpc-notification-model';\r\nimport { Rpc } from '../rpc/rpc';\r\nimport { ClientNotification, ClientNotificationType } from './client-notification';\r\nimport { ClientNotificationInstance } from './client-notification-instance';\r\nimport { NotificationManager } from './notification-manager';\r\nimport { NotificationState } from './notification-state';\r\n\r\n/**\r\n * Notification connection class.\r\n */\r\nexport class NotificationConnection {\r\n public notificationManager: NotificationManager;\r\n\r\n /**\r\n * Initializes a new instance of the NotificationConnection class.\r\n *\r\n * @param rpc the RPC object.\r\n */\r\n constructor(private rpc: Rpc) {\r\n // create only if we are running in the shell window.\r\n if (MsftSme.isShell()) {\r\n this.notificationManager = new NotificationManager(this.rpc);\r\n }\r\n }\r\n\r\n /**\r\n * Create a new client notification instance.\r\n *\r\n * @param nodeName the node name. it should set node name of current action connection or gateway name.\r\n * Only shell code could set the node name be null if notification action against shell generic task.\r\n */\r\n public create(nodeName: string): ClientNotificationInstance {\r\n return new ClientNotificationInstance(this, nodeName);\r\n }\r\n\r\n /**\r\n * Send a client notification and an alert either directly to NotificationManager or through RPC.\r\n *\r\n * @param nodeName the node name.\r\n * @param notification the client notification object.\r\n */\r\n public notify(nodeName: string, notification: ClientNotification): Observable<any> {\r\n const data: RpcNotification = {\r\n ...notification,\r\n ...{\r\n nodeName: nodeName,\r\n timestamp: Date.now()\r\n }\r\n };\r\n\r\n if (this.notificationManager) {\r\n return this.notificationManager.notify(data);\r\n }\r\n\r\n return from(RpcNotificationClient.notify(this.rpc, data));\r\n }\r\n\r\n /**\r\n * send updated notification with new message and state\r\n * @param nodeName the node name\r\n * @param state the new notification state\r\n * @param message the new message\r\n * @param notification the existing notification\r\n */\r\n public updateNotification(nodeName: string, notification: ClientNotification, state: NotificationState, message: string) {\r\n notification.message = message;\r\n notification.state = state;\r\n this.notify(nodeName, notification);\r\n }\r\n\r\n /**\r\n * @deprecated\r\n *\r\n * Send an alert bar based client notification either directly to NotificationManager or through RPC.\r\n *\r\n * Please use create(), ClientNotificationInstance class or notify() instead.\r\n * Recommend to use create() or ClientNotificationInstance class which allows to display in-progress state of notification,\r\n * and properly set title, message and supported state.\r\n *\r\n * @param nodeName the node name of alert source.\r\n * @param state the notification state.\r\n * @param message the message of alert bar.\r\n * @param title the title of alert bar.\r\n */\r\n public alert(\r\n nodeName: string,\r\n state: NotificationState,\r\n message: string,\r\n title?: string): Observable<any> {\r\n const global: MsftSme.SMEWindow = <any>window;\r\n const notification: ClientNotification = {\r\n id: MsftSme.getUniqueId(),\r\n state: state,\r\n message: message,\r\n title: title,\r\n link: null,\r\n description: null,\r\n type: ClientNotificationType.NotificationCenter\r\n };\r\n const data: RpcNotification = {\r\n ...notification,\r\n ...{\r\n sourceName: global.MsftSme.Environment.name,\r\n nodeName: nodeName,\r\n timestamp: Date.now()\r\n }\r\n };\r\n\r\n if (this.notificationManager) {\r\n return this.notificationManager.notify(data);\r\n }\r\n\r\n return from(RpcNotificationClient.notify(this.rpc, data));\r\n }\r\n}\r\n"]}