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) {
|
showConfirmModal(payload) {
|
||||||
var scope = this.$rootScope.$new();
|
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() {
|
scope.onConfirm = function() {
|
||||||
if (!scope.confirmTextRequired || (scope.confirmTextRequired && scope.confirmTextValid)) {
|
payload.onConfirm();
|
||||||
payload.onConfirm();
|
scope.dismiss();
|
||||||
scope.dismiss();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
scope.updateConfirmText = function(value) {
|
scope.updateConfirmText = function(value) {
|
||||||
scope.confirmTextValid = payload.confirmText.toLowerCase() === value.toLowerCase();
|
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.onConfirm = payload.onConfirm;
|
||||||
scope.onAltAction = payload.onAltAction;
|
scope.onAltAction = payload.onAltAction;
|
||||||
scope.altActionText = payload.altActionText;
|
scope.altActionText = payload.altActionText;
|
||||||
scope.icon = payload.icon || "fa-check";
|
scope.icon = payload.icon || "fa-check";
|
||||||
scope.yesText = payload.yesText || "Yes";
|
scope.yesText = payload.yesText || "Yes";
|
||||||
scope.noText = payload.noText || "Cancel";
|
scope.noText = payload.noText || "Cancel";
|
||||||
|
scope.confirmTextValid = scope.confirmText ? false : true;
|
||||||
|
|
||||||
var confirmModal = this.$modal({
|
var confirmModal = this.$modal({
|
||||||
template: 'public/app/partials/confirm_modal.html',
|
template: 'public/app/partials/confirm_modal.html',
|
||||||
|
@ -158,18 +158,13 @@ export class DashNavCtrl {
|
|||||||
$scope.deleteDashboard = function() {
|
$scope.deleteDashboard = function() {
|
||||||
var confirmText = "";
|
var confirmText = "";
|
||||||
var text2 = $scope.dashboard.title;
|
var text2 = $scope.dashboard.title;
|
||||||
var alerts = 0;
|
var alerts = $scope.dashboard.rows.reduce((memo, row) => {
|
||||||
|
memo += row.panels.filter(panel => panel.alert && panel.alert.enabled).length;
|
||||||
_.each($scope.dashboard.rows, row => {
|
return memo;
|
||||||
_.each(row.panels, panel => {
|
}, 0);
|
||||||
if (panel.alerting && panel.alerting.queryRef !== '- select query -') {
|
|
||||||
alerts += 1;
|
|
||||||
};
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
if (alerts > 0) {
|
if (alerts > 0) {
|
||||||
confirmText = $scope.dashboard.title;
|
confirmText = 'DELETE';
|
||||||
text2 = `This dashboad contains ${alerts} alerts. Deleting this dashboad will also delete those alerts`;
|
text2 = `This dashboad contains ${alerts} alerts. Deleting this dashboad will also delete those alerts`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,14 +22,13 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="modal-content-confirm-text" ng-if="confirmTextRequired">
|
<div class="modal-content-confirm-text" ng-if="confirmText">
|
||||||
<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;" placeholder="Type {{confirmText}} to confirm" ng-model="confirmInput" ng-change="updateConfirmText(confirmInput)">
|
||||||
<input type="text" class="gf-form-input width-16" style="display: inline-block;" ng-model="confirmInput" ng-change="updateConfirmText(confirmInput)">
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="confirm-modal-buttons">
|
<div class="confirm-modal-buttons">
|
||||||
<button type="button" class="btn btn-inverse" ng-click="dismiss()">{{noText}}</button>
|
<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>
|
<button ng-show="onAltAction" type="button" class="btn btn-success" ng-click="dismiss();onAltAction();">{{altActionText}}</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user