Skip to content

editorGlobalsWebsiteContext

Class: WebsiteContext

Offers methods relevant for integrating the editor with the kyub website and its API. Takes care of preparing the HttpRequest to correctly authenticate the user.

Hierarchy

  • WebsiteContext

Index

Constructors

Properties

Methods

Constructors

constructor

+ new WebsiteContext(editor: Editor): WebsiteContext

Defined in src/WebsiteContext.ts:58

Parameters:

Name Type
editor Editor

Returns: WebsiteContext

Properties

Private accessToken

accessToken: string | null = null

Defined in src/WebsiteContext.ts:47


Private apiClient

apiClient: ApiClient‹› = new ApiClient(Config.get("general.apiRoot", "/"))

Defined in src/WebsiteContext.ts:52


Private editor

editor: any

Defined in src/WebsiteContext.ts:53


Private impersonationToken

impersonationToken: string | null = null

Defined in src/WebsiteContext.ts:48


notifyWebsiteOfChangedModel

notifyWebsiteOfChangedModel: DebouncedFunc‹(Anonymous function)› = throttle(() => { this._postMessageParent({ event: "unsaved" }); }, 500)

Defined in src/WebsiteContext.ts:43


Private profileImagePromise

profileImagePromise: Promise‹Blob› = null

Defined in src/WebsiteContext.ts:50


Private queryWebsiteDialogShowing

queryWebsiteDialogShowing: DebouncedFunc‹(Anonymous function)› = throttle( () => this._postMessageParent({ event: "isWebsiteDialogShowing" }), 1000, )

Defined in src/WebsiteContext.ts:55


Private roundedProfileImageBuffer

roundedProfileImageBuffer: ArrayBuffer = null

Defined in src/WebsiteContext.ts:51


Private userProfile

userProfile: IUserProfile = null

Defined in src/WebsiteContext.ts:49


Private websiteDialogIsShowing

websiteDialogIsShowing: boolean = false

Defined in src/WebsiteContext.ts:54

Methods

Private _getAccessToken

_getAccessToken(): string | null

Defined in src/WebsiteContext.ts:208

Returns: string | null

either the token this user uses to impersonates somebody else, or the user's original token if the user currently isn't impersonating anyone


Private _getLatestAssetReference

_getLatestAssetReference(modelProjectId: string): Promise‹any›

Defined in src/WebsiteContext.ts:268

Parameters:

Name Type
modelProjectId string

Returns: Promise‹any›


Private _importAssets

_importAssets(assetIds: string[]): void

Defined in src/WebsiteContext.ts:255

Parameters:

Name Type
assetIds string[]

Returns: void


Private _importModels

_importModels(modelIds: string[]): void

Defined in src/WebsiteContext.ts:249

Parameters:

Name Type
modelIds string[]

Returns: void


Private _initializeFromLocalStorage

_initializeFromLocalStorage(): void

Defined in src/WebsiteContext.ts:187

Returns: void


Private _onWindowMessage

_onWindowMessage(messageEvent: MessageEvent): void

Defined in src/WebsiteContext.ts:216

Parameters:

Name Type
messageEvent MessageEvent

Returns: void


Private _postMessageParent

_postMessageParentT›(message: T): void

Defined in src/WebsiteContext.ts:180

Type parameters:

T: IWindowMessage

Parameters:

Name Type
message T

Returns: void


getCapability

getCapability(capabilityName: string): Promise‹boolean›

Defined in src/WebsiteContext.ts:120

Parameters:

Name Type
capabilityName string

Returns: Promise‹boolean›


getDatabaseRepresentativeForMaterial

getDatabaseRepresentativeForMaterial(materialType: string, materialThickness: number): Promise‹any›

Defined in src/WebsiteContext.ts:135

Parameters:

Name Type
materialType string
materialThickness number

Returns: Promise‹any›


getModel

getModel(): Promise‹any›

Defined in src/WebsiteContext.ts:139

Returns: Promise‹any›


getProfileImage

getProfileImage(): Promise‹null | Blob›

Defined in src/WebsiteContext.ts:77

Returns: Promise‹null | Blob›


getProfileImageBuffer

getProfileImageBuffer(): Promise‹ArrayBuffer | null›

Defined in src/WebsiteContext.ts:97

Returns: Promise‹ArrayBuffer | null›


getReachableTools

getReachableTools(): Promise‹string[]›

Defined in src/WebsiteContext.ts:132

Returns: Promise‹string[]›


getRoundedProfileImageBuffer

getRoundedProfileImageBuffer(): Promise‹ArrayBuffer›

Defined in src/WebsiteContext.ts:112

Returns: Promise‹ArrayBuffer›


getUserDisabledTools

getUserDisabledTools(modelId: string): Promise‹string[]›

Defined in src/WebsiteContext.ts:128

Parameters:

Name Type
modelId string

Returns: Promise‹string[]›


getUserProfile

getUserProfile(): IUserProfile

Defined in src/WebsiteContext.ts:73

Returns: IUserProfile


isLoggedIn

isLoggedIn(): boolean

Defined in src/WebsiteContext.ts:69

Returns: boolean


isWebsiteDialogShowing

isWebsiteDialogShowing(): boolean

Defined in src/WebsiteContext.ts:170

"Website dialog" could be the modal that is shown to import kyub models into the current project.

Returns: boolean


notifyWebsiteCloseImportModelsModal

notifyWebsiteCloseImportModelsModal(): void

Defined in src/WebsiteContext.ts:162

Returns: void


notifyWebsiteOfNewModel

notifyWebsiteOfNewModel(modelId: string): void

Defined in src/WebsiteContext.ts:149

If the editor saved the website as a new model, tell the website, so that the globally visible URL is changed to the new ID

Parameters:

Name Type Description
modelId string -

Returns: void


notifyWebsiteOfSavedModel

notifyWebsiteOfSavedModel(): void

Defined in src/WebsiteContext.ts:153

Returns: void


notifyWebsiteOpenImportModelsModal

notifyWebsiteOpenImportModelsModal(importAssets: boolean): void

Defined in src/WebsiteContext.ts:157

Parameters:

Name Type Default
importAssets boolean false

Returns: void


userMayModifyModel

userMayModifyModel(userId: string, modelId: string): Promise‹boolean›

Defined in src/WebsiteContext.ts:124

Parameters:

Name Type
userId string
modelId string

Returns: Promise‹boolean›


Static getInstance

getInstance(editor?: Editor): WebsiteContext‹›

Defined in src/WebsiteContext.ts:33

Parameters:

Name Type
editor? Editor

Returns: WebsiteContext‹›