discourse/app/assets/javascripts/admin/models/admin-dashboard.js.es6

47 lines
1.0 KiB
Plaintext
Raw Normal View History

2018-06-15 23:03:24 +08:00
import { ajax } from "discourse/lib/ajax";
const GENERAL_ATTRIBUTES = [
"updated_at",
"discourse_updated_at",
"release_notes_link"
];
2019-04-01 18:39:49 +08:00
const AdminDashboard = Discourse.Model.extend({});
AdminDashboard.reopenClass({
2019-04-01 18:39:49 +08: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 23:03:24 +08:00
model.set("loaded", true);
return model;
});
2018-06-15 23:03:24 +08:00
}
});
export default AdminDashboard;