Skip to content

Commit eda076a

Browse files
committed
Console: Add confirmation modal for deleting a resource
1 parent 1a49b7d commit eda076a

File tree

3 files changed

+82
-17
lines changed

3 files changed

+82
-17
lines changed

dist/hawkular-ui-components-metrics.js

Lines changed: 36 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<div class="modal-header">
2+
<button type="button" class="close" ng-click="cancel()">
3+
<span class="pficon pficon-close"></span>
4+
</button>
5+
<h4 class="modal-title">Delete Resource</h4>
6+
</div>
7+
<div class="modal-body">
8+
<div class="form-group">
9+
<p class="primary-message">Are you sure you want to stop monitoring and delete the data for the site <strong>{{ vm.resource.parameters.url }}</strong> (Resource ID: {{ vm.resource.id }}) ?</p>
10+
<p>This action can't be undone.</p>
11+
</div>
12+
</div>
13+
<div class="modal-footer">
14+
<button type="button" class="btn btn-default" ng-click="vm.cancel()">Cancel</button>
15+
<button type="button" class="btn btn-danger" ng-click="vm.deleteResource()">Delete</button>
16+
</div>

plugins/metrics/plugins/metrics/ts/addUrlPage.ts

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module HawkularMetrics {
2222

2323
export class AddUrlController {
2424
/// this is for minification purposes
25-
public static $inject = ['$location', '$scope', '$rootScope', '$interval', '$log', '$filter', 'HawkularInventory', 'HawkularMetric', 'HawkularAlert', 'HawkularAlertsManager','HawkularErrorManager','$q'];
25+
public static $inject = ['$location', '$scope', '$rootScope', '$interval', '$log', '$filter', '$modal', 'HawkularInventory', 'HawkularMetric', 'HawkularAlert', 'HawkularAlertsManager','HawkularErrorManager','$q'];
2626

2727
private httpUriPart = 'http://';
2828
public addProgress: boolean = false;
@@ -34,6 +34,7 @@ module HawkularMetrics {
3434
private $interval:ng.IIntervalService,
3535
private $log:ng.ILogService,
3636
private $filter:ng.IFilterService,
37+
private $modal:any,
3738
private HawkularInventory:any,
3839
private HawkularMetric:any,
3940
private HawkularAlert:any,
@@ -184,18 +185,40 @@ module HawkularMetrics {
184185
}
185186

186187
deleteResource(resource:any):any {
187-
// TODO: use modal to confirm delete...
188+
this.$modal.open({
189+
templateUrl: 'plugins/metrics/html/modals/delete-resource.html',
190+
controller: DeleteResourceModalController,
191+
resolve: {
192+
resource: () => resource
193+
}
194+
}).result.then(result => this.getResourceList());
195+
}
196+
}
197+
198+
_module.controller('HawkularMetrics.AddUrlController', AddUrlController);
199+
200+
class DeleteResourceModalController {
201+
202+
static $inject = ['$scope', '$modalInstance', 'HawkularInventory', 'resource'];
203+
204+
constructor(private $scope, private $modalInstance: any, private HawkularInventory, public resource) {
205+
$scope.vm = this;
206+
}
207+
208+
deleteResource() {
188209
this.HawkularInventory.Resource.delete({
189210
tenantId: globalTenantId,
190-
resourceId: resource.id
211+
resourceId: this.resource.id
191212
}).$promise.then((res) => {
192-
toastr.info('The site ' + resource.parameters.url + ' is no longer being monitored.');
193-
this.resourceList = this.getResourceList();
213+
toastr.info('The site ' + this.resource.parameters.url + ' is no longer being monitored.');
214+
this.$modalInstance.close(res);
194215
});
195216
}
196217

197-
}
218+
cancel() {
219+
this.$modalInstance.dismiss('cancel');
220+
}
198221

199-
_module.controller('HawkularMetrics.AddUrlController', AddUrlController);
222+
}
200223

201224
}

0 commit comments

Comments
 (0)