GithubHelp home page GithubHelp logo

simple-viewer-app's Introduction

Simple Viewer App

NOTE: This repository has been archived and all future updates will be made in the iModel.js Samples repository.

Copyright © 2019 Bentley Systems, Incorporated. All rights reserved.

An iModel.js sample application that demonstrates opening an iModel and viewing its data. The data is presented using the following components:

  • Viewport: Renders geometric data onto an HTMLCanvasElement.
  • Tree: Displays a hierarchical view of iModel contents.
  • Property Grid: Displays properties of selected element(s).
  • Table: Displays element properties in a tabular format.

This app serves as a guide on how you can embed one or more of these components into your own application. See http://imodeljs.org for comprehensive documentation on the iModel.js API and the various constructs used in this sample.

Development Setup

  1. Get the required tools and ensure you have Node.js 10.x LTS installed on your machine.

  2. (Optional) Create a sample project using the procedure at Developer Registration. This step is not needed if you already have a project to test with.

  3. (Recommended) Register your application at Developer Registration.

    For the purpose of running this sample on localhost, ensure your registration includes http://localhost:3000/signin-callback as a valid redirect URI.

    If you would like to run this sample in electron, another application should be registered which includes electron://frontend/signin-callback as a valid redirect URI.

    Note: If you are just testing on localhost you can use the default registration included in this sample. However, it's recommended that you complete the registration, especially since registration is a requirement before the application can be deployed. For more information, see the section on authorization.

  4. Edit src/common/configuration.ts and src/common/config.json to set the values you obtain from the registration process.

  5. Install the dependencies

npm install
  1. Build the application
npm run build
  1. There are two servers, a web server that delivers the static web resources (the frontend Javascript, localizable strings, fonts, cursors, etc.), and the backend RPC server that opens the iModel on behalf of the application. Start them both running locally:
npm run start:servers
  1. Open a web browser (e.g., Chrome or Edge), and browse to localhost:3000.

Screenshot of the application

Testing

Run both e2e and unit tests with npm test

End-to-end tests

You can run just end-to-end tests with npm run test:e2e. But it takes a while to build and start the tests, so if want to actively change something within them, first launch the app with npm run test:e2e:start-app and when it's done npm run test:e2e:test-app

If you want to see what tests do behind the scenes, you can launch them in non headless mode. Edit the file in ./test/end-to-end/setupTests.ts and add

{ headless: false }

to puppeteer launch options. Like this

before(async () => {
  browser = await Puppeteer.launch({ headless: false });
});

Unit tests

Run with npm run test:unit

Purpose

The purpose of this application is to demonstrate the following:

Contributing

Contributing to iModel.js

simple-viewer-app's People

Contributors

imodeljs-admin avatar williamkbentley avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

simple-viewer-app's Issues

unable to build iModel mobile backend

unable to build iModel mobile backend

command used to build backend :
"npm run build:mobile-backend"

ERROR in ./node_modules/opener/lib/opener.js
Module not found: Error: Can't resolve 'child_process' in 'C:\CodeBase\imodeljs\pocs\sv-189\simple-viewer-app\node_modules\opener\lib'
@ ./node_modules/opener/lib/opener.js 2:19-43
@ ./node_modules/@openid/appauth/built/node_support/node_request_handler.js
@ ./node_modules/@openid/appauth/built/node_support/index.js
@ ./node_modules/@bentley/imodeljs-clients-backend/lib/oidc/OidcDeviceClient.js
@ ./node_modules/@bentley/imodeljs-clients-backend/lib/oidc/index.js
@ ./node_modules/@bentley/imodeljs-clients-backend/lib/imodeljs-clients-backend.js
@ ./node_modules/@bentley/imodeljs-backend/lib/BriefcaseManager.js
@ ./node_modules/@bentley/imodeljs-backend/lib/imodeljs-backend.js
@ ./lib/backend/main.js

