mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 22:16:01 +08:00
Cleaned up admin JS, added YUIDoc headers to all admin classes.
This commit is contained in:
@ -1,79 +1,81 @@
|
|||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
/**
|
||||||
|
Our data model for dealing with users from the admin section.
|
||||||
|
|
||||||
|
@class AdminUser
|
||||||
|
@extends Discourse.Model
|
||||||
|
@namespace Discourse
|
||||||
|
@module Discourse
|
||||||
|
**/
|
||||||
window.Discourse.AdminUser = Discourse.Model.extend({
|
window.Discourse.AdminUser = Discourse.Model.extend({
|
||||||
|
|
||||||
deleteAllPosts: function() {
|
deleteAllPosts: function() {
|
||||||
this.set('can_delete_all_posts', false);
|
this.set('can_delete_all_posts', false);
|
||||||
return jQuery.ajax("/admin/users/" + (this.get('id')) + "/delete_all_posts", {
|
jQuery.ajax("/admin/users/" + (this.get('id')) + "/delete_all_posts", {type: 'PUT'});
|
||||||
type: 'PUT'
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
/* Revoke the user's admin access
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
// Revoke the user's admin access
|
||||||
revokeAdmin: function() {
|
revokeAdmin: function() {
|
||||||
this.set('admin', false);
|
this.set('admin', false);
|
||||||
this.set('can_grant_admin', true);
|
this.set('can_grant_admin', true);
|
||||||
this.set('can_revoke_admin', false);
|
this.set('can_revoke_admin', false);
|
||||||
return jQuery.ajax("/admin/users/" + (this.get('id')) + "/revoke_admin", {
|
return jQuery.ajax("/admin/users/" + (this.get('id')) + "/revoke_admin", {type: 'PUT'});
|
||||||
type: 'PUT'
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
grantAdmin: function() {
|
grantAdmin: function() {
|
||||||
this.set('admin', true);
|
this.set('admin', true);
|
||||||
this.set('can_grant_admin', false);
|
this.set('can_grant_admin', false);
|
||||||
this.set('can_revoke_admin', true);
|
this.set('can_revoke_admin', true);
|
||||||
return jQuery.ajax("/admin/users/" + (this.get('id')) + "/grant_admin", {
|
jQuery.ajax("/admin/users/" + (this.get('id')) + "/grant_admin", {type: 'PUT'});
|
||||||
type: 'PUT'
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
/* Revoke the user's moderation access
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
// Revoke the user's moderation access
|
||||||
revokeModeration: function() {
|
revokeModeration: function() {
|
||||||
this.set('moderator', false);
|
this.set('moderator', false);
|
||||||
this.set('can_grant_moderation', true);
|
this.set('can_grant_moderation', true);
|
||||||
this.set('can_revoke_moderation', false);
|
this.set('can_revoke_moderation', false);
|
||||||
return jQuery.ajax("/admin/users/" + (this.get('id')) + "/revoke_moderation", {
|
return jQuery.ajax("/admin/users/" + (this.get('id')) + "/revoke_moderation", {type: 'PUT'});
|
||||||
type: 'PUT'
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
grantModeration: function() {
|
grantModeration: function() {
|
||||||
this.set('moderator', true);
|
this.set('moderator', true);
|
||||||
this.set('can_grant_moderation', false);
|
this.set('can_grant_moderation', false);
|
||||||
this.set('can_revoke_moderation', true);
|
this.set('can_revoke_moderation', true);
|
||||||
return jQuery.ajax("/admin/users/" + (this.get('id')) + "/grant_moderation", {
|
jQuery.ajax("/admin/users/" + (this.get('id')) + "/grant_moderation", {type: 'PUT'});
|
||||||
type: 'PUT'
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
refreshBrowsers: function() {
|
refreshBrowsers: function() {
|
||||||
jQuery.ajax("/admin/users/" + (this.get('id')) + "/refresh_browsers", {
|
jQuery.ajax("/admin/users/" + (this.get('id')) + "/refresh_browsers", {type: 'POST'});
|
||||||
type: 'POST'
|
bootbox.alert("Message sent to all clients!");
|
||||||
});
|
|
||||||
return bootbox.alert("Message sent to all clients!");
|
|
||||||
},
|
},
|
||||||
|
|
||||||
approve: function() {
|
approve: function() {
|
||||||
this.set('can_approve', false);
|
this.set('can_approve', false);
|
||||||
this.set('approved', true);
|
this.set('approved', true);
|
||||||
this.set('approved_by', Discourse.get('currentUser'));
|
this.set('approved_by', Discourse.get('currentUser'));
|
||||||
return jQuery.ajax("/admin/users/" + (this.get('id')) + "/approve", {
|
jQuery.ajax("/admin/users/" + (this.get('id')) + "/approve", {type: 'PUT'});
|
||||||
type: 'PUT'
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
username_lower: (function() {
|
username_lower: (function() {
|
||||||
return this.get('username').toLowerCase();
|
return this.get('username').toLowerCase();
|
||||||
}).property('username'),
|
}).property('username'),
|
||||||
|
|
||||||
trustLevel: (function() {
|
trustLevel: (function() {
|
||||||
return Discourse.get('site.trust_levels').findProperty('id', this.get('trust_level'));
|
return Discourse.get('site.trust_levels').findProperty('id', this.get('trust_level'));
|
||||||
}).property('trust_level'),
|
}).property('trust_level'),
|
||||||
|
|
||||||
canBan: (function() {
|
canBan: (function() {
|
||||||
return !this.admin && !this.moderator;
|
return !this.admin && !this.moderator;
|
||||||
}).property('admin', 'moderator'),
|
}).property('admin', 'moderator'),
|
||||||
|
|
||||||
banDuration: (function() {
|
banDuration: (function() {
|
||||||
var banned_at, banned_till;
|
var banned_at, banned_till;
|
||||||
banned_at = Date.create(this.banned_at);
|
banned_at = Date.create(this.banned_at);
|
||||||
banned_till = Date.create(this.banned_till);
|
banned_till = Date.create(this.banned_till);
|
||||||
return "" + (banned_at.short()) + " - " + (banned_till.short());
|
return "" + (banned_at.short()) + " - " + (banned_till.short());
|
||||||
}).property('banned_till', 'banned_at'),
|
}).property('banned_till', 'banned_at'),
|
||||||
|
|
||||||
ban: function() {
|
ban: function() {
|
||||||
var duration,
|
var duration,
|
||||||
_this = this;
|
_this = this;
|
||||||
@ -81,9 +83,7 @@
|
|||||||
if (duration > 0) {
|
if (duration > 0) {
|
||||||
return jQuery.ajax("/admin/users/" + this.id + "/ban", {
|
return jQuery.ajax("/admin/users/" + this.id + "/ban", {
|
||||||
type: 'PUT',
|
type: 'PUT',
|
||||||
data: {
|
data: {duration: duration},
|
||||||
duration: duration
|
|
||||||
},
|
|
||||||
success: function() {
|
success: function() {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
},
|
},
|
||||||
@ -98,6 +98,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
unban: function() {
|
unban: function() {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
return jQuery.ajax("/admin/users/" + this.id + "/unban", {
|
return jQuery.ajax("/admin/users/" + this.id + "/unban", {
|
||||||
@ -114,6 +115,7 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
impersonate: function() {
|
impersonate: function() {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
return jQuery.ajax("/admin/impersonate", {
|
return jQuery.ajax("/admin/impersonate", {
|
||||||
@ -134,13 +136,11 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
window.Discourse.AdminUser.reopenClass({
|
window.Discourse.AdminUser.reopenClass({
|
||||||
create: function(result) {
|
|
||||||
result = this._super(result);
|
|
||||||
return result;
|
|
||||||
},
|
|
||||||
bulkApprove: function(users) {
|
bulkApprove: function(users) {
|
||||||
users.each(function(user) {
|
users.each(function(user) {
|
||||||
user.set('approved', true);
|
user.set('approved', true);
|
||||||
@ -156,6 +156,7 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
find: function(username) {
|
find: function(username) {
|
||||||
var promise;
|
var promise;
|
||||||
promise = new RSVP.Promise();
|
promise = new RSVP.Promise();
|
||||||
@ -167,6 +168,7 @@
|
|||||||
});
|
});
|
||||||
return promise;
|
return promise;
|
||||||
},
|
},
|
||||||
|
|
||||||
findAll: function(query, filter) {
|
findAll: function(query, filter) {
|
||||||
var result;
|
var result;
|
||||||
result = Em.A();
|
result = Em.A();
|
||||||
|
@ -1,25 +1,33 @@
|
|||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
/**
|
||||||
|
Our data model for representing an email log.
|
||||||
|
|
||||||
|
@class EmailLog
|
||||||
|
@extends Discourse.Model
|
||||||
|
@namespace Discourse
|
||||||
|
@module Discourse
|
||||||
|
**/
|
||||||
window.Discourse.EmailLog = Discourse.Model.extend({});
|
window.Discourse.EmailLog = Discourse.Model.extend({});
|
||||||
|
|
||||||
window.Discourse.EmailLog.reopenClass({
|
window.Discourse.EmailLog.reopenClass({
|
||||||
|
|
||||||
create: function(attrs) {
|
create: function(attrs) {
|
||||||
if (attrs.user) {
|
if (attrs.user) {
|
||||||
attrs.user = Discourse.AdminUser.create(attrs.user);
|
attrs.user = Discourse.AdminUser.create(attrs.user);
|
||||||
}
|
}
|
||||||
return this._super(attrs);
|
return this._super(attrs);
|
||||||
},
|
},
|
||||||
|
|
||||||
findAll: function(filter) {
|
findAll: function(filter) {
|
||||||
var result;
|
var result;
|
||||||
result = Em.A();
|
result = Em.A();
|
||||||
jQuery.ajax({
|
jQuery.ajax({
|
||||||
url: "/admin/email_logs.json",
|
url: "/admin/email_logs.json",
|
||||||
data: {
|
data: { filter: filter },
|
||||||
filter: filter
|
|
||||||
},
|
|
||||||
success: function(logs) {
|
success: function(logs) {
|
||||||
return logs.each(function(log) {
|
logs.each(function(log) {
|
||||||
return result.pushObject(Discourse.EmailLog.create(log));
|
result.pushObject(Discourse.EmailLog.create(log));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,6 +1,15 @@
|
|||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
/**
|
||||||
|
Our data model for interacting with flagged posts.
|
||||||
|
|
||||||
|
@class FlaggedPost
|
||||||
|
@extends Discourse.Post
|
||||||
|
@namespace Discourse
|
||||||
|
@module Discourse
|
||||||
|
**/
|
||||||
window.Discourse.FlaggedPost = Discourse.Post.extend({
|
window.Discourse.FlaggedPost = Discourse.Post.extend({
|
||||||
|
|
||||||
flaggers: (function() {
|
flaggers: (function() {
|
||||||
var r,
|
var r,
|
||||||
_this = this;
|
_this = this;
|
||||||
@ -10,6 +19,7 @@
|
|||||||
});
|
});
|
||||||
return r;
|
return r;
|
||||||
}).property(),
|
}).property(),
|
||||||
|
|
||||||
messages: (function() {
|
messages: (function() {
|
||||||
var r,
|
var r,
|
||||||
_this = this;
|
_this = this;
|
||||||
@ -24,15 +34,19 @@
|
|||||||
});
|
});
|
||||||
return r;
|
return r;
|
||||||
}).property(),
|
}).property(),
|
||||||
|
|
||||||
lastFlagged: (function() {
|
lastFlagged: (function() {
|
||||||
return this.post_actions[0].created_at;
|
return this.post_actions[0].created_at;
|
||||||
}).property(),
|
}).property(),
|
||||||
|
|
||||||
user: (function() {
|
user: (function() {
|
||||||
return this.userLookup[this.user_id];
|
return this.userLookup[this.user_id];
|
||||||
}).property(),
|
}).property(),
|
||||||
|
|
||||||
topicHidden: (function() {
|
topicHidden: (function() {
|
||||||
return this.get('topic_visible') === 'f';
|
return this.get('topic_visible') === 'f';
|
||||||
}).property('topic_hidden'),
|
}).property('topic_hidden'),
|
||||||
|
|
||||||
deletePost: function() {
|
deletePost: function() {
|
||||||
var promise;
|
var promise;
|
||||||
promise = new RSVP.Promise();
|
promise = new RSVP.Promise();
|
||||||
@ -41,10 +55,10 @@
|
|||||||
type: 'DELETE',
|
type: 'DELETE',
|
||||||
cache: false,
|
cache: false,
|
||||||
success: function() {
|
success: function() {
|
||||||
return promise.resolve();
|
promise.resolve();
|
||||||
},
|
},
|
||||||
error: function(e) {
|
error: function(e) {
|
||||||
return promise.reject();
|
promise.reject();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@ -52,14 +66,15 @@
|
|||||||
type: 'DELETE',
|
type: 'DELETE',
|
||||||
cache: false,
|
cache: false,
|
||||||
success: function() {
|
success: function() {
|
||||||
return promise.resolve();
|
promise.resolve();
|
||||||
},
|
},
|
||||||
error: function(e) {
|
error: function(e) {
|
||||||
return promise.reject();
|
promise.reject();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
clearFlags: function() {
|
clearFlags: function() {
|
||||||
var promise;
|
var promise;
|
||||||
promise = new RSVP.Promise();
|
promise = new RSVP.Promise();
|
||||||
@ -67,19 +82,19 @@
|
|||||||
type: 'POST',
|
type: 'POST',
|
||||||
cache: false,
|
cache: false,
|
||||||
success: function() {
|
success: function() {
|
||||||
return promise.resolve();
|
promise.resolve();
|
||||||
},
|
},
|
||||||
error: function(e) {
|
error: function(e) {
|
||||||
return promise.reject();
|
promise.reject();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return promise;
|
return promise;
|
||||||
},
|
},
|
||||||
|
|
||||||
hiddenClass: (function() {
|
hiddenClass: (function() {
|
||||||
if (this.get('hidden') === "t") {
|
if (this.get('hidden') === "t") return "hidden-post";
|
||||||
return "hidden-post";
|
|
||||||
}
|
|
||||||
}).property()
|
}).property()
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
window.Discourse.FlaggedPost.reopenClass({
|
window.Discourse.FlaggedPost.reopenClass({
|
||||||
|
@ -1,15 +1,26 @@
|
|||||||
(function() {
|
(function() {
|
||||||
var SiteCustomizations;
|
var SiteCustomizations;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Our data model for interacting with site customizations.
|
||||||
|
|
||||||
|
@class SiteCustomization
|
||||||
|
@extends Discourse.Model
|
||||||
|
@namespace Discourse
|
||||||
|
@module Discourse
|
||||||
|
**/
|
||||||
window.Discourse.SiteCustomization = Discourse.Model.extend({
|
window.Discourse.SiteCustomization = Discourse.Model.extend({
|
||||||
|
trackedProperties: ['enabled', 'name', 'stylesheet', 'header', 'override_default_style'],
|
||||||
|
|
||||||
init: function() {
|
init: function() {
|
||||||
this._super();
|
this._super();
|
||||||
return this.startTrackingChanges();
|
return this.startTrackingChanges();
|
||||||
},
|
},
|
||||||
trackedProperties: ['enabled', 'name', 'stylesheet', 'header', 'override_default_style'],
|
|
||||||
description: (function() {
|
description: (function() {
|
||||||
return "" + this.name + (this.enabled ? ' (*)' : '');
|
return "" + this.name + (this.enabled ? ' (*)' : '');
|
||||||
}).property('selected', 'name'),
|
}).property('selected', 'name'),
|
||||||
|
|
||||||
changed: (function() {
|
changed: (function() {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
if (!this.originals) {
|
if (!this.originals) {
|
||||||
@ -19,6 +30,7 @@
|
|||||||
return _this.originals[p] !== _this.get(p);
|
return _this.originals[p] !== _this.get(p);
|
||||||
});
|
});
|
||||||
}).property('override_default_style', 'enabled', 'name', 'stylesheet', 'header', 'originals'),
|
}).property('override_default_style', 'enabled', 'name', 'stylesheet', 'header', 'originals'),
|
||||||
|
|
||||||
startTrackingChanges: function() {
|
startTrackingChanges: function() {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
this.set('originals', {});
|
this.set('originals', {});
|
||||||
@ -27,12 +39,15 @@
|
|||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
previewUrl: (function() {
|
previewUrl: (function() {
|
||||||
return "/?preview-style=" + (this.get('key'));
|
return "/?preview-style=" + (this.get('key'));
|
||||||
}).property('key'),
|
}).property('key'),
|
||||||
|
|
||||||
disableSave: (function() {
|
disableSave: (function() {
|
||||||
return !this.get('changed');
|
return !this.get('changed');
|
||||||
}).property('changed'),
|
}).property('changed'),
|
||||||
|
|
||||||
save: function() {
|
save: function() {
|
||||||
var data;
|
var data;
|
||||||
this.startTrackingChanges();
|
this.startTrackingChanges();
|
||||||
@ -51,15 +66,16 @@
|
|||||||
type: this.id ? 'PUT' : 'POST'
|
type: this.id ? 'PUT' : 'POST'
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
"delete": function() {
|
"delete": function() {
|
||||||
if (!this.id) {
|
if (!this.id) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
return jQuery.ajax({
|
return jQuery.ajax({
|
||||||
url: "/admin/site_customizations/" + this.id,
|
url: "/admin/site_customizations/" + this.id,
|
||||||
type: 'DELETE'
|
type: 'DELETE'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
SiteCustomizations = Ember.ArrayProxy.extend({
|
SiteCustomizations = Ember.ArrayProxy.extend({
|
||||||
|
@ -1,21 +1,26 @@
|
|||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
window.Discourse.SiteSetting = Discourse.Model.extend(Discourse.Presence, {
|
/**
|
||||||
/* Whether a property is short.
|
Our data model for interacting with site settings.
|
||||||
*/
|
|
||||||
|
|
||||||
|
@class SiteCustomization
|
||||||
|
@extends Discourse.Model
|
||||||
|
@namespace Discourse
|
||||||
|
@module Discourse
|
||||||
|
**/
|
||||||
|
window.Discourse.SiteSetting = Discourse.Model.extend(Discourse.Presence, {
|
||||||
|
|
||||||
|
// Whether a property is short.
|
||||||
short: (function() {
|
short: (function() {
|
||||||
if (this.blank('value')) {
|
if (this.blank('value')) return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return this.get('value').toString().length < 80;
|
return this.get('value').toString().length < 80;
|
||||||
}).property('value'),
|
}).property('value'),
|
||||||
/* Whether the site setting has changed
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
// Whether the site setting has changed
|
||||||
dirty: (function() {
|
dirty: (function() {
|
||||||
return this.get('originalValue') !== this.get('value');
|
return this.get('originalValue') !== this.get('value');
|
||||||
}).property('originalValue', 'value'),
|
}).property('originalValue', 'value'),
|
||||||
|
|
||||||
overridden: (function() {
|
overridden: (function() {
|
||||||
var defaultVal, val;
|
var defaultVal, val;
|
||||||
val = this.get('value');
|
val = this.get('value');
|
||||||
@ -25,21 +30,19 @@
|
|||||||
}
|
}
|
||||||
return val !== defaultVal;
|
return val !== defaultVal;
|
||||||
}).property('value'),
|
}).property('value'),
|
||||||
resetValue: function() {
|
|
||||||
return this.set('value', this.get('originalValue'));
|
|
||||||
},
|
|
||||||
save: function() {
|
|
||||||
/* Update the setting
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
resetValue: function() {
|
||||||
|
this.set('value', this.get('originalValue'));
|
||||||
|
},
|
||||||
|
|
||||||
|
save: function() {
|
||||||
|
// Update the setting
|
||||||
var _this = this;
|
var _this = this;
|
||||||
return jQuery.ajax("/admin/site_settings/" + (this.get('setting')), {
|
return jQuery.ajax("/admin/site_settings/" + (this.get('setting')), {
|
||||||
data: {
|
data: { value: this.get('value') },
|
||||||
value: this.get('value')
|
|
||||||
},
|
|
||||||
type: 'PUT',
|
type: 'PUT',
|
||||||
success: function() {
|
success: function() {
|
||||||
return _this.set('originalValue', _this.get('value'));
|
_this.set('originalValue', _this.get('value'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,13 @@
|
|||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
/**
|
||||||
|
Our data model for determining whether there's a new version of Discourse
|
||||||
|
|
||||||
|
@class VersionCheck
|
||||||
|
@extends Discourse.Model
|
||||||
|
@namespace Discourse
|
||||||
|
@module Discourse
|
||||||
|
**/
|
||||||
window.Discourse.VersionCheck = Discourse.Model.extend({});
|
window.Discourse.VersionCheck = Discourse.Model.extend({});
|
||||||
|
|
||||||
Discourse.VersionCheck.reopenClass({
|
Discourse.VersionCheck.reopenClass({
|
||||||
|
@ -1,5 +1,13 @@
|
|||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
/**
|
||||||
|
Handles routes related to customization
|
||||||
|
|
||||||
|
@class AdminCustomizeRoute
|
||||||
|
@extends Discourse.Route
|
||||||
|
@namespace Discourse
|
||||||
|
@module Discourse
|
||||||
|
**/
|
||||||
Discourse.AdminCustomizeRoute = Discourse.Route.extend({
|
Discourse.AdminCustomizeRoute = Discourse.Route.extend({
|
||||||
model: function() {
|
model: function() {
|
||||||
return Discourse.SiteCustomization.findAll();
|
return Discourse.SiteCustomization.findAll();
|
||||||
|
@ -1,11 +1,19 @@
|
|||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
/**
|
||||||
|
Handles the default admin route
|
||||||
|
|
||||||
|
@class AdminDashboardRoute
|
||||||
|
@extends Discourse.Route
|
||||||
|
@namespace Discourse
|
||||||
|
@module Discourse
|
||||||
|
**/
|
||||||
Discourse.AdminDashboardRoute = Discourse.Route.extend({
|
Discourse.AdminDashboardRoute = Discourse.Route.extend({
|
||||||
setupController: function(c) {
|
setupController: function(c) {
|
||||||
if( Discourse.SiteSettings.version_checks ) {
|
if( Discourse.SiteSettings.version_checks ) {
|
||||||
return Discourse.VersionCheck.find().then(function(vc) {
|
Discourse.VersionCheck.find().then(function(vc) {
|
||||||
c.set('versionCheck', vc);
|
c.set('versionCheck', vc);
|
||||||
return c.set('loading', false);
|
c.set('loading', false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,13 @@
|
|||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
/**
|
||||||
|
Handles routes related to viewing email logs.
|
||||||
|
|
||||||
|
@class AdminEmailLogsRoute
|
||||||
|
@extends Discourse.Route
|
||||||
|
@namespace Discourse
|
||||||
|
@module Discourse
|
||||||
|
**/
|
||||||
Discourse.AdminEmailLogsRoute = Discourse.Route.extend({
|
Discourse.AdminEmailLogsRoute = Discourse.Route.extend({
|
||||||
model: function() {
|
model: function() {
|
||||||
return Discourse.EmailLog.findAll();
|
return Discourse.EmailLog.findAll();
|
||||||
|
@ -1,15 +1,25 @@
|
|||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
/**
|
||||||
|
Handles routes related to viewing active flags.
|
||||||
|
|
||||||
|
@class AdminFlagsActiveRoute
|
||||||
|
@extends Discourse.Route
|
||||||
|
@namespace Discourse
|
||||||
|
@module Discourse
|
||||||
|
**/
|
||||||
Discourse.AdminFlagsActiveRoute = Discourse.Route.extend({
|
Discourse.AdminFlagsActiveRoute = Discourse.Route.extend({
|
||||||
|
|
||||||
model: function() {
|
model: function() {
|
||||||
return Discourse.FlaggedPost.findAll('active');
|
return Discourse.FlaggedPost.findAll('active');
|
||||||
},
|
},
|
||||||
|
|
||||||
setupController: function(controller, model) {
|
setupController: function(controller, model) {
|
||||||
var c;
|
var adminFlagsController = this.controllerFor('adminFlags');
|
||||||
c = this.controllerFor('adminFlags');
|
adminFlagsController.set('content', model);
|
||||||
c.set('content', model);
|
adminFlagsController.set('query', 'active');
|
||||||
return c.set('query', 'active');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}).call(this);
|
}).call(this);
|
||||||
|
@ -1,15 +1,25 @@
|
|||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
/**
|
||||||
|
Handles routes related to viewing old flags.
|
||||||
|
|
||||||
|
@class AdminFlagsOldRoute
|
||||||
|
@extends Discourse.Route
|
||||||
|
@namespace Discourse
|
||||||
|
@module Discourse
|
||||||
|
**/
|
||||||
Discourse.AdminFlagsOldRoute = Discourse.Route.extend({
|
Discourse.AdminFlagsOldRoute = Discourse.Route.extend({
|
||||||
|
|
||||||
model: function() {
|
model: function() {
|
||||||
return Discourse.FlaggedPost.findAll('old');
|
return Discourse.FlaggedPost.findAll('old');
|
||||||
},
|
},
|
||||||
|
|
||||||
setupController: function(controller, model) {
|
setupController: function(controller, model) {
|
||||||
var c;
|
var adminFlagsController = this.controllerFor('adminFlags');
|
||||||
c = this.controllerFor('adminFlags');
|
adminFlagsController.set('content', model);
|
||||||
c.set('content', model);
|
adminFlagsController.set('query', 'old');
|
||||||
return c.set('query', 'old');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}).call(this);
|
}).call(this);
|
||||||
|
@ -1,51 +1,30 @@
|
|||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
/**
|
||||||
|
Declare all the routes used in the admin section.
|
||||||
|
**/
|
||||||
Discourse.buildRoutes(function() {
|
Discourse.buildRoutes(function() {
|
||||||
return this.resource('admin', {
|
return this.resource('admin', { path: '/admin' }, function() {
|
||||||
path: '/admin'
|
|
||||||
}, function() {
|
this.route('dashboard', { path: '/' });
|
||||||
this.route('dashboard', {
|
this.route('site_settings', { path: '/site_settings' });
|
||||||
path: '/'
|
this.route('email_logs', { path: '/email_logs' });
|
||||||
|
this.route('customize', { path: '/customize' });
|
||||||
|
|
||||||
|
this.resource('adminFlags', { path: '/flags' }, function() {
|
||||||
|
this.route('active', { path: '/active' });
|
||||||
|
this.route('old', { path: '/old' });
|
||||||
});
|
});
|
||||||
this.route('site_settings', {
|
|
||||||
path: '/site_settings'
|
this.resource('adminUsers', { path: '/users' }, function() {
|
||||||
});
|
this.resource('adminUser', { path: '/:username' });
|
||||||
this.route('email_logs', {
|
this.resource('adminUsersList', { path: '/list' }, function() {
|
||||||
path: '/email_logs'
|
this.route('active', { path: '/active' });
|
||||||
});
|
this.route('new', { path: '/new' });
|
||||||
this.route('customize', {
|
this.route('pending', { path: '/pending' });
|
||||||
path: '/customize'
|
|
||||||
});
|
|
||||||
this.resource('adminFlags', {
|
|
||||||
path: '/flags'
|
|
||||||
}, function() {
|
|
||||||
this.route('active', {
|
|
||||||
path: '/active'
|
|
||||||
});
|
|
||||||
return this.route('old', {
|
|
||||||
path: '/old'
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return this.resource('adminUsers', {
|
|
||||||
path: '/users'
|
|
||||||
}, function() {
|
|
||||||
this.resource('adminUser', {
|
|
||||||
path: '/:username'
|
|
||||||
});
|
|
||||||
return this.resource('adminUsersList', {
|
|
||||||
path: '/list'
|
|
||||||
}, function() {
|
|
||||||
this.route('active', {
|
|
||||||
path: '/active'
|
|
||||||
});
|
|
||||||
this.route('new', {
|
|
||||||
path: '/new'
|
|
||||||
});
|
|
||||||
return this.route('pending', {
|
|
||||||
path: '/pending'
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,5 +1,13 @@
|
|||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
/**
|
||||||
|
Handles routes related to viewing and editing site settings.
|
||||||
|
|
||||||
|
@class AdminSiteSettingsRoute
|
||||||
|
@extends Discourse.Route
|
||||||
|
@namespace Discourse
|
||||||
|
@module Discourse
|
||||||
|
**/
|
||||||
Discourse.AdminSiteSettingsRoute = Discourse.Route.extend({
|
Discourse.AdminSiteSettingsRoute = Discourse.Route.extend({
|
||||||
model: function() {
|
model: function() {
|
||||||
return Discourse.SiteSetting.findAll();
|
return Discourse.SiteSetting.findAll();
|
||||||
|
@ -1,5 +1,13 @@
|
|||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
/**
|
||||||
|
Handles routes related to users.
|
||||||
|
|
||||||
|
@class AdminUserRoute
|
||||||
|
@extends Discourse.Route
|
||||||
|
@namespace Discourse
|
||||||
|
@module Discourse
|
||||||
|
**/
|
||||||
Discourse.AdminUserRoute = Discourse.Route.extend({
|
Discourse.AdminUserRoute = Discourse.Route.extend({
|
||||||
model: function(params) {
|
model: function(params) {
|
||||||
return Discourse.AdminUser.find(params.username);
|
return Discourse.AdminUser.find(params.username);
|
||||||
|
@ -1,7 +1,15 @@
|
|||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
/**
|
||||||
|
Handles the route that lists active users.
|
||||||
|
|
||||||
|
@class AdminUsersListActiveRoute
|
||||||
|
@extends Discourse.Route
|
||||||
|
@namespace Discourse
|
||||||
|
@module Discourse
|
||||||
|
**/
|
||||||
Discourse.AdminUsersListActiveRoute = Discourse.Route.extend({
|
Discourse.AdminUsersListActiveRoute = Discourse.Route.extend({
|
||||||
setupController: function(c) {
|
setupController: function() {
|
||||||
return this.controllerFor('adminUsersList').show('active');
|
return this.controllerFor('adminUsersList').show('active');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,7 +1,15 @@
|
|||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
/**
|
||||||
|
Handles the route that lists new users.
|
||||||
|
|
||||||
|
@class AdminUsersListNewRoute
|
||||||
|
@extends Discourse.Route
|
||||||
|
@namespace Discourse
|
||||||
|
@module Discourse
|
||||||
|
**/
|
||||||
Discourse.AdminUsersListNewRoute = Discourse.Route.extend({
|
Discourse.AdminUsersListNewRoute = Discourse.Route.extend({
|
||||||
setupController: function(c) {
|
setupController: function() {
|
||||||
return this.controllerFor('adminUsersList').show('new');
|
return this.controllerFor('adminUsersList').show('new');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,7 +1,15 @@
|
|||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
Discourse.AdminUsersListNewRoute = Discourse.Route.extend({
|
/**
|
||||||
setupController: function(c) {
|
Handles the route that lists pending users.
|
||||||
|
|
||||||
|
@class AdminUsersListNewRoute
|
||||||
|
@extends Discourse.Route
|
||||||
|
@namespace Discourse
|
||||||
|
@module Discourse
|
||||||
|
**/
|
||||||
|
Discourse.AdminUsersListPendingRoute = Discourse.Route.extend({
|
||||||
|
setupController: function() {
|
||||||
return this.controllerFor('adminUsersList').show('pending');
|
return this.controllerFor('adminUsersList').show('pending');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,14 +1,24 @@
|
|||||||
/*global ace:true */
|
/*global ace:true */
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
/**
|
||||||
|
A view that wraps the ACE editor (http://ace.ajax.org/)
|
||||||
|
|
||||||
|
@class AceEditorView
|
||||||
|
@extends Discourse.View
|
||||||
|
@namespace Discourse
|
||||||
|
@module Discourse
|
||||||
|
**/
|
||||||
Discourse.AceEditorView = window.Discourse.View.extend({
|
Discourse.AceEditorView = window.Discourse.View.extend({
|
||||||
mode: 'css',
|
mode: 'css',
|
||||||
classNames: ['ace-wrapper'],
|
classNames: ['ace-wrapper'],
|
||||||
|
|
||||||
contentChanged: (function() {
|
contentChanged: (function() {
|
||||||
if (this.editor && !this.skipContentChangeEvent) {
|
if (this.editor && !this.skipContentChangeEvent) {
|
||||||
return this.editor.getSession().setValue(this.get('content'));
|
return this.editor.getSession().setValue(this.get('content'));
|
||||||
}
|
}
|
||||||
}).observes('content'),
|
}).observes('content'),
|
||||||
|
|
||||||
render: function(buffer) {
|
render: function(buffer) {
|
||||||
buffer.push("<div class='ace'>");
|
buffer.push("<div class='ace'>");
|
||||||
if (this.get('content')) {
|
if (this.get('content')) {
|
||||||
@ -16,12 +26,14 @@
|
|||||||
}
|
}
|
||||||
return buffer.push("</div>");
|
return buffer.push("</div>");
|
||||||
},
|
},
|
||||||
|
|
||||||
willDestroyElement: function() {
|
willDestroyElement: function() {
|
||||||
if (this.editor) {
|
if (this.editor) {
|
||||||
this.editor.destroy();
|
this.editor.destroy();
|
||||||
this.editor = null;
|
this.editor = null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
didInsertElement: function() {
|
didInsertElement: function() {
|
||||||
var initAce,
|
var initAce,
|
||||||
_this = this;
|
_this = this;
|
||||||
@ -32,21 +44,11 @@
|
|||||||
_this.editor.getSession().setMode("ace/mode/" + (_this.get('mode')));
|
_this.editor.getSession().setMode("ace/mode/" + (_this.get('mode')));
|
||||||
return _this.editor.on("change", function(e) {
|
return _this.editor.on("change", function(e) {
|
||||||
/* amending stuff as you type seems a bit out of scope for now - can revisit after launch
|
/* amending stuff as you type seems a bit out of scope for now - can revisit after launch
|
||||||
*/
|
changes = @get('changes')
|
||||||
|
unless changes
|
||||||
/* changes = @get('changes')
|
changes = []
|
||||||
*/
|
@set('changes', changes)
|
||||||
|
changes.push e.data
|
||||||
/* unless changes
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* changes = []
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* @set('changes', changes)
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* changes.push e.data
|
|
||||||
*/
|
*/
|
||||||
_this.skipContentChangeEvent = true;
|
_this.skipContentChangeEvent = true;
|
||||||
_this.set('content', _this.editor.getSession().getValue());
|
_this.set('content', _this.editor.getSession().getValue());
|
||||||
|
@ -1,26 +1,40 @@
|
|||||||
/*global Mousetrap:true */
|
/*global Mousetrap:true */
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
/**
|
||||||
|
A view to handle site customizations
|
||||||
|
|
||||||
|
@class AdminCustomizeView
|
||||||
|
@extends Discourse.View
|
||||||
|
@namespace Discourse
|
||||||
|
@module Discourse
|
||||||
|
**/
|
||||||
Discourse.AdminCustomizeView = window.Discourse.View.extend({
|
Discourse.AdminCustomizeView = window.Discourse.View.extend({
|
||||||
templateName: 'admin/templates/customize',
|
templateName: 'admin/templates/customize',
|
||||||
classNames: ['customize'],
|
classNames: ['customize'],
|
||||||
contentBinding: 'controller.content',
|
contentBinding: 'controller.content',
|
||||||
|
|
||||||
init: function() {
|
init: function() {
|
||||||
this._super();
|
this._super();
|
||||||
return this.set('selected', 'stylesheet');
|
this.set('selected', 'stylesheet');
|
||||||
},
|
},
|
||||||
|
|
||||||
headerActive: (function() {
|
headerActive: (function() {
|
||||||
return this.get('selected') === 'header';
|
return this.get('selected') === 'header';
|
||||||
}).property('selected'),
|
}).property('selected'),
|
||||||
|
|
||||||
stylesheetActive: (function() {
|
stylesheetActive: (function() {
|
||||||
return this.get('selected') === 'stylesheet';
|
return this.get('selected') === 'stylesheet';
|
||||||
}).property('selected'),
|
}).property('selected'),
|
||||||
|
|
||||||
selectHeader: function() {
|
selectHeader: function() {
|
||||||
return this.set('selected', 'header');
|
this.set('selected', 'header');
|
||||||
},
|
},
|
||||||
|
|
||||||
selectStylesheet: function() {
|
selectStylesheet: function() {
|
||||||
return this.set('selected', 'stylesheet');
|
this.set('selected', 'stylesheet');
|
||||||
},
|
},
|
||||||
|
|
||||||
didInsertElement: function() {
|
didInsertElement: function() {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
return Mousetrap.bindGlobal(['meta+s', 'ctrl+s'], function() {
|
return Mousetrap.bindGlobal(['meta+s', 'ctrl+s'], function() {
|
||||||
@ -28,9 +42,11 @@
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
willDestroyElement: function() {
|
willDestroyElement: function() {
|
||||||
return Mousetrap.unbindGlobal('meta+s', 'ctrl+s');
|
return Mousetrap.unbindGlobal('meta+s', 'ctrl+s');
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}).call(this);
|
}).call(this);
|
||||||
|
@ -1,5 +1,13 @@
|
|||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
/**
|
||||||
|
The default view in the admin section
|
||||||
|
|
||||||
|
@class AdminDashboardView
|
||||||
|
@extends Discourse.View
|
||||||
|
@namespace Discourse
|
||||||
|
@module Discourse
|
||||||
|
**/
|
||||||
Discourse.AdminDashboardView = window.Discourse.View.extend({
|
Discourse.AdminDashboardView = window.Discourse.View.extend({
|
||||||
templateName: 'admin/templates/dashboard'
|
templateName: 'admin/templates/dashboard'
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,13 @@
|
|||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
/**
|
||||||
|
A view for listing email logs
|
||||||
|
|
||||||
|
@class AdminEmailLogsView
|
||||||
|
@extends Discourse.View
|
||||||
|
@namespace Discourse
|
||||||
|
@module Discourse
|
||||||
|
**/
|
||||||
Discourse.AdminEmailLogsView = window.Discourse.View.extend({
|
Discourse.AdminEmailLogsView = window.Discourse.View.extend({
|
||||||
templateName: 'admin/templates/email_logs'
|
templateName: 'admin/templates/email_logs'
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,13 @@
|
|||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
/**
|
||||||
|
A view for listing admin flags
|
||||||
|
|
||||||
|
@class AdminFlagsView
|
||||||
|
@extends Discourse.View
|
||||||
|
@namespace Discourse
|
||||||
|
@module Discourse
|
||||||
|
**/
|
||||||
Discourse.AdminFlagsView = window.Discourse.View.extend({
|
Discourse.AdminFlagsView = window.Discourse.View.extend({
|
||||||
templateName: 'admin/templates/flags'
|
templateName: 'admin/templates/flags'
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,13 @@
|
|||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
/**
|
||||||
|
A view for dealing with site settings
|
||||||
|
|
||||||
|
@class AdminSiteSettingsView
|
||||||
|
@extends Discourse.View
|
||||||
|
@namespace Discourse
|
||||||
|
@module Discourse
|
||||||
|
**/
|
||||||
Discourse.AdminSiteSettingsView = window.Discourse.View.extend({
|
Discourse.AdminSiteSettingsView = window.Discourse.View.extend({
|
||||||
templateName: 'admin/templates/site_settings'
|
templateName: 'admin/templates/site_settings'
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,13 @@
|
|||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
/**
|
||||||
|
A view for showing a user in the admin section
|
||||||
|
|
||||||
|
@class AdminUserView
|
||||||
|
@extends Discourse.View
|
||||||
|
@namespace Discourse
|
||||||
|
@module Discourse
|
||||||
|
**/
|
||||||
Discourse.AdminUserView = window.Discourse.View.extend({
|
Discourse.AdminUserView = window.Discourse.View.extend({
|
||||||
templateName: 'admin/templates/user'
|
templateName: 'admin/templates/user'
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,13 @@
|
|||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
/**
|
||||||
|
A view for listing users in the admin section
|
||||||
|
|
||||||
|
@class AdminUsersListView
|
||||||
|
@extends Discourse.View
|
||||||
|
@namespace Discourse
|
||||||
|
@module Discourse
|
||||||
|
**/
|
||||||
Discourse.AdminUsersListView = window.Discourse.View.extend({
|
Discourse.AdminUsersListView = window.Discourse.View.extend({
|
||||||
templateName: 'admin/templates/users_list'
|
templateName: 'admin/templates/users_list'
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,13 @@
|
|||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
/**
|
||||||
|
A base view for the admin section
|
||||||
|
|
||||||
|
@class AdminView
|
||||||
|
@extends Discourse.View
|
||||||
|
@namespace Discourse
|
||||||
|
@module Discourse
|
||||||
|
**/
|
||||||
Discourse.AdminView = window.Discourse.View.extend({
|
Discourse.AdminView = window.Discourse.View.extend({
|
||||||
templateName: 'admin/templates/admin'
|
templateName: 'admin/templates/admin'
|
||||||
});
|
});
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
"description": "This is the EmberJS client to access a Discourse Server",
|
"description": "This is the EmberJS client to access a Discourse Server",
|
||||||
"url": "http://www.discourse.org/",
|
"url": "http://www.discourse.org/",
|
||||||
"options": {
|
"options": {
|
||||||
"exclude": "external,external_production",
|
"exclude": "external,external_production,defer",
|
||||||
"outdir": "./build"
|
"outdir": "./build"
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user