Display errors, convert integers
This commit is contained in:
@@ -4,5 +4,5 @@ export default Ember.TextField.extend({
|
||||
this.get('params')[this.get('pname')] = value;
|
||||
}
|
||||
return this.get('params')[this.get('pname')];
|
||||
}.property()
|
||||
}.property('params', 'pname')
|
||||
});
|
||||
|
||||
@@ -137,14 +137,17 @@ export default Ember.ArrayController.extend({
|
||||
explain: this.get('explain')
|
||||
}
|
||||
}).then(function(result) {
|
||||
self.set('results', result);
|
||||
if (!result.success) {
|
||||
return popupAjaxError(result);
|
||||
self.set('showResults', false);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(result);
|
||||
self.set('showResults', true);
|
||||
}).catch(function(result) {
|
||||
self.set('showResults', false);
|
||||
self.set('results', result);
|
||||
}).catch(popupAjaxError).finally(function() {
|
||||
}).finally(function() {
|
||||
self.set('loading', false);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -5,10 +5,20 @@ Query = RestModel.extend({
|
||||
dirty: false,
|
||||
params: {},
|
||||
|
||||
_init: function() {
|
||||
this._super();
|
||||
if (!this.get('options')) {
|
||||
this.set('options', {defaults:{}});
|
||||
}
|
||||
this.set('dirty', false);
|
||||
}.on('init'),
|
||||
|
||||
_initParams: function() {
|
||||
this.resetParams();
|
||||
}.on('init').observes('param_names'),
|
||||
|
||||
options: Em.computed.alias('qopts'),
|
||||
|
||||
markDirty: function() {
|
||||
this.set('dirty', true);
|
||||
}.observes('name', 'description', 'sql', 'options', 'options.defaults'),
|
||||
@@ -37,7 +47,11 @@ Query = RestModel.extend({
|
||||
const currentParams = this.get('params');
|
||||
let defaults = {};
|
||||
(this.get('param_names') || []).forEach(function(name) {
|
||||
defaults[name] = currentParams[name];
|
||||
if (currentParams[name]) {
|
||||
defaults[name] = currentParams[name];
|
||||
} else {
|
||||
delete defaults[name];
|
||||
}
|
||||
});
|
||||
this.set('options.defaults', defaults);
|
||||
},
|
||||
@@ -80,7 +94,7 @@ Query = RestModel.extend({
|
||||
});
|
||||
|
||||
Query.reopenClass({
|
||||
updatePropertyNames: ["name", "description", "sql", "options"]
|
||||
updatePropertyNames: ["name", "description", "sql", "qopts"]
|
||||
});
|
||||
|
||||
export default Query;
|
||||
|
||||
@@ -1,24 +1,38 @@
|
||||
<h3>Queries</h3>
|
||||
<h2>Queries</h2>
|
||||
|
||||
<div class="query-list">
|
||||
{{combo-box valueAttribute="id" value=selectedQueryId nameProperty="listName" content=content castInteger="true" nameChanges="true"}}
|
||||
{{d-button action="showCreate" icon="plus" class="no-text"}}
|
||||
{{d-button action="importQuery" label="explorer.import.label" icon="upload"}}
|
||||
</div>
|
||||
|
||||
{{#if showCreate}}
|
||||
<div class="query-create">
|
||||
{{text-field value=newQueryName placeholderKey="explorer.create_placeholder"}}
|
||||
{{d-button action="create" label="explorer.create" icon="plus" class="btn-primary"}}
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="query-edit">
|
||||
{{partial "admin/plugins-explorer-show" model=selectedItem}}
|
||||
</div>
|
||||
|
||||
{{conditional-loading-spinner condition=loading}}
|
||||
|
||||
<div class="query-run">
|
||||
{{#if selectedItem.param_names}}
|
||||
<div class="query-params">
|
||||
<div class="param-save">
|
||||
{{d-button action="saveDefaults" label="explorer.save_params"}}
|
||||
{{d-button action="resetParams" label="explorer.reset_params"}}
|
||||
</div>
|
||||
{{#each selectedItem.param_names as |pname|}}
|
||||
{{param-field params=selectedItem.params pname=pname}} {{pname}}
|
||||
<div class="param">
|
||||
{{param-field params=selectedItem.params pname=pname}}
|
||||
<span class="param-name">{{pname}}</span>
|
||||
</div>
|
||||
{{/each}}
|
||||
</div>
|
||||
{{/if}}
|
||||
@@ -27,10 +41,17 @@
|
||||
</div>
|
||||
{{d-button action="run" label="explorer.run" disabled=runDisabled}}
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
{{conditional-loading-spinner condition=loading}}
|
||||
|
||||
{{#if results}}
|
||||
<div class="query-results">
|
||||
{{query-result query=selectedItem content=results}}
|
||||
{{#if showResults}}
|
||||
{{query-result query=selectedItem content=results}}
|
||||
{{else}}
|
||||
{{#each results.errors as |err|}}
|
||||
<pre class="query-error"><code>{{~err}}</code></pre>
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
Reference in New Issue
Block a user