mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
began work on custom confirm modal
This commit is contained in:
parent
3aa619b617
commit
27ec0d532e
@ -76,9 +76,12 @@ function (angular, app, _) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
$scope.remove_panel_from_row = function(row, panel) {
|
$scope.remove_panel_from_row = function(row, panel) {
|
||||||
if (confirm('Are you sure you want to remove this ' + panel.type + ' panel?')) {
|
$scope.appEvent('confirm-modal', {
|
||||||
row.panels = _.without(row.panels,panel);
|
title: 'Are you sure you want to remove this panel?',
|
||||||
}
|
onConfirm: function() {
|
||||||
|
row.panels = _.without(row.panels, panel);
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.replacePanel = function(newPanel, oldPanel) {
|
$scope.replacePanel = function(newPanel, oldPanel) {
|
||||||
|
@ -22,8 +22,8 @@ function (angular, app, _, kbn, $) {
|
|||||||
var data;
|
var data;
|
||||||
var i;
|
var i;
|
||||||
|
|
||||||
scope.$on('render', function(event, renderData) {
|
scope.$on('render', function() {
|
||||||
data = renderData || data;
|
data = scope.seriesList;
|
||||||
if (data) {
|
if (data) {
|
||||||
render();
|
render();
|
||||||
}
|
}
|
||||||
|
20
src/app/partials/confirm_modal.html
Normal file
20
src/app/partials/confirm_modal.html
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<div class="modal-body">
|
||||||
|
<div class="dashboard-editor-header">
|
||||||
|
<div class="dashboard-editor-title">
|
||||||
|
<i class="icon icon-ok"></i>
|
||||||
|
Confirm
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="dashboard-editor-body">
|
||||||
|
<div class="row-fluid">
|
||||||
|
<span class="span4">
|
||||||
|
{{title}}
|
||||||
|
</span>
|
||||||
|
<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>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
@ -7,7 +7,7 @@ function (angular, _) {
|
|||||||
|
|
||||||
var module = angular.module('grafana.services');
|
var module = angular.module('grafana.services');
|
||||||
|
|
||||||
module.service('alertSrv', function($timeout, $sce, $rootScope) {
|
module.service('alertSrv', function($timeout, $sce, $rootScope, $modal, $q) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
this.init = function() {
|
this.init = function() {
|
||||||
@ -20,6 +20,7 @@ function (angular, _) {
|
|||||||
$rootScope.onAppEvent('alert-success', function(e, alert) {
|
$rootScope.onAppEvent('alert-success', function(e, alert) {
|
||||||
self.set(alert[0], alert[1], 'success', 3000);
|
self.set(alert[0], alert[1], 'success', 3000);
|
||||||
});
|
});
|
||||||
|
$rootScope.onAppEvent('confirm-modal', this.showConfirmModal);
|
||||||
};
|
};
|
||||||
|
|
||||||
// List of all alert objects
|
// List of all alert objects
|
||||||
@ -57,5 +58,27 @@ function (angular, _) {
|
|||||||
this.clearAll = function() {
|
this.clearAll = function() {
|
||||||
self.list = [];
|
self.list = [];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.showConfirmModal = function(e, payload) {
|
||||||
|
var scope = $rootScope.$new();
|
||||||
|
|
||||||
|
scope.title = payload.title;
|
||||||
|
scope.text = payload.text;
|
||||||
|
scope.onConfirm = payload.onConfirm;
|
||||||
|
|
||||||
|
var confirmModal = $modal({
|
||||||
|
template: './app/partials/confirm_modal.html',
|
||||||
|
persist: true,
|
||||||
|
show: false,
|
||||||
|
scope: scope,
|
||||||
|
keyboard: false
|
||||||
|
});
|
||||||
|
|
||||||
|
$q.when(confirmModal).then(function(modalEl) {
|
||||||
|
modalEl.modal('show');
|
||||||
|
});
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user