2016-06-30 13:55:44 -04:00
|
|
|
import { ajax } from 'discourse/lib/ajax';
|
2013-03-29 15:48:26 -04:00
|
|
|
|
2015-11-20 20:27:06 -05:00
|
|
|
const AdminDashboard = Discourse.Model.extend({});
|
2013-03-29 15:48:26 -04:00
|
|
|
|
2015-11-20 20:27:06 -05:00
|
|
|
AdminDashboard.reopenClass({
|
2013-03-29 15:48:26 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Fetch all dashboard data. This can be an expensive request when the cached data
|
|
|
|
has expired and the server must collect the data again.
|
|
|
|
|
|
|
|
@method find
|
|
|
|
@return {jqXHR} a jQuery Promise object
|
|
|
|
**/
|
2013-03-14 18:26:12 -04:00
|
|
|
find: function() {
|
2016-06-30 13:55:44 -04:00
|
|
|
return ajax("/admin/dashboard.json").then(function(json) {
|
2015-11-20 20:27:06 -05:00
|
|
|
var model = AdminDashboard.create(json);
|
2013-04-03 16:06:55 -04:00
|
|
|
model.set('loaded', true);
|
|
|
|
return model;
|
2013-03-14 18:26:12 -04:00
|
|
|
});
|
2013-03-29 15:48:26 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
Only fetch the list of problems that should be rendered on the dashboard.
|
|
|
|
The model will only have its "problems" attribute set.
|
|
|
|
|
|
|
|
@method fetchProblems
|
|
|
|
@return {jqXHR} a jQuery Promise object
|
|
|
|
**/
|
|
|
|
fetchProblems: function() {
|
2016-06-30 13:55:44 -04:00
|
|
|
return ajax("/admin/dashboard/problems.json", {
|
2013-03-29 15:48:26 -04:00
|
|
|
type: 'GET',
|
2013-04-03 16:06:55 -04:00
|
|
|
dataType: 'json'
|
|
|
|
}).then(function(json) {
|
2015-11-20 20:27:06 -05:00
|
|
|
var model = AdminDashboard.create(json);
|
2013-04-03 16:06:55 -04:00
|
|
|
model.set('loaded', true);
|
|
|
|
return model;
|
2013-03-29 15:48:26 -04:00
|
|
|
});
|
2013-03-14 18:26:12 -04:00
|
|
|
}
|
2013-03-21 11:24:05 -04:00
|
|
|
});
|
2015-11-20 20:27:06 -05:00
|
|
|
|
|
|
|
export default AdminDashboard;
|