mirror of
https://github.com/discourse/discourse.git
synced 2025-05-25 19:29:34 +08:00
basic api support
This commit is contained in:
24
app/assets/javascripts/admin/models/admin_api.js
Normal file
24
app/assets/javascripts/admin/models/admin_api.js
Normal file
@ -0,0 +1,24 @@
|
||||
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 _this = this;
|
||||
|
||||
$.ajax(Discourse.getURL('/admin/api/generate_key'),{
|
||||
type: 'POST'
|
||||
}).success(function(result){
|
||||
_this.set('key', result.key);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Discourse.AdminApi.reopenClass({
|
||||
find: function(){
|
||||
return this.getAjax('/admin/api');
|
||||
}
|
||||
});
|
Reference in New Issue
Block a user