mirror of
https://github.com/valitydev/redash.git
synced 2024-11-07 09:28:51 +00:00
DAT-741
This commit is contained in:
parent
d73dbdeee0
commit
8be95262d4
@ -92,10 +92,15 @@
|
||||
})
|
||||
}
|
||||
|
||||
$scope.saveQuery = function (duplicate, oldId) {
|
||||
$scope.saveQuery = function (duplicate, oldId, updateUrl) {
|
||||
if (!oldId) {
|
||||
oldId = $scope.query.id;
|
||||
}
|
||||
|
||||
if (updateUrl == undefined) {
|
||||
updateUrl = true;
|
||||
}
|
||||
|
||||
delete $scope.query.latest_query_data;
|
||||
$scope.query.$save(function (q) {
|
||||
pristineHash = q.getHash();
|
||||
@ -108,7 +113,7 @@
|
||||
}
|
||||
|
||||
if (oldId != q.id) {
|
||||
if (oldId == undefined) {
|
||||
if (oldId == undefined && updateUrl) {
|
||||
$location.path($location.path().replace('new', q.id)).replace();
|
||||
} else {
|
||||
// TODO: replace this with a safer method
|
||||
|
@ -46,7 +46,7 @@
|
||||
}
|
||||
}]);
|
||||
|
||||
directives.directive('editVisulatizationForm', ['Visualization', 'growl', function(Visualization, growl) {
|
||||
directives.directive('editVisulatizationForm', ['Visualization', 'growl', '$location', function(Visualization, growl, $location) {
|
||||
return {
|
||||
restrict: 'E',
|
||||
templateUrl: '/views/edit_visualization.html',
|
||||
@ -76,7 +76,7 @@
|
||||
};
|
||||
|
||||
scope.stacking = "none";
|
||||
|
||||
|
||||
if (!scope.vis) {
|
||||
// create new visualization
|
||||
// wait for query to load to populate with defaults
|
||||
@ -149,17 +149,42 @@
|
||||
};
|
||||
|
||||
scope.submit = function() {
|
||||
if (!scope.query.id) {
|
||||
scope.$parent.saveQuery(false, null, false);
|
||||
var unwatch = scope.$watch('query', function(q) {
|
||||
if (q && q.id) {
|
||||
unwatch();
|
||||
scope.vis['query_id'] = q.id;
|
||||
|
||||
scope.saveVisualization(false);
|
||||
|
||||
$location.path($location.path().replace('new', q.id)).replace();
|
||||
}
|
||||
}, true);
|
||||
} else {
|
||||
scope.saveVisualization();
|
||||
}
|
||||
};
|
||||
|
||||
scope.saveVisualization = function(updateTabs) {
|
||||
if (updateTabs == undefined) {
|
||||
updateTabs = true;
|
||||
}
|
||||
|
||||
Visualization.save(scope.vis, function success(result) {
|
||||
growl.addSuccessMessage("Visualization saved");
|
||||
|
||||
scope.vis = result;
|
||||
|
||||
var visIds = _.pluck(scope.query.visualizations, 'id');
|
||||
var index = visIds.indexOf(result.id);
|
||||
if (index > -1) {
|
||||
scope.query.visualizations[index] = result;
|
||||
} else {
|
||||
scope.query.visualizations.push(result);
|
||||
|
||||
if (updateTabs) {
|
||||
scope.vis = result;
|
||||
|
||||
var visIds = _.pluck(scope.query.visualizations, 'id');
|
||||
var index = visIds.indexOf(result.id);
|
||||
|
||||
if (index > -1) {
|
||||
scope.query.visualizations[index] = result;
|
||||
} else {
|
||||
scope.query.visualizations.push(result);
|
||||
}
|
||||
}
|
||||
}, function error() {
|
||||
growl.addErrorMessage("Visualization could not be saved");
|
||||
|
@ -210,7 +210,7 @@
|
||||
scope.chart.series[0].remove(false);
|
||||
};
|
||||
|
||||
if (_.some(scope.series[0].data, function (p) {
|
||||
if (scope.series.length > 0 && _.some(scope.series[0].data, function (p) {
|
||||
return angular.isString(p.x)
|
||||
})) {
|
||||
scope.chart.xAxis[0].update({type: 'category'});
|
||||
|
@ -279,7 +279,7 @@
|
||||
Query.prototype.getHash = function() {
|
||||
return [this.name, this.description, this.query].join('!#');
|
||||
};
|
||||
|
||||
|
||||
return Query;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user