2015-06-25 17:53:03 -04:00
|
|
|
import showModal from 'discourse/lib/show-modal';
|
2015-06-26 12:16:09 -04:00
|
|
|
import Query from 'discourse/plugins/discourse-data-explorer/discourse/models/query';
|
2015-06-25 17:53:03 -04:00
|
|
|
|
|
|
|
export default Ember.Controller.extend({
|
|
|
|
selectedItem: null,
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
selectItem(item) {
|
|
|
|
this.set('selectedItem', item);
|
|
|
|
},
|
|
|
|
|
|
|
|
dummy() {},
|
|
|
|
|
|
|
|
create() {
|
2015-06-26 12:16:09 -04:00
|
|
|
var newQuery = Query.create({name: this.get('newQueryName')});
|
|
|
|
//var newQuery = this.store.createRecord('query', {name: this.get('newQueryName')});
|
2015-06-25 17:53:03 -04:00
|
|
|
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);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|