Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

Commit 6e2075a

Browse files
committed
Merge branch 'dev' to release WDC 2.1
# Conflicts: # README.md # Simulator/tests/unit/components.js
2 parents ac5696b + 2554cb3 commit 6e2075a

31 files changed

Lines changed: 1624 additions & 445 deletions

Examples/html/IncrementalRefreshConnector.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
77
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js" type="text/javascript"></script>
88
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
9-
<script src="https://connectors.tableau.com/libs/tableauwdc-2.0.latest.js" type="text/javascript"></script>
9+
<script src="https://connectors.tableau.com/libs/tableauwdc-2.1.1.js" type="text/javascript"></script>
1010
<script src="../js/IncrementalRefreshConnector.js" type="text/javascript"></script>
1111

1212
</head>

Examples/html/MadMoneyScraper.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
77
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js" type="text/javascript"></script>
88
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
9-
<script src="https://connectors.tableau.com/libs/tableauwdc-2.0.latest.js" type="text/javascript"></script>
9+
<script src="https://connectors.tableau.com/libs/tableauwdc-2.1.1.js" type="text/javascript"></script>
1010
<script src="../js/MadMoneyScraper.js" type="text/javascript"></script>
1111

1212
</head>
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Standard Connections Placeholder Example</title>
6+
<!-- In order to use promises, like this example, you will need to include this polyfill to add promises
7+
functionality to the built in Tableau WDC browser (it does not have ES6 functionality by default) -->
8+
<script src="https://www.promisejs.org/polyfills/promise-7.0.4.min.js"></script>
9+
<script src="https://connectors.tableau.com/libs/tableauwdc-2.1.1.js" type="text/javascript"></script>
10+
<script src="../js/StandardConnectionsExample.js"></script>
11+
<style>
12+
* {
13+
padding: 0px;
14+
margin: 0px;
15+
font-family: Arial, sans-serif;
16+
color: #1c1c1c;
17+
}
18+
body {
19+
background-color: #f5f5f5;
20+
text-align: center;
21+
}
22+
h1 {
23+
margin-top: 30px;
24+
font-weight: normal;
25+
margin-bottom: 15px;
26+
}
27+
p {
28+
margin-bottom: 15px;
29+
line-height: 1.4;
30+
}
31+
button {
32+
padding: 6px 12px;
33+
background-color: #5cb85c;
34+
border: 2px solid #4cae4c;
35+
color: white;
36+
border-radius: 4px;
37+
margin: 0 auto;
38+
font-size: 1.2em;
39+
transition: background-color .4s, border-color .4s;
40+
}
41+
button:hover{
42+
cursor: pointer;
43+
background-color: #3c9e3c;
44+
border-color: #3c9e3c;
45+
}
46+
</style>
47+
</head>
48+
<body>
49+
<h1>JSON Placeholder Web Data Connector <br> Standard Connections</h1>
50+
<p>Example Web Data Connector demonstrating the Standard Connections feature <br>using the <a href="http://jsonplaceholder.typicode.com/">JSON Placeholder REST service</a>.</p>
51+
<button id="submitButton" onclick="send()">Get Data</button>
52+
</body>
53+
</html>

Examples/html/StockQuoteConnector_promises.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js" type="text/javascript"></script>
88
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
99
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore.js"></script>
10-
<script src="https://connectors.tableau.com/libs/tableauwdc-2.0.latest.js" type="text/javascript"></script>
10+
<script src="https://connectors.tableau.com/libs/tableauwdc-2.1.1.js" type="text/javascript"></script>
1111
<script src="../js/es6-promise.min.js" type="text/javascript"></script>
1212
<script src="../js/StockQuoteConnector_promises.js" type="text/javascript"></script>
1313

Examples/html/earthquakeMultilingual.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js" type="text/javascript"></script>
88
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
99

10-
<script src="https://connectors.tableau.com/libs/tableauwdc-2.0.latest.js" type="text/javascript"></script>
10+
<script src="https://connectors.tableau.com/libs/tableauwdc-2.1.1.js" type="text/javascript"></script>
1111
<script src="../js/earthquakeMultilingual.js" type="text/javascript"></script>
1212
</head>
1313

Examples/html/earthquakeMultitable.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js" type="text/javascript"></script>
88
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
99

