Convert all CoffeeScript to Javascript. See:
http://meta.discourse.org/t/is-it-better-for-discourse-to-use-javascript-or-coffeescript/3153
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
(function() {
|
||||
|
||||
window.Discourse.AdminCustomizeController = Ember.Controller.extend({
|
||||
newCustomization: function() {
|
||||
var item;
|
||||
item = Discourse.SiteCustomization.create({
|
||||
name: 'New Style'
|
||||
});
|
||||
this.get('content').pushObject(item);
|
||||
return this.set('content.selectedItem', item);
|
||||
},
|
||||
selectStyle: function(style) {
|
||||
return this.set('content.selectedItem', style);
|
||||
},
|
||||
save: function() {
|
||||
return this.get('content.selectedItem').save();
|
||||
},
|
||||
"delete": function() {
|
||||
var _this = this;
|
||||
return bootbox.confirm(Em.String.i18n("admin.customize.delete_confirm"), Em.String.i18n("no_value"), Em.String.i18n("yes_value"), function(result) {
|
||||
var selected;
|
||||
if (result) {
|
||||
selected = _this.get('content.selectedItem');
|
||||
selected["delete"]();
|
||||
_this.set('content.selectedItem', null);
|
||||
return _this.get('content').removeObject(selected);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -1,18 +0,0 @@
|
||||
window.Discourse.AdminCustomizeController = Ember.Controller.extend
|
||||
newCustomization: ->
|
||||
item = Discourse.SiteCustomization.create(name: 'New Style')
|
||||
@get('content').pushObject(item)
|
||||
@set('content.selectedItem', item)
|
||||
|
||||
selectStyle: (style)-> @set('content.selectedItem', style)
|
||||
|
||||
save: -> @get('content.selectedItem').save()
|
||||
|
||||
delete: ->
|
||||
bootbox.confirm Em.String.i18n("admin.customize.delete_confirm"), Em.String.i18n("no_value"), Em.String.i18n("yes_value"), (result) =>
|
||||
if result
|
||||
selected = @get('content.selectedItem')
|
||||
selected.delete()
|
||||
@set('content.selectedItem', null)
|
||||
@get('content').removeObject(selected)
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
(function() {
|
||||
|
||||
window.Discourse.AdminDashboardController = Ember.Controller.extend({
|
||||
loading: true,
|
||||
versionCheck: null,
|
||||
upToDate: (function() {
|
||||
if (this.versionCheck) {
|
||||
return this.versionCheck.latest_version === this.versionCheck.installed_version;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}).property('versionCheck'),
|
||||
updateIconClasses: (function() {
|
||||
var classes;
|
||||
classes = "icon icon-warning-sign ";
|
||||
if (this.get('versionCheck.critical_updates')) {
|
||||
classes += "critical-updates-available";
|
||||
} else {
|
||||
classes += "updates-available";
|
||||
}
|
||||
return classes;
|
||||
}).property('versionCheck'),
|
||||
priorityClass: (function() {
|
||||
if (this.get('versionCheck.critical_updates')) {
|
||||
return 'version-check critical';
|
||||
} else {
|
||||
return 'version-check normal';
|
||||
}
|
||||
}).property('versionCheck')
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -1,26 +0,0 @@
|
||||
window.Discourse.AdminDashboardController = Ember.Controller.extend
|
||||
loading: true
|
||||
versionCheck: null
|
||||
|
||||
upToDate: (->
|
||||
if @versionCheck
|
||||
@versionCheck.latest_version == @versionCheck.installed_version
|
||||
else
|
||||
true
|
||||
).property('versionCheck')
|
||||
|
||||
updateIconClasses: (->
|
||||
classes = "icon icon-warning-sign "
|
||||
if @get('versionCheck.critical_updates')
|
||||
classes += "critical-updates-available"
|
||||
else
|
||||
classes += "updates-available"
|
||||
classes
|
||||
).property('versionCheck')
|
||||
|
||||
priorityClass: (->
|
||||
if @get('versionCheck.critical_updates')
|
||||
'version-check critical'
|
||||
else
|
||||
'version-check normal'
|
||||
).property('versionCheck')
|
||||
@@ -0,0 +1,24 @@
|
||||
(function() {
|
||||
|
||||
window.Discourse.AdminEmailLogsController = Ember.ArrayController.extend(Discourse.Presence, {
|
||||
sendTestEmailDisabled: (function() {
|
||||
return this.blank('testEmailAddress');
|
||||
}).property('testEmailAddress'),
|
||||
sendTestEmail: function() {
|
||||
var _this = this;
|
||||
this.set('sentTestEmail', false);
|
||||
jQuery.ajax({
|
||||
url: '/admin/email_logs/test',
|
||||
type: 'POST',
|
||||
data: {
|
||||
email_address: this.get('testEmailAddress')
|
||||
},
|
||||
success: function() {
|
||||
return _this.set('sentTestEmail', true);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -1,17 +0,0 @@
|
||||
window.Discourse.AdminEmailLogsController = Ember.ArrayController.extend Discourse.Presence,
|
||||
|
||||
sendTestEmailDisabled: (->
|
||||
@blank('testEmailAddress')
|
||||
).property('testEmailAddress')
|
||||
|
||||
sendTestEmail: ->
|
||||
@set('sentTestEmail', false)
|
||||
$.ajax
|
||||
url: '/admin/email_logs/test',
|
||||
type: 'POST'
|
||||
data:
|
||||
email_address: @get('testEmailAddress')
|
||||
success: =>
|
||||
@set('sentTestEmail', true)
|
||||
false
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
(function() {
|
||||
|
||||
window.Discourse.AdminFlagsController = Ember.Controller.extend({
|
||||
clearFlags: function(item) {
|
||||
var _this = this;
|
||||
return item.clearFlags().then((function() {
|
||||
return _this.content.removeObject(item);
|
||||
}), (function() {
|
||||
return bootbox.alert("something went wrong");
|
||||
}));
|
||||
},
|
||||
deletePost: function(item) {
|
||||
var _this = this;
|
||||
return item.deletePost().then((function() {
|
||||
return _this.content.removeObject(item);
|
||||
}), (function() {
|
||||
return bootbox.alert("something went wrong");
|
||||
}));
|
||||
},
|
||||
adminOldFlagsView: (function() {
|
||||
return this.query === 'old';
|
||||
}).property('query'),
|
||||
adminActiveFlagsView: (function() {
|
||||
return this.query === 'active';
|
||||
}).property('query')
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -1,23 +0,0 @@
|
||||
window.Discourse.AdminFlagsController = Ember.Controller.extend
|
||||
|
||||
clearFlags: (item) ->
|
||||
item.clearFlags().then (=>
|
||||
@content.removeObject(item)
|
||||
), (->
|
||||
bootbox.alert("something went wrong")
|
||||
)
|
||||
|
||||
deletePost: (item) ->
|
||||
item.deletePost().then (=>
|
||||
@content.removeObject(item)
|
||||
), (->
|
||||
bootbox.alert("something went wrong")
|
||||
)
|
||||
|
||||
adminOldFlagsView: (->
|
||||
@query == 'old'
|
||||
).property('query')
|
||||
|
||||
adminActiveFlagsView: (->
|
||||
@query == 'active'
|
||||
).property('query')
|
||||
@@ -0,0 +1,47 @@
|
||||
(function() {
|
||||
|
||||
window.Discourse.AdminSiteSettingsController = Ember.ArrayController.extend(Discourse.Presence, {
|
||||
filter: null,
|
||||
onlyOverridden: false,
|
||||
filteredContent: (function() {
|
||||
var filter,
|
||||
_this = this;
|
||||
if (!this.present('content')) {
|
||||
return null;
|
||||
}
|
||||
if (this.get('filter')) {
|
||||
filter = this.get('filter').toLowerCase();
|
||||
}
|
||||
return this.get('content').filter(function(item, index, enumerable) {
|
||||
if (_this.get('onlyOverridden') && !item.get('overridden')) {
|
||||
return false;
|
||||
}
|
||||
if (filter) {
|
||||
if (item.get('setting').toLowerCase().indexOf(filter) > -1) {
|
||||
return true;
|
||||
}
|
||||
if (item.get('description').toLowerCase().indexOf(filter) > -1) {
|
||||
return true;
|
||||
}
|
||||
if (item.get('value').toLowerCase().indexOf(filter) > -1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}).property('filter', 'content.@each', 'onlyOverridden'),
|
||||
resetDefault: function(setting) {
|
||||
setting.set('value', setting.get('default'));
|
||||
return setting.save();
|
||||
},
|
||||
save: function(setting) {
|
||||
return setting.save();
|
||||
},
|
||||
cancel: function(setting) {
|
||||
return setting.resetValue();
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -1,30 +0,0 @@
|
||||
window.Discourse.AdminSiteSettingsController = Ember.ArrayController.extend Discourse.Presence,
|
||||
|
||||
filter: null
|
||||
onlyOverridden: false
|
||||
|
||||
filteredContent: (->
|
||||
return null unless @present('content')
|
||||
filter = @get('filter').toLowerCase() if @get('filter')
|
||||
|
||||
@get('content').filter (item, index, enumerable) =>
|
||||
|
||||
return false if @get('onlyOverridden') and !item.get('overridden')
|
||||
|
||||
if filter
|
||||
return true if item.get('setting').toLowerCase().indexOf(filter) > -1
|
||||
return true if item.get('description').toLowerCase().indexOf(filter) > -1
|
||||
return true if item.get('value').toLowerCase().indexOf(filter) > -1
|
||||
return false
|
||||
else
|
||||
true
|
||||
).property('filter', 'content.@each', 'onlyOverridden')
|
||||
|
||||
|
||||
resetDefault: (setting) ->
|
||||
setting.set('value', setting.get('default'))
|
||||
setting.save()
|
||||
|
||||
save: (setting) -> setting.save()
|
||||
|
||||
cancel: (setting) -> setting.resetValue()
|
||||
@@ -0,0 +1,55 @@
|
||||
(function() {
|
||||
|
||||
window.Discourse.AdminUsersListController = Ember.ArrayController.extend(Discourse.Presence, {
|
||||
username: null,
|
||||
query: null,
|
||||
selectAll: false,
|
||||
content: null,
|
||||
selectAllChanged: (function() {
|
||||
var _this = this;
|
||||
return this.get('content').each(function(user) {
|
||||
return user.set('selected', _this.get('selectAll'));
|
||||
});
|
||||
}).observes('selectAll'),
|
||||
filterUsers: Discourse.debounce(function() {
|
||||
return this.refreshUsers();
|
||||
}, 250).observes('username'),
|
||||
orderChanged: (function() {
|
||||
return this.refreshUsers();
|
||||
}).observes('query'),
|
||||
showApproval: (function() {
|
||||
if (!Discourse.SiteSettings.must_approve_users) {
|
||||
return false;
|
||||
}
|
||||
if (this.get('query') === 'new') {
|
||||
return true;
|
||||
}
|
||||
if (this.get('query') === 'pending') {
|
||||
return true;
|
||||
}
|
||||
}).property('query'),
|
||||
selectedCount: (function() {
|
||||
if (this.blank('content')) {
|
||||
return 0;
|
||||
}
|
||||
return this.get('content').filterProperty('selected').length;
|
||||
}).property('content.@each.selected'),
|
||||
hasSelection: (function() {
|
||||
return this.get('selectedCount') > 0;
|
||||
}).property('selectedCount'),
|
||||
refreshUsers: function() {
|
||||
return this.set('content', Discourse.AdminUser.findAll(this.get('query'), this.get('username')));
|
||||
},
|
||||
show: function(term) {
|
||||
if (this.get('query') === term) {
|
||||
return this.refreshUsers();
|
||||
} else {
|
||||
return this.set('query', term);
|
||||
}
|
||||
},
|
||||
approveUsers: function() {
|
||||
return Discourse.AdminUser.bulkApprove(this.get('content').filterProperty('selected'));
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -1,45 +0,0 @@
|
||||
window.Discourse.AdminUsersListController = Ember.ArrayController.extend Discourse.Presence,
|
||||
|
||||
username: null
|
||||
query: null
|
||||
selectAll: false
|
||||
content: null
|
||||
|
||||
selectAllChanged: (->
|
||||
@get('content').each (user) => user.set('selected', @get('selectAll'))
|
||||
).observes('selectAll')
|
||||
|
||||
filterUsers: Discourse.debounce(->
|
||||
@refreshUsers()
|
||||
,250).observes('username')
|
||||
|
||||
orderChanged: (->
|
||||
@refreshUsers()
|
||||
).observes('query')
|
||||
|
||||
showApproval: (->
|
||||
return false unless Discourse.SiteSettings.must_approve_users
|
||||
return true if @get('query') is 'new'
|
||||
return true if @get('query') is 'pending'
|
||||
).property('query')
|
||||
|
||||
selectedCount: (->
|
||||
return 0 if @blank('content')
|
||||
@get('content').filterProperty('selected').length
|
||||
).property('content.@each.selected')
|
||||
|
||||
hasSelection: (->
|
||||
@get('selectedCount') > 0
|
||||
).property('selectedCount')
|
||||
|
||||
refreshUsers: ->
|
||||
@set 'content', Discourse.AdminUser.findAll(@get('query'), @get('username'))
|
||||
|
||||
show: (term) ->
|
||||
if @get('query') == term
|
||||
@refreshUsers()
|
||||
else
|
||||
@set('query', term)
|
||||
|
||||
approveUsers: ->
|
||||
Discourse.AdminUser.bulkApprove(@get('content').filterProperty('selected'))
|
||||
@@ -0,0 +1,188 @@
|
||||
(function() {
|
||||
|
||||
window.Discourse.AdminUser = Discourse.Model.extend({
|
||||
deleteAllPosts: function() {
|
||||
this.set('can_delete_all_posts', false);
|
||||
return jQuery.ajax("/admin/users/" + (this.get('id')) + "/delete_all_posts", {
|
||||
type: 'PUT'
|
||||
});
|
||||
},
|
||||
/* Revoke the user's admin access
|
||||
*/
|
||||
|
||||
revokeAdmin: function() {
|
||||
this.set('admin', false);
|
||||
this.set('can_grant_admin', true);
|
||||
this.set('can_revoke_admin', false);
|
||||
return jQuery.ajax("/admin/users/" + (this.get('id')) + "/revoke_admin", {
|
||||
type: 'PUT'
|
||||
});
|
||||
},
|
||||
grantAdmin: function() {
|
||||
this.set('admin', true);
|
||||
this.set('can_grant_admin', false);
|
||||
this.set('can_revoke_admin', true);
|
||||
return jQuery.ajax("/admin/users/" + (this.get('id')) + "/grant_admin", {
|
||||
type: 'PUT'
|
||||
});
|
||||
},
|
||||
/* Revoke the user's moderation access
|
||||
*/
|
||||
|
||||
revokeModeration: function() {
|
||||
this.set('moderator', false);
|
||||
this.set('can_grant_moderation', true);
|
||||
this.set('can_revoke_moderation', false);
|
||||
return jQuery.ajax("/admin/users/" + (this.get('id')) + "/revoke_moderation", {
|
||||
type: 'PUT'
|
||||
});
|
||||
},
|
||||
grantModeration: function() {
|
||||
this.set('moderator', true);
|
||||
this.set('can_grant_moderation', false);
|
||||
this.set('can_revoke_moderation', true);
|
||||
return jQuery.ajax("/admin/users/" + (this.get('id')) + "/grant_moderation", {
|
||||
type: 'PUT'
|
||||
});
|
||||
},
|
||||
refreshBrowsers: function() {
|
||||
jQuery.ajax("/admin/users/" + (this.get('id')) + "/refresh_browsers", {
|
||||
type: 'POST'
|
||||
});
|
||||
return bootbox.alert("Message sent to all clients!");
|
||||
},
|
||||
approve: function() {
|
||||
this.set('can_approve', false);
|
||||
this.set('approved', true);
|
||||
this.set('approved_by', Discourse.get('currentUser'));
|
||||
return jQuery.ajax("/admin/users/" + (this.get('id')) + "/approve", {
|
||||
type: 'PUT'
|
||||
});
|
||||
},
|
||||
username_lower: (function() {
|
||||
return this.get('username').toLowerCase();
|
||||
}).property('username'),
|
||||
trustLevel: (function() {
|
||||
return Discourse.get('site.trust_levels').findProperty('id', this.get('trust_level'));
|
||||
}).property('trust_level'),
|
||||
canBan: (function() {
|
||||
return !this.admin && !this.moderator;
|
||||
}).property('admin', 'moderator'),
|
||||
banDuration: (function() {
|
||||
var banned_at, banned_till;
|
||||
banned_at = Date.create(this.banned_at);
|
||||
banned_till = Date.create(this.banned_till);
|
||||
return "" + (banned_at.short()) + " - " + (banned_till.short());
|
||||
}).property('banned_till', 'banned_at'),
|
||||
ban: function() {
|
||||
var duration,
|
||||
_this = this;
|
||||
if (duration = parseInt(window.prompt(Em.String.i18n('admin.user.ban_duration')), 10)) {
|
||||
if (duration > 0) {
|
||||
return jQuery.ajax("/admin/users/" + this.id + "/ban", {
|
||||
type: 'PUT',
|
||||
data: {
|
||||
duration: duration
|
||||
},
|
||||
success: function() {
|
||||
window.location.reload();
|
||||
},
|
||||
error: function(e) {
|
||||
var error;
|
||||
error = Em.String.i18n('admin.user.ban_failed', {
|
||||
error: "http: " + e.status + " - " + e.body
|
||||
});
|
||||
bootbox.alert(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
unban: function() {
|
||||
var _this = this;
|
||||
return jQuery.ajax("/admin/users/" + this.id + "/unban", {
|
||||
type: 'PUT',
|
||||
success: function() {
|
||||
window.location.reload();
|
||||
},
|
||||
error: function(e) {
|
||||
var error;
|
||||
error = Em.String.i18n('admin.user.unban_failed', {
|
||||
error: "http: " + e.status + " - " + e.body
|
||||
});
|
||||
bootbox.alert(error);
|
||||
}
|
||||
});
|
||||
},
|
||||
impersonate: function() {
|
||||
var _this = this;
|
||||
return jQuery.ajax("/admin/impersonate", {
|
||||
type: 'POST',
|
||||
data: {
|
||||
username_or_email: this.get('username')
|
||||
},
|
||||
success: function() {
|
||||
document.location = "/";
|
||||
},
|
||||
error: function(e) {
|
||||
_this.set('loading', false);
|
||||
if (e.status === 404) {
|
||||
return bootbox.alert(Em.String.i18n('admin.impersonate.not_found'));
|
||||
} else {
|
||||
return bootbox.alert(Em.String.i18n('admin.impersonate.invalid'));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
window.Discourse.AdminUser.reopenClass({
|
||||
create: function(result) {
|
||||
result = this._super(result);
|
||||
return result;
|
||||
},
|
||||
bulkApprove: function(users) {
|
||||
users.each(function(user) {
|
||||
user.set('approved', true);
|
||||
user.set('can_approve', false);
|
||||
return user.set('selected', false);
|
||||
});
|
||||
return jQuery.ajax("/admin/users/approve-bulk", {
|
||||
type: 'PUT',
|
||||
data: {
|
||||
users: users.map(function(u) {
|
||||
return u.id;
|
||||
})
|
||||
}
|
||||
});
|
||||
},
|
||||
find: function(username) {
|
||||
var promise;
|
||||
promise = new RSVP.Promise();
|
||||
jQuery.ajax({
|
||||
url: "/admin/users/" + username,
|
||||
success: function(result) {
|
||||
return promise.resolve(Discourse.AdminUser.create(result));
|
||||
}
|
||||
});
|
||||
return promise;
|
||||
},
|
||||
findAll: function(query, filter) {
|
||||
var result;
|
||||
result = Em.A();
|
||||
jQuery.ajax({
|
||||
url: "/admin/users/list/" + query + ".json",
|
||||
data: {
|
||||
filter: filter
|
||||
},
|
||||
success: function(users) {
|
||||
return users.each(function(u) {
|
||||
return result.pushObject(Discourse.AdminUser.create(u));
|
||||
});
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -1,137 +0,0 @@
|
||||
window.Discourse.AdminUser = Discourse.Model.extend
|
||||
|
||||
deleteAllPosts: ->
|
||||
@set('can_delete_all_posts', false)
|
||||
$.ajax "/admin/users/#{@get('id')}/delete_all_posts", type: 'PUT'
|
||||
|
||||
# Revoke the user's admin access
|
||||
revokeAdmin: ->
|
||||
@set('admin',false)
|
||||
@set('can_grant_admin',true)
|
||||
@set('can_revoke_admin',false)
|
||||
$.ajax "/admin/users/#{@get('id')}/revoke_admin", type: 'PUT'
|
||||
|
||||
grantAdmin: ->
|
||||
@set('admin',true)
|
||||
@set('can_grant_admin',false)
|
||||
@set('can_revoke_admin',true)
|
||||
$.ajax "/admin/users/#{@get('id')}/grant_admin", type: 'PUT'
|
||||
|
||||
# Revoke the user's moderation access
|
||||
revokeModeration: ->
|
||||
@set('moderator',false)
|
||||
@set('can_grant_moderation',true)
|
||||
@set('can_revoke_moderation',false)
|
||||
$.ajax "/admin/users/#{@get('id')}/revoke_moderation", type: 'PUT'
|
||||
|
||||
grantModeration: ->
|
||||
@set('moderator',true)
|
||||
@set('can_grant_moderation',false)
|
||||
@set('can_revoke_moderation',true)
|
||||
$.ajax "/admin/users/#{@get('id')}/grant_moderation", type: 'PUT'
|
||||
|
||||
refreshBrowsers: ->
|
||||
$.ajax "/admin/users/#{@get('id')}/refresh_browsers",
|
||||
type: 'POST'
|
||||
bootbox.alert("Message sent to all clients!")
|
||||
|
||||
approve: ->
|
||||
@set('can_approve', false)
|
||||
@set('approved', true)
|
||||
@set('approved_by', Discourse.get('currentUser'))
|
||||
$.ajax "/admin/users/#{@get('id')}/approve", type: 'PUT'
|
||||
|
||||
username_lower:(->
|
||||
@get('username').toLowerCase()
|
||||
).property('username')
|
||||
|
||||
trustLevel: (->
|
||||
Discourse.get('site.trust_levels').findProperty('id', @get('trust_level'))
|
||||
).property('trust_level')
|
||||
|
||||
|
||||
canBan: ( ->
|
||||
!@admin && !@moderator
|
||||
).property('admin','moderator')
|
||||
|
||||
banDuration: (->
|
||||
banned_at = Date.create(@banned_at)
|
||||
banned_till = Date.create(@banned_till)
|
||||
|
||||
"#{banned_at.short()} - #{banned_till.short()}"
|
||||
|
||||
).property('banned_till', 'banned_at')
|
||||
|
||||
ban: ->
|
||||
debugger
|
||||
if duration = parseInt(window.prompt(Em.String.i18n('admin.user.ban_duration')))
|
||||
if duration > 0
|
||||
$.ajax "/admin/users/#{@id}/ban",
|
||||
type: 'PUT'
|
||||
data:
|
||||
duration: duration
|
||||
success: ->
|
||||
window.location.reload()
|
||||
return
|
||||
error: (e) =>
|
||||
error = Em.String.i18n('admin.user.ban_failed', error: "http: #{e.status} - #{e.body}")
|
||||
bootbox.alert error
|
||||
return
|
||||
|
||||
unban: ->
|
||||
$.ajax "/admin/users/#{@id}/unban",
|
||||
type: 'PUT'
|
||||
success: ->
|
||||
window.location.reload()
|
||||
return
|
||||
error: (e) =>
|
||||
error = Em.String.i18n('admin.user.unban_failed', error: "http: #{e.status} - #{e.body}")
|
||||
bootbox.alert error
|
||||
return
|
||||
|
||||
impersonate: ->
|
||||
$.ajax "/admin/impersonate"
|
||||
type: 'POST'
|
||||
data:
|
||||
username_or_email: @get('username')
|
||||
success: ->
|
||||
document.location = "/"
|
||||
error: (e) =>
|
||||
@set('loading', false)
|
||||
if e.status == 404
|
||||
bootbox.alert Em.String.i18n('admin.impersonate.not_found')
|
||||
else
|
||||
bootbox.alert Em.String.i18n('admin.impersonate.invalid')
|
||||
|
||||
window.Discourse.AdminUser.reopenClass
|
||||
|
||||
create: (result) ->
|
||||
result = @_super(result)
|
||||
result
|
||||
|
||||
bulkApprove: (users) ->
|
||||
users.each (user) ->
|
||||
user.set('approved', true)
|
||||
user.set('can_approve', false)
|
||||
user.set('selected', false)
|
||||
|
||||
$.ajax "/admin/users/approve-bulk",
|
||||
type: 'PUT'
|
||||
data: {users: users.map (u) -> u.id}
|
||||
|
||||
find: (username)->
|
||||
promise = new RSVP.Promise()
|
||||
$.ajax
|
||||
url: "/admin/users/#{username}"
|
||||
success: (result) -> promise.resolve(Discourse.AdminUser.create(result))
|
||||
promise
|
||||
|
||||
findAll: (query, filter)->
|
||||
result = Em.A()
|
||||
$.ajax
|
||||
url: "/admin/users/list/#{query}.json"
|
||||
data: {filter: filter}
|
||||
success: (users) ->
|
||||
users.each (u) -> result.pushObject(Discourse.AdminUser.create(u))
|
||||
result
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
(function() {
|
||||
|
||||
window.Discourse.EmailLog = Discourse.Model.extend({});
|
||||
|
||||
window.Discourse.EmailLog.reopenClass({
|
||||
create: function(attrs) {
|
||||
if (attrs.user) {
|
||||
attrs.user = Discourse.AdminUser.create(attrs.user);
|
||||
}
|
||||
return this._super(attrs);
|
||||
},
|
||||
findAll: function(filter) {
|
||||
var result;
|
||||
result = Em.A();
|
||||
jQuery.ajax({
|
||||
url: "/admin/email_logs.json",
|
||||
data: {
|
||||
filter: filter
|
||||
},
|
||||
success: function(logs) {
|
||||
return logs.each(function(log) {
|
||||
return result.pushObject(Discourse.EmailLog.create(log));
|
||||
});
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -1,17 +0,0 @@
|
||||
window.Discourse.EmailLog = Discourse.Model.extend({})
|
||||
|
||||
window.Discourse.EmailLog.reopenClass
|
||||
|
||||
create: (attrs) ->
|
||||
attrs.user = Discourse.AdminUser.create(attrs.user) if attrs.user
|
||||
@_super(attrs)
|
||||
|
||||
findAll: (filter)->
|
||||
result = Em.A()
|
||||
$.ajax
|
||||
url: "/admin/email_logs.json"
|
||||
data: {filter: filter}
|
||||
success: (logs) ->
|
||||
logs.each (log) -> result.pushObject(Discourse.EmailLog.create(log))
|
||||
result
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
(function() {
|
||||
|
||||
window.Discourse.FlaggedPost = Discourse.Post.extend({
|
||||
flaggers: (function() {
|
||||
var r,
|
||||
_this = this;
|
||||
r = [];
|
||||
this.post_actions.each(function(a) {
|
||||
return r.push(_this.userLookup[a.user_id]);
|
||||
});
|
||||
return r;
|
||||
}).property(),
|
||||
messages: (function() {
|
||||
var r,
|
||||
_this = this;
|
||||
r = [];
|
||||
this.post_actions.each(function(a) {
|
||||
if (a.message) {
|
||||
return r.push({
|
||||
user: _this.userLookup[a.user_id],
|
||||
message: a.message
|
||||
});
|
||||
}
|
||||
});
|
||||
return r;
|
||||
}).property(),
|
||||
lastFlagged: (function() {
|
||||
return this.post_actions[0].created_at;
|
||||
}).property(),
|
||||
user: (function() {
|
||||
return this.userLookup[this.user_id];
|
||||
}).property(),
|
||||
topicHidden: (function() {
|
||||
return this.get('topic_visible') === 'f';
|
||||
}).property('topic_hidden'),
|
||||
deletePost: function() {
|
||||
var promise;
|
||||
promise = new RSVP.Promise();
|
||||
if (this.get('post_number') === "1") {
|
||||
return jQuery.ajax("/t/" + this.topic_id, {
|
||||
type: 'DELETE',
|
||||
cache: false,
|
||||
success: function() {
|
||||
return promise.resolve();
|
||||
},
|
||||
error: function(e) {
|
||||
return promise.reject();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
return jQuery.ajax("/posts/" + this.id, {
|
||||
type: 'DELETE',
|
||||
cache: false,
|
||||
success: function() {
|
||||
return promise.resolve();
|
||||
},
|
||||
error: function(e) {
|
||||
return promise.reject();
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
clearFlags: function() {
|
||||
var promise;
|
||||
promise = new RSVP.Promise();
|
||||
jQuery.ajax("/admin/flags/clear/" + this.id, {
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
success: function() {
|
||||
return promise.resolve();
|
||||
},
|
||||
error: function(e) {
|
||||
return promise.reject();
|
||||
}
|
||||
});
|
||||
return promise;
|
||||
},
|
||||
hiddenClass: (function() {
|
||||
if (this.get('hidden') === "t") {
|
||||
return "hidden-post";
|
||||
}
|
||||
}).property()
|
||||
});
|
||||
|
||||
window.Discourse.FlaggedPost.reopenClass({
|
||||
findAll: function(filter) {
|
||||
var result;
|
||||
result = Em.A();
|
||||
jQuery.ajax({
|
||||
url: "/admin/flags/" + filter + ".json",
|
||||
success: function(data) {
|
||||
var userLookup;
|
||||
userLookup = {};
|
||||
data.users.each(function(u) {
|
||||
userLookup[u.id] = Discourse.User.create(u);
|
||||
});
|
||||
return data.posts.each(function(p) {
|
||||
var f;
|
||||
f = Discourse.FlaggedPost.create(p);
|
||||
f.userLookup = userLookup;
|
||||
return result.pushObject(f);
|
||||
});
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -1,81 +0,0 @@
|
||||
window.Discourse.FlaggedPost = Discourse.Post.extend
|
||||
flaggers: (->
|
||||
r = []
|
||||
@post_actions.each (a)=>
|
||||
r.push(@userLookup[a.user_id])
|
||||
r
|
||||
).property()
|
||||
|
||||
messages: (->
|
||||
r = []
|
||||
@post_actions.each (a)=>
|
||||
if a.message
|
||||
r.push
|
||||
user: @userLookup[a.user_id]
|
||||
message: a.message
|
||||
r
|
||||
).property()
|
||||
|
||||
lastFlagged: (->
|
||||
@post_actions[0].created_at
|
||||
).property()
|
||||
|
||||
user: (->
|
||||
@userLookup[@user_id]
|
||||
).property()
|
||||
|
||||
topicHidden: (->
|
||||
@get('topic_visible') == 'f'
|
||||
).property('topic_hidden')
|
||||
|
||||
deletePost: ->
|
||||
promise = new RSVP.Promise()
|
||||
if @get('post_number') == "1"
|
||||
$.ajax "/t/#{@topic_id}",
|
||||
type: 'DELETE'
|
||||
cache: false
|
||||
success: ->
|
||||
promise.resolve()
|
||||
error: (e)->
|
||||
promise.reject()
|
||||
else
|
||||
$.ajax "/posts/#{@id}",
|
||||
type: 'DELETE'
|
||||
cache: false
|
||||
success: ->
|
||||
promise.resolve()
|
||||
error: (e)->
|
||||
promise.reject()
|
||||
|
||||
clearFlags: ->
|
||||
promise = new RSVP.Promise()
|
||||
$.ajax "/admin/flags/clear/#{@id}",
|
||||
type: 'POST'
|
||||
cache: false
|
||||
success: ->
|
||||
promise.resolve()
|
||||
error: (e)->
|
||||
promise.reject()
|
||||
|
||||
promise
|
||||
|
||||
hiddenClass: (->
|
||||
"hidden-post" if @get('hidden') == "t"
|
||||
).property()
|
||||
|
||||
|
||||
window.Discourse.FlaggedPost.reopenClass
|
||||
|
||||
findAll: (filter) ->
|
||||
result = Em.A()
|
||||
$.ajax
|
||||
url: "/admin/flags/#{filter}.json"
|
||||
success: (data) ->
|
||||
userLookup = {}
|
||||
data.users.each (u) -> userLookup[u.id] = Discourse.User.create(u)
|
||||
data.posts.each (p) ->
|
||||
f = Discourse.FlaggedPost.create(p)
|
||||
f.userLookup = userLookup
|
||||
result.pushObject(f)
|
||||
result
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
(function() {
|
||||
var SiteCustomizations;
|
||||
|
||||
window.Discourse.SiteCustomization = Discourse.Model.extend({
|
||||
init: function() {
|
||||
this._super();
|
||||
return this.startTrackingChanges();
|
||||
},
|
||||
trackedProperties: ['enabled', 'name', 'stylesheet', 'header', 'override_default_style'],
|
||||
description: (function() {
|
||||
return "" + this.name + (this.enabled ? ' (*)' : '');
|
||||
}).property('selected', 'name'),
|
||||
changed: (function() {
|
||||
var _this = this;
|
||||
if (!this.originals) {
|
||||
return false;
|
||||
}
|
||||
return this.trackedProperties.any(function(p) {
|
||||
return _this.originals[p] !== _this.get(p);
|
||||
});
|
||||
}).property('override_default_style', 'enabled', 'name', 'stylesheet', 'header', 'originals'),
|
||||
startTrackingChanges: function() {
|
||||
var _this = this;
|
||||
this.set('originals', {});
|
||||
return this.trackedProperties.each(function(p) {
|
||||
_this.originals[p] = _this.get(p);
|
||||
return true;
|
||||
});
|
||||
},
|
||||
previewUrl: (function() {
|
||||
return "/?preview-style=" + (this.get('key'));
|
||||
}).property('key'),
|
||||
disableSave: (function() {
|
||||
return !this.get('changed');
|
||||
}).property('changed'),
|
||||
save: function() {
|
||||
var data;
|
||||
this.startTrackingChanges();
|
||||
data = {
|
||||
name: this.name,
|
||||
enabled: this.enabled,
|
||||
stylesheet: this.stylesheet,
|
||||
header: this.header,
|
||||
override_default_style: this.override_default_style
|
||||
};
|
||||
return jQuery.ajax({
|
||||
url: "/admin/site_customizations" + (this.id ? '/' + this.id : ''),
|
||||
data: {
|
||||
site_customization: data
|
||||
},
|
||||
type: this.id ? 'PUT' : 'POST'
|
||||
});
|
||||
},
|
||||
"delete": function() {
|
||||
if (!this.id) {
|
||||
return;
|
||||
}
|
||||
return jQuery.ajax({
|
||||
url: "/admin/site_customizations/" + this.id,
|
||||
type: 'DELETE'
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
SiteCustomizations = Ember.ArrayProxy.extend({
|
||||
selectedItemChanged: (function() {
|
||||
var selected;
|
||||
selected = this.get('selectedItem');
|
||||
return this.get('content').each(function(i) {
|
||||
return i.set('selected', selected === i);
|
||||
});
|
||||
}).observes('selectedItem')
|
||||
});
|
||||
|
||||
Discourse.SiteCustomization.reopenClass({
|
||||
findAll: function() {
|
||||
var content,
|
||||
_this = this;
|
||||
content = SiteCustomizations.create({
|
||||
content: [],
|
||||
loading: true
|
||||
});
|
||||
jQuery.ajax({
|
||||
url: "/admin/site_customizations",
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
if (data) {
|
||||
data.site_customizations.each(function(c) {
|
||||
var item;
|
||||
item = Discourse.SiteCustomization.create(c);
|
||||
return content.pushObject(item);
|
||||
});
|
||||
}
|
||||
return content.set('loading', false);
|
||||
}
|
||||
});
|
||||
return content;
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -1,78 +0,0 @@
|
||||
window.Discourse.SiteCustomization = Discourse.Model.extend
|
||||
|
||||
init: ->
|
||||
@_super()
|
||||
@startTrackingChanges()
|
||||
|
||||
trackedProperties: ['enabled','name', 'stylesheet', 'header', 'override_default_style']
|
||||
|
||||
description: (->
|
||||
"#{@name}#{if @enabled then ' (*)' else ''}"
|
||||
).property('selected', 'name')
|
||||
|
||||
changed: (->
|
||||
return false unless @originals
|
||||
@trackedProperties.any (p)=>
|
||||
@originals[p] != @get(p)
|
||||
).property('override_default_style','enabled','name', 'stylesheet', 'header', 'originals') # TODO figure out how to call with apply
|
||||
|
||||
startTrackingChanges: ->
|
||||
@set('originals',{})
|
||||
|
||||
@trackedProperties.each (p)=>
|
||||
@originals[p] = @get(p)
|
||||
true
|
||||
|
||||
previewUrl: (->
|
||||
"/?preview-style=#{@get('key')}"
|
||||
).property('key')
|
||||
|
||||
disableSave:(->
|
||||
!@get('changed')
|
||||
).property('changed')
|
||||
|
||||
save: ->
|
||||
@startTrackingChanges()
|
||||
data =
|
||||
name: @name
|
||||
enabled: @enabled
|
||||
stylesheet: @stylesheet
|
||||
header: @header
|
||||
override_default_style: @override_default_style
|
||||
|
||||
$.ajax
|
||||
url: "/admin/site_customizations#{if @id then '/' + @id else ''}"
|
||||
data:
|
||||
site_customization: data
|
||||
type: if @id then 'PUT' else 'POST'
|
||||
|
||||
delete: ->
|
||||
return unless @id
|
||||
$.ajax
|
||||
url: "/admin/site_customizations/#{ @id }"
|
||||
type: 'DELETE'
|
||||
|
||||
SiteCustomizations = Ember.ArrayProxy.extend
|
||||
selectedItemChanged: (->
|
||||
selected = @get('selectedItem')
|
||||
@get('content').each (i)->
|
||||
i.set('selected', selected == i)
|
||||
).observes('selectedItem')
|
||||
|
||||
|
||||
Discourse.SiteCustomization.reopenClass
|
||||
findAll: ->
|
||||
content = SiteCustomizations.create
|
||||
content: []
|
||||
loading: true
|
||||
|
||||
$.ajax
|
||||
url: "/admin/site_customizations"
|
||||
dataType: "json"
|
||||
success: (data)=>
|
||||
data?.site_customizations.each (c)->
|
||||
item = Discourse.SiteCustomization.create(c)
|
||||
content.pushObject(item)
|
||||
content.set('loading',false)
|
||||
|
||||
content
|
||||
@@ -0,0 +1,62 @@
|
||||
(function() {
|
||||
|
||||
window.Discourse.SiteSetting = Discourse.Model.extend(Discourse.Presence, {
|
||||
/* Whether a property is short.
|
||||
*/
|
||||
|
||||
short: (function() {
|
||||
if (this.blank('value')) {
|
||||
return true;
|
||||
}
|
||||
return this.get('value').toString().length < 80;
|
||||
}).property('value'),
|
||||
/* Whether the site setting has changed
|
||||
*/
|
||||
|
||||
dirty: (function() {
|
||||
return this.get('originalValue') !== this.get('value');
|
||||
}).property('originalValue', 'value'),
|
||||
overridden: (function() {
|
||||
var defaultVal, val;
|
||||
val = this.get('value');
|
||||
defaultVal = this.get('default');
|
||||
if (val && defaultVal) {
|
||||
return val.toString() !== defaultVal.toString();
|
||||
}
|
||||
return val !== defaultVal;
|
||||
}).property('value'),
|
||||
resetValue: function() {
|
||||
return this.set('value', this.get('originalValue'));
|
||||
},
|
||||
save: function() {
|
||||
/* Update the setting
|
||||
*/
|
||||
|
||||
var _this = this;
|
||||
return jQuery.ajax("/admin/site_settings/" + (this.get('setting')), {
|
||||
data: {
|
||||
value: this.get('value')
|
||||
},
|
||||
type: 'PUT',
|
||||
success: function() {
|
||||
return _this.set('originalValue', _this.get('value'));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
window.Discourse.SiteSetting.reopenClass({
|
||||
findAll: function() {
|
||||
var result;
|
||||
result = Em.A();
|
||||
jQuery.get("/admin/site_settings", function(settings) {
|
||||
return settings.each(function(s) {
|
||||
s.originalValue = s.value;
|
||||
return result.pushObject(Discourse.SiteSetting.create(s));
|
||||
});
|
||||
});
|
||||
return result;
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -1,42 +0,0 @@
|
||||
window.Discourse.SiteSetting = Discourse.Model.extend Discourse.Presence,
|
||||
|
||||
# Whether a property is short.
|
||||
short: (->
|
||||
return true if @blank('value')
|
||||
return @get('value').toString().length < 80
|
||||
).property('value')
|
||||
|
||||
# Whether the site setting has changed
|
||||
dirty: (->
|
||||
@get('originalValue') != @get('value')
|
||||
).property('originalValue', 'value')
|
||||
|
||||
overridden: (->
|
||||
val = @get('value')
|
||||
defaultVal = @get('default')
|
||||
return val.toString() != defaultVal.toString() if (val and defaultVal)
|
||||
return val != defaultVal
|
||||
).property('value')
|
||||
|
||||
resetValue: ->
|
||||
@set('value', @get('originalValue'))
|
||||
|
||||
save: ->
|
||||
|
||||
# Update the setting
|
||||
$.ajax "/admin/site_settings/#{@get('setting')}",
|
||||
data:
|
||||
value: @get('value')
|
||||
type: 'PUT'
|
||||
success: => @set('originalValue', @get('value'))
|
||||
|
||||
|
||||
window.Discourse.SiteSetting.reopenClass
|
||||
findAll: ->
|
||||
result = Em.A()
|
||||
$.get "/admin/site_settings", (settings) ->
|
||||
settings.each (s) ->
|
||||
s.originalValue = s.value
|
||||
result.pushObject(Discourse.SiteSetting.create(s))
|
||||
result
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
(function() {
|
||||
|
||||
window.Discourse.VersionCheck = Discourse.Model.extend({});
|
||||
|
||||
Discourse.VersionCheck.reopenClass({
|
||||
find: function() {
|
||||
var _this = this;
|
||||
return jQuery.ajax({
|
||||
url: '/admin/version_check',
|
||||
dataType: 'json',
|
||||
success: function(json) {
|
||||
return Discourse.VersionCheck.create(json);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -1,9 +0,0 @@
|
||||
window.Discourse.VersionCheck = Discourse.Model.extend({})
|
||||
|
||||
Discourse.VersionCheck.reopenClass
|
||||
find: ->
|
||||
$.ajax
|
||||
url: '/admin/version_check'
|
||||
dataType: 'json'
|
||||
success: (json) =>
|
||||
Discourse.VersionCheck.create(json)
|
||||
@@ -0,0 +1,9 @@
|
||||
(function() {
|
||||
|
||||
Discourse.AdminCustomizeRoute = Discourse.Route.extend({
|
||||
model: function() {
|
||||
return Discourse.SiteCustomization.findAll();
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -1,2 +0,0 @@
|
||||
Discourse.AdminCustomizeRoute = Discourse.Route.extend
|
||||
model: -> Discourse.SiteCustomization.findAll()
|
||||
@@ -0,0 +1,12 @@
|
||||
(function() {
|
||||
|
||||
Discourse.AdminDashboardRoute = Discourse.Route.extend({
|
||||
setupController: function(c) {
|
||||
return Discourse.VersionCheck.find().then(function(vc) {
|
||||
c.set('versionCheck', vc);
|
||||
return c.set('loading', false);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -1,6 +0,0 @@
|
||||
Discourse.AdminDashboardRoute = Discourse.Route.extend
|
||||
setupController: (c) ->
|
||||
Discourse.VersionCheck.find().then (vc) ->
|
||||
# Loading finished!
|
||||
c.set('versionCheck', vc)
|
||||
c.set('loading', false)
|
||||
@@ -0,0 +1,9 @@
|
||||
(function() {
|
||||
|
||||
Discourse.AdminEmailLogsRoute = Discourse.Route.extend({
|
||||
model: function() {
|
||||
return Discourse.EmailLog.findAll();
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -1,2 +0,0 @@
|
||||
Discourse.AdminEmailLogsRoute = Discourse.Route.extend
|
||||
model: -> Discourse.EmailLog.findAll()
|
||||
@@ -0,0 +1,15 @@
|
||||
(function() {
|
||||
|
||||
Discourse.AdminFlagsActiveRoute = Discourse.Route.extend({
|
||||
model: function() {
|
||||
return Discourse.FlaggedPost.findAll('active');
|
||||
},
|
||||
setupController: function(controller, model) {
|
||||
var c;
|
||||
c = this.controllerFor('adminFlags');
|
||||
c.set('content', model);
|
||||
return c.set('query', 'active');
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -1,6 +0,0 @@
|
||||
Discourse.AdminFlagsActiveRoute = Discourse.Route.extend
|
||||
model: -> Discourse.FlaggedPost.findAll('active')
|
||||
setupController: (controller, model) ->
|
||||
c = @controllerFor('adminFlags')
|
||||
c.set('content', model)
|
||||
c.set('query', 'active')
|
||||
@@ -0,0 +1,15 @@
|
||||
(function() {
|
||||
|
||||
Discourse.AdminFlagsOldRoute = Discourse.Route.extend({
|
||||
model: function() {
|
||||
return Discourse.FlaggedPost.findAll('old');
|
||||
},
|
||||
setupController: function(controller, model) {
|
||||
var c;
|
||||
c = this.controllerFor('adminFlags');
|
||||
c.set('content', model);
|
||||
return c.set('query', 'old');
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -1,6 +0,0 @@
|
||||
Discourse.AdminFlagsOldRoute = Discourse.Route.extend
|
||||
model: -> Discourse.FlaggedPost.findAll('old')
|
||||
setupController: (controller, model) ->
|
||||
c = @controllerFor('adminFlags')
|
||||
c.set('content', model)
|
||||
c.set('query', 'old')
|
||||
@@ -0,0 +1,52 @@
|
||||
(function() {
|
||||
|
||||
Discourse.buildRoutes(function() {
|
||||
return this.resource('admin', {
|
||||
path: '/admin'
|
||||
}, function() {
|
||||
this.route('dashboard', {
|
||||
path: '/'
|
||||
});
|
||||
this.route('site_settings', {
|
||||
path: '/site_settings'
|
||||
});
|
||||
this.route('email_logs', {
|
||||
path: '/email_logs'
|
||||
});
|
||||
this.route('customize', {
|
||||
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'
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -1,17 +0,0 @@
|
||||
Discourse.buildRoutes ->
|
||||
@resource 'admin', path: '/admin', ->
|
||||
@route 'dashboard', path: '/'
|
||||
@route 'site_settings', path: '/site_settings'
|
||||
@route 'email_logs', path: '/email_logs'
|
||||
@route 'customize', path: '/customize'
|
||||
|
||||
@resource 'adminFlags', path: '/flags', ->
|
||||
@route 'active', path: '/active'
|
||||
@route 'old', path: '/old'
|
||||
|
||||
@resource 'adminUsers', path: '/users', ->
|
||||
@resource 'adminUser', path: '/:username'
|
||||
@resource 'adminUsersList', path: '/list', ->
|
||||
@route 'active', path: '/active'
|
||||
@route 'new', path: '/new'
|
||||
@route 'pending', path: '/pending'
|
||||
@@ -0,0 +1,9 @@
|
||||
(function() {
|
||||
|
||||
Discourse.AdminSiteSettingsRoute = Discourse.Route.extend({
|
||||
model: function() {
|
||||
return Discourse.SiteSetting.findAll();
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -1,2 +0,0 @@
|
||||
Discourse.AdminSiteSettingsRoute = Discourse.Route.extend
|
||||
model: -> Discourse.SiteSetting.findAll()
|
||||
@@ -0,0 +1,9 @@
|
||||
(function() {
|
||||
|
||||
Discourse.AdminUserRoute = Discourse.Route.extend({
|
||||
model: function(params) {
|
||||
return Discourse.AdminUser.find(params.username);
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -1,2 +0,0 @@
|
||||
Discourse.AdminUserRoute = Discourse.Route.extend
|
||||
model: (params) -> Discourse.AdminUser.find(params.username)
|
||||
@@ -0,0 +1,9 @@
|
||||
(function() {
|
||||
|
||||
Discourse.AdminUsersListActiveRoute = Discourse.Route.extend({
|
||||
setupController: function(c) {
|
||||
return this.controllerFor('adminUsersList').show('active');
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -1,2 +0,0 @@
|
||||
Discourse.AdminUsersListActiveRoute = Discourse.Route.extend
|
||||
setupController: (c) -> @controllerFor('adminUsersList').show('active')
|
||||
@@ -0,0 +1,9 @@
|
||||
(function() {
|
||||
|
||||
Discourse.AdminUsersListNewRoute = Discourse.Route.extend({
|
||||
setupController: function(c) {
|
||||
return this.controllerFor('adminUsersList').show('new');
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -1,2 +0,0 @@
|
||||
Discourse.AdminUsersListNewRoute = Discourse.Route.extend
|
||||
setupController: (c) -> @controllerFor('adminUsersList').show('new')
|
||||
@@ -0,0 +1,9 @@
|
||||
(function() {
|
||||
|
||||
Discourse.AdminUsersListNewRoute = Discourse.Route.extend({
|
||||
setupController: function(c) {
|
||||
return this.controllerFor('adminUsersList').show('pending');
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -1,2 +0,0 @@
|
||||
Discourse.AdminUsersListNewRoute = Discourse.Route.extend
|
||||
setupController: (c) -> @controllerFor('adminUsersList').show('pending')
|
||||
@@ -4,4 +4,4 @@
|
||||
<% admin = SimplesIdeias::I18n.translation_segments['app/assets/javascripts/i18n/admin.en.js']
|
||||
admin[:en][:js] = admin[:en].delete(:admin_js)
|
||||
%>
|
||||
$.extend(true, I18n.translations, <%= admin.to_json %>);
|
||||
jQuery.extend(true, I18n.translations, <%= admin.to_json %>);
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
/*global ace:true */
|
||||
(function() {
|
||||
|
||||
Discourse.AceEditorView = window.Discourse.View.extend({
|
||||
mode: 'css',
|
||||
classNames: ['ace-wrapper'],
|
||||
contentChanged: (function() {
|
||||
if (this.editor && !this.skipContentChangeEvent) {
|
||||
return this.editor.getSession().setValue(this.get('content'));
|
||||
}
|
||||
}).observes('content'),
|
||||
render: function(buffer) {
|
||||
buffer.push("<div class='ace'>");
|
||||
if (this.get('content')) {
|
||||
buffer.push(Handlebars.Utils.escapeExpression(this.get('content')));
|
||||
}
|
||||
return buffer.push("</div>");
|
||||
},
|
||||
willDestroyElement: function() {
|
||||
if (this.editor) {
|
||||
this.editor.destroy();
|
||||
this.editor = null;
|
||||
}
|
||||
},
|
||||
didInsertElement: function() {
|
||||
var initAce,
|
||||
_this = this;
|
||||
initAce = function() {
|
||||
_this.editor = ace.edit(_this.$('.ace')[0]);
|
||||
_this.editor.setTheme("ace/theme/chrome");
|
||||
_this.editor.setShowPrintMargin(false);
|
||||
_this.editor.getSession().setMode("ace/mode/" + (_this.get('mode')));
|
||||
return _this.editor.on("change", function(e) {
|
||||
/* amending stuff as you type seems a bit out of scope for now - can revisit after launch
|
||||
*/
|
||||
|
||||
/* changes = @get('changes')
|
||||
*/
|
||||
|
||||
/* unless changes
|
||||
*/
|
||||
|
||||
/* changes = []
|
||||
*/
|
||||
|
||||
/* @set('changes', changes)
|
||||
*/
|
||||
|
||||
/* changes.push e.data
|
||||
*/
|
||||
_this.skipContentChangeEvent = true;
|
||||
_this.set('content', _this.editor.getSession().getValue());
|
||||
_this.skipContentChangeEvent = false;
|
||||
});
|
||||
};
|
||||
if (window.ace) {
|
||||
return initAce();
|
||||
} else {
|
||||
return $LAB.script('http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js').wait(initAce);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -1,42 +0,0 @@
|
||||
Discourse.AceEditorView = window.Discourse.View.extend
|
||||
mode: 'css'
|
||||
classNames: ['ace-wrapper']
|
||||
|
||||
contentChanged:(->
|
||||
if @editor && !@skipContentChangeEvent
|
||||
@editor.getSession().setValue(@get('content'))
|
||||
).observes('content')
|
||||
|
||||
render: (buffer) ->
|
||||
buffer.push("<div class='ace'>")
|
||||
buffer.push(Handlebars.Utils.escapeExpression(@get('content'))) if @get('content')
|
||||
buffer.push("</div>")
|
||||
|
||||
willDestroyElement: ->
|
||||
if @editor
|
||||
@editor.destroy()
|
||||
@editor = null
|
||||
|
||||
didInsertElement: ->
|
||||
initAce = =>
|
||||
@editor = ace.edit(@$('.ace')[0])
|
||||
@editor.setTheme("ace/theme/chrome")
|
||||
@editor.setShowPrintMargin(false)
|
||||
@editor.getSession().setMode("ace/mode/#{@get('mode')}")
|
||||
@editor.on "change", (e)=>
|
||||
# amending stuff as you type seems a bit out of scope for now - can revisit after launch
|
||||
# changes = @get('changes')
|
||||
# unless changes
|
||||
# changes = []
|
||||
# @set('changes', changes)
|
||||
# changes.push e.data
|
||||
|
||||
@skipContentChangeEvent = true
|
||||
@set('content', @editor.getSession().getValue())
|
||||
@skipContentChangeEvent = false
|
||||
if window.ace
|
||||
initAce()
|
||||
else
|
||||
$LAB.script('http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js').wait initAce
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/*global Mousetrap:true */
|
||||
(function() {
|
||||
|
||||
Discourse.AdminCustomizeView = window.Discourse.View.extend({
|
||||
templateName: 'admin/templates/customize',
|
||||
classNames: ['customize'],
|
||||
contentBinding: 'controller.content',
|
||||
init: function() {
|
||||
this._super();
|
||||
return this.set('selected', 'stylesheet');
|
||||
},
|
||||
headerActive: (function() {
|
||||
return this.get('selected') === 'header';
|
||||
}).property('selected'),
|
||||
stylesheetActive: (function() {
|
||||
return this.get('selected') === 'stylesheet';
|
||||
}).property('selected'),
|
||||
selectHeader: function() {
|
||||
return this.set('selected', 'header');
|
||||
},
|
||||
selectStylesheet: function() {
|
||||
return this.set('selected', 'stylesheet');
|
||||
},
|
||||
didInsertElement: function() {
|
||||
var _this = this;
|
||||
return Mousetrap.bindGlobal(['meta+s', 'ctrl+s'], function() {
|
||||
_this.get('controller').save();
|
||||
return false;
|
||||
});
|
||||
},
|
||||
willDestroyElement: function() {
|
||||
return Mousetrap.unbindGlobal('meta+s', 'ctrl+s');
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -1,33 +0,0 @@
|
||||
Discourse.AdminCustomizeView = window.Discourse.View.extend
|
||||
templateName: 'admin/templates/customize'
|
||||
classNames: ['customize']
|
||||
contentBinding: 'controller.content'
|
||||
|
||||
init: ->
|
||||
@_super()
|
||||
@set('selected', 'stylesheet')
|
||||
|
||||
headerActive: (->
|
||||
@get('selected') == 'header'
|
||||
).property('selected')
|
||||
|
||||
stylesheetActive: (->
|
||||
@get('selected') == 'stylesheet'
|
||||
).property('selected')
|
||||
|
||||
selectHeader: ->
|
||||
@set('selected', 'header')
|
||||
|
||||
selectStylesheet: ->
|
||||
@set('selected', 'stylesheet')
|
||||
|
||||
|
||||
didInsertElement: ->
|
||||
Mousetrap.bindGlobal ['meta+s', 'ctrl+s'], =>
|
||||
@get('controller').save()
|
||||
return false
|
||||
|
||||
willDestroyElement: ->
|
||||
Mousetrap.unbindGlobal('meta+s','ctrl+s')
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
(function() {
|
||||
|
||||
Discourse.AdminDashboardView = window.Discourse.View.extend({
|
||||
templateName: 'admin/templates/dashboard'
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -1,2 +0,0 @@
|
||||
Discourse.AdminDashboardView = window.Discourse.View.extend
|
||||
templateName: 'admin/templates/dashboard'
|
||||
@@ -0,0 +1,7 @@
|
||||
(function() {
|
||||
|
||||
Discourse.AdminEmailLogsView = window.Discourse.View.extend({
|
||||
templateName: 'admin/templates/email_logs'
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -1,2 +0,0 @@
|
||||
Discourse.AdminEmailLogsView = window.Discourse.View.extend
|
||||
templateName: 'admin/templates/email_logs'
|
||||
@@ -0,0 +1,7 @@
|
||||
(function() {
|
||||
|
||||
Discourse.AdminFlagsView = window.Discourse.View.extend({
|
||||
templateName: 'admin/templates/flags'
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -1,3 +0,0 @@
|
||||
Discourse.AdminFlagsView = window.Discourse.View.extend
|
||||
templateName: 'admin/templates/flags'
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
(function() {
|
||||
|
||||
Discourse.AdminSiteSettingsView = window.Discourse.View.extend({
|
||||
templateName: 'admin/templates/site_settings'
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -1,2 +0,0 @@
|
||||
Discourse.AdminSiteSettingsView = window.Discourse.View.extend
|
||||
templateName: 'admin/templates/site_settings'
|
||||
@@ -0,0 +1,7 @@
|
||||
(function() {
|
||||
|
||||
Discourse.AdminUserView = window.Discourse.View.extend({
|
||||
templateName: 'admin/templates/user'
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -1,2 +0,0 @@
|
||||
Discourse.AdminUserView = window.Discourse.View.extend
|
||||
templateName: 'admin/templates/user'
|
||||
@@ -0,0 +1,7 @@
|
||||
(function() {
|
||||
|
||||
Discourse.AdminUsersListView = window.Discourse.View.extend({
|
||||
templateName: 'admin/templates/users_list'
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -1,2 +0,0 @@
|
||||
Discourse.AdminUsersListView = window.Discourse.View.extend
|
||||
templateName: 'admin/templates/users_list'
|
||||
@@ -0,0 +1,7 @@
|
||||
(function() {
|
||||
|
||||
Discourse.AdminView = window.Discourse.View.extend({
|
||||
templateName: 'admin/templates/admin'
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -1,2 +0,0 @@
|
||||
Discourse.AdminView = window.Discourse.View.extend
|
||||
templateName: 'admin/templates/admin'
|
||||
Reference in New Issue
Block a user