discourse/app/assets/javascripts/admin/models/admin_api.js
2013-04-16 00:04:12 +02:00

25 lines
610 B
JavaScript

Discourse.AdminApi = Discourse.Model.extend({
VALID_KEY_LENGTH: 64,
keyExists: function(){
var key = this.get('key') || '';
return key && key.length === this.VALID_KEY_LENGTH;
}.property('key'),
generateKey: function(){
var adminApi = this;
Discourse.ajax(Discourse.getURL('/admin/api/generate_key'),{type: 'POST'}).then(function (result) {
adminApi.set('key', result.key);
});
},
regenerateKey: function(){
alert(Em.String.i18n('not_implemented'));
}
});
Discourse.AdminApi.reopenClass({
find: function() {
return this.getModelAjax('/admin/api');
}
});