mirror of
https://github.com/discourse/discourse.git
synced 2026-07-29 23:58:12 -05:00
REFACTOR: Remove Discourse.Ajax
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { ajax } from 'discourse/lib/ajax';
|
||||
|
||||
export default Ember.Component.extend({
|
||||
classNames: ["ip-lookup"],
|
||||
@@ -23,7 +24,7 @@ export default Ember.Component.extend({
|
||||
this.set("show", true);
|
||||
|
||||
if (!this.get("location")) {
|
||||
Discourse.ajax("/admin/users/ip-info", {
|
||||
ajax("/admin/users/ip-info", {
|
||||
data: { ip: this.get("ip") }
|
||||
}).then(function (location) {
|
||||
self.set("location", Em.Object.create(location));
|
||||
@@ -39,7 +40,7 @@ export default Ember.Component.extend({
|
||||
"order": "trust_level DESC"
|
||||
};
|
||||
|
||||
Discourse.ajax("/admin/users/total-others-with-same-ip", { data }).then(function (result) {
|
||||
ajax("/admin/users/total-others-with-same-ip", { data }).then(function (result) {
|
||||
self.set("totalOthersWithSameIP", result.total);
|
||||
});
|
||||
|
||||
@@ -67,7 +68,7 @@ export default Ember.Component.extend({
|
||||
totalOthersWithSameIP: null
|
||||
});
|
||||
|
||||
Discourse.ajax("/admin/users/delete-others-with-same-ip.json", {
|
||||
ajax("/admin/users/delete-others-with-same-ip.json", {
|
||||
type: "DELETE",
|
||||
data: {
|
||||
"ip": self.get("ip"),
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { ajax } from 'discourse/lib/ajax';
|
||||
export default Ember.ArrayController.extend({
|
||||
needs: ["adminBackups"],
|
||||
status: Ember.computed.alias("controllers.adminBackups"),
|
||||
@@ -39,7 +40,7 @@ export default Ember.ArrayController.extend({
|
||||
|
||||
_toggleReadOnlyMode(enable) {
|
||||
var site = this.site;
|
||||
Discourse.ajax("/admin/backups/readonly", {
|
||||
ajax("/admin/backups/readonly", {
|
||||
type: "PUT",
|
||||
data: { enable: enable }
|
||||
}).then(function() {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { ajax } from 'discourse/lib/ajax';
|
||||
export default Ember.Controller.extend({
|
||||
|
||||
/**
|
||||
@@ -29,7 +30,7 @@ export default Ember.Controller.extend({
|
||||
});
|
||||
|
||||
var self = this;
|
||||
Discourse.ajax("/admin/email/test", {
|
||||
ajax("/admin/email/test", {
|
||||
type: 'POST',
|
||||
data: { email_address: this.get('testEmailAddress') }
|
||||
}).then(function () {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { ajax } from 'discourse/lib/ajax';
|
||||
export default Ember.ArrayController.extend({
|
||||
sortProperties: ["name"],
|
||||
|
||||
@@ -15,7 +16,7 @@ export default Ember.ArrayController.extend({
|
||||
I18n.t("yes_value"),
|
||||
function(destroy) {
|
||||
if (destroy) {
|
||||
return Discourse.ajax("/admin/customize/emojis/" + emoji.get("name"), { type: "DELETE" }).then(function() {
|
||||
return ajax("/admin/customize/emojis/" + emoji.get("name"), { type: "DELETE" }).then(function() {
|
||||
self.removeObject(emoji);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { ajax } from 'discourse/lib/ajax';
|
||||
import computed from 'ember-addons/ember-computed-decorators';
|
||||
import { popupAjaxError } from 'discourse/lib/ajax-error';
|
||||
|
||||
@@ -20,7 +21,7 @@ export default Ember.Controller.extend({
|
||||
.reject(x => x.length === 0);
|
||||
|
||||
this.set('saving', true);
|
||||
Discourse.ajax('/admin/groups/bulk', {
|
||||
ajax('/admin/groups/bulk', {
|
||||
data: { users, group_id: this.get('groupId') },
|
||||
method: 'PUT'
|
||||
}).then(() => {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { ajax } from 'discourse/lib/ajax';
|
||||
export default Ember.ArrayController.extend({
|
||||
sortProperties: ['name'],
|
||||
refreshingAutoGroups: false,
|
||||
@@ -9,7 +10,7 @@ export default Ember.ArrayController.extend({
|
||||
refreshAutoGroups: function(){
|
||||
var self = this;
|
||||
this.set('refreshingAutoGroups', true);
|
||||
Discourse.ajax('/admin/groups/refresh_automatic_groups', {type: 'POST'}).then(function() {
|
||||
ajax('/admin/groups/refresh_automatic_groups', {type: 'POST'}).then(function() {
|
||||
self.transitionToRoute("adminGroupsType", "automatic").then(function() {
|
||||
self.set('refreshingAutoGroups', false);
|
||||
});
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { ajax } from 'discourse/lib/ajax';
|
||||
import CanCheckEmails from 'discourse/mixins/can-check-emails';
|
||||
import { propertyNotEqual, setting } from 'discourse/lib/computed';
|
||||
|
||||
@@ -38,7 +39,7 @@ export default Ember.Controller.extend(CanCheckEmails, {
|
||||
saveTitle() {
|
||||
const self = this;
|
||||
|
||||
return Discourse.ajax("/users/" + this.get('model.username').toLowerCase(), {
|
||||
return ajax("/users/" + this.get('model.username').toLowerCase(), {
|
||||
data: {title: this.get('userTitleValue')},
|
||||
type: 'PUT'
|
||||
}).catch(function(e) {
|
||||
@@ -68,7 +69,7 @@ export default Ember.Controller.extend(CanCheckEmails, {
|
||||
savePrimaryGroup() {
|
||||
const self = this;
|
||||
|
||||
return Discourse.ajax("/admin/users/" + this.get('model.id') + "/primary_group", {
|
||||
return ajax("/admin/users/" + this.get('model.id') + "/primary_group", {
|
||||
type: 'PUT',
|
||||
data: {primary_group_id: this.get('model.primary_group_id')}
|
||||
}).then(function () {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { ajax } from 'discourse/lib/ajax';
|
||||
export default Ember.Controller.extend({
|
||||
needs: ['modal'],
|
||||
|
||||
@@ -57,7 +58,7 @@ export default Ember.Controller.extend({
|
||||
const groupIds = items.map(function(i){return i.get("id") || -1;});
|
||||
const names = items.map(function(i){return i.get("name");});
|
||||
|
||||
Discourse.ajax('/admin/badges/badge_groupings',{
|
||||
ajax('/admin/badges/badge_groupings',{
|
||||
data: {ids: groupIds, names: names},
|
||||
method: 'POST'
|
||||
}).then(function(data){
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { ajax } from 'discourse/lib/ajax';
|
||||
|
||||
const AdminDashboard = Discourse.Model.extend({});
|
||||
|
||||
@@ -11,7 +12,7 @@ AdminDashboard.reopenClass({
|
||||
@return {jqXHR} a jQuery Promise object
|
||||
**/
|
||||
find: function() {
|
||||
return Discourse.ajax("/admin/dashboard.json").then(function(json) {
|
||||
return ajax("/admin/dashboard.json").then(function(json) {
|
||||
var model = AdminDashboard.create(json);
|
||||
model.set('loaded', true);
|
||||
return model;
|
||||
@@ -26,7 +27,7 @@ AdminDashboard.reopenClass({
|
||||
@return {jqXHR} a jQuery Promise object
|
||||
**/
|
||||
fetchProblems: function() {
|
||||
return Discourse.ajax("/admin/dashboard/problems.json", {
|
||||
return ajax("/admin/dashboard/problems.json", {
|
||||
type: 'GET',
|
||||
dataType: 'json'
|
||||
}).then(function(json) {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { ajax } from 'discourse/lib/ajax';
|
||||
import computed from 'ember-addons/ember-computed-decorators';
|
||||
import { propertyNotEqual } from 'discourse/lib/computed';
|
||||
import { popupAjaxError } from 'discourse/lib/ajax-error';
|
||||
@@ -40,7 +41,7 @@ const AdminUser = Discourse.User.extend({
|
||||
canResetBounceScore: Ember.computed.gt("bounce_score", 0),
|
||||
|
||||
resetBounceScore() {
|
||||
return Discourse.ajax(`/admin/users/${this.get("id")}/reset_bounce_score`, {
|
||||
return ajax(`/admin/users/${this.get("id")}/reset_bounce_score`, {
|
||||
type: 'POST'
|
||||
}).then(() => this.setProperties({
|
||||
"bounce_score": 0,
|
||||
@@ -50,7 +51,7 @@ const AdminUser = Discourse.User.extend({
|
||||
|
||||
generateApiKey() {
|
||||
const self = this;
|
||||
return Discourse.ajax("/admin/users/" + this.get('id') + "/generate_api_key", {
|
||||
return ajax("/admin/users/" + this.get('id') + "/generate_api_key", {
|
||||
type: 'POST'
|
||||
}).then(function (result) {
|
||||
const apiKey = ApiKey.create(result.api_key);
|
||||
@@ -60,20 +61,20 @@ const AdminUser = Discourse.User.extend({
|
||||
},
|
||||
|
||||
groupAdded(added) {
|
||||
return Discourse.ajax("/admin/users/" + this.get('id') + "/groups", {
|
||||
return ajax("/admin/users/" + this.get('id') + "/groups", {
|
||||
type: 'POST',
|
||||
data: { group_id: added.id }
|
||||
}).then(() => this.get('groups').pushObject(added));
|
||||
},
|
||||
|
||||
groupRemoved(groupId) {
|
||||
return Discourse.ajax("/admin/users/" + this.get('id') + "/groups/" + groupId, {
|
||||
return ajax("/admin/users/" + this.get('id') + "/groups/" + groupId, {
|
||||
type: 'DELETE'
|
||||
}).then(() => this.set('groups.[]', this.get('groups').rejectBy("id", groupId)));
|
||||
},
|
||||
|
||||
revokeApiKey() {
|
||||
return Discourse.ajax("/admin/users/" + this.get('id') + "/revoke_api_key", {
|
||||
return ajax("/admin/users/" + this.get('id') + "/revoke_api_key", {
|
||||
type: 'DELETE'
|
||||
}).then(() => this.set('api_key', null));
|
||||
},
|
||||
@@ -104,7 +105,7 @@ const AdminUser = Discourse.User.extend({
|
||||
"label": '<i class="fa fa-exclamation-triangle"></i> ' + I18n.t("admin.user.delete_all_posts"),
|
||||
"class": "btn btn-danger",
|
||||
"callback": function() {
|
||||
Discourse.ajax("/admin/users/" + user.get('id') + "/delete_all_posts", {
|
||||
ajax("/admin/users/" + user.get('id') + "/delete_all_posts", {
|
||||
type: 'PUT'
|
||||
}).then(() => user.set('post_count', 0));
|
||||
}
|
||||
@@ -114,7 +115,7 @@ const AdminUser = Discourse.User.extend({
|
||||
|
||||
revokeAdmin() {
|
||||
const self = this;
|
||||
return Discourse.ajax("/admin/users/" + this.get('id') + "/revoke_admin", {
|
||||
return ajax("/admin/users/" + this.get('id') + "/revoke_admin", {
|
||||
type: 'PUT'
|
||||
}).then(function() {
|
||||
self.setProperties({
|
||||
@@ -127,7 +128,7 @@ const AdminUser = Discourse.User.extend({
|
||||
|
||||
grantAdmin() {
|
||||
const self = this;
|
||||
return Discourse.ajax("/admin/users/" + this.get('id') + "/grant_admin", {
|
||||
return ajax("/admin/users/" + this.get('id') + "/grant_admin", {
|
||||
type: 'PUT'
|
||||
}).then(function() {
|
||||
self.setProperties({
|
||||
@@ -140,7 +141,7 @@ const AdminUser = Discourse.User.extend({
|
||||
|
||||
revokeModeration() {
|
||||
const self = this;
|
||||
return Discourse.ajax("/admin/users/" + this.get('id') + "/revoke_moderation", {
|
||||
return ajax("/admin/users/" + this.get('id') + "/revoke_moderation", {
|
||||
type: 'PUT'
|
||||
}).then(function() {
|
||||
self.setProperties({
|
||||
@@ -153,7 +154,7 @@ const AdminUser = Discourse.User.extend({
|
||||
|
||||
grantModeration() {
|
||||
const self = this;
|
||||
return Discourse.ajax("/admin/users/" + this.get('id') + "/grant_moderation", {
|
||||
return ajax("/admin/users/" + this.get('id') + "/grant_moderation", {
|
||||
type: 'PUT'
|
||||
}).then(function() {
|
||||
self.setProperties({
|
||||
@@ -165,14 +166,14 @@ const AdminUser = Discourse.User.extend({
|
||||
},
|
||||
|
||||
refreshBrowsers() {
|
||||
return Discourse.ajax("/admin/users/" + this.get('id') + "/refresh_browsers", {
|
||||
return ajax("/admin/users/" + this.get('id') + "/refresh_browsers", {
|
||||
type: 'POST'
|
||||
}).finally(() => bootbox.alert(I18n.t("admin.user.refresh_browsers_message")));
|
||||
},
|
||||
|
||||
approve() {
|
||||
const self = this;
|
||||
return Discourse.ajax("/admin/users/" + this.get('id') + "/approve", {
|
||||
return ajax("/admin/users/" + this.get('id') + "/approve", {
|
||||
type: 'PUT'
|
||||
}).then(function() {
|
||||
self.setProperties({
|
||||
@@ -190,7 +191,7 @@ const AdminUser = Discourse.User.extend({
|
||||
dirty: propertyNotEqual('originalTrustLevel', 'trustLevel.id'),
|
||||
|
||||
saveTrustLevel() {
|
||||
return Discourse.ajax("/admin/users/" + this.id + "/trust_level", {
|
||||
return ajax("/admin/users/" + this.id + "/trust_level", {
|
||||
type: 'PUT',
|
||||
data: { level: this.get('trustLevel.id') }
|
||||
}).then(function() {
|
||||
@@ -210,7 +211,7 @@ const AdminUser = Discourse.User.extend({
|
||||
},
|
||||
|
||||
lockTrustLevel(locked) {
|
||||
return Discourse.ajax("/admin/users/" + this.id + "/trust_level_lock", {
|
||||
return ajax("/admin/users/" + this.id + "/trust_level_lock", {
|
||||
type: 'PUT',
|
||||
data: { locked: !!locked }
|
||||
}).then(function() {
|
||||
@@ -239,14 +240,14 @@ const AdminUser = Discourse.User.extend({
|
||||
}.property('suspended_till', 'suspended_at'),
|
||||
|
||||
suspend(duration, reason) {
|
||||
return Discourse.ajax("/admin/users/" + this.id + "/suspend", {
|
||||
return ajax("/admin/users/" + this.id + "/suspend", {
|
||||
type: 'PUT',
|
||||
data: { duration: duration, reason: reason }
|
||||
});
|
||||
},
|
||||
|
||||
unsuspend() {
|
||||
return Discourse.ajax("/admin/users/" + this.id + "/unsuspend", {
|
||||
return ajax("/admin/users/" + this.id + "/unsuspend", {
|
||||
type: 'PUT'
|
||||
}).then(function() {
|
||||
window.location.reload();
|
||||
@@ -257,7 +258,7 @@ const AdminUser = Discourse.User.extend({
|
||||
},
|
||||
|
||||
log_out() {
|
||||
return Discourse.ajax("/admin/users/" + this.id + "/log_out", {
|
||||
return ajax("/admin/users/" + this.id + "/log_out", {
|
||||
type: 'POST',
|
||||
data: { username_or_email: this.get('username') }
|
||||
}).then(function() {
|
||||
@@ -266,7 +267,7 @@ const AdminUser = Discourse.User.extend({
|
||||
},
|
||||
|
||||
impersonate() {
|
||||
return Discourse.ajax("/admin/impersonate", {
|
||||
return ajax("/admin/impersonate", {
|
||||
type: 'POST',
|
||||
data: { username_or_email: this.get('username') }
|
||||
}).then(function() {
|
||||
@@ -281,7 +282,7 @@ const AdminUser = Discourse.User.extend({
|
||||
},
|
||||
|
||||
activate() {
|
||||
return Discourse.ajax('/admin/users/' + this.id + '/activate', {
|
||||
return ajax('/admin/users/' + this.id + '/activate', {
|
||||
type: 'PUT'
|
||||
}).then(function() {
|
||||
window.location.reload();
|
||||
@@ -292,7 +293,7 @@ const AdminUser = Discourse.User.extend({
|
||||
},
|
||||
|
||||
deactivate() {
|
||||
return Discourse.ajax('/admin/users/' + this.id + '/deactivate', {
|
||||
return ajax('/admin/users/' + this.id + '/deactivate', {
|
||||
type: 'PUT'
|
||||
}).then(function() {
|
||||
window.location.reload();
|
||||
@@ -304,7 +305,7 @@ const AdminUser = Discourse.User.extend({
|
||||
|
||||
unblock() {
|
||||
this.set('blockingUser', true);
|
||||
return Discourse.ajax('/admin/users/' + this.id + '/unblock', {
|
||||
return ajax('/admin/users/' + this.id + '/unblock', {
|
||||
type: 'PUT'
|
||||
}).then(function() {
|
||||
window.location.reload();
|
||||
@@ -320,7 +321,7 @@ const AdminUser = Discourse.User.extend({
|
||||
|
||||
const performBlock = function() {
|
||||
user.set('blockingUser', true);
|
||||
return Discourse.ajax('/admin/users/' + user.id + '/block', {
|
||||
return ajax('/admin/users/' + user.id + '/block', {
|
||||
type: 'PUT'
|
||||
}).then(function() {
|
||||
window.location.reload();
|
||||
@@ -345,7 +346,7 @@ const AdminUser = Discourse.User.extend({
|
||||
},
|
||||
|
||||
sendActivationEmail() {
|
||||
return Discourse.ajax('/users/action/send_activation_email', {
|
||||
return ajax('/users/action/send_activation_email', {
|
||||
type: 'POST',
|
||||
data: { username: this.get('username') }
|
||||
}).then(function() {
|
||||
@@ -360,7 +361,7 @@ const AdminUser = Discourse.User.extend({
|
||||
message = I18n.t("admin.user.anonymize_confirm");
|
||||
|
||||
const performAnonymize = function() {
|
||||
return Discourse.ajax("/admin/users/" + user.get('id') + '/anonymize.json', {
|
||||
return ajax("/admin/users/" + user.get('id') + '/anonymize.json', {
|
||||
type: 'PUT'
|
||||
}).then(function(data) {
|
||||
if (data.success) {
|
||||
@@ -422,7 +423,7 @@ const AdminUser = Discourse.User.extend({
|
||||
if (opts && opts.deletePosts) {
|
||||
formData["delete_posts"] = true;
|
||||
}
|
||||
return Discourse.ajax("/admin/users/" + user.get('id') + '.json', {
|
||||
return ajax("/admin/users/" + user.get('id') + '.json', {
|
||||
type: 'DELETE',
|
||||
data: formData
|
||||
}).then(function(data) {
|
||||
@@ -481,7 +482,7 @@ const AdminUser = Discourse.User.extend({
|
||||
"label": '<i class="fa fa-exclamation-triangle"></i> ' + I18n.t("flagging.yes_delete_spammer"),
|
||||
"class": "btn btn-danger",
|
||||
"callback": function() {
|
||||
return Discourse.ajax("/admin/users/" + user.get('id') + '.json', {
|
||||
return ajax("/admin/users/" + user.get('id') + '.json', {
|
||||
type: 'DELETE',
|
||||
data: {
|
||||
delete_posts: true,
|
||||
@@ -549,7 +550,7 @@ AdminUser.reopenClass({
|
||||
});
|
||||
});
|
||||
|
||||
return Discourse.ajax("/admin/users/approve-bulk", {
|
||||
return ajax("/admin/users/approve-bulk", {
|
||||
type: 'PUT',
|
||||
data: { users: users.map((u) => u.id) }
|
||||
}).finally(() => bootbox.alert(I18n.t("admin.user.approve_bulk_success")));
|
||||
@@ -561,7 +562,7 @@ AdminUser.reopenClass({
|
||||
user.set('selected', false);
|
||||
});
|
||||
|
||||
return Discourse.ajax("/admin/users/reject-bulk", {
|
||||
return ajax("/admin/users/reject-bulk", {
|
||||
type: 'DELETE',
|
||||
data: {
|
||||
users: users.map((u) => u.id),
|
||||
@@ -571,14 +572,14 @@ AdminUser.reopenClass({
|
||||
},
|
||||
|
||||
find(user_id) {
|
||||
return Discourse.ajax("/admin/users/" + user_id + ".json").then(result => {
|
||||
return ajax("/admin/users/" + user_id + ".json").then(result => {
|
||||
result.loadedDetails = true;
|
||||
return AdminUser.create(result);
|
||||
});
|
||||
},
|
||||
|
||||
findAll(query, filter) {
|
||||
return Discourse.ajax("/admin/users/list/" + query + ".json", {
|
||||
return ajax("/admin/users/list/" + query + ".json", {
|
||||
data: filter
|
||||
}).then(function(users) {
|
||||
return users.map((u) => AdminUser.create(u));
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { ajax } from 'discourse/lib/ajax';
|
||||
const ApiKey = Discourse.Model.extend({
|
||||
|
||||
/**
|
||||
@@ -8,7 +9,7 @@ const ApiKey = Discourse.Model.extend({
|
||||
**/
|
||||
regenerate: function() {
|
||||
var self = this;
|
||||
return Discourse.ajax('/admin/api/key', {type: 'PUT', data: {id: this.get('id')}}).then(function (result) {
|
||||
return ajax('/admin/api/key', {type: 'PUT', data: {id: this.get('id')}}).then(function (result) {
|
||||
self.set('key', result.api_key.key);
|
||||
return self;
|
||||
});
|
||||
@@ -21,7 +22,7 @@ const ApiKey = Discourse.Model.extend({
|
||||
@returns {Promise} a promise that resolves when the key has been revoked
|
||||
**/
|
||||
revoke: function() {
|
||||
return Discourse.ajax('/admin/api/key', {type: 'DELETE', data: {id: this.get('id')}});
|
||||
return ajax('/admin/api/key', {type: 'DELETE', data: {id: this.get('id')}});
|
||||
}
|
||||
|
||||
});
|
||||
@@ -51,7 +52,7 @@ ApiKey.reopenClass({
|
||||
@returns {Promise} a promise that resolves to the array of `ApiKey` instances
|
||||
**/
|
||||
find: function() {
|
||||
return Discourse.ajax("/admin/api").then(function(keys) {
|
||||
return ajax("/admin/api").then(function(keys) {
|
||||
return keys.map(function (key) {
|
||||
return ApiKey.create(key);
|
||||
});
|
||||
@@ -65,7 +66,7 @@ ApiKey.reopenClass({
|
||||
@returns {Promise} a promise that resolves to a master `ApiKey`
|
||||
**/
|
||||
generateMasterKey: function() {
|
||||
return Discourse.ajax("/admin/api/key", {type: 'POST'}).then(function (result) {
|
||||
return ajax("/admin/api/key", {type: 'POST'}).then(function (result) {
|
||||
return ApiKey.create(result.api_key);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import { ajax } from 'discourse/lib/ajax';
|
||||
const Backup = Discourse.Model.extend({
|
||||
|
||||
destroy() {
|
||||
return Discourse.ajax("/admin/backups/" + this.get("filename"), { type: "DELETE" });
|
||||
return ajax("/admin/backups/" + this.get("filename"), { type: "DELETE" });
|
||||
},
|
||||
|
||||
restore() {
|
||||
return Discourse.ajax("/admin/backups/" + this.get("filename") + "/restore", {
|
||||
return ajax("/admin/backups/" + this.get("filename") + "/restore", {
|
||||
type: "POST",
|
||||
data: { client_id: window.MessageBus.clientId }
|
||||
});
|
||||
@@ -16,13 +17,13 @@ const Backup = Discourse.Model.extend({
|
||||
Backup.reopenClass({
|
||||
|
||||
find() {
|
||||
return PreloadStore.getAndRemove("backups", () => Discourse.ajax("/admin/backups.json"))
|
||||
return PreloadStore.getAndRemove("backups", () => ajax("/admin/backups.json"))
|
||||
.then(backups => backups.map(backup => Backup.create(backup)));
|
||||
},
|
||||
|
||||
start(withUploads) {
|
||||
if (withUploads === undefined) { withUploads = true; }
|
||||
return Discourse.ajax("/admin/backups", {
|
||||
return ajax("/admin/backups", {
|
||||
type: "POST",
|
||||
data: {
|
||||
with_uploads: withUploads,
|
||||
@@ -34,14 +35,14 @@ Backup.reopenClass({
|
||||
},
|
||||
|
||||
cancel() {
|
||||
return Discourse.ajax("/admin/backups/cancel.json")
|
||||
return ajax("/admin/backups/cancel.json")
|
||||
.then(result => {
|
||||
if (!result.success) { bootbox.alert(result.message); }
|
||||
});
|
||||
},
|
||||
|
||||
rollback() {
|
||||
return Discourse.ajax("/admin/backups/rollback.json")
|
||||
return ajax("/admin/backups/rollback.json")
|
||||
.then(result => {
|
||||
if (!result.success) {
|
||||
bootbox.alert(result.message);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { ajax } from 'discourse/lib/ajax';
|
||||
import ColorSchemeColor from 'admin/models/color-scheme-color';
|
||||
|
||||
const ColorScheme = Discourse.Model.extend(Ember.Copyable, {
|
||||
@@ -65,7 +66,7 @@ const ColorScheme = Discourse.Model.extend(Ember.Copyable, {
|
||||
});
|
||||
}
|
||||
|
||||
return Discourse.ajax("/admin/color_schemes" + (this.id ? '/' + this.id : '') + '.json', {
|
||||
return ajax("/admin/color_schemes" + (this.id ? '/' + this.id : '') + '.json', {
|
||||
data: JSON.stringify({"color_scheme": data}),
|
||||
type: this.id ? 'PUT' : 'POST',
|
||||
dataType: 'json',
|
||||
@@ -88,7 +89,7 @@ const ColorScheme = Discourse.Model.extend(Ember.Copyable, {
|
||||
|
||||
destroy: function() {
|
||||
if (this.id) {
|
||||
return Discourse.ajax("/admin/color_schemes/" + this.id, { type: 'DELETE' });
|
||||
return ajax("/admin/color_schemes/" + this.id, { type: 'DELETE' });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +107,7 @@ var ColorSchemes = Ember.ArrayProxy.extend({
|
||||
ColorScheme.reopenClass({
|
||||
findAll: function() {
|
||||
var colorSchemes = ColorSchemes.create({ content: [], loading: true });
|
||||
Discourse.ajax('/admin/color_schemes').then(function(all) {
|
||||
ajax('/admin/color_schemes').then(function(all) {
|
||||
_.each(all, function(colorScheme){
|
||||
colorSchemes.pushObject(ColorScheme.create({
|
||||
id: colorScheme.id,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { ajax } from 'discourse/lib/ajax';
|
||||
import AdminUser from 'admin/models/admin-user';
|
||||
|
||||
const EmailLog = Discourse.Model.extend({});
|
||||
@@ -21,7 +22,7 @@ EmailLog.reopenClass({
|
||||
const status = filter.status || "sent";
|
||||
filter = _.omit(filter, "status");
|
||||
|
||||
return Discourse.ajax(`/admin/email/${status}.json?offset=${offset}`, { data: filter })
|
||||
return ajax(`/admin/email/${status}.json?offset=${offset}`, { data: filter })
|
||||
.then(logs => _.map(logs, log => EmailLog.create(log)));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { ajax } from 'discourse/lib/ajax';
|
||||
const EmailPreview = Discourse.Model.extend({});
|
||||
|
||||
EmailPreview.reopenClass({
|
||||
@@ -11,7 +12,7 @@ EmailPreview.reopenClass({
|
||||
username = Discourse.User.current().username;
|
||||
}
|
||||
|
||||
return Discourse.ajax("/admin/email/preview-digest.json", {
|
||||
return ajax("/admin/email/preview-digest.json", {
|
||||
data: { last_seen_at: lastSeenAt, username: username }
|
||||
}).then(function (result) {
|
||||
return EmailPreview.create(result);
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { ajax } from 'discourse/lib/ajax';
|
||||
const EmailSettings = Discourse.Model.extend({});
|
||||
|
||||
EmailSettings.reopenClass({
|
||||
find: function() {
|
||||
return Discourse.ajax("/admin/email.json").then(function (settings) {
|
||||
return ajax("/admin/email.json").then(function (settings) {
|
||||
return EmailSettings.create(settings);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { ajax } from 'discourse/lib/ajax';
|
||||
import RestModel from 'discourse/models/rest';
|
||||
const { getProperties } = Ember;
|
||||
|
||||
export default RestModel.extend({
|
||||
revert() {
|
||||
return Discourse.ajax(`/admin/customize/email_templates/${this.get('id')}`, {
|
||||
return ajax(`/admin/customize/email_templates/${this.get('id')}`, {
|
||||
method: 'DELETE'
|
||||
}).then(result => getProperties(result.email_template, 'subject', 'body', 'can_revert'));
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { ajax } from 'discourse/lib/ajax';
|
||||
import AdminUser from 'admin/models/admin-user';
|
||||
import Topic from 'discourse/models/topic';
|
||||
import Post from 'discourse/models/post';
|
||||
@@ -106,22 +107,22 @@ const FlaggedPost = Post.extend({
|
||||
|
||||
deletePost: function() {
|
||||
if (this.get('post_number') === 1) {
|
||||
return Discourse.ajax('/t/' + this.topic_id, { type: 'DELETE', cache: false });
|
||||
return ajax('/t/' + this.topic_id, { type: 'DELETE', cache: false });
|
||||
} else {
|
||||
return Discourse.ajax('/posts/' + this.id, { type: 'DELETE', cache: false });
|
||||
return ajax('/posts/' + this.id, { type: 'DELETE', cache: false });
|
||||
}
|
||||
},
|
||||
|
||||
disagreeFlags: function () {
|
||||
return Discourse.ajax('/admin/flags/disagree/' + this.id, { type: 'POST', cache: false });
|
||||
return ajax('/admin/flags/disagree/' + this.id, { type: 'POST', cache: false });
|
||||
},
|
||||
|
||||
deferFlags: function (deletePost) {
|
||||
return Discourse.ajax('/admin/flags/defer/' + this.id, { type: 'POST', cache: false, data: { delete_post: deletePost } });
|
||||
return ajax('/admin/flags/defer/' + this.id, { type: 'POST', cache: false, data: { delete_post: deletePost } });
|
||||
},
|
||||
|
||||
agreeFlags: function (actionOnPost) {
|
||||
return Discourse.ajax('/admin/flags/agree/' + this.id, { type: 'POST', cache: false, data: { action_on_post: actionOnPost } });
|
||||
return ajax('/admin/flags/agree/' + this.id, { type: 'POST', cache: false, data: { action_on_post: actionOnPost } });
|
||||
},
|
||||
|
||||
postHidden: Em.computed.alias('hidden'),
|
||||
@@ -144,7 +145,7 @@ FlaggedPost.reopenClass({
|
||||
var result = Em.A();
|
||||
result.set('loading', true);
|
||||
|
||||
return Discourse.ajax('/admin/flags/' + filter + '.json?offset=' + offset).then(function (data) {
|
||||
return ajax('/admin/flags/' + filter + '.json?offset=' + offset).then(function (data) {
|
||||
// users
|
||||
var userLookup = {};
|
||||
_.each(data.users, function (user) {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { ajax } from 'discourse/lib/ajax';
|
||||
import AdminUser from 'admin/models/admin-user';
|
||||
|
||||
const IncomingEmail = Discourse.Model.extend({});
|
||||
@@ -15,7 +16,7 @@ IncomingEmail.reopenClass({
|
||||
},
|
||||
|
||||
find(id) {
|
||||
return Discourse.ajax(`/admin/email/incoming/${id}.json`);
|
||||
return ajax(`/admin/email/incoming/${id}.json`);
|
||||
},
|
||||
|
||||
findAll(filter, offset) {
|
||||
@@ -25,12 +26,12 @@ IncomingEmail.reopenClass({
|
||||
const status = filter.status || "received";
|
||||
filter = _.omit(filter, "status");
|
||||
|
||||
return Discourse.ajax(`/admin/email/${status}.json?offset=${offset}`, { data: filter })
|
||||
return ajax(`/admin/email/${status}.json?offset=${offset}`, { data: filter })
|
||||
.then(incomings => _.map(incomings, incoming => IncomingEmail.create(incoming)));
|
||||
},
|
||||
|
||||
loadRawEmail(id) {
|
||||
return Discourse.ajax(`/admin/email/incoming/${id}/raw.json`);
|
||||
return ajax(`/admin/email/incoming/${id}/raw.json`);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
import { ajax } from 'discourse/lib/ajax';
|
||||
const Permalink = Discourse.Model.extend({
|
||||
save: function() {
|
||||
return Discourse.ajax("/admin/permalinks.json", {
|
||||
return ajax("/admin/permalinks.json", {
|
||||
type: 'POST',
|
||||
data: {url: this.get('url'), permalink_type: this.get('permalink_type'), permalink_type_value: this.get('permalink_type_value')}
|
||||
});
|
||||
},
|
||||
|
||||
destroy: function() {
|
||||
return Discourse.ajax("/admin/permalinks/" + this.get('id') + ".json", {type: 'DELETE'});
|
||||
return ajax("/admin/permalinks/" + this.get('id') + ".json", {type: 'DELETE'});
|
||||
}
|
||||
});
|
||||
|
||||
Permalink.reopenClass({
|
||||
findAll: function(filter) {
|
||||
return Discourse.ajax("/admin/permalinks.json", { data: { filter: filter } }).then(function(permalinks) {
|
||||
return ajax("/admin/permalinks.json", { data: { filter: filter } }).then(function(permalinks) {
|
||||
return permalinks.map(p => Permalink.create(p));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { ajax } from 'discourse/lib/ajax';
|
||||
import round from "discourse/lib/round";
|
||||
import { fmt } from 'discourse/lib/computed';
|
||||
|
||||
@@ -132,7 +133,7 @@ const Report = Discourse.Model.extend({
|
||||
Report.reopenClass({
|
||||
|
||||
find(type, startDate, endDate, categoryId, groupId) {
|
||||
return Discourse.ajax("/admin/reports/" + type, {
|
||||
return ajax("/admin/reports/" + type, {
|
||||
data: {
|
||||
start_date: startDate,
|
||||
end_date: endDate,
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
import { ajax } from 'discourse/lib/ajax';
|
||||
const ScreenedEmail = Discourse.Model.extend({
|
||||
actionName: function() {
|
||||
return I18n.t("admin.logs.screened_actions." + this.get('action'));
|
||||
}.property('action'),
|
||||
|
||||
clearBlock: function() {
|
||||
return Discourse.ajax('/admin/logs/screened_emails/' + this.get('id'), {method: 'DELETE'});
|
||||
return ajax('/admin/logs/screened_emails/' + this.get('id'), {method: 'DELETE'});
|
||||
}
|
||||
});
|
||||
|
||||
ScreenedEmail.reopenClass({
|
||||
findAll: function() {
|
||||
return Discourse.ajax("/admin/logs/screened_emails.json").then(function(screened_emails) {
|
||||
return ajax("/admin/logs/screened_emails.json").then(function(screened_emails) {
|
||||
return screened_emails.map(function(b) {
|
||||
return ScreenedEmail.create(b);
|
||||
});
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { ajax } from 'discourse/lib/ajax';
|
||||
import computed from 'ember-addons/ember-computed-decorators';
|
||||
|
||||
const ScreenedIpAddress = Discourse.Model.extend({
|
||||
@@ -14,25 +15,25 @@ const ScreenedIpAddress = Discourse.Model.extend({
|
||||
},
|
||||
|
||||
save() {
|
||||
return Discourse.ajax("/admin/logs/screened_ip_addresses" + (this.id ? '/' + this.id : '') + ".json", {
|
||||
return ajax("/admin/logs/screened_ip_addresses" + (this.id ? '/' + this.id : '') + ".json", {
|
||||
type: this.id ? 'PUT' : 'POST',
|
||||
data: {ip_address: this.get('ip_address'), action_name: this.get('action_name')}
|
||||
});
|
||||
},
|
||||
|
||||
destroy() {
|
||||
return Discourse.ajax("/admin/logs/screened_ip_addresses/" + this.get('id') + ".json", {type: 'DELETE'});
|
||||
return ajax("/admin/logs/screened_ip_addresses/" + this.get('id') + ".json", {type: 'DELETE'});
|
||||
}
|
||||
});
|
||||
|
||||
ScreenedIpAddress.reopenClass({
|
||||
findAll(filter) {
|
||||
return Discourse.ajax("/admin/logs/screened_ip_addresses.json", { data: { filter: filter } })
|
||||
return ajax("/admin/logs/screened_ip_addresses.json", { data: { filter: filter } })
|
||||
.then(screened_ips => screened_ips.map(b => ScreenedIpAddress.create(b)));
|
||||
},
|
||||
|
||||
rollUp() {
|
||||
return Discourse.ajax("/admin/logs/screened_ip_addresses/roll_up", { type: "POST" });
|
||||
return ajax("/admin/logs/screened_ip_addresses/roll_up", { type: "POST" });
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { ajax } from 'discourse/lib/ajax';
|
||||
const ScreenedUrl = Discourse.Model.extend({
|
||||
actionName: function() {
|
||||
return I18n.t("admin.logs.screened_actions." + this.get('action'));
|
||||
@@ -6,7 +7,7 @@ const ScreenedUrl = Discourse.Model.extend({
|
||||
|
||||
ScreenedUrl.reopenClass({
|
||||
findAll: function() {
|
||||
return Discourse.ajax("/admin/logs/screened_urls.json").then(function(screened_urls) {
|
||||
return ajax("/admin/logs/screened_urls.json").then(function(screened_urls) {
|
||||
return screened_urls.map(function(b) {
|
||||
return ScreenedUrl.create(b);
|
||||
});
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { ajax } from 'discourse/lib/ajax';
|
||||
const SiteSetting = Discourse.Model.extend({
|
||||
overridden: function() {
|
||||
let val = this.get('value'),
|
||||
@@ -28,7 +29,7 @@ const SiteSetting = Discourse.Model.extend({
|
||||
|
||||
SiteSetting.reopenClass({
|
||||
findAll() {
|
||||
return Discourse.ajax("/admin/site_settings").then(function (settings) {
|
||||
return ajax("/admin/site_settings").then(function (settings) {
|
||||
// Group the results by category
|
||||
const categories = {};
|
||||
settings.site_settings.forEach(function(s) {
|
||||
@@ -47,7 +48,7 @@ SiteSetting.reopenClass({
|
||||
update(key, value) {
|
||||
const data = {};
|
||||
data[key] = value;
|
||||
return Discourse.ajax("/admin/site_settings/" + key, { type: 'PUT', data });
|
||||
return ajax("/admin/site_settings/" + key, { type: 'PUT', data });
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { ajax } from 'discourse/lib/ajax';
|
||||
import RestModel from 'discourse/models/rest';
|
||||
const { getProperties } = Ember;
|
||||
|
||||
export default RestModel.extend({
|
||||
revert() {
|
||||
return Discourse.ajax(`/admin/customize/site_texts/${this.get('id')}`, {
|
||||
return ajax(`/admin/customize/site_texts/${this.get('id')}`, {
|
||||
method: 'DELETE'
|
||||
}).then(result => getProperties(result.site_text, 'value', 'can_revert'));
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { ajax } from 'discourse/lib/ajax';
|
||||
import AdminUser from 'admin/models/admin-user';
|
||||
import { escapeExpression } from 'discourse/lib/utilities';
|
||||
|
||||
@@ -56,7 +57,7 @@ StaffActionLog.reopenClass({
|
||||
},
|
||||
|
||||
findAll: function(filters) {
|
||||
return Discourse.ajax("/admin/logs/staff_action_logs.json", { data: filters }).then(function(staff_actions) {
|
||||
return ajax("/admin/logs/staff_action_logs.json", { data: filters }).then(function(staff_actions) {
|
||||
return staff_actions.map(function(s) {
|
||||
return StaffActionLog.create(s);
|
||||
});
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { ajax } from 'discourse/lib/ajax';
|
||||
const VersionCheck = Discourse.Model.extend({
|
||||
|
||||
noCheckPerformed: function() {
|
||||
@@ -33,7 +34,7 @@ const VersionCheck = Discourse.Model.extend({
|
||||
|
||||
VersionCheck.reopenClass({
|
||||
find: function() {
|
||||
return Discourse.ajax('/admin/version_check').then(function(json) {
|
||||
return ajax('/admin/version_check').then(function(json) {
|
||||
return VersionCheck.create(json);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { ajax } from 'discourse/lib/ajax';
|
||||
import showModal from 'discourse/lib/show-modal';
|
||||
import BackupStatus from 'admin/models/backup-status';
|
||||
import Backup from 'admin/models/backup';
|
||||
@@ -31,7 +32,7 @@ export default Discourse.Route.extend({
|
||||
|
||||
model() {
|
||||
return PreloadStore.getAndRemove("operations_status", function() {
|
||||
return Discourse.ajax("/admin/backups/status.json");
|
||||
return ajax("/admin/backups/status.json");
|
||||
}).then(status => {
|
||||
return BackupStatus.create({
|
||||
isOperationRunning: status.is_operation_running,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { ajax } from 'discourse/lib/ajax';
|
||||
import Badge from 'discourse/models/badge';
|
||||
import showModal from 'discourse/lib/show-modal';
|
||||
|
||||
@@ -31,7 +32,7 @@ export default Ember.Route.extend({
|
||||
|
||||
preview(badge, explain) {
|
||||
badge.set('preview_loading', true);
|
||||
Discourse.ajax('/admin/badges/preview.json', {
|
||||
ajax('/admin/badges/preview.json', {
|
||||
method: 'post',
|
||||
data: {
|
||||
sql: badge.get('query'),
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { ajax } from 'discourse/lib/ajax';
|
||||
import Badge from 'discourse/models/badge';
|
||||
import BadgeGrouping from 'discourse/models/badge-grouping';
|
||||
|
||||
@@ -6,7 +7,7 @@ export default Discourse.Route.extend({
|
||||
|
||||
model: function() {
|
||||
var self = this;
|
||||
return Discourse.ajax('/admin/badges.json').then(function(json) {
|
||||
return ajax('/admin/badges.json').then(function(json) {
|
||||
self._json = json;
|
||||
return Badge.createFromJson(json);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { ajax } from 'discourse/lib/ajax';
|
||||
export default Discourse.Route.extend({
|
||||
model: function() {
|
||||
return Discourse.ajax("/admin/customize/emojis.json").then(function(emojis) {
|
||||
return ajax("/admin/customize/emojis.json").then(function(emojis) {
|
||||
return emojis.map(function (emoji) { return Ember.Object.create(emoji); });
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user