ERROR in ./node_modules/forever-agent/index.js
Module not found: Error: Can't resolve 'net' in 'C:\CodeBase\imodeljs\pocs\sv-189\simple-viewer-app\node_modules\forever-agent'
@ ./node_modules/forever-agent/index.js 6:10-24
@ ./node_modules/request/request.js
@ ./node_modules/request/index.js
@ ./node_modules/openid-client/lib/helpers/http_request.js
@ ./node_modules/openid-client/lib/issuer.js
@ ./node_modules/openid-client/lib/index.js
@ ./node_modules/@bentley/imodeljs-clients-backend/lib/oidc/OidcBackendClient.js
@ ./node_modules/@bentley/imodeljs-clients-backend/lib/oidc/index.js
@ ./node_modules/@bentley/imodeljs-clients-backend/lib/imodeljs-clients-backend.js
@ ./node_modules/@bentley/imodeljs-backend/lib/BriefcaseManager.js
@ ./node_modules/@bentley/imodeljs-backend/lib/imodeljs-backend.js
@ ./lib/backend/main.js

ERROR in ./node_modules/https-proxy-agent/index.js
Module not found: Error: Can't resolve 'net' in 'C:\CodeBase\imodeljs\pocs\sv-189\simple-viewer-app\node_modules\https-proxy-agent'
@ ./node_modules/https-proxy-agent/index.js 5:10-24
@ ./node_modules/@bentley/imodeljs-clients-backend/lib/RequestHost.js
@ ./node_modules/@bentley/imodeljs-clients-backend/lib/imodeljs-clients-backend.js
@ ./node_modules/@bentley/imodeljs-backend/lib/BriefcaseManager.js
@ ./node_modules/@bentley/imodeljs-backend/lib/imodeljs-backend.js
@ ./lib/backend/main.js

ERROR in ./node_modules/request/node_modules/tough-cookie/lib/cookie.js
Module not found: Error: Can't resolve 'net' in 'C:\CodeBase\imodeljs\pocs\sv-189\simple-viewer-app\node_modules\request\node_modules\tough-cookie\lib'
@ ./node_modules/request/node_modules/tough-cookie/lib/cookie.js 32:10-24
@ ./node_modules/request/lib/cookies.js
@ ./node_modules/request/index.js
@ ./node_modules/openid-client/lib/helpers/http_request.js
@ ./node_modules/openid-client/lib/issuer.js
@ ./node_modules/openid-client/lib/index.js
@ ./node_modules/@bentley/imodeljs-clients-backend/lib/oidc/OidcBackendClient.js
@ ./node_modules/@bentley/imodeljs-clients-backend/lib/oidc/index.js
@ ./node_modules/@bentley/imodeljs-clients-backend/lib/imodeljs-clients-backend.js
@ ./node_modules/@bentley/imodeljs-backend/lib/BriefcaseManager.js
@ ./node_modules/@bentley/imodeljs-backend/lib/imodeljs-backend.js
@ ./lib/backend/main.js

ERROR in ./node_modules/tunnel-agent/index.js
Module not found: Error: Can't resolve 'net' in 'C:\CodeBase\imodeljs\pocs\sv-189\simple-viewer-app\node_modules\tunnel-agent'
@ ./node_modules/tunnel-agent/index.js 3:10-24
@ ./node_modules/request/lib/tunnel.js
@ ./node_modules/request/request.js
@ ./node_modules/request/index.js
@ ./node_modules/openid-client/lib/helpers/http_request.js
@ ./node_modules/openid-client/lib/issuer.js
@ ./node_modules/openid-client/lib/index.js
@ ./node_modules/@bentley/imodeljs-clients-backend/lib/oidc/OidcBackendClient.js
@ ./node_modules/@bentley/imodeljs-clients-backend/lib/oidc/index.js
@ ./node_modules/@bentley/imodeljs-clients-backend/lib/imodeljs-clients-backend.js
@ ./node_modules/@bentley/imodeljs-backend/lib/BriefcaseManager.js
@ ./node_modules/@bentley/imodeljs-backend/lib/imodeljs-backend.js
@ ./lib/backend/main.js

