mirror of
https://github.com/getredash/redash.git
synced 2025-12-20 01:47:39 -05:00
Show query's data source.
This commit is contained in:
@@ -1,12 +1,14 @@
|
|||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var QueryViewCtrl = function ($scope, $window, $route, $http, $location, growl, notifications, Query, Visualization) {
|
var QueryViewCtrl = function ($scope, $window, $route, $http, $location, growl, notifications, Query, Visualization, DataSource) {
|
||||||
var DEFAULT_TAB = 'table';
|
var DEFAULT_TAB = 'table';
|
||||||
var pristineHash = "";
|
var pristineHash = "";
|
||||||
var leavingPageText = "You will lose your changes if you leave";
|
var leavingPageText = "You will lose your changes if you leave";
|
||||||
var route = $route.current;
|
var route = $route.current;
|
||||||
|
|
||||||
|
$scope.dataSources = DataSource.get();
|
||||||
|
|
||||||
$scope.dirty = undefined;
|
$scope.dirty = undefined;
|
||||||
$scope.isNewQuery = false;
|
$scope.isNewQuery = false;
|
||||||
$scope.isOwner = false;
|
$scope.isOwner = false;
|
||||||
@@ -278,6 +280,7 @@
|
|||||||
'notifications',
|
'notifications',
|
||||||
'Query',
|
'Query',
|
||||||
'Visualization',
|
'Visualization',
|
||||||
|
'DataSource',
|
||||||
QueryViewCtrl
|
QueryViewCtrl
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
@@ -284,10 +284,10 @@
|
|||||||
return queryResult;
|
return queryResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
QueryResult.get = function (query, ttl) {
|
QueryResult.get = function (data_source_id, query, ttl) {
|
||||||
var queryResult = new QueryResult();
|
var queryResult = new QueryResult();
|
||||||
|
|
||||||
QueryResultResource.post({'query': query, 'ttl': ttl}, function (response) {
|
QueryResultResource.post({'data_source_id': data_source_id, 'query': query, 'ttl': ttl}, function (response) {
|
||||||
queryResult.update(response);
|
queryResult.update(response);
|
||||||
|
|
||||||
if ('job' in response) {
|
if ('job' in response) {
|
||||||
@@ -301,7 +301,7 @@
|
|||||||
return QueryResult;
|
return QueryResult;
|
||||||
};
|
};
|
||||||
|
|
||||||
var Query = function ($resource, QueryResult) {
|
var Query = function ($resource, QueryResult, DataSource) {
|
||||||
var Query = $resource('/api/queries/:id', {id: '@id'});
|
var Query = $resource('/api/queries/:id', {id: '@id'});
|
||||||
|
|
||||||
Query.prototype.getQueryResult = function(ttl) {
|
Query.prototype.getQueryResult = function(ttl) {
|
||||||
@@ -316,7 +316,7 @@
|
|||||||
} else if (this.latest_query_data_id && ttl != 0) {
|
} else if (this.latest_query_data_id && ttl != 0) {
|
||||||
queryResult = QueryResult.getById(this.latest_query_data_id);
|
queryResult = QueryResult.getById(this.latest_query_data_id);
|
||||||
} else {
|
} else {
|
||||||
queryResult = QueryResult.get(this.query, ttl);
|
queryResult = QueryResult.get(this.data_source_id, this.query, ttl);
|
||||||
}
|
}
|
||||||
|
|
||||||
return queryResult;
|
return queryResult;
|
||||||
@@ -329,7 +329,14 @@
|
|||||||
return Query;
|
return Query;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var DataSource = function($resource) {
|
||||||
|
var DataSourceResource = $resource('/api/data_sources/:id', {id: '@id'}, {'get': {'method': 'GET', 'cache': true, 'isArray': true}});
|
||||||
|
|
||||||
|
return DataSourceResource;
|
||||||
|
}
|
||||||
|
|
||||||
angular.module('redash.services', [])
|
angular.module('redash.services', [])
|
||||||
.factory('QueryResult', ['$resource', '$timeout', QueryResult])
|
.factory('QueryResult', ['$resource', '$timeout', QueryResult])
|
||||||
.factory('Query', ['$resource', 'QueryResult', Query])
|
.factory('Query', ['$resource', 'QueryResult', 'DataSource', Query])
|
||||||
|
.factory('DataSource', ['$resource', DataSource]);
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -112,6 +112,12 @@
|
|||||||
<select ng-disabled="!isOwner" ng-model="query.ttl" ng-change="saveQuery()" ng-options="c.value as c.name for c in refreshOptions"></select>
|
<select ng-disabled="!isOwner" ng-model="query.ttl" ng-change="saveQuery()" ng-options="c.value as c.name for c in refreshOptions"></select>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<span class="glyphicon glyphicon-hdd"></span>
|
||||||
|
<span class="text-muted">Data Source</span>
|
||||||
|
<select ng-disabled="!isOwner" ng-model="query.data_source_id" ng-options="ds.id as ds.name for ds in dataSources"></select>
|
||||||
|
</p>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|||||||
Reference in New Issue
Block a user