@@ -16,6 +16,7 @@ index_module.controller('ActiveDcMigrationEventDetailsContentCtl', ['$rootScope'
16
16
17
17
function init ( ) {
18
18
if ( $scope . migrationCluster ) {
19
+ loadDetails ( ) ;
19
20
if ( $scope . migrationCluster . migrationShards ) {
20
21
initStatus ( ) ;
21
22
} else {
@@ -57,127 +58,72 @@ index_module.controller('ActiveDcMigrationEventDetailsContentCtl', ['$rootScope'
57
58
} ) ;
58
59
}
59
60
}
61
+
62
+ var stopInterval ;
63
+
64
+ function loadDetails ( ) {
65
+ toastr . success ( "操作成功" ) ;
66
+ if ( angular . isDefined ( stopInterval ) ) return ;
67
+
68
+ stopInterval = $interval ( function ( ) {
69
+ MigrationService . findEventDetails ( $scope . eventId ) . then (
70
+ function ( result ) {
71
+ $scope . $parent . eventDetails = result ;
72
+ $scope . $parent . eventDetails . forEach ( function ( migrationCluster ) {
73
+ if ( migrationCluster . migrationCluster . id == $scope . migrationCluster . migrationCluster . id ) {
74
+ $scope . migrationCluster = migrationCluster ;
75
+ initStatus ( ) ;
76
+ if ( migrationCluster . migrationCluster . status == "Success" ||
77
+ migrationCluster . migrationCluster . status == "Aborted" ||
78
+ migrationCluster . migrationCluster . status == "ForceEnd" ) {
79
+
80
+ $interval . cancel ( stopInterval ) ;
81
+ stopInterval = undefined ;
82
+ }
83
+ }
84
+ } ) ;
85
+ } ,
86
+ function ( result ) {
87
+ } ) ;
88
+ } , 1500 ) ;
89
+ }
90
+
60
91
61
92
$scope . continueMigrationCluster = function ( eventId , clusterId ) {
62
93
MigrationService . continueMigrationCluster ( eventId , clusterId ) . then (
63
- function ( result ) {
64
- toastr . success ( "操作成功" ) ;
65
-
66
- $interval ( function ( ) {
67
- MigrationService . findEventDetails ( $scope . eventId ) . then (
68
- function ( result ) {
69
- $scope . $parent . eventDetails = result ;
70
- $scope . $parent . eventDetails . forEach ( function ( migrationCluster ) {
71
- if ( migrationCluster . migrationCluster . id == $scope . migrationCluster . migrationCluster . id ) {
72
- $scope . migrationCluster = migrationCluster ;
73
- initStatus ( ) ;
74
- }
75
- } ) ;
76
- } ,
77
- function ( result ) {
78
- } ) ;
79
- } , 1000 , 10 ) ;
80
- } ,
94
+ loadDetails ,
81
95
function ( result ) {
82
96
toastr . error ( AppUtil . errorMsg ( result ) ) ;
83
97
} ) ;
84
98
}
85
99
86
100
$scope . cancelMigrationCluster = function ( eventId , clusterId ) {
87
101
MigrationService . cancelMigrationCluster ( eventId , clusterId ) . then (
88
- function ( result ) {
89
- toastr . success ( "操作成功" ) ;
90
-
91
- $interval ( function ( ) {
92
- MigrationService . findEventDetails ( $scope . eventId ) . then (
93
- function ( result ) {
94
- $scope . $parent . eventDetails = result ;
95
- $scope . $parent . eventDetails . forEach ( function ( migrationCluster ) {
96
- if ( migrationCluster . migrationCluster . id == $scope . migrationCluster . migrationCluster . id ) {
97
- $scope . migrationCluster = migrationCluster ;
98
- initStatus ( ) ;
99
- }
100
- } ) ;
101
- } ,
102
- function ( result ) {
103
- } ) ;
104
- } , 1000 , 5 ) ;
105
- } ,
102
+ loadDetails ,
106
103
function ( result ) {
107
104
toastr . error ( AppUtil . errorMsg ( result ) ) ;
108
105
} ) ;
109
106
}
110
107
111
108
$scope . rollbackMigrationCluster = function ( eventId , clusterId ) {
112
109
MigrationService . rollbackMigrationCluster ( eventId , clusterId ) . then (
113
- function ( result ) {
114
- toastr . success ( "操作成功" ) ;
115
-
116
- $interval ( function ( ) {
117
- MigrationService . findEventDetails ( $scope . eventId ) . then (
118
- function ( result ) {
119
- $scope . $parent . eventDetails = result ;
120
- $scope . $parent . eventDetails . forEach ( function ( migrationCluster ) {
121
- if ( migrationCluster . migrationCluster . id == $scope . migrationCluster . migrationCluster . id ) {
122
- $scope . migrationCluster = migrationCluster ;
123
- initStatus ( ) ;
124
- }
125
- } ) ;
126
- } ,
127
- function ( result ) {
128
- } ) ;
129
- } , 1000 , 5 ) ;
130
- } ,
110
+ loadDetails ,
131
111
function ( result ) {
132
112
toastr . error ( AppUtil . errorMsg ( result ) ) ;
133
113
} ) ;
134
114
}
135
115
136
116
$scope . forcePublishMigrationCluster = function ( eventId , clusterId ) {
137
117
MigrationService . forcePublishMigrationCluster ( eventId , clusterId ) . then (
138
- function ( result ) {
139
- toastr . success ( "操作成功" ) ;
140
-
141
- $interval ( function ( ) {
142
- MigrationService . findEventDetails ( $scope . eventId ) . then (
143
- function ( result ) {
144
- $scope . $parent . eventDetails = result ;
145
- $scope . $parent . eventDetails . forEach ( function ( migrationCluster ) {
146
- if ( migrationCluster . migrationCluster . id == $scope . migrationCluster . migrationCluster . id ) {
147
- $scope . migrationCluster = migrationCluster ;
148
- initStatus ( ) ;
149
- }
150
- } ) ;
151
- } ,
152
- function ( result ) {
153
- } ) ;
154
- } , 1000 , 5 ) ;
155
- } ,
156
- function ( result ) {
118
+ loadDetails ,
119
+ function ( result ) {
157
120
toastr . error ( AppUtil . errorMsg ( result ) ) ;
158
121
} ) ;
159
122
}
160
123
161
124
$scope . forceEndMigrationCluster = function ( eventId , clusterId ) {
162
125
MigrationService . forceEndMigrationCluster ( eventId , clusterId ) . then (
163
- function ( result ) {
164
- toastr . success ( "操作成功" ) ;
165
-
166
- $interval ( function ( ) {
167
- MigrationService . findEventDetails ( $scope . eventId ) . then (
168
- function ( result ) {
169
- $scope . $parent . eventDetails = result ;
170
- $scope . $parent . eventDetails . forEach ( function ( migrationCluster ) {
171
- if ( migrationCluster . migrationCluster . id == $scope . migrationCluster . migrationCluster . id ) {
172
- $scope . migrationCluster = migrationCluster ;
173
- initStatus ( ) ;
174
- }
175
- } ) ;
176
- } ,
177
- function ( result ) {
178
- } ) ;
179
- } , 1000 , 5 ) ;
180
- } ,
126
+ loadDetails ,
181
127
function ( result ) {
182
128
toastr . error ( AppUtil . errorMsg ( result ) ) ;
183
129
} ) ;
0 commit comments