ERROR in ./node_modules/forever-agent/index.js
Module not found: Error: Can't resolve 'tls' in 'C:\CodeBase\imodeljs\pocs\sv-189\simple-viewer-app\node_modules\forever-agent'
@ ./node_modules/forever-agent/index.js 7:10-24
@ ./node_modules/request/request.js
@ ./node_modules/request/index.js
@ ./node_modules/openid-client/lib/helpers/http_request.js
@ ./node_modules/openid-client/lib/issuer.js
@ ./node_modules/openid-client/lib/index.js
@ ./node_modules/@bentley/imodeljs-clients-backend/lib/oidc/OidcBackendClient.js
@ ./node_modules/@bentley/imodeljs-clients-backend/lib/oidc/index.js
@ ./node_modules/@bentley/imodeljs-clients-backend/lib/imodeljs-clients-backend.js
@ ./node_modules/@bentley/imodeljs-backend/lib/BriefcaseManager.js
@ ./node_modules/@bentley/imodeljs-backend/lib/imodeljs-backend.js
@ ./lib/backend/main.js

ERROR in ./node_modules/https-proxy-agent/index.js
Module not found: Error: Can't resolve 'tls' in 'C:\CodeBase\imodeljs\pocs\sv-189\simple-viewer-app\node_modules\https-proxy-agent'
@ ./node_modules/https-proxy-agent/index.js 6:10-24
@ ./node_modules/@bentley/imodeljs-clients-backend/lib/RequestHost.js
@ ./node_modules/@bentley/imodeljs-clients-backend/lib/imodeljs-clients-backend.js
@ ./node_modules/@bentley/imodeljs-backend/lib/BriefcaseManager.js
@ ./node_modules/@bentley/imodeljs-backend/lib/imodeljs-backend.js
@ ./lib/backend/main.js

ERROR in ./node_modules/tunnel-agent/index.js
Module not found: Error: Can't resolve 'tls' in 'C:\CodeBase\imodeljs\pocs\sv-189\simple-viewer-app\node_modules\tunnel-agent'
@ ./node_modules/tunnel-agent/index.js 4:10-24
@ ./node_modules/request/lib/tunnel.js
@ ./node_modules/request/request.js
@ ./node_modules/request/index.js
@ ./node_modules/openid-client/lib/helpers/http_request.js
@ ./node_modules/openid-client/lib/issuer.js
@ ./node_modules/openid-client/lib/index.js
@ ./node_modules/@bentley/imodeljs-clients-backend/lib/oidc/OidcBackendClient.js
@ ./node_modules/@bentley/imodeljs-clients-backend/lib/oidc/index.js
@ ./node_modules/@bentley/imodeljs-clients-backend/lib/imodeljs-clients-backend.js
@ ./node_modules/@bentley/imodeljs-backend/lib/BriefcaseManager.js
@ ./node_modules/@bentley/imodeljs-backend/lib/imodeljs-backend.js
@ ./lib/backend/main.js
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! @bentley/[email protected] build:mobile-backend: tsc 1>&2 && webpack --config ./node_modules/@bentley/webpack-tools/mobile/backend.config.js --env.outdir=./lib/mobile --env.entry=./lib/backend/main.js --env.bundlename=main
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the @bentley/[email protected] build:mobile-backend script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!

Error 400: "unauthorized_client"

Hi,
when I try to sign into "simple-viewer-app", the following error will occur:

image
Invalid scope for client!

registered app:

image

registered project:

image

configuration.ts-imjs_browser_test_scope(default):

image

Node.js version: 10.15.3
Regards,

He

How do I show my imodel files in an offline environment using imodeljs?

I don't want to use the user authorization module provided in the project to access the imodel files published in the cloud. I need to use imodejs to access the imodel files on my own server, but I haven't seen the relevant code instance in the project description. Could you please provide the relevant technical materials?thank you

Weird characters displayed in the application GUI

Hi,

when simple-viewer-app is opened, some captions are displayed using weird / incorrect characters:

simple-viewer-application

Used configuration:

  • Windows 10 version 1709
  • National settings: Czech
  • Node.js version: 8.12.0

Not critical issue, unofrtunatelly my current knowledge of Node.js / Electron / TypeScript is not good enough to find the bug and to push a modification.

Regards,

Jan

click button "Open Sample iModel" have dialog box "Property imjs_test_project does not exists."

Your statement
https://z5h64q92x9.net/proxy_u/en-ru.ru/https/github.com/imodeljs/simple-viewer-app
https://imodeljs.github.io/iModelJs-docs-output/getting-started/
does not have enough data on which file to write "imjs_test_project"
This is only described in the video https://www.youtube.com/watch?v=SPyN8w1XEAE

