This package has been deprecated

Author message:

This package has deprecated in favor of @itwin/imodel-browser-react

@bentley/imodel-select-ui
TypeScript icon, indicating that this package has built-in type declarations

1.0.7 • Public • Published

imodel-selector-ui

Copyright © Bentley Systems, Incorporated. All rights reserved.

The imodel-selector-ui provides UI components to select an iModel or a project on iModelHub.

Sample deployments

Selecting an iModel in iModelHub

Just assign the IModelSelect component with its callback functions

this.reactElement = <IModelSelect onIModelSelected={this._onSelectIModel} showSignoutButton={true} />;

This frontstage example assumes sign-in has already been completed

  /*---------------------------------------------------------------------------------------------
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
  * Licensed under the MIT License. See LICENSE.md in the project root for license terms.
  *--------------------------------------------------------------------------------------------*/
  import * as React from "react";
  import {
    CoreTools, ContentGroup, ContentControl,
    ConfigurableCreateInfo, FrontstageProvider, FrontstageProps,
    Frontstage, IModelInfo, UiFramework,
  } from "@bentley/ui-framework";
  import { IModelSelect } from "@bentley/imodel-select-ui";
  import { remote } from "electron";

  class IModelSelectControl extends ContentControl {
    constructor(info: ConfigurableCreateInfo, options: any) {
      super(info, options);

      this.reactElement = <IModelSelect onIModelSelected={this._onSelectIModel} showSignoutButton={true} />;
    }

    // called when an imodel has been selected on the IModelSelect
    private _onSelectIModel = async (iModelInfo: IModelInfo) => {

      const accessToken = UiFramework.getAccessToken();
      const jsonData = {
        token: accessToken,
        project: iModelInfo.projectInfo.wsgId,
        model: iModelInfo.wsgId,
      };
      // log data to stdout and exit with success (0)
      const dataStr: string = JSON.stringify(jsonData);
      const con = remote.getGlobal("console");
      con.log(dataStr);

      window.close();
      return process.exit(0);
      }
  }

  export class IModelSelectFrontstage extends FrontstageProvider {

    public get frontstage(): React.ReactElement<FrontstageProps> {
      const contentGroup: ContentGroup = new ContentGroup({
        contents: [
          {
            classId: IModelSelectControl,
          },
        ],
      });

      return (
        <Frontstage id="IModelSelect"
          defaultTool={CoreTools.selectElementCommand}
          defaultLayout="SingleContent"
          contentGroup={contentGroup}
          isInFooterMode={false}
        />
      );
    }
  }

Selecting a Project in iModelHub

Just assign the ProjectSelect component with its callback functions

this.reactElement = <ProjectSelect onClose={this._onCloseProjectDialog} onProjectSelected={this._onSelectProject} />;

This frontstage example assumes sign-in has been completed

  /*---------------------------------------------------------------------------------------------
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
  * Licensed under the MIT License. See LICENSE.md in the project root for license terms.
  *--------------------------------------------------------------------------------------------*/
  import * as React from "react";
  import { remote } from "electron";
  import {
    CoreTools, ContentGroup, ContentControl,
    ConfigurableCreateInfo, FrontstageProvider, FrontstageProps,
    Frontstage, ProjectInfo, UiFramework,
  } from "@bentley/ui-framework";
  import { ProjectSelect } from "@bentley/imodel-select-ui";


  class ProjectSelectControl extends ContentControl {
    constructor(info: ConfigurableCreateInfo, options: any) {
      super(info, options);

      // Assign the ProjectSelect component with its callback functions
      this.reactElement = <ProjectSelect onClose={this._onCloseProjectDialog} onProjectSelected={this._onSelectProject} />;
    }

    // called when a project has been selected
    private _onSelectProject = async (projectInfo: ProjectInfo) => {
      const accessToken = UiFramework.getAccessToken();
      const jsonData = {
        token: accessToken,
        project: projectInfo.wsgId
      };
      // log data to stdout and exit with success (0)
      const dataStr: string = JSON.stringify(jsonData);
      const con = remote.getGlobal("console");
      con.log(dataStr);

      window.close();
      return process.exit(0);
    }

    // called when the project dialog is closed
    private _onCloseProjectDialog = () => {
      window.close();
      return process.exit(0);
    }  
  }

  export class ProjectSelectFrontstage extends FrontstageProvider {

    public get frontstage(): React.ReactElement<FrontstageProps> {
      const contentGroup: ContentGroup = new ContentGroup({
        contents: [
          {
            classId: ProjectSelectControl,
          },
        ],
      });

      return (
        <Frontstage id="ProjectSelect"
          defaultTool={CoreTools.selectElementCommand}
          defaultLayout="SingleContent"
          contentGroup={contentGroup}
          isInFooterMode={false}
        />
      );
    }
  }

Package Sidebar

Install

npm i @bentley/imodel-select-ui

Weekly Downloads

4

Version

1.0.7

License

MIT

Unpacked Size

204 kB

Total Files

38

Last publish

Collaborators

  • aruniverse
  • colinkerr
  • cshafer
  • imodeljs
  • wgoehrig