mirror of
				https://github.com/discourse/discourse-data-explorer.git
				synced 2025-10-31 06:08:38 +00:00 
			
		
		
		
	Add text for no queries, keep results in query object
This commit is contained in:
		
							parent
							
								
									052fb97396
								
							
						
					
					
						commit
						d9dbfc8408
					
				| @ -2,10 +2,11 @@ import showModal from 'discourse/lib/show-modal'; | ||||
| import Query from 'discourse/plugins/discourse-data-explorer/discourse/models/query'; | ||||
| import { popupAjaxError } from 'discourse/lib/ajax-error'; | ||||
| 
 | ||||
| const NoQuery = Query.create({name: "No queries", fake: true}); | ||||
| 
 | ||||
| export default Ember.ArrayController.extend({ | ||||
|   queryParams: { selectedQueryId: "id" }, | ||||
|   selectedQueryId: null, | ||||
|   results: null, | ||||
|   showResults: false, | ||||
|   loading: false, | ||||
| 
 | ||||
| @ -17,15 +18,13 @@ export default Ember.ArrayController.extend({ | ||||
|   selectedItem: function() { | ||||
|     const _id = this.get('selectedQueryId'); | ||||
|     const id = parseInt(_id); | ||||
|     return this.get('content').find(function(q) { | ||||
|     const item = this.get('content').find(function(q) { | ||||
|       return q.get('id') === id; | ||||
|     }); | ||||
|     return item || NoQuery; | ||||
|   }.property('selectedQueryId'), | ||||
| 
 | ||||
|   clearResults: function() { | ||||
|     this.set('showResults', false); | ||||
|     this.set('results', null); | ||||
|   }.observes('selectedQueryId'), | ||||
|   results: Em.computed.alias('selectedItem.results'), | ||||
| 
 | ||||
|   addCreatedRecord(record) { | ||||
|     this.pushObject(record); | ||||
| @ -103,7 +102,6 @@ export default Ember.ArrayController.extend({ | ||||
|         query.setProperties(result.getProperties(Query.updatePropertyNames)); | ||||
|         query.markNotDirty(); | ||||
|         self.set('editName', false); | ||||
|         self.set('results', null); | ||||
|       }).catch(popupAjaxError).finally(function() { | ||||
|         self.set('loading', false); | ||||
|       }); | ||||
| @ -138,6 +136,7 @@ export default Ember.ArrayController.extend({ | ||||
|       } | ||||
| 
 | ||||
|       this.set('loading', true); | ||||
|       this.set('showResults', false); | ||||
|       Discourse.ajax("/admin/plugins/explorer/queries/" + this.get('selectedItem.id') + "/run", { | ||||
|         type: "POST", | ||||
|         data: { | ||||
|  | ||||
| @ -4,6 +4,7 @@ let Query; | ||||
| Query = RestModel.extend({ | ||||
|   dirty: false, | ||||
|   params: {}, | ||||
|   results: null, | ||||
| 
 | ||||
|   _init: function() { | ||||
|     this._super(); | ||||
|  | ||||
| @ -22,6 +22,9 @@ | ||||
| 
 | ||||
| <hr> | ||||
| 
 | ||||
| {{#if selectedItem.fake}} | ||||
|   {{i18n "explorer.no_queries"}} <a {{action "showCreate"}}>{{i18n "explorer.no_queries_hook"}}</a> | ||||
| {{else}} | ||||
|   <div class="query-edit {{if editName "editing"}}"> | ||||
|     {{partial "admin/plugins-explorer-show" model=selectedItem}} | ||||
|   </div> | ||||
| @ -48,9 +51,9 @@ | ||||
|   </div> | ||||
| 
 | ||||
|   <hr> | ||||
| 
 | ||||
| {{/if}} | ||||
| {{conditional-loading-spinner condition=loading}} | ||||
| 
 | ||||
| {{#unless selectedItem.fake}} | ||||
|   {{#if results}} | ||||
|     <div class="query-results"> | ||||
|       {{#if showResults}} | ||||
| @ -62,3 +65,4 @@ | ||||
|       {{/if}} | ||||
|     </div> | ||||
|   {{/if}} | ||||
| {{/unless}} | ||||
|  | ||||
| @ -41,3 +41,5 @@ en: | ||||
|       save_params: "Set Defaults" | ||||
|       reset_params: "Reset" | ||||
|       https_warning: "Use of the Data Explorer on sites not protected by HTTPS is discouraged. Please be careful to not retrieve sensitive information over insecure links." | ||||
|       no_queries: "There are no queries. Why not " | ||||
|       no_queries_hook: "create one?" | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user