10-
<script src="https://connectors.tableau.com/libs/tableauwdc-2.0.latest.js" type="text/javascript"></script>
10+
<script src="https://connectors.tableau.com/libs/tableauwdc-2.1.1.js" type="text/javascript"></script>
1111
<script src="../js/earthquakeMultitable.js" type="text/javascript"></script>
1212
</head>
1313

Examples/html/earthquakeUSGS.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js" type="text/javascript"></script>
88
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
99

10-
<script src="https://connectors.tableau.com/libs/tableauwdc-2.0.latest.js" type="text/javascript"></script>
10+
<script src="https://connectors.tableau.com/libs/tableauwdc-2.1.1.js" type="text/javascript"></script>
1111
<script src="../js/earthquakeUSGS.js" type="text/javascript"></script>
1212
</head>
1313

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
// Example of Standard Connections in Web Data Connectors using JSONPlaceholder JSON endpoints
2+
// Tableau 10.1 - WDC API v2.1
3+
4+
// Define our Web Data Connector
5+
(function(){
6+
var myConnector = tableau.makeConnector();
7+
myConnector.getSchema = function(schemaCallback) {
8+
// Create a promise to get our Standard Connections List from a JSON file. This increases code readability since we
9+
// no longer need to define the lengthy object within our javascript itself.
10+
var standardConnections = new Promise(function(resolve, reject) {
11+
loadJSON("StandardConnectionsData", function(json) {
12+
var obj = JSON.parse(json);
13+
var connectionList = [];
14+
for (var connection in obj.connections) {
15+
connectionList.push(obj.connections[connection]);
16+
}
17+
resolve(connectionList);
18+
}, true);
19+
});
20+
// Create a promise to get our table schema info as well, just like above
21+
var tables = new Promise(function(resolve, reject) {
22+
loadJSON("StandardConnectionsTableInfoData", function(json) {
23+
var obj = JSON.parse(json);
24+
var tableList = [];
25+
for (var table in obj.tables) {
26+
tableList.push(obj.tables[table]);
27+
}
28+
resolve(tableList);
29+
}, true);
30+
});
31+
// Once all our promises are resolved, we can call the schemaCallback to send this info to Tableau
32+
Promise.all([tables, standardConnections]).then(function(data) {
33+
schemaCallback(data[0], data[1]);
34+
});
35+
}
36+
37+
myConnector.getData = function(table, doneCallback) {
38+
// Load our data from the API. Multiple tables for WDC work by calling getData multiple times with a different id
39+
// so we want to make sure we are getting the correct table data per getData call
40+
loadJSON(table.tableInfo.id, function(data) {
41+
var obj = JSON.parse(data);
42+
var tableData = [];
43+
// Iterate through the data and build our table
44+
for (var i = 0; i < obj.length; i++) {
45+
tableEntry = {};
46+
var ref = obj[i];
47+
// We can use this handy shortcut because our JSON column names match our schema's column names perfectly
48+
Object.getOwnPropertyNames(ref).forEach(function(val, idx, array){
49+
// Handle specific cases by checking the name of the property
50+
switch(val) {
51+
case "address":
52+
tableEntry.lat = ref[val].geo.lat;
53+
tableEntry.lng = ref[val].geo.lng;
54+
tableEntry.zipcode = ref[val].zipcode;
55+
break;
56+
case "company":
57+
tableEntry.companyname = ref[val].name;
58+
tableEntry.catchPhrase = ref[val].catchPhrase;
59+
tableEntry.bs = ref[val].bs;
60+
break;
61+
default:
62+
tableEntry[val] = ref[val];
63+
}
64+
});
65+
tableData.push(tableEntry);
66+
}
67+
// Once we have all the data parsed, we send it to the Tableau table object
68+
table.appendRows(tableData);
69+
doneCallback();
70+
});
71+
}
72+
tableau.registerConnector(myConnector);
73+
})();
74+
75+
76+
// Helper function that loads a json and a callback to call once that file is loaded
77+
78+
function loadJSON(path, cb, isLocal) {
79+
var obj = new XMLHttpRequest();
80+
obj.overrideMimeType("application/json");
81+
if(isLocal) {
82+
obj.open("GET", "../json/" + path + ".json", true);
83+
}
84+
else {
85+
obj.open("GET", "https://crossorigin.me/http://jsonplaceholder.typicode.com/" + path, true);
86+
}
87+
obj.onreadystatechange = function() {
88+
if (obj.readyState == 4 && obj.status == "200"){
89+
cb(obj.responseText);
90+
}
91+
}
92+
obj.send(null);
93+
}
94+
95+
function send() {
96+
tableau.submit();
97+
}
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
{
2+
"connections" : [
3+
{
4+
"alias" : "User and Their Photos",
5+
"tables" : [
6+
{ "id" : "users",
7+
"alias" : "Users" },
8+
{ "id" : "albums",
9+
"alias" : "Albums" },
10+
{ "id" : "photos",
11+
"alias" : "Photos" }
12+
],
13+
"joins" : [
14+
{
15+
"left" : {
16+
"tableAlias" : "Users",
17+
"columnId" : "id"
18+
},
19+
"right" : {
20+
"tableAlias" : "Albums",
21+
"columnId" : "userId"
22+
},
23+
"joinType" : "inner"
24+
},{
25+
"left" : {
26+
"tableAlias" : "Albums",
27+
"columnId" : "id"
28+
},
29+
"right" : {
30+
"tableAlias" : "Photos",
31+
"columnId" : "albumId"
32+
},
33+
"joinType" : "inner"
34+
}
35+
]
36+
},{
37+
"alias" : "Comments on User's Posts",
38+
"tables" : [
39+
{ "id" : "users",
40+
"alias" : "Users" },
41+
{ "id" : "posts",
42+
"alias" : "Posts" },
43+
{ "id" : "comments",
44+
"alias" : "Comments" }
45+
],
46+
"joins" : [
47+
{
48+
"left" : {
49+
"tableAlias" : "Users",
50+
"columnId" : "id"
51+
},
52+
"right" : {
53+
"tableAlias" : "Posts",
54+
"columnId" : "userId"
55+
},
56+
"joinType" : "inner"
57+
},{
58+
"left" : {
59+
"tableAlias" : "Posts",
60+
"columnId" : "id"
61+
},
62+
"right" : {
63+
"tableAlias" : "Comments",
64+
"columnId" : "postId"
65+
},
66+
"joinType" : "inner"
67+
}
68+
]
69+
},{
70+
"alias" : "Complete Data Joins",
71+
"tables" : [
72+
{ "id" : "users",
73+
"alias" : "Users" },
74+
{ "id" : "albums",
75+
"alias" : "Albums" },
76+
{ "id" : "photos",
77+
"alias" : "Photos" },
78+
{ "id" : "posts",
79+
"alias" : "Posts" },
80+
{ "id" : "comments",
81+
"alias" : "Comments" },
82+
{ "id" : "todos",
83+
"alias" : "Todos" }
84+
],
85+
"joins" : [
86+
{
87+
"left" : {
88+
"tableAlias" : "Users",
89+
"columnId" : "id"
90+
},
91+
"right" : {
92+
"tableAlias" : "Albums",
93+
"columnId" : "userId"
94+
},
95+
"joinType" : "inner"
96+
},{
97+
"left" : {
98+
"tableAlias" : "Albums",
99+
"columnId" : "id"
100+
},
101+
"right" : {
102+
"tableAlias" : "Photos",
103+
"columnId" : "albumId"
104+
},
105+
"joinType" : "inner"
106+
},{
107+
"left" : {
108+
"tableAlias" : "Users",
109+
"columnId" : "id"
110+
},
111+
"right" : {
112+
"tableAlias" : "Posts",
113+
"columnId" : "userId"
114+
},
115+
"joinType" : "inner"
116+
},{
117+
"left" : {
118+
"tableAlias" : "Posts",
119+
"columnId" : "id"
120+
},
121+
"right" : {
122+
"tableAlias" : "Comments",
123+
"columnId" : "postId"
124+
},
125+
"joinType" : "inner"
126+
},{
127+
"left" : {
128+
"tableAlias" : "Users",
129+
"columnId" : "id"
130+
},
131+
"right" : {
132+
"tableAlias" : "Todos",
133+
"columnId" : "userId"
134+
},
135+
"joinType" : "inner"
136+
}
137+
]
138+
}
139+
]
140+
}

0 commit comments

Comments
 (0)