Cleaned up JS, added basic documentation support for Admin Controllers
This commit is contained in:
parent
6096a447b7
commit
13f8f3c45e
|
@ -1,25 +1,30 @@
|
|||
(function() {
|
||||
|
||||
/**
|
||||
This controller supports interface for creating custom CSS skins in Discourse.
|
||||
|
||||
@class AdminCustomizeController
|
||||
@extends Ember.Controller
|
||||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
window.Discourse.AdminCustomizeController = Ember.Controller.extend({
|
||||
|
||||
newCustomization: function() {
|
||||
var item;
|
||||
item = Discourse.SiteCustomization.create({
|
||||
name: 'New Style'
|
||||
});
|
||||
var item = Discourse.SiteCustomization.create({name: 'New Style'});
|
||||
this.get('content').pushObject(item);
|
||||
return this.set('content.selectedItem', item);
|
||||
this.set('content.selectedItem', item);
|
||||
},
|
||||
|
||||
selectStyle: function(style) {
|
||||
return this.set('content.selectedItem', style);
|
||||
this.set('content.selectedItem', style);
|
||||
},
|
||||
|
||||
save: function() {
|
||||
return this.get('content.selectedItem').save();
|
||||
this.get('content.selectedItem').save();
|
||||
},
|
||||
|
||||
"delete": function() {
|
||||
destroy: 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;
|
||||
|
@ -31,7 +36,7 @@
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
|
|
|
@ -1,5 +1,13 @@
|
|||
(function() {
|
||||
|
||||
/**
|
||||
This controller supports the default interface when you enter the admin section.
|
||||
|
||||
@class AdminDashboardController
|
||||
@extends Ember.Controller
|
||||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
window.Discourse.AdminDashboardController = Ember.Controller.extend({
|
||||
loading: true,
|
||||
versionCheck: null,
|
||||
|
@ -7,9 +15,8 @@
|
|||
upToDate: (function() {
|
||||
if (this.versionCheck) {
|
||||
return this.versionCheck.latest_version === this.versionCheck.installed_version;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}).property('versionCheck'),
|
||||
|
||||
updateIconClasses: (function() {
|
||||
|
@ -26,11 +33,10 @@
|
|||
priorityClass: (function() {
|
||||
if (this.get('versionCheck.critical_updates')) {
|
||||
return 'version-check critical';
|
||||
} else {
|
||||
return 'version-check normal';
|
||||
}
|
||||
return 'version-check normal';
|
||||
}).property('versionCheck')
|
||||
|
||||
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
|
|
|
@ -1,5 +1,13 @@
|
|||
(function() {
|
||||
|
||||
/**
|
||||
This controller supports the interface for reviewing email logs.
|
||||
|
||||
@class AdminEmailLogsController
|
||||
@extends Ember.ArrayController
|
||||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
window.Discourse.AdminEmailLogsController = Ember.ArrayController.extend(Discourse.Presence, {
|
||||
|
||||
sendTestEmailDisabled: (function() {
|
||||
|
@ -8,13 +16,11 @@
|
|||
|
||||
sendTestEmail: function() {
|
||||
var _this = this;
|
||||
this.set('sentTestEmail', false);
|
||||
_this.set('sentTestEmail', false);
|
||||
jQuery.ajax({
|
||||
url: '/admin/email_logs/test',
|
||||
type: 'POST',
|
||||
data: {
|
||||
email_address: this.get('testEmailAddress')
|
||||
},
|
||||
data: { email_address: this.get('testEmailAddress') },
|
||||
success: function() {
|
||||
return _this.set('sentTestEmail', true);
|
||||
}
|
||||
|
|
|
@ -1,22 +1,30 @@
|
|||
(function() {
|
||||
|
||||
/**
|
||||
This controller supports the interface for dealing with flags in the admin section.
|
||||
|
||||
@class AdminFlagsController
|
||||
@extends Ember.Controller
|
||||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
window.Discourse.AdminFlagsController = Ember.Controller.extend({
|
||||
|
||||
clearFlags: function(item) {
|
||||
var _this = this;
|
||||
return item.clearFlags().then((function() {
|
||||
return _this.content.removeObject(item);
|
||||
item.clearFlags().then((function() {
|
||||
_this.content.removeObject(item);
|
||||
}), (function() {
|
||||
return bootbox.alert("something went wrong");
|
||||
bootbox.alert("something went wrong");
|
||||
}));
|
||||
},
|
||||
|
||||
deletePost: function(item) {
|
||||
var _this = this;
|
||||
return item.deletePost().then((function() {
|
||||
return _this.content.removeObject(item);
|
||||
item.deletePost().then((function() {
|
||||
_this.content.removeObject(item);
|
||||
}), (function() {
|
||||
return bootbox.alert("something went wrong");
|
||||
bootbox.alert("something went wrong");
|
||||
}));
|
||||
},
|
||||
|
||||
|
|
|
@ -1,5 +1,13 @@
|
|||
(function() {
|
||||
|
||||
/**
|
||||
This controller supports the interface for SiteSettings.
|
||||
|
||||
@class AdminSiteSettingsController
|
||||
@extends Ember.ArrayController
|
||||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
window.Discourse.AdminSiteSettingsController = Ember.ArrayController.extend(Discourse.Presence, {
|
||||
filter: null,
|
||||
onlyOverridden: false,
|
||||
|
@ -7,44 +15,35 @@
|
|||
filteredContent: (function() {
|
||||
var filter,
|
||||
_this = this;
|
||||
if (!this.present('content')) {
|
||||
return null;
|
||||
}
|
||||
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 (_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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}).property('filter', 'content.@each', 'onlyOverridden'),
|
||||
|
||||
resetDefault: function(setting) {
|
||||
setting.set('value', setting.get('default'));
|
||||
return setting.save();
|
||||
setting.save();
|
||||
},
|
||||
|
||||
save: function(setting) {
|
||||
return setting.save();
|
||||
setting.save();
|
||||
},
|
||||
|
||||
cancel: function(setting) {
|
||||
return setting.resetValue();
|
||||
setting.resetValue();
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -1,5 +1,13 @@
|
|||
(function() {
|
||||
|
||||
/**
|
||||
This controller supports the interface for listing users in the admin section.
|
||||
|
||||
@class AdminUsersListController
|
||||
@extends Ember.ArrayController
|
||||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
window.Discourse.AdminUsersListController = Ember.ArrayController.extend(Discourse.Presence, {
|
||||
username: null,
|
||||
query: null,
|
||||
|
@ -8,35 +16,27 @@
|
|||
|
||||
selectAllChanged: (function() {
|
||||
var _this = this;
|
||||
return this.get('content').each(function(user) {
|
||||
return user.set('selected', _this.get('selectAll'));
|
||||
this.get('content').each(function(user) {
|
||||
user.set('selected', _this.get('selectAll'));
|
||||
});
|
||||
}).observes('selectAll'),
|
||||
|
||||
filterUsers: Discourse.debounce(function() {
|
||||
return this.refreshUsers();
|
||||
this.refreshUsers();
|
||||
}, 250).observes('username'),
|
||||
|
||||
orderChanged: (function() {
|
||||
return this.refreshUsers();
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
if (this.blank('content')) return 0;
|
||||
return this.get('content').filterProperty('selected').length;
|
||||
}).property('content.@each.selected'),
|
||||
|
||||
|
@ -45,19 +45,20 @@
|
|||
}).property('selectedCount'),
|
||||
|
||||
refreshUsers: function() {
|
||||
return this.set('content', Discourse.AdminUser.findAll(this.get('query'), this.get('username')));
|
||||
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);
|
||||
this.refreshUsers();
|
||||
return;
|
||||
}
|
||||
|
||||
this.set('query', term);
|
||||
},
|
||||
|
||||
approveUsers: function() {
|
||||
return Discourse.AdminUser.bulkApprove(this.get('content').filterProperty('selected'));
|
||||
Discourse.AdminUser.bulkApprove(this.get('content').filterProperty('selected'));
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
(function() {
|
||||
|
||||
window.Discourse.VersionCheck = Discourse.Model.extend({
|
||||
hasInstalledSha: function() {
|
||||
console.log( 'hello??' );
|
||||
return( this.get('installed_sha') && this.get('installed_sha') != 'unknown' );
|
||||
}.property('installed_sha')
|
||||
});
|
||||
window.Discourse.VersionCheck = Discourse.Model.extend({});
|
||||
|
||||
Discourse.VersionCheck.reopenClass({
|
||||
find: function() {
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
|
||||
<div class='buttons'>
|
||||
<button {{action save target="controller"}} {{bindAttr disabled="content.selectedItem.disableSave"}} class='btn btn-primary'>{{i18n admin.customize.save}}</button>
|
||||
<a {{action delete target="controller"}} class='delete-link'>{{i18n admin.customize.delete}}</a>
|
||||
<a {{action destroy target="controller"}} class='delete-link'>{{i18n admin.customize.delete}}</a>
|
||||
<span class='saving'>{{content.savingStatus}}</span>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"name": "Discourse Client",
|
||||
"description": "This is the EmberJS client to access a Discourse Server",
|
||||
"url": "http://www.discourse.org/",
|
||||
"options": {
|
||||
"exclude": "external,external_production",
|
||||
"outdir": "./build"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue