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

30 lines
700 B
JavaScript
Raw Normal View History

2013-03-25 21:04:28 -04: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-25 21:04:28 -04:00
generateKey: function(){
var adminApi = this;
Discourse.ajax('/admin/api/generate_key', {type: 'POST'}).then(function (result) {
adminApi.set('key', result.key);
});
2013-04-15 18:04:12 -04:00
},
regenerateKey: function(){
alert(I18n.t('not_implemented'));
2013-03-25 21:04:28 -04:00
}
});
Discourse.AdminApi.reopenClass({
find: function() {
var model = Discourse.AdminApi.create();
Discourse.ajax("/admin/api").then(function(data) {
model.setProperties(data);
});
return model;
2013-03-25 21:04:28 -04:00
}
});