45 lines
1.0 KiB
JavaScript
Raw Normal View History

2019-11-08 14:13:35 -05:00
import EmberObject from "@ember/object";
import { ajax } from "discourse/lib/ajax";
const GENERAL_ATTRIBUTES = [
"updated_at",
"discourse_updated_at",
"release_notes_link",
];
2019-04-01 12:39:49 +02:00
export default class AdminDashboard extends EmberObject {
static fetch() {
return ajax("/admin/dashboard.json").then((json) => {
2019-04-01 12:39:49 +02:00
const model = AdminDashboard.create();
model.set("version_check", json.version_check);
2019-04-01 12:39:49 +02:00
return model;
});
}
2019-04-01 12:39:49 +02:00
static fetchGeneral() {
return ajax("/admin/dashboard/general.json").then((json) => {
2019-04-01 12:39:49 +02:00
const model = AdminDashboard.create();
const attributes = {};
GENERAL_ATTRIBUTES.forEach((a) => (attributes[a] = json[a]));
2019-04-01 12:39:49 +02:00
model.setProperties({
reports: json.reports,
attributes,
loaded: true,
2019-04-01 12:39:49 +02:00
});
return model;
});
}
2019-04-01 12:39:49 +02:00
static fetchProblems() {
return ajax("/admin/dashboard/problems.json").then((json) => {
2019-04-01 12:39:49 +02:00
const model = AdminDashboard.create(json);
2018-06-15 17:03:24 +02:00
model.set("loaded", true);
return model;
});
}
}