discourse/app/assets/javascripts/admin/addon/models/admin-dashboard.js
David Taylor 64557c4076
DEV: Update admin models to native class syntax (#20704)
This commit was generated using the ember-native-class-codemod along with a handful of manual updates
2023-03-17 10:18:42 +00:00

45 lines
1.0 KiB
JavaScript

import EmberObject from "@ember/object";
import { ajax } from "discourse/lib/ajax";
const GENERAL_ATTRIBUTES = [
"updated_at",
"discourse_updated_at",
"release_notes_link",
];
export default class AdminDashboard extends EmberObject {
static fetch() {
return ajax("/admin/dashboard.json").then((json) => {
const model = AdminDashboard.create();
model.set("version_check", json.version_check);
return model;
});
}
static 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;
});
}
static fetchProblems() {
return ajax("/admin/dashboard/problems.json").then((json) => {
const model = AdminDashboard.create(json);
model.set("loaded", true);
return model;
});
}
}