Skip to content

Commit f29249a

Browse files
committed
loadMigrationEvent until end state
1 parent bf5c238 commit f29249a

File tree

1 file changed

+37
-91
lines changed

1 file changed

+37
-91
lines changed

redis/redis-console/src/main/resources/static/scripts/controllers/ActiveDcMigrationEventDetailsContentCtl.js

+37-91
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ index_module.controller('ActiveDcMigrationEventDetailsContentCtl', ['$rootScope'
1616

1717
function init() {
1818
if($scope.migrationCluster) {
19+
loadDetails();
1920
if($scope.migrationCluster.migrationShards) {
2021
initStatus();
2122
} else {
@@ -57,127 +58,72 @@ index_module.controller('ActiveDcMigrationEventDetailsContentCtl', ['$rootScope'
5758
});
5859
}
5960
}
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+
6091

6192
$scope.continueMigrationCluster = function(eventId, clusterId) {
6293
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,
8195
function(result) {
8296
toastr.error(AppUtil.errorMsg(result));
8397
});
8498
}
8599

86100
$scope.cancelMigrationCluster = function(eventId, clusterId) {
87101
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,
106103
function(result) {
107104
toastr.error(AppUtil.errorMsg(result));
108105
});
109106
}
110107

111108
$scope.rollbackMigrationCluster = function (eventId, clusterId) {
112109
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,
131111
function(result) {
132112
toastr.error(AppUtil.errorMsg(result));
133113
});
134114
}
135115

136116
$scope.forcePublishMigrationCluster = function(eventId, clusterId) {
137117
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) {
157120
toastr.error(AppUtil.errorMsg(result));
158121
});
159122
}
160123

161124
$scope.forceEndMigrationCluster = function(eventId, clusterId) {
162125
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,
181127
function(result) {
182128
toastr.error(AppUtil.errorMsg(result));
183129
});

0 commit comments

Comments
 (0)