discourse-data-explorer/assets/javascripts/discourse/routes/admin-plugins-explorer.js.es6

51 lines
1.3 KiB
Plaintext
Raw Normal View History

2018-10-10 07:56:23 -04:00
import { ajax } from "discourse/lib/ajax";
2015-06-25 16:26:31 -04:00
export default Discourse.Route.extend({
2018-10-10 07:56:23 -04:00
controllerName: "admin-plugins-explorer",
2015-06-25 16:26:31 -04:00
model() {
const groupPromise = this.store.findAll("group");
const schemaPromise = ajax("/admin/plugins/explorer/schema.json", { cache: true });
const queryPromise = this.store.findAll("query");
return groupPromise
.then(groups => {
let groupNames = {};
groups.forEach(g => {
groupNames[g.id] = g.name;
});
return schemaPromise.then(schema => {
return queryPromise.then(model => {
model.forEach(query => {
query.markNotDirty();
query.set(
"group_names",
query.group_ids
.map(id => groupNames[id])
.filter(n => n)
.join(", ")
);
});
return { model, schema, groups };
});
2018-10-10 07:56:23 -04:00
});
})
.catch(() => {
schemaPromise.catch(() => {});
queryPromise.catch(() => {});
return { model: null, schema: null, disallow: true, groups: null };
2018-10-10 07:56:23 -04:00
});
2015-07-08 16:45:13 -04:00
},
setupController(controller, model) {
controller.setProperties(model);
},
actions: {
refreshModel() {
2018-10-10 07:56:23 -04:00
this.refresh();
2018-12-16 09:22:23 -05:00
return false;
2018-10-10 07:56:23 -04:00
}
2015-06-25 16:26:31 -04:00
}
2018-10-10 07:56:23 -04:00
});