fix(save as): fixed issue with save as and overwriting a dashboard with the same name
This commit is contained in:
@@ -14,16 +14,33 @@ function (angular) {
|
||||
$scope.clone.title = $scope.clone.title + " Copy";
|
||||
};
|
||||
|
||||
function saveDashboard(options) {
|
||||
return backendSrv.saveDashboard($scope.clone, options).then(function(result) {
|
||||
$scope.appEvent('alert-success', ['Dashboard saved', 'Saved as ' + $scope.clone.title]);
|
||||
|
||||
$location.url('/dashboard/db/' + result.slug);
|
||||
|
||||
$scope.appEvent('dashboard-saved', $scope.clone);
|
||||
$scope.dismiss();
|
||||
});
|
||||
}
|
||||
|
||||
$scope.saveClone = function() {
|
||||
backendSrv.saveDashboard($scope.clone)
|
||||
.then(function(result) {
|
||||
$scope.appEvent('alert-success', ['Dashboard saved', 'Saved as ' + $scope.clone.title]);
|
||||
saveDashboard({overwrite: false}).then(null, function(err) {
|
||||
if (err.data && err.data.status === "name-exists") {
|
||||
err.isHandled = true;
|
||||
|
||||
$location.url('/dashboard/db/' + result.slug);
|
||||
|
||||
$scope.appEvent('dashboard-saved', $scope.clone);
|
||||
$scope.dismiss();
|
||||
});
|
||||
$scope.appEvent('confirm-modal', {
|
||||
title: 'Another dashboard with the same name exists',
|
||||
text: "Would you still like to save this dashboard?",
|
||||
yesText: "Save & Overwrite",
|
||||
icon: "fa-warning",
|
||||
onConfirm: function() {
|
||||
saveDashboard({overwrite: true});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user