Skip to content

Commit

Permalink
Merge pull request #5 from RobDWaller/update-fixes
Browse files Browse the repository at this point in the history
Fixed tableau workflow so it loads correctly
  • Loading branch information
RobDWaller authored Jul 13, 2018
2 parents 8bad493 + 4792b30 commit dd5d87c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
2 changes: 2 additions & 0 deletions src/js/helper/ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class Ajax
request.open('GET', url, true);
request.send();

}).catch(e => {
tableau.abortWithError(e);
});

return data.then(function(result){
Expand Down
30 changes: 16 additions & 14 deletions src/js/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,21 @@ import '../scss/main.scss';
* @author Rob Waller <rdwaller1984@googlemail.com>
*/

/**
* Initiate and Load Tableau
*/
(function () {
var tableauBuilder = new TableauBuilder(tableau, new Ajax);

try {
tableauBuilder.init();
var connector = tableauBuilder.makeSchema();
connector = tableauBuilder.getData(connector);
tableauBuilder.registerConnector(connector);
} catch (e) {
tableau.abortWithError(e);
}
})();

/**
* Starting place for all functionality, events, etc.
Expand Down Expand Up @@ -48,20 +63,6 @@ window.onload = function(){
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));

/**
* Initiate and Load Tableau
*/
var tableauBuilder = new TableauBuilder(tableau, new Ajax);

try {
tableauBuilder.init();
var connector = tableauBuilder.makeSchema();
connector = tableauBuilder.getData(connector);
tableauBuilder.registerConnector(connector);
} catch (e) {
tableau.abortWithError(e);
}

/**
* Initiate simple wrapper for working with the DOM
*/
Expand Down Expand Up @@ -105,6 +106,7 @@ window.onload = function(){
* before auth data is submitted to Tableau.
*/
async function submitTableau() {
var tableauBuilder = new TableauBuilder(tableau, new Ajax);
await tableauBuilder.setConnectionData(app.getFacebookAccessToken());
tableauBuilder.setConnectionName("Fableau Facebook Metrics");
tableauBuilder.submit();
Expand Down
4 changes: 1 addition & 3 deletions src/js/tableau/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,20 +181,18 @@ class TableauBuilder
let data = [];

return Promise.all(pageIds.map((id) => {
this.tableau.log('here');
return this.ajax.getData(`https://graph.facebook.com/${id.page_id}?access_token=${accessToken}&fields=access_token`).then((result) => {
data.push(result);
});
})).then(() => {
this.tableau.connectionData = JSON.stringify(data);
return;
});
}

/**
* Name the Tableau Web Data Connector
*
* @param string connectionName
* @param string connectionName
*/
setConnectionName(connectionName)
{
Expand Down

0 comments on commit dd5d87c

Please sign in to comment.