Skip to content

Instantly share code, notes, and snippets.

@Mariusio
Created March 3, 2016 17:17
Show Gist options
  • Save Mariusio/6c9863700044fdd0e081 to your computer and use it in GitHub Desktop.
Save Mariusio/6c9863700044fdd0e081 to your computer and use it in GitHub Desktop.
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