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";
|
$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() {
|
$scope.saveClone = function() {
|
||||||
backendSrv.saveDashboard($scope.clone)
|
saveDashboard({overwrite: false}).then(null, function(err) {
|
||||||
.then(function(result) {
|
if (err.data && err.data.status === "name-exists") {
|
||||||
$scope.appEvent('alert-success', ['Dashboard saved', 'Saved as ' + $scope.clone.title]);
|
err.isHandled = true;
|
||||||
|
|
||||||
$location.url('/dashboard/db/' + result.slug);
|
$scope.appEvent('confirm-modal', {
|
||||||
|
title: 'Another dashboard with the same name exists',
|
||||||
$scope.appEvent('dashboard-saved', $scope.clone);
|
text: "Would you still like to save this dashboard?",
|
||||||
$scope.dismiss();
|
yesText: "Save & Overwrite",
|
||||||
});
|
icon: "fa-warning",
|
||||||
|
onConfirm: function() {
|
||||||
|
saveDashboard({overwrite: true});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user