add a link to it in the statement

did everything as in video but all the same I receive an error: "Property imjs_test_project does not exists."

С:\project\simple-viewer-app>npm install

run 'npm audit fix' to fix them, or 'npm audit' for details

after
npm run build
npm run start:servers
http://localhost:3000/
click button "Open Sample iModel"
have dialog box "Property imjs_test_project does not exists."
Screenshot100

Electron version of app ending up at chrome-error://chromewebdata

When working on the electron version of the app, signing in redirects me eventually to https://qa-ims.bentley.com/?wtrealm=https%3A%2F%2Fqa-imsoidc.bentley.com%2F&wa=wsignin1.0&wreply=https%3A%2F%2Fqa-imsoidc.bentley.com%2Fsignin-wsfed&wctx=CfDJ8EX5Kg56z6hPiC8QAlcWdnN8ZtFl7paCO2Rt8vfBPVfBLFVPNinqWmua3OXo8swANKXStw4KoXijFTDe9ylzJ7V2ojchZCrKHf_cikOf-xmOaXS9NGtY-hPx9B1IE9y4uB1sf8YDQ28qoKAypfXBjuti0URv0PQRarhEIaCYnETU. From here the app attempts to load an invalid URL, which navigates to chrome-error://chromewebdata, but does not throw an error message. How can I fix this?
Edit* I've found that even when running as electron, in frontend/api/rpc.ts web app RPC is initialized, not electron. Is this intended behavior?
To reproduce:

  1. Clone the repository
  2. npm install, npm run build, npm run electron
  3. Login and travel through the steps with console logging saved until it freezes on a blank IFrame.
    2019-06-05_11-36-07

error:“npm run start:backend ”

node -v
v10.15.1

npm run start:backend

node lib/backend/main.js

internal/modules/cjs/loader.js:718
return process.dlopen(module, path.toNamespacedPath(filename));
^

Error: The specified procedure could not be found.
\?\E:\CompanySVN\47_2018-12-01_BIM\Project\Code\simple-viewer-app\trunk\node_modules@bentley\imodeljs-native\imodeljs-win32-x64\imodeljs.node
at Object.Module._extensions..node (internal/modules/cjs/loader.js:718:18)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.exports.loadNativePlatform (E:\CompanySVN\47_2018-12-01_BIM\Project\Code\simple-viewer-app\trunk\node_modules@bentley\imodeljs-native\loadNativePlatform.js:28:12)
at Function.load (E:\CompanySVN\47_2018-12-01_BIM\Project\Code\simple-viewer-app\trunk\node_modules@bentley\imodeljs-backend\lib\IModelHost.js:139:71)
at Function.loadNative (E:\CompanySVN\47_2018-12-01_BIM\Project\Code\simple-viewer-app\trunk\node_modules@bentley\imodeljs-backend\lib\IModelHost.js:66:69)
at Function.startup (E:\CompanySVN\47_2018-12-01_BIM\Project\Code\simple-viewer-app\trunk\node_modules@bentley\imodeljs-backend\lib\IModelHost.js:82:22)

Permissions error during npm run build

When attempting to do "npm run build" step I get the following:

Error { Error: EPERM: operation not permitted, symlink 'C:\Code\simple-viewer-app\node_modules@bentley\bentleyjs-core\lib\module\dev\bentleyjs-core.js' -> 'C:\Code\simple-viewer-app\lib\webresources\v-latest\bentleyjs-core.js'
at Object.symlinkSync (fs.js:905:3)
at linkModuleFile (C:\Code\simple-viewer-app\node_modules@bentley\webpack-tools\modules\copyExternalModules.js:93:8)
at main (C:\Code\simple-viewer-app\node_modules@bentley\webpack-tools\modules\copyExternalModules.js:201:13)
at Object. (C:\Code\simple-viewer-app\node_modules@bentley\webpack-tools\modules\copyExternalModules.js:223:1)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
errno: -4048,
syscall: 'symlink',
code: 'EPERM',
path:
'C:\Code\simple-viewer-app\node_modules\@bentley\bentleyjs-core\lib\module\dev\bentleyjs-core.js',
dest:
'C:\Code\simple-viewer-app\lib\webresources\v-latest\bentleyjs-core.js' }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.