Commit f9c3cdab by Torkel Ödegaard

UI: replaced native confirm dialogs with nicer custom ones

parent 27ec0d53
...@@ -93,12 +93,18 @@ function (angular, _, moment, config, store) { ...@@ -93,12 +93,18 @@ function (angular, _, moment, config, store) {
}; };
$scope.deleteDashboard = function(evt, options) { $scope.deleteDashboard = function(evt, options) {
if (!confirm('Do you want to delete dashboard ' + options.title + ' ?')) {
return;
}
if (!$scope.isAdmin()) { return false; } if (!$scope.isAdmin()) { return false; }
$scope.appEvent('confirm-modal', {
title: 'Delete dashboard',
text: 'Do you want to delete dashboard ' + options.title + '?',
onConfirm: function() {
$scope.deleteDashboardConfirmed(options);
}
});
};
$scope.deleteDashboardConfirmed = function(options) {
var id = options.id; var id = options.id;
$scope.db.deleteDashboard(id).then(function(id) { $scope.db.deleteDashboard(id).then(function(id) {
$scope.appEvent('alert-success', ['Dashboard Deleted', id + ' has been deleted']); $scope.appEvent('alert-success', ['Dashboard Deleted', id + ' has been deleted']);
......
...@@ -47,9 +47,13 @@ function (angular, app, _) { ...@@ -47,9 +47,13 @@ function (angular, app, _) {
}; };
$scope.delete_row = function() { $scope.delete_row = function() {
if (confirm("Are you sure you want to delete this row?")) { $scope.appEvent('confirm-modal', {
title: 'Delete row',
text: 'Are you sure you want to delete this row?',
onConfirm: function() {
$scope.dashboard.rows = _.without($scope.dashboard.rows, $scope.row); $scope.dashboard.rows = _.without($scope.dashboard.rows, $scope.row);
} }
});
}; };
$scope.move_row = function(direction) { $scope.move_row = function(direction) {
...@@ -77,7 +81,8 @@ function (angular, app, _) { ...@@ -77,7 +81,8 @@ function (angular, app, _) {
$scope.remove_panel_from_row = function(row, panel) { $scope.remove_panel_from_row = function(row, panel) {
$scope.appEvent('confirm-modal', { $scope.appEvent('confirm-modal', {
title: 'Are you sure you want to remove this panel?', title: 'Remove panel',
text: 'Are you sure you want to remove this panel?',
onConfirm: function() { onConfirm: function() {
row.panels = _.without(row.panels, panel); row.panels = _.without(row.panels, panel);
} }
......
...@@ -2,17 +2,20 @@ ...@@ -2,17 +2,20 @@
<div class="dashboard-editor-header"> <div class="dashboard-editor-header">
<div class="dashboard-editor-title"> <div class="dashboard-editor-title">
<i class="icon icon-ok"></i> <i class="icon icon-ok"></i>
Confirm {{title}}
</div> </div>
</div> </div>
<div class="dashboard-editor-body"> <div class="dashboard-editor-body">
<p class="row-fluid text-center large">
{{text}}
<br>
<br>
</p>
<div class="row-fluid"> <div class="row-fluid">
<span class="span4"> <span class="span4"></span>
{{title}} <button type="button" class="btn btn-success span2" ng-click="dismiss()">No</button>
</span> <button type="button" class="btn btn-danger span2" ng-click="onConfirm();dismiss();">Yes</button>
<button type="button" class="btn btn-info span2" ng-click="dismiss()">Cancel</button>
<button type="button" class="btn btn-success span2" ng-click="onConfirm();dismiss();">OK</button>
<span class="span4"></span> <span class="span4"></span>
</div> </div>
......
...@@ -69,6 +69,7 @@ function (angular, _) { ...@@ -69,6 +69,7 @@ function (angular, _) {
var confirmModal = $modal({ var confirmModal = $modal({
template: './app/partials/confirm_modal.html', template: './app/partials/confirm_modal.html',
persist: true, persist: true,
modalClass: 'confirm-modal',
show: false, show: false,
scope: scope, scope: scope,
keyboard: false keyboard: false
......
...@@ -561,3 +561,7 @@ select.grafana-target-segment-input { ...@@ -561,3 +561,7 @@ select.grafana-target-segment-input {
th:last-child { text-align: left; } th:last-child { text-align: left; }
td:first-child { text-align: right; } td:first-child { text-align: right; }
} }
.confirm-modal {
max-width: 500px;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment