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.

47 lines
1.0 KiB
JavaScript
Raw Normal View History

2019-11-09 03:13:35 +08:00
import EmberObject from "@ember/object";
2016-07-01 01:55:44 +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
export default class AdminDashboard extends EmberObject {
static fetch() {
2019-04-01 18:39:49 +08:00
return ajax("/admin/dashboard.json").then((json) => {
const model = AdminDashboard.create();
model.setProperties({
version_check: json.version_check,
});
2019-04-01 18:39:49 +08:00
return model;
});
}
2019-04-01 18:39:49 +08:00
static fetchGeneral() {
2019-04-01 18:39:49 +08:00
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;
});
}
2019-04-01 18:39:49 +08:00
static fetchProblems() {
2019-04-01 18:39:49 +08:00
return ajax("/admin/dashboard/problems.json").then((json) => {
const model = AdminDashboard.create(json);
model.set("loaded", true);
return model;
});
}
}