Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
iconSpec: "icon-placeholder", labelKey: "SampleApp:buttons.restoreContentLayout", badgeType: BadgeType.New, execute: async () => {
const iModelConnection = UiFramework.getIModelConnection();
if (ViewsFrontstage.savedViewLayoutProps && iModelConnection) {
// Parse SavedViewLayoutProps
const savedViewLayoutProps: SavedViewLayoutProps = JSON.parse(ViewsFrontstage.savedViewLayoutProps);
// Create ContentLayoutDef
const contentLayoutDef = new ContentLayoutDef(savedViewLayoutProps.contentLayoutProps);
// Create ViewStates
const viewStates = await SavedViewLayout.viewStatesFromProps(iModelConnection, savedViewLayoutProps);
// Add applicationData to the ContentProps
savedViewLayoutProps.contentGroupProps.contents.forEach((contentProps: ContentProps, index: number) => {
contentProps.applicationData = { viewState: viewStates[index], iModelConnection, rulesetId: "Items" };
});
const contentGroup = new ContentGroup(savedViewLayoutProps.contentGroupProps);
// activate the layout
await ContentLayoutManager.setActiveLayout(contentLayoutDef, contentGroup);
public static async showIModelIndex(contextId: string, iModelId: string) {
const currentConnection = UiFramework.getIModelConnection();
if (!currentConnection || (currentConnection.iModelToken.iModelId !== iModelId)) {
// Close the current iModelConnection
await SampleAppIModelApp.closeCurrentIModel();
// open the imodel
Logger.logInfo(SampleAppIModelApp.loggerCategory(this), `showIModelIndex: projectId=${contextId}&iModelId=${iModelId}`);
const iModelConnection = await UiFramework.iModelServices.openIModel(contextId, iModelId);
SampleAppIModelApp.setIsIModelLocal(false, true);
SyncUiEventDispatcher.initializeConnectionEvents(iModelConnection);
// store the IModelConnection in the sample app store
UiFramework.setIModelConnection(iModelConnection, true);
}
await SampleAppIModelApp.showFrontstage("IModelIndex");
constructor(info: ConfigurableCreateInfo, options: any) {
super(info, options);
const iModelConnection = UiFramework.getIModelConnection();
if (iModelConnection && UiFramework.oidcClient && UiFramework.oidcClient.isAuthorized)
this.reactElement = ;
else
this.reactElement = null;
}
constructor(info: ConfigurableCreateInfo, options: any) {
super(info, options);
const _iModelConnection = UiFramework.getIModelConnection();
if (_iModelConnection)
this.reactElement = { this.viewport = v; }} />;
else
this.reactElement = null;
}
}
public static async closeCurrentIModel() {
const currentIModelConnection = UiFramework.getIModelConnection();
if (currentIModelConnection) {
SyncUiEventDispatcher.clearConnectionEvents(currentIModelConnection);
if (SampleAppIModelApp.isIModelLocal)
await currentIModelConnection.closeSnapshot();
else
await currentIModelConnection.close();
UiFramework.setIModelConnection(undefined);
}
}
constructor(info: ConfigurableCreateInfo, options: any) {
super(info, options);
if (UiFramework.getIModelConnection())
this.reactElement = ;
else
this.reactElement = null;
}
}
constructor(info: ConfigurableCreateInfo, options: any) {
super(info, options);
if (UiFramework.getIModelConnection())
this.reactElement = ;
else
this.reactElement = null;
}
}
constructor(info: ConfigurableCreateInfo, options: any) {
super(info, options);
if (UiFramework.getIModelConnection())
this.reactElement = ;
else
this.reactElement = null;
}
}
private _onOpen = async (viewIds: Id64String[]) => {
const iModelConnection = UiFramework.getIModelConnection();
if (iModelConnection) {
const contextId = iModelConnection.iModelToken.contextId!;
const iModelId = iModelConnection.iModelToken.iModelId!;
await SampleAppIModelApp.openIModelAndViews(contextId, iModelId, viewIds);
}
}
}