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;
|
2013-04-02 04:28:26 +08:00
|
|
|
}.property('key'),
|
2013-03-26 09:04:28 +08:00
|
|
|
|
|
|
|
generateKey: function(){
|
2013-04-02 04:28:26 +08:00
|
|
|
var adminApi = this;
|
2013-05-08 01:30:12 +08:00
|
|
|
Discourse.ajax('/admin/api/generate_key', {type: 'POST'}).then(function (result) {
|
2013-04-02 04:28:26 +08:00
|
|
|
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({
|
2013-04-02 04:28:26 +08:00
|
|
|
find: function() {
|
2013-06-05 01:06:02 +08:00
|
|
|
var model = Discourse.AdminApi.create();
|
|
|
|
Discourse.ajax("/admin/api").then(function(data) {
|
|
|
|
model.setProperties(data);
|
2013-05-08 01:30:12 +08:00
|
|
|
});
|
2013-06-05 01:06:02 +08:00
|
|
|
return model;
|
2013-03-26 09:04:28 +08:00
|
|
|
}
|
|
|
|
});
|