@microsoft/windows-admin-center-sdk
Version:
Microsoft - Windows Admin Center Shell
222 lines (221 loc) • 6.54 kB
TypeScript
import { RpcNotification } from '../rpc/notification/rpc-notification-model';
import { RpcWorkItem } from '../rpc/work-item/rpc-work-item-model';
import { NotificationLinkType } from './notification-link-type';
import { IFrameService } from './notification-manager';
import { NotificationMessage } from './notification-message';
import { NotificationState } from './notification-state';
import { PowerShellWorkItemMessage } from './powershell-notification';
import { SocketMessage } from './socket-signalr';
import { RecoveredWorkItem } from './work-item-request';
/**
* Notification changed event type.
*/
export declare enum NotificationChangeEvent {
Initialized = 0,
InitializationFailed = 1,
Add = 2,
Remove = 3,
Change = 4
}
/**
* Notification changed event packet.
*/
export interface NotificationEvent {
changeEvent: NotificationChangeEvent;
notification?: Notification;
}
/**
* Internal notification object converted from ClientNotification object.
* Contains data to track notifications.
*/
export declare class Notification {
id: string;
private strings;
/**
* Work item passed from RPC or client on shell.
*/
private workItem;
/**
* The type ID of work item.
*/
typeId: string;
/**
* The node name.
*/
nodeName: string;
/**
* The module name.
*/
moduleName: string;
/**
* The entry point name within the module
*/
entryPointName: string;
/**
* The module display name.
*/
moduleDisplayName: string;
/**
* Object included last response.
*/
object: any;
/**
* The state of notification.
*/
state: NotificationState;
/**
* The title of work item to display user. (localized)
*/
title: string;
/**
* @depracated
* The description of work item to display user. (localized)
*/
description: string;
/**
* The message. (localized)
*/
message: string;
/**
* Possible solution message to address error. (localized)
*/
solutionMessage: string;
/**
* True if the notification was created from recover, updates from messages should be taken
*/
isFromRecover: boolean;
/**
* True if the notification is disabled and should not be shown to the user
*/
isDisabled: boolean;
/**
* The start timestamp as a formatted globalized string
*/
startTimestamp: string;
/**
* The last changed timestamp as a formatted globalized string
*/
changedTimestamp: string;
/**
* The last changed timestamp as a number
*/
changedTimestampValue: number;
/**
* The end timestamp as a formatted globalized string
*/
endTimestamp: string;
/**
* The progress percent.
*/
progressPercent: number;
/**
* The success link to navigate to the object view. (optional)
* At default, it brings to the home page of the module.
*/
link: string;
/**
* the notification link type of the link
*/
linkType: NotificationLinkType;
/**
* True if we should show the link in the notification's alert
* We will show the link if there is a custom link or it is a long running request
*/
showLinkInAlert: boolean;
/**
* Marked it's no longer display to include list of notifications.
*/
dismissed: boolean;
/**
* The parent URI window.location.pathname.
*/
locationPathname: string;
/**
* The parent URI window.location.search
*/
locationSearch: string;
/**
*
* Tracks if the notification has been read.
*/
isUnread: boolean;
/**
* Create notification from WorkItem.
*
* @param id the notification ID.
* @param workItem the RPC work item.
* @param state the initial state.
* @param object the object from query result.
* @return notification the notification object.
*/
static createFromWorkItem(id: string, workItem: RpcWorkItem, state: NotificationState, iFrameService: IFrameService, object?: any): Notification;
/**
* Create notification from recovered work item.
*
* @param recoveredWorkItem the recovered work item.
* @return notification the notification object.
*/
static createFromRecover(recoveredWorkItem: RecoveredWorkItem, iFrameService: IFrameService): Notification;
/**
* Create notification from instant request.
*
* @param client the RPC notification request.
* @return notification the notification object.
*/
static createFromClient(client: RpcNotification, iFrameService: IFrameService): Notification;
/**
* Initializes a new instance of the Notification class.
*
* @param id the notification ID.
*/
constructor(id: string);
/**
* Update a notification by work item from RPC.
* @param id the notification id.
* @param workItem the work item.
* @param state the state of the notification.
* @param object the object from query result.
*/
updateFromWorkItem(id: string, workItem: RpcWorkItem, state: NotificationState, object?: any): boolean;
/**
* Update the notification by socket message from the gateway.
*
* @param item the socket message.
* @return boolean the changed status.
*/
updateFromMessage(item: SocketMessage<PowerShellWorkItemMessage>): boolean;
/**
* Update the notification by socket message from the gateway.
*
* @param state the state of notification.
* @param item the socket message.
* @return boolean the changed status.
*/
updateFromNotificationMessage(state: NotificationState, item: NotificationMessage): boolean;
/**
* Update the notification by instant notification message from the client.
*
* @param client the instant notification object.
* @param boolean the changed status.
*/
updateFromClient(client: RpcNotification): boolean;
/**
* Gets the module display name.
*/
private getModuleDisplayName;
/**
* Update the state.
*
* @param state the new state.
* @return boolean the changed state.
*/
private updateState;
private initializeFromWorkItem;
private updateMessageAndLinkAndTitle;
private initializeFromInstant;
private getGlobalizedTimestamp;
private formatLink;
private formatMessage;
private findParameters;
private replaceParameters;
}