discourse/app/assets/javascripts/admin/models/admin_api.js

28 lines
665 B
JavaScript
Raw Normal View History

2013-03-26 09:04:28 +08:00
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'),
2013-03-26 09:04:28 +08:00
generateKey: function(){
var adminApi = this;
Discourse.ajax('/admin/api/generate_key', {type: 'POST'}).then(function (result) {
adminApi.set('key', result.key);
});
2013-04-16 06:04:12 +08:00
},
regenerateKey: function(){
alert(Em.String.i18n('not_implemented'));
2013-03-26 09:04:28 +08:00
}
});
Discourse.AdminApi.reopenClass({
find: function() {
return Discourse.ajax("/admin/api").then(function(data) {
return Discourse.AdminApi.create(data);
});
2013-03-26 09:04:28 +08:00
}
});