Created
March 3, 2016 18:37
-
-
Save Mariusio/f743c6d21e16d2ad8e79 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
import Ember from 'ember'; | |
import ENV from 'zenline-frontend/config/environment'; | |
export default Ember.Route.extend({ | |
model: function(params) { | |
return new Promise((resolve, reject) => { | |
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) => { | |
this.store.pushPayload(data); | |
console.log(data); | |
var model = Ember.RSVP.hash({ | |
dashboard: this.store.peekRecord('dashboard', parseInt(data.data["id"])), | |
reports: this.store.peekRecord('dashboard', parseInt(data.data["id"])).get('reports') | |
}); | |
console.log("model"); | |
console.log(model); | |
resolve(model); | |
}, | |
error: (jqXHR, textStatus, errorThrown) => { | |
console.log("ajax error"); | |
resolve(jqXHR); | |
} | |
}); | |
}).then((model) => { | |
console.log("model"); | |
console.log(model); | |
return model; | |
}, (error) => { | |
console.log("error"); | |
console.log(error); | |
return error; | |
}); | |
}, | |
setupController(controller, model) { | |
console.log("model.dashboard"); | |
console.log(model.dashboard); | |
console.log(model.dashboard == true); | |
if (model.dashboard) { | |
console.log(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