@@ -25,38 +25,35 @@ angular.module('openshiftConsole')
25
25
] ;
26
26
27
27
var watches = [ ] ;
28
-
28
+
29
+ var pvcResolved = function ( pvc , action ) {
30
+ $scope . pvc = pvc ;
31
+ $scope . loaded = true ;
32
+ if ( action === "DELETED" ) {
33
+ $scope . alerts [ "deleted" ] = {
34
+ type : "warning" ,
35
+ message : "This persistent volume claim has been deleted."
36
+ } ;
37
+ }
38
+ } ;
39
+
29
40
ProjectsService
30
41
. get ( $routeParams . project )
31
42
. then ( _ . spread ( function ( project , context ) {
32
43
$scope . project = project ;
33
- DataService . get ( "persistentvolumeclaims" , $routeParams . pvc , context ) . then (
34
- // success
35
- function ( pvc ) {
36
- $scope . loaded = true ;
37
- $scope . pvc = pvc ;
38
-
39
- // If we found the item successfully, watch for changes on it
40
- watches . push ( DataService . watchObject ( "persistentvolumeclaims" , $routeParams . pvc , context , function ( pvc , action ) {
41
- if ( action === "DELETED" ) {
42
- $scope . alerts [ "deleted" ] = {
43
- type : "warning" ,
44
- message : "This persistent volume claim has been deleted."
45
- } ;
46
- }
47
- $scope . pvc = pvc ;
48
- } ) ) ;
49
- } ,
50
- // failure
51
- function ( e ) {
44
+ DataService
45
+ . get ( "persistentvolumeclaims" , $routeParams . pvc , context )
46
+ . then ( function ( pvc ) {
47
+ pvcResolved ( pvc ) ;
48
+ watches . push ( DataService . watchObject ( "persistentvolumeclaims" , $routeParams . pvc , context , pvcResolved ) ) ;
49
+ } , function ( e ) {
52
50
$scope . loaded = true ;
53
51
$scope . alerts [ "load" ] = {
54
52
type : "error" ,
55
53
message : "The persistent volume claim details could not be loaded." ,
56
54
details : "Reason: " + $filter ( 'getErrorDetails' ) ( e )
57
55
} ;
58
- }
59
- ) ;
56
+ } ) ;
60
57
61
58
$scope . $on ( '$destroy' , function ( ) {
62
59
DataService . unwatchAll ( watches ) ;
0 commit comments