Skip to content

Commit 236e519

Browse files
authored
feat: CHARTS 3840 Release sweep (#10)
* chore: CHARTS-3840 Added quickstart to readme. Removed global install instructions for authenticated jwt * chore: CHARTS-3840 Fixed issue where example code was using a non-existent field `id` instead of `chartId` * chore: CHARTS-3840 Added `quickstart` section to all readme's in the examples directory * chore: CHARTS-3840 Updated global readme links to include all examples. Added a parent Readme in the example level directory. * chore: CHARTS-3840 Added hyperlinking to the bottom of example Readme's.
1 parent 23b5244 commit 236e519

File tree

10 files changed

+72
-38
lines changed

10 files changed

+72
-38
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,7 @@ yarn add @mongodb-js/charts-embed-dom
2929
- [Installation & MongoDB Docs](https://docs.mongodb.com/charts/master/embedding-charts-sdk/)
3030
- [Examples](https://github.com/mongodb-js/charts-embed-sdk/blob/master/examples)
3131
- Guides 🤠
32+
- [Getting started with the MongoDB Charts SDK](https://github.com/mongodb-js/charts-embed-sdk/tree/master/examples/unauthenticated)
3233
- [Getting started with custom JWT authentication](https://github.com/mongodb-js/charts-embed-sdk/tree/master/examples/authenticated-custom-jwt)
3334
- [Getting started with Realm authentication](https://github.com/mongodb-js/charts-embed-sdk/tree/master/examples/authenticated-realm)
35+
- [Getting started with Google authentication](https://github.com/mongodb-js/charts-embed-sdk/tree/master/examples/authenticated-google)

examples/authenticated-custom-jwt/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"express": "^4.16.3",
1414
"jsonwebtoken": "^8.3.0",
1515
"regenerator-runtime": "^0.13.3",
16-
"request": "^2.88.2"
16+
"request": "^2.88.2",
17+
"parcel": "^1.12.4"
1718
},
1819
"devDependencies": {
1920
"@babel/core": "^7.8.6",

examples/authenticated-custom-jwt/readme.md

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@ This sample shows how to use the JavaScript Embedding SDK to render **authentica
1818
- 🔒 Only render charts to valid users
1919
- 🔑 Custom JWT authentication via `jsonwebtoken`
2020

21+
## Quickstart
22+
_The following steps presume the use of npm, though yarn works as well._
23+
24+
1. Ensure you have Node installed. You can confirm with `node --version`. On some operating systems, Node available as the `nodejs` binary instead.
25+
26+
2. Clone the Git repository or download the code to your computer.
27+
28+
3. Run `npm install` to install the package dependencies.
29+
30+
4. Run `npm start` to start the application. This will utilise parcel.js
31+
- Optional Parcel.js documentation https://parceljs.org/ for more information on what this is
32+
2133
## Preparing your Chart for Embedding
2234

2335
This sample is preconfigured to render a specific chart. You can run the sample as-is, or you can modify it to render your own chart by completing the following steps:
@@ -46,24 +58,15 @@ This sample is preconfigured to render a specific chart. You can run the sample
4658
- Signing Algorithm: `HS256` _Note, this is the default signing algorithm for the `jsonwebtoken` library and many others_
4759
- Signing Key: `topsecret` _Note, this key must correlate with the key found in `config.js`_
4860

49-
## Running this Sample
50-
51-
_The following steps presume the use of npm, though yarn works as well._
52-
53-
1. Ensure you have Node installed. You can confirm with `node --version`. On some operating systems, Node available as the `nodejs` binary instead.
54-
55-
2. Clone the Git repository or download the code to your computer.
61+
## Running this Sample with your data
5662

57-
3. **Optional**
63+
1.
5864
If you do not wish to use our sample data and have completed the above steps to prepare your own chart for embedding,
5965
- Open the _index.js_ file (`src/index.js`)
60-
- Replace the `baseUrl` string on with the base URL you copied from the MongoDB Charts Embedded Chart menu (look for "\~REPLACE\~" in the comments)
61-
- Replace the `chartId` string on with the chart ID you copied from the MongoDB Charts Embedded Chart menu (look for "\~REPLACE\~" in the comments)
62-
- Replace the second `chartId`string with the same ID. (look for "\~REPLACE\~" in the comments)
63-
4. Run `npm install` to install the package dependencies.
64-
5. Run `npm install -g parcel-bundler` to install Parcel. You may need to run `sudo npm install -g parcel-bundler` if you lack permissions.
65-
- Optional Parcel.js documentation https://parceljs.org/ for more information on what this is
66-
6. Run `npm start` to start the application.
66+
- Replace the `baseUrl` string with the base URL you copied from the MongoDB Charts Embedded Chart menu (look for "\~REPLACE\~" in the comments)
67+
- Replace the `chartId` string with the chart ID you copied from the MongoDB Charts Embedded Chart menu. (look for "\~REPLACE\~" in the comments)
68+
2. Run `npm install` to install the package dependencies.
69+
3. Run `npm start` to start the application.
6770

6871
This should create a local server running the Charts demo. Open a web browser and navigate to `http://localhost:1234` in the url bar to see the sample. Along with this, a local jwt authentication server will be spun up on `http://localhost:8000`.
6972

@@ -77,6 +80,6 @@ Once you gain an understanding of the API, consider the following
7780

7881
- Take on the optional steps to prepare and manipulate your own data source rather than the sample.
7982
- Change the login logic to adapt to your project's security workflow.
80-
- Think whether an authenticated chart is the feature you're after. If you're simply looking for a way to show off your data, unauthenticated embedding simplifies the workflow even further.
83+
- Think whether an authenticated chart is the feature you're after. If you're simply looking for a way to show off your data, [unauthenticated embedding](https://github.com/mongodb-js/charts-embed-sdk/tree/master/examples/unauthenticated) simplifies the workflow even further.
8184

8285
Happy Charting! 🚀📈

examples/authenticated-custom-jwt/src/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,12 @@ async function login(username, password) {
5151
async function renderChart() {
5252
const sdk = new ChartsEmbedSDK({
5353
baseUrl: "https://charts-dev.mongodb.com/charts-test2-pebbp", // Optional: ~REPLACE~ with the Base URL from your Embed Chart dialog
54-
chartId: "a2e775e6-f267-4c2c-a65d-fbf3fad4a4f2", // Optional: ~REPLACE~ with the Chart ID from your Embed Chart dialog
5554
getUserToken: async function() {
5655
return await login(getUser(), getPass());
5756
}
5857
});
5958

60-
const chart = sdk.createChart({ id: "a2e775e6-f267-4c2c-a65d-fbf3fad4a4f2" }); // Optional: ~REPLACE~ with the Chart ID from your Embed Chart dialog
59+
const chart = sdk.createChart({ chartId: "a2e775e6-f267-4c2c-a65d-fbf3fad4a4f2" }); // Optional: ~REPLACE~ with the Chart ID from your Embed Chart dialog
6160

6261
// render the chart into a container
6362
chart.render(document.getElementById("chart"));

examples/authenticated-google/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,6 @@ Once you gain an understanding of the API, consider the following
9393
- ![Screen Shot 2020-04-21 at 1 47 54 pm](https://user-images.githubusercontent.com/19422770/79823279-b9b35880-83d6-11ea-8370-774bcde80252.png)
9494
- This will only allow users from your company domain to view the chart data 🔒
9595

96-
- Think whether an authenticated chart is the feature you're after. If you're simply looking for a way to show off your data, unauthenticated embedding simplifies the workflow even further.
96+
- Think whether an authenticated chart is the feature you're after. If you're simply looking for a way to show off your data, [unauthenticated embedding](https://github.com/mongodb-js/charts-embed-sdk/tree/master/examples/unauthenticated) simplifies the workflow even further.
9797

9898
Happy Charting! 🚀📈

examples/authenticated-realm/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "",
55
"main": "index.html",
66
"scripts": {
7-
"start": "node app.js & parcel index.html --open",
7+
"start": "parcel index.html --open",
88
"build": "parcel build index.html"
99
},
1010
"dependencies": {

examples/authenticated-realm/readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ _The following steps presume the use of npm, though yarn works as well._
3131

3232
3. Run `npm install` to install the package dependencies.
3333

34-
4. Run `parcel index.html` to start the application.
34+
4. Run `npm start` to start the application. This will utilise parcel.js
3535
- Optional Parcel.js documentation https://parceljs.org/ for more information on what this is
3636

3737
This should create a local server running the Charts demo. Open a web browser and navigate to `http://localhost:1234` in the url bar to see the sample.
@@ -137,6 +137,6 @@ Once you gain an understanding of the API, consider the following
137137

138138
- Take on the optional steps to prepare and manipulate your own data source rather than the sample.
139139
- Play with Realms Rules system, and change how different accounts see your Chart.
140-
- Think whether an authenticated chart is the feature you're after. If you're simply looking for a way to show off your data, unauthenticated embedding simplifies the workflow even further.
140+
- Think whether an authenticated chart is the feature you're after. If you're simply looking for a way to show off your data, [unauthenticated embedding](https://github.com/mongodb-js/charts-embed-sdk/tree/master/examples/unauthenticated) simplifies the workflow even further.
141141

142142
Happy Charting! 🚀📈

examples/readme.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# MongoDB Embedding SDK Examples
2+
3+
MongoDB Charts allows you to create visualizations of your MongoDB data using a simple web interface. You can view the visualizations within the Charts UI, or you can use the Embedding feature to render the charts in an external web application.
4+
5+
Charts can be embedded either using a simple IFRAME snippet, or by using the Charts Embedding SDK from your JavaScript code. When using the SDK, embedded charts can be either unauthenticated (meaning anyone who has the embed code can view the chart), or authenticated (whereby the user can only view the chart if they have an active authentication session linked to a Charts authentication provider).
6+
7+
This directory contains example applications making use of both unauthenticated and authenticated utilizations of the SDK. They are provided as a reference to kick start your development process. To run these examples, simply clone the directory, and run the following commands:
8+
- `npm install`
9+
- `npm start`
10+
11+
in the example directory of your choosing.
12+
13+
The [Unauthenticated](https://github.com/mongodb-js/charts-embed-sdk/blob/master/examples/unauthenticated) example is the best place to see all the current SDK features being used. Since it doesn't require authentication, it's the easiest example to set up and follow along with.
14+
15+
Our **authenticated** examples are great references if you need help getting started creating Authenticated Embedded Charts. We have three examples, each tailored for the three Authentication Providers now available in MongoDB Charts. The three examples are:
16+
- [Custom JWT](https://github.com/mongodb-js/charts-embed-sdk/blob/master/examples/authenticated-custom-jwt)
17+
- [MongoDB Realm](https://github.com/mongodb-js/charts-embed-sdk/blob/master/examples/authenticated-realm)
18+
- [Google](https://github.com/mongodb-js/charts-embed-sdk/blob/master/examples/authenticated-google)
19+
20+
We hope these resources help, and as always,
21+
22+
Happy Charting! 🚀📈

examples/unauthenticated/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
},
1010
"dependencies": {
1111
"@mongodb-js/charts-embed-dom": "^1.0.0",
12-
"regenerator-runtime": "^0.13.3"
12+
"regenerator-runtime": "^0.13.3",
13+
"parcel": "^1.12.4"
1314
},
1415
"devDependencies": {
1516
"@babel/core": "^7.8.4",

examples/unauthenticated/readme.md

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,21 @@ This sample shows how to use the JavaScript Embedding SDK to render unauthentica
2626
- Note, filtering on a chart requires setting up white listed fields in MongoDB Charts. We have done this for our sample data.
2727
- Get the current filter on a chart
2828

29+
## Quickstart
30+
31+
_The following steps presume the use of npm, though yarn works as well._
32+
33+
1. Ensure you have Node installed. You can confirm with `node --version`. On some operating systems, Node is available as the `nodejs` binary instead.
34+
35+
2. Clone the Git repository or download the code to your computer.
36+
37+
3. Run `npm install` to install the package dependencies.
38+
39+
4. Run `npm start` to start the application. This will utilise parcel.js
40+
- Optional Parcel.js documentation https://parceljs.org/ for more information on what this is
41+
42+
This should create a local server running the Charts demo. Open a web browser and navigate to `http://localhost:1234` in the url bar to see the sample.
43+
2944
## Preparing your Chart for Embedding
3045

3146
This sample is preconfigured to render a specific chart. You can run the sample as-is, or you can modify it to render your own chart by completing the following steps:
@@ -50,24 +65,15 @@ This sample is preconfigured to render a specific chart. You can run the sample
5065
- Update the query **field** in `src/index.js`
5166
- Update the query **values** in `index.html`
5267

53-
## Running this Sample
54-
55-
_The following steps presume the use of npm, though yarn works as well._
56-
57-
1. Ensure you have Node installed. You can confirm with `node --version`. On some operating systems, Node available as the `nodejs` binary instead.
58-
59-
2. Clone the Git repository or download the code to your computer.
68+
## Running this Sample with your data
6069

61-
3. **Optional**
62-
If you do not wish to use our sample data and have completed the above steps to prepare your own chart for embedding,
70+
1. If you do not wish to use our sample data and have completed the above steps to prepare your own chart for embedding,
6371
- Open the _index.js_ file (`src/index.js`)
6472
- Replace the `baseUrl` string on with the base URL you copied from the MongoDB Charts Embedded Chart menu (look for "\~REPLACE\~" in the comments)
6573
- Replace the `chartId` string on with the chart ID you copied from the MongoDB Charts Embedded Chart menu (look for "\~REPLACE\~" in the comments)
6674
- Replace `address.country` in the `setFilter` code with your whitelisted field (look for "\~REPLACE\~" in the comments)
67-
4. Run `npm install` to install the package dependencies.
68-
5. Run `npm install -g parcel-bundler` to install Parcel. You may need to run `sudo npm install -g parcel-bundler` if you lack permissions.
69-
- Optional Parcel.js documentation https://parceljs.org/ for more information on what this is
70-
6. Run `parcel index.html` to launch the sample application
75+
2. Run `npm install` to install the package dependencies.
76+
3. Run `npm start` to launch the sample application
7177

7278
This should create a local server running the Charts demo. Open a web browser and navigate to `http://localhost:1234` in the url bar to see the sample.
7379

@@ -76,7 +82,7 @@ This should create a local server running the Charts demo. Open a web browser an
7682
Once you gain an understanding of the API, consider the following
7783

7884
- Take on the optional steps to prepare and manipulate your own data source rather than the sample.
79-
- Think whether an unauthenticated chart is the feature you're after. Embedding iframes from Charts is a great way to showcase your data if you don't need the user to interact with the chart.
85+
- Think whether an unauthenticated chart is the feature you're after. [Embedding iframes](https://docs.mongodb.com/charts/master/embedded-chart-options/) from Charts is a great way to showcase your data if you don't need the user to interact with the chart.
8086
- Consider the data you're making available, and the queries you're allowing. If the data is sensitive and you need to ensure the charts can only be accessed by authorized people, you should look at using authenticated embedding.
8187

8288
Happy Charting! 🚀📈

0 commit comments

Comments
 (0)