discourse-data-explorer/assets/javascripts/discourse/routes/group-reports-show.js

43 lines
1.0 KiB
JavaScript
Raw Normal View History

import { ajax } from "discourse/lib/ajax";
2020-05-12 14:41:26 -04:00
import DiscourseRoute from "discourse/routes/discourse";
import { action } from "@ember/object";
2020-05-12 14:41:26 -04:00
export default DiscourseRoute.extend({
controllerName: "group-reports-show",
model(params) {
const group = this.modelFor("group");
return ajax(`/g/${group.name}/reports/${params.query_id}`)
2020-09-04 07:23:11 -04:00
.then((response) => {
let query = response.query;
let queryGroup = response.query_group;
const queryParamInfo = query.param_info;
const queryParams = queryParamInfo.reduce((acc, param) => {
acc[param.identifier] = param.default;
return acc;
}, {});
return {
model: Object.assign({ params: queryParams }, query),
2020-09-04 07:23:11 -04:00
group,
queryGroup,
};
})
2019-09-11 11:30:39 -04:00
.catch(() => {
this.transitionTo("group.members", group);
});
},
setupController(controller, model) {
controller.setProperties(model);
},
@action
refreshModel() {
this.refresh();
return false;
2020-09-04 07:23:11 -04:00
},
});