Created
March 3, 2016 17:17
-
-
Save Mariusio/6c9863700044fdd0e081 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default Ember.Route.extend({ | |
model: function(params) { | |
return Em.$.ajax(ENV.api.host + '/dashboards/' + params["dashboard_share_token"] + "/public", { | |
type: 'GET', // HTTP method | |
dataType: 'JSON', // type of data expected from the API response | |
contentType: "application/json", | |
success: (data, textStatus, jqXHR) => { | |
console.log("success"); | |
console.log(data); | |
this.store.pushPayload(data); | |
return Ember.RSVP.hash({ | |
dashboard: this.store.peekRecord('dashboard', parseInt(data.data["id"])), | |
reports: this.store.peekRecord('dashboard', parseInt(data.data["id"])).get('reports') | |
}); | |
}, | |
error: (jqXHR, textStatus, errorThrown) => { | |
console.log(jqXHR); | |
console.log("Error!"); | |
this.notifications.error('Error: ' + jqXHR["responseText"], { | |
autoClear: true | |
}); | |
} | |
}); | |
}, | |
setupController(controller, model) { | |
console.log(model); | |
console.log(model.reports); | |
console.log(model.dashboard); | |
var reports = model.reports; | |
var dashboard = model.dashboard; | |
controller.set('dashboard', dashboard); | |
controller.set('reports', reports); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment