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

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

49 lines
1.1 KiB
JavaScript
Raw Normal View History

2019-11-08 14:13:35 -05:00
import EmberObject from "@ember/object";
2016-06-30 13:55:44 -04:00
import { ajax } from "discourse/lib/ajax";
const GENERAL_ATTRIBUTES = [
"updated_at",
"discourse_updated_at",
"release_notes_link",
];
2019-04-01 06:39:49 -04:00
2019-11-08 14:13:35 -05:00
const AdminDashboard = EmberObject.extend({});
AdminDashboard.reopenClass({
2019-04-01 06:39:49 -04:00
fetch() {
return ajax("/admin/dashboard.json").then((json) => {
const model = AdminDashboard.create();
model.set("version_check", json.version_check);
2019-04-01 06:39:49 -04:00
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;