This sample provides example of using Tandem Viewer in React application. It covers following concepts:
- Using 2-legged authentication
- How to wrap Tandem Viewer by React component
- How to get list of facilities for user
- How to display default view of facility
- APS credentials.
- Service account added to your facility or account. This allows using 2-legged authentication to access facility.
- Node.js.
- Vite.
This is assuming you're using VS Code as your development editor. It's possible to use another environment but steps below may differ.
Follow these steps to run application locally:
- Run
git clone
to clone repository. The repo has two sub folders:server
client
- Start VS Code and open
server
folder. - Run
npm install
. - Update
.env
file with your details. - Run server under debugger (Run - Start Debugging or F5).
- Open new VS Code window (File - New Window).
- Open
client
folder. - Run
npm install
. - Open terminal and run
npm run dev
. - Open your browser and navigate to http://localhost:3000
The server is simple Node.js server which exposes following end points:
/api/auth/token
- provides valid token to the client. Then token is used by viewer to display facility.
- When the application is loaded it intialized viewer component.
- This trigger
onAppInitialized
callback. From within the callback the drop down is populated by available facilities. - When user selects facility it's passed to
Viewer
component. The facility is loaded and default view is set as active.
Note If you're looking for 3-legged example you can find it here.