mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-11 08:11:15 -05:00
29 lines
700 B
JavaScript
29 lines
700 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('/admin/api/generate_key', {type: 'POST'}).then(function (result) {
|
|
adminApi.set('key', result.key);
|
|
});
|
|
},
|
|
|
|
regenerateKey: function(){
|
|
alert(I18n.t('not_implemented'));
|
|
}
|
|
});
|
|
|
|
Discourse.AdminApi.reopenClass({
|
|
find: function() {
|
|
var model = Discourse.AdminApi.create();
|
|
Discourse.ajax("/admin/api").then(function(data) {
|
|
model.setProperties(data);
|
|
});
|
|
return model;
|
|
}
|
|
});
|