2018-06-15 10:03:24 -05:00
|
|
|
import { ajax } from "discourse/lib/ajax";
|
2013-03-29 14:48:26 -05:00
|
|
|
|
2019-05-17 00:42:45 -05:00
|
|
|
const GENERAL_ATTRIBUTES = [
|
|
|
|
"updated_at",
|
|
|
|
"discourse_updated_at",
|
|
|
|
"release_notes_link"
|
|
|
|
];
|
2019-04-01 05:39:49 -05:00
|
|
|
|
2015-11-20 19:27:06 -06:00
|
|
|
const AdminDashboard = Discourse.Model.extend({});
|
2013-03-29 14:48:26 -05:00
|
|
|
|
2015-11-20 19:27:06 -06:00
|
|
|
AdminDashboard.reopenClass({
|
2019-04-01 05:39:49 -05:00
|
|
|
fetch() {
|
|
|
|
return ajax("/admin/dashboard.json").then(json => {
|
|
|
|
const model = AdminDashboard.create();
|
|
|
|
model.set("version_check", json.version_check);
|
|
|
|
return model;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
fetchGeneral() {
|
|
|
|
return ajax("/admin/dashboard/general.json").then(json => {
|
|
|
|
const model = AdminDashboard.create();
|
|
|
|
|
|
|
|
const attributes = {};
|
|
|
|
GENERAL_ATTRIBUTES.forEach(a => (attributes[a] = json[a]));
|
|
|
|
|
|
|
|
model.setProperties({
|
|
|
|
reports: json.reports,
|
|
|
|
attributes,
|
|
|
|
loaded: true
|
|
|
|
});
|
|
|
|
|
|
|
|
return model;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
fetchProblems() {
|
|
|
|
return ajax("/admin/dashboard/problems.json").then(json => {
|
|
|
|
const model = AdminDashboard.create(json);
|
2018-06-15 10:03:24 -05:00
|
|
|
model.set("loaded", true);
|
2013-04-03 15:06:55 -05:00
|
|
|
return model;
|
2013-03-14 17:26:12 -05:00
|
|
|
});
|
2018-06-15 10:03:24 -05:00
|
|
|
}
|
2013-03-21 10:24:05 -05:00
|
|
|
});
|
2015-11-20 19:27:06 -06:00
|
|
|
|
|
|
|
export default AdminDashboard;
|