discourse-data-explorer/assets/javascripts/discourse/controllers/admin-plugins-explorer.js.es6

42 lines
1.0 KiB
Plaintext
Raw Normal View History

import showModal from 'discourse/lib/show-modal';
import Query from 'discourse/plugins/discourse-data-explorer/discourse/models/query';
export default Ember.Controller.extend({
selectedItem: null,
actions: {
selectItem(item) {
this.set('selectedItem', item);
},
dummy() {},
create() {
var newQuery = Query.create({name: this.get('newQueryName')});
//var newQuery = this.store.createRecord('query', {name: this.get('newQueryName')});
newQuery.save();
},
importQuery() {
showModal('import-query');
},
run() {
const self = this;
this.set('loading', true);
Discourse.ajax("/admin/plugins/explorer/query/" + this.get('selectedItem.id') + "/run", {
type: "POST",
data: {
params: JSON.stringify({foo: 34}),
explain: true
}
}).then(function(result) {
console.log(result);
self.set('results', result);
}).finally(function() {
self.set('loading', false);
});
}
}
});