2014-07-22 23:20:45 -04:00
|
|
|
export default Ember.ObjectController.extend({
|
2013-03-17 15:02:36 -04:00
|
|
|
viewMode: 'table',
|
2013-05-29 13:33:54 -04:00
|
|
|
viewingTable: Em.computed.equal('viewMode', 'table'),
|
|
|
|
viewingBarChart: Em.computed.equal('viewMode', 'barChart'),
|
2014-11-05 14:46:27 -05:00
|
|
|
startDate: null,
|
|
|
|
endDate: null,
|
2015-06-24 09:19:39 -04:00
|
|
|
categoryId: null,
|
2014-11-05 14:46:27 -05:00
|
|
|
refreshing: false,
|
2013-03-17 15:02:36 -04:00
|
|
|
|
2015-07-03 12:58:13 -04:00
|
|
|
categoryOptions: function() {
|
|
|
|
var arr = [{name: I18n.t('category.all'), value: 'all'}];
|
|
|
|
return arr.concat( Discourse.Site.currentProp('sortedCategories').map(function(i) { return {name: i.get('name'), value: i.get('id') }; }) );
|
|
|
|
}.property(),
|
|
|
|
|
2013-09-16 14:08:55 -04:00
|
|
|
actions: {
|
2015-06-24 09:19:39 -04:00
|
|
|
refreshReport() {
|
2015-07-03 12:58:13 -04:00
|
|
|
var q;
|
2015-06-24 09:19:39 -04:00
|
|
|
this.set("refreshing", true);
|
2015-07-03 12:58:13 -04:00
|
|
|
if (this.get('categoryId') === "all") {
|
|
|
|
q = Discourse.Report.find(this.get("model.type"), this.get("startDate"), this.get("endDate"));
|
|
|
|
} else {
|
|
|
|
q = Discourse.Report.find(this.get("model.type"), this.get("startDate"), this.get("endDate"), this.get("categoryId"));
|
|
|
|
}
|
|
|
|
q.then(m => this.set("model", m)).finally(() => this.set("refreshing", false));
|
2014-11-05 14:46:27 -05:00
|
|
|
},
|
|
|
|
|
2015-06-24 09:19:39 -04:00
|
|
|
viewAsTable() {
|
2013-09-16 14:08:55 -04:00
|
|
|
this.set('viewMode', 'table');
|
|
|
|
},
|
2013-03-17 15:02:36 -04:00
|
|
|
|
2015-06-24 09:19:39 -04:00
|
|
|
viewAsBarChart() {
|
2013-09-16 14:08:55 -04:00
|
|
|
this.set('viewMode', 'barChart');
|
|
|
|
}
|
2013-03-17 15:02:36 -04:00
|
|
|
}
|
2014-06-10 11:54:38 -04:00
|
|
|
});
|