mirror of
https://github.com/grafana/grafana.git
synced 2024-11-30 20:54:22 -06:00
feat(alerting): fixed confirm delete dashboard issue
This commit is contained in:
parent
daea38060f
commit
e2f5bf1666
@ -80,28 +80,27 @@ export class AlertSrv {
|
||||
showConfirmModal(payload) {
|
||||
var scope = this.$rootScope.$new();
|
||||
|
||||
scope.title = payload.title;
|
||||
scope.text = payload.text;
|
||||
scope.text2 = payload.text2;
|
||||
scope.confirmTextRequired = payload.confirmText !== undefined && payload.confirmText !== "";
|
||||
|
||||
scope.onConfirm = function() {
|
||||
if (!scope.confirmTextRequired || (scope.confirmTextRequired && scope.confirmTextValid)) {
|
||||
payload.onConfirm();
|
||||
scope.dismiss();
|
||||
}
|
||||
};
|
||||
|
||||
scope.updateConfirmText = function(value) {
|
||||
scope.confirmTextValid = payload.confirmText.toLowerCase() === value.toLowerCase();
|
||||
};
|
||||
|
||||
scope.title = payload.title;
|
||||
scope.text = payload.text;
|
||||
scope.text2 = payload.text2;
|
||||
scope.confirmText = payload.confirmText;
|
||||
|
||||
scope.onConfirm = payload.onConfirm;
|
||||
scope.onAltAction = payload.onAltAction;
|
||||
scope.altActionText = payload.altActionText;
|
||||
scope.icon = payload.icon || "fa-check";
|
||||
scope.yesText = payload.yesText || "Yes";
|
||||
scope.noText = payload.noText || "Cancel";
|
||||
scope.confirmTextValid = scope.confirmText ? false : true;
|
||||
|
||||
var confirmModal = this.$modal({
|
||||
template: 'public/app/partials/confirm_modal.html',
|
||||
|
@ -158,18 +158,13 @@ export class DashNavCtrl {
|
||||
$scope.deleteDashboard = function() {
|
||||
var confirmText = "";
|
||||
var text2 = $scope.dashboard.title;
|
||||
var alerts = 0;
|
||||
|
||||
_.each($scope.dashboard.rows, row => {
|
||||
_.each(row.panels, panel => {
|
||||
if (panel.alerting && panel.alerting.queryRef !== '- select query -') {
|
||||
alerts += 1;
|
||||
};
|
||||
});
|
||||
});
|
||||
var alerts = $scope.dashboard.rows.reduce((memo, row) => {
|
||||
memo += row.panels.filter(panel => panel.alert && panel.alert.enabled).length;
|
||||
return memo;
|
||||
}, 0);
|
||||
|
||||
if (alerts > 0) {
|
||||
confirmText = $scope.dashboard.title;
|
||||
confirmText = 'DELETE';
|
||||
text2 = `This dashboad contains ${alerts} alerts. Deleting this dashboad will also delete those alerts`;
|
||||
}
|
||||
|
||||
|
@ -22,14 +22,13 @@
|
||||
</div>
|
||||
|
||||
|
||||
<div class="modal-content-confirm-text" ng-if="confirmTextRequired">
|
||||
<span><i class="fa fa-warning"></i> Please type in the name of the dashboard to confirm.</span>
|
||||
<input type="text" class="gf-form-input width-16" style="display: inline-block;" ng-model="confirmInput" ng-change="updateConfirmText(confirmInput)">
|
||||
<div class="modal-content-confirm-text" ng-if="confirmText">
|
||||
<input type="text" class="gf-form-input width-16" style="display: inline-block;" placeholder="Type {{confirmText}} to confirm" ng-model="confirmInput" ng-change="updateConfirmText(confirmInput)">
|
||||
</div>
|
||||
|
||||
<div class="confirm-modal-buttons">
|
||||
<button type="button" class="btn btn-inverse" ng-click="dismiss()">{{noText}}</button>
|
||||
<button type="button" class="btn btn-danger" ng-click="onConfirm();dismiss();">{{yesText}}</button>
|
||||
<button type="button" class="btn btn-danger" ng-click="onConfirm();dismiss();" ng-disabled="!confirmTextValid">{{yesText}}</button>
|
||||
<button ng-show="onAltAction" type="button" class="btn btn-success" ng-click="dismiss();onAltAction();">{{altActionText}}</button>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user