@@ -22,7 +22,7 @@ module HawkularMetrics {
22
22
23
23
export class AddUrlController {
24
24
/// 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' ] ;
26
26
27
27
private httpUriPart = 'http://' ;
28
28
public addProgress : boolean = false ;
@@ -34,6 +34,7 @@ module HawkularMetrics {
34
34
private $interval :ng . IIntervalService ,
35
35
private $log :ng . ILogService ,
36
36
private $filter :ng . IFilterService ,
37
+ private $modal :any ,
37
38
private HawkularInventory :any ,
38
39
private HawkularMetric :any ,
39
40
private HawkularAlert :any ,
@@ -184,18 +185,40 @@ module HawkularMetrics {
184
185
}
185
186
186
187
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 ( ) {
188
209
this . HawkularInventory . Resource . delete ( {
189
210
tenantId : globalTenantId ,
190
- resourceId : resource . id
211
+ resourceId : this . resource . id
191
212
} ) . $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 ) ;
194
215
} ) ;
195
216
}
196
217
197
- }
218
+ cancel ( ) {
219
+ this . $modalInstance . dismiss ( 'cancel' ) ;
220
+ }
198
221
199
- _module . controller ( 'HawkularMetrics.AddUrlController' , AddUrlController ) ;
222
+ }
200
223
201
224
}
0 commit comments