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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

48 lines
1.0 KiB
Plaintext
Raw Normal View History

2016-07-01 01:55:44 +08:00
import { ajax } from "discourse/lib/ajax";
2019-11-09 03:13:35 +08:00
import EmberObject from "@ember/object";
const GENERAL_ATTRIBUTES = [
"updated_at",
"discourse_updated_at",
"release_notes_link"
];
2019-04-01 18:39:49 +08:00
2019-11-09 03:13:35 +08:00
const AdminDashboard = EmberObject.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);
model.set("loaded", true);
return model;
});
}
});
export default AdminDashboard;