[#138] Query.newQuery

This commit is contained in:
Amir Nissim 2014-03-23 16:56:36 +02:00
parent 34fb58d403
commit c4cbe06c12
2 changed files with 12 additions and 10 deletions

View File

@ -17,15 +17,6 @@ angular.module('redash', [
]).config(['$routeProvider', '$locationProvider', '$compileProvider', 'growlProvider',
function($routeProvider, $locationProvider, $compileProvider, growlProvider) {
function newQuery(Query) {
return new Query({
query: "",
name: "New Query",
ttl: -1,
user: currentUser
});
}
function getQuery(Query, $q, $route) {
var defer = $q.defer();
@ -56,7 +47,9 @@ angular.module('redash', [
controller: 'QueryEditCtrl',
reloadOnSearch: false,
resolve: {
'query': ['Query', newQuery]
'query': ['Query', function newQuery(Query) {
return Query.newQuery();
}]
}
});
$routeProvider.when('/queries/:queryId', {

View File

@ -304,6 +304,15 @@
var Query = function ($resource, QueryResult, DataSource) {
var Query = $resource('/api/queries/:id', {id: '@id'});
Query.newQuery = function() {
return new Query({
query: "",
name: "New Query",
ttl: -1,
user: currentUser
});
};
Query.prototype.getQueryResult = function(ttl) {
if (ttl == undefined) {
ttl = this.ttl;