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";
|
2013-03-30 03:48:26 +08:00
|
|
|
|
2019-05-17 13:42:45 +08:00
|
|
|
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({});
|
2013-03-30 03:48:26 +08:00
|
|
|
|
2015-11-21 09:27:06 +08:00
|
|
|
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);
|
2013-04-04 04:06:55 +08:00
|
|
|
model.set("loaded", true);
|
|
|
|
return model;
|
2013-03-15 06:26:12 +08:00
|
|
|
});
|
2013-03-30 03:48:26 +08:00
|
|
|
}
|
2013-03-21 23:24:05 +08:00
|
|
|
});
|
2015-11-21 09:27:06 +08:00
|
|
|
|
|
|
|
export default AdminDashboard;
|