Giter Site home page Giter Site logo

autodesk-platform-services / aps-db-sample Goto Github PK

View Code? Open in Web Editor NEW
7.0 4.0 2.0 750 KB

Connected Database:Sample to demonstrate how to connect with an external DB on demand

Home Page: https://aps-db-sample.autodesk.io

License: MIT License

C# 55.72% JavaScript 35.03% HTML 3.89% CSS 5.36%
autodesk-viewer database dotnet sample autodesk-bim360 autodesk-construction-cloud

aps-db-sample's Introduction

aps-db-sample

.NET MIT Level

oAuth2 Data-Management BIM360 ACC

Thumbnail

Thumbnail

Description

This sample demonstrates how to connect with an external DB on demand, adding custom properties to Viewer property panel. It uses Websocket to notify different users when the parameters they might be seeing changes. We can understand how it works dividing the connection to DB in two sections.

First, Reading the Data from DB and aggregating into property Panel.

1 - User select an element from the scene, which triggers a job to retrieve associated properties (specific to this element) from an external DB (MongoDB in this case)

2 - A task retrieves the associated properties from the external DB.

3 - If those properties exists they are returned and aggregated to the properties panel inside an input element, so the user can change them. If not, the properties are aggregated on properties panel as blank inputs, so user can write values to those, creating new values in the external DB.

Then, updating the properties from Viewer.

1 - User update a custom parameter on viewer’s property panel inputs, which triggers a job to update this parameters value in the external DB (MongoDB in this case).

2 - A task updates the property value (or create it, if it doesn’t exists).

3 - The client that triggered the task (A) get notified about the result, while other clients (B and C) receives a notification with the changed/created value.

Setup

Prerequisites

  1. APS Account: Learn how to create a APS Account, activate subscription and create an app at this tutorial.
  2. Visual Studio: Either Community (Windows) or Code (Windows, MacOS).
  3. .NET 6: basic knowledge of C#.
  4. MongoDB Atlas: Cloud-hosted MongoDB refer here.

Use of this sample requires Autodesk developer credentials. Visit the APS Developer Portal, sign up for an account and create an app that uses Data Management and Model Derivative APIs. For this new app, use http://localhost:3000/api/aps/callback/oauth as Callback URL, although is not used in a 2-legged flow. Finally, make a note of the Client ID and Client Secret.

Running locally

Clone this project or download it. We recommend installing GitHub desktop. To clone it via command line, use the following (Terminal on MacOSX/Linux, Git Shell on Windows):

git clone https://github.com/autodesk-platform-services/aps-db-sample

Environment variables

At the .appsettings.Development.json, find the env vars and add your APS Client ID, Secret and callback URL. The end result should be as shown below:

  "APS_CLIENT_ID": "your APS app client id",
  "APS_CLIENT_SECRET": "your APS app client secret",
  "APS_CALLBACK_URL": "http://localhost:8080/api/auth/callback",
  "APS_BUCKET": "your bucket name",
  "MONGODB_CON_STRING": "your MongoDB connection string",
  "MONGODB_DBNAME": "your MongoDB DB name",
  "MONGODB_COLLECTION": "your MongoDB collection name",
  "DB_PROPERTIES_NAMES": "your comma separated properties"

License

This sample is licensed under the terms of the MIT License. Please see the LICENSE file for full details.

Written by

Joao Martins @JooPaulodeOrne2, Developer Advocate

aps-db-sample's People

Contributors

joaomartins-callmejohn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

aps-db-sample's Issues

pleasee provide Mongo db schema and samples

Please provide more details on how to connect with the database and the schema. Would be great if you upload the db files you used. The repository is great, however, a youtube video to explain the code is much needed. Thanks

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.