From a81f8495b04c263a0de90321f798936f4525d044 Mon Sep 17 00:00:00 2001 From: Kane York Date: Tue, 30 Jun 2015 15:56:09 -0700 Subject: [PATCH] Update URL. Regression - select2 not updating --- .../controllers/admin-plugins-explorer.js.es6 | 5 +++-- assets/javascripts/discourse/explorer-route-map.js.es6 | 1 - .../routes/admin-plugins-explorer-show.js.es6 | 6 ------ .../discourse/routes/admin-plugins-explorer.js.es6 | 2 +- .../discourse/templates/admin/plugins-explorer.hbs | 3 +++ .../discourse/templates/explorer-query-result.hbs | 10 +++++++--- assets/stylesheets/explorer.scss | 9 ++++++++- config/locales/client.en.yml | 1 + plugin.rb | 5 +++-- 9 files changed, 26 insertions(+), 16 deletions(-) delete mode 100644 assets/javascripts/discourse/routes/admin-plugins-explorer-show.js.es6 diff --git a/assets/javascripts/discourse/controllers/admin-plugins-explorer.js.es6 b/assets/javascripts/discourse/controllers/admin-plugins-explorer.js.es6 index 920ab44..1a74ec2 100644 --- a/assets/javascripts/discourse/controllers/admin-plugins-explorer.js.es6 +++ b/assets/javascripts/discourse/controllers/admin-plugins-explorer.js.es6 @@ -3,12 +3,13 @@ import Query from 'discourse/plugins/discourse-data-explorer/discourse/models/qu import { popupAjaxError } from 'discourse/lib/ajax-error'; export default Ember.ArrayController.extend({ + queryParams: { selectedQueryId: "id" }, selectedQueryId: null, results: null, showResults: false, loading: false, - explain: false, + explain: true, saveDisabled: Ember.computed.not('selectedItem.dirty'), runDisabled: Ember.computed.alias('selectedItem.dirty'), @@ -133,7 +134,7 @@ export default Ember.ArrayController.extend({ type: "POST", data: { params: JSON.stringify(this.get('selectedItem.params')), - explain: true + explain: this.get('explain') } }).then(function(result) { if (!result.success) { diff --git a/assets/javascripts/discourse/explorer-route-map.js.es6 b/assets/javascripts/discourse/explorer-route-map.js.es6 index 19c9f76..fa61c71 100644 --- a/assets/javascripts/discourse/explorer-route-map.js.es6 +++ b/assets/javascripts/discourse/explorer-route-map.js.es6 @@ -3,6 +3,5 @@ export default { path: '/plugins', map() { this.route('explorer'); - this.route('explorer-show', {path: 'explorer/:id'}); } }; diff --git a/assets/javascripts/discourse/routes/admin-plugins-explorer-show.js.es6 b/assets/javascripts/discourse/routes/admin-plugins-explorer-show.js.es6 deleted file mode 100644 index 877f0a8..0000000 --- a/assets/javascripts/discourse/routes/admin-plugins-explorer-show.js.es6 +++ /dev/null @@ -1,6 +0,0 @@ - -export default Discourse.Route.extend({ - model(params) { - return this.store.find('query', params.get('id')); - } -}); diff --git a/assets/javascripts/discourse/routes/admin-plugins-explorer.js.es6 b/assets/javascripts/discourse/routes/admin-plugins-explorer.js.es6 index ed58205..0438c9b 100644 --- a/assets/javascripts/discourse/routes/admin-plugins-explorer.js.es6 +++ b/assets/javascripts/discourse/routes/admin-plugins-explorer.js.es6 @@ -1,7 +1,7 @@ - export default Discourse.Route.extend({ controllerName: 'admin-plugins-explorer', + queryParams: { id: { replace: true } }, model() { return this.store.findAll('query'); diff --git a/assets/javascripts/discourse/templates/admin/plugins-explorer.hbs b/assets/javascripts/discourse/templates/admin/plugins-explorer.hbs index 7f035cc..0e34c83 100644 --- a/assets/javascripts/discourse/templates/admin/plugins-explorer.hbs +++ b/assets/javascripts/discourse/templates/admin/plugins-explorer.hbs @@ -22,6 +22,9 @@ {{/each}} {{/if}} +
+ +
{{d-button action="run" label="explorer.run" disabled=runDisabled}}
diff --git a/assets/javascripts/discourse/templates/explorer-query-result.hbs b/assets/javascripts/discourse/templates/explorer-query-result.hbs index e6b0d65..a09dbf0 100644 --- a/assets/javascripts/discourse/templates/explorer-query-result.hbs +++ b/assets/javascripts/discourse/templates/explorer-query-result.hbs @@ -7,9 +7,13 @@ {{duration}} -{{#if hasExplain}} -
{{content.explain}}
-{{/if}} + +{{~#if hasExplain}} +

+    {{~content.explain}}
+  
+{{~/if}} + diff --git a/assets/stylesheets/explorer.scss b/assets/stylesheets/explorer.scss index 804826c..96bf019 100644 --- a/assets/stylesheets/explorer.scss +++ b/assets/stylesheets/explorer.scss @@ -28,6 +28,13 @@ .clear { clear: both; } } -.query-list, .query-edit, .query-results { +.query-params { + border: 1px solid dark-light-diff($primary, $secondary, 60%, -20%); + input { + margin: 9px; + } +} + +.query-list, .query-edit, .query-results, .query-params { margin: 10px 0; } diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 239942d..e4a238c 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -37,3 +37,4 @@ en: download_json: "Save Query Results" run_time: "Query completed in {{value}} ms." column: "Column {{number}}" + explain_label: "Include query plan?" diff --git a/plugin.rb b/plugin.rb index 5241ee8..3a1e0c1 100644 --- a/plugin.rb +++ b/plugin.rb @@ -276,7 +276,7 @@ SQL end query.save - render_serialized query, DataExplorer::QuerySerializer, root: true + render_serialized query, DataExplorer::QuerySerializer, root: 'query' end def destroy @@ -290,7 +290,7 @@ SQL query = DataExplorer::Query.find(params[:id].to_i) query_params = MultiJson.load(params[:params]) opts = {current_user: current_user.username} - opts[:explain] = true if params[:explain] + opts[:explain] = true if params[:explain] == "true" result = DataExplorer.run_query(query, query_params, opts) if result[:error] @@ -340,6 +340,7 @@ SQL DataExplorer::Engine.routes.draw do root to: "query#index" + get 'queries' => "query#index" post 'queries' => "query#create" get 'queries/:id' => "query#show"