mirror of
https://github.com/apache/rocketmq-dashboard.git
synced 2026-05-08 16:52:59 +08:00
* [ISSUE #30]Supports batch resending and batch exporting dlq messages. * Optimize the code Co-authored-by: zhangjidi2016 <zhangjidi@cmss.chinamobile.com>
This commit is contained in:
@@ -82,6 +82,9 @@ module.controller('dlqMessageController', ['$scope', 'ngDialog', '$http', 'Notif
|
||||
if ($scope.messageShowList.length == 0){
|
||||
$("#noMsgTip").removeAttr("style");
|
||||
}
|
||||
for (const message of $scope.messageShowList) {
|
||||
message.checked = false;
|
||||
}
|
||||
console.log($scope.messageShowList);
|
||||
if (resp.data.page.first) {
|
||||
$scope.paginationConf.currentPage = 1;
|
||||
@@ -180,5 +183,109 @@ module.controller('dlqMessageController', ['$scope', 'ngDialog', '$http', 'Notif
|
||||
|
||||
$scope.exportDlqMessage = function (msgId, consumerGroup) {
|
||||
window.location.href = "dlqMessage/exportDlqMessage.do?msgId=" + msgId + "&consumerGroup=" + consumerGroup;
|
||||
};
|
||||
|
||||
$scope.selectedDlqMessage = [];
|
||||
$scope.batchResendDlqMessage = function (consumerGroup) {
|
||||
for (const message of $scope.messageCheckedList) {
|
||||
const dlqMessage = {};
|
||||
dlqMessage.topic = message.properties.RETRY_TOPIC;
|
||||
dlqMessage.msgId = message.properties.ORIGIN_MESSAGE_ID;
|
||||
dlqMessage.consumerGroup = consumerGroup;
|
||||
$scope.selectedDlqMessage.push(dlqMessage);
|
||||
}
|
||||
$http({
|
||||
method: "POST",
|
||||
url: "dlqMessage/batchResendDlqMessage.do",
|
||||
data: $scope.selectedDlqMessage
|
||||
}).success(function (resp) {
|
||||
$scope.selectedDlqMessage = [];
|
||||
if (resp.status == 0) {
|
||||
ngDialog.open({
|
||||
template: 'operationResultDialog',
|
||||
data: {
|
||||
result: resp.data
|
||||
}
|
||||
});
|
||||
} else {
|
||||
ngDialog.open({
|
||||
template: 'operationResultDialog',
|
||||
data: {
|
||||
result: resp.errMsg
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.batchExportDlqMessage = function (consumerGroup) {
|
||||
for (const message of $scope.messageCheckedList) {
|
||||
const dlqMessage = {};
|
||||
dlqMessage.msgId = message.msgId;
|
||||
dlqMessage.consumerGroup = consumerGroup;
|
||||
$scope.selectedDlqMessage.push(dlqMessage);
|
||||
}
|
||||
$http({
|
||||
method: "POST",
|
||||
url: "dlqMessage/batchExportDlqMessage.do",
|
||||
data: $scope.selectedDlqMessage,
|
||||
headers: {
|
||||
'Content-type': 'application/json'
|
||||
},
|
||||
responseType: "arraybuffer"
|
||||
}).success(function (resp) {
|
||||
$scope.selectedDlqMessage = [];
|
||||
const blob = new Blob([resp], {type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"});
|
||||
const objectUrl = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.style.display = 'none';
|
||||
a.download = 'dlqs.xlsx';
|
||||
a.href = objectUrl;
|
||||
a.click();
|
||||
document.body.removeChild(a)
|
||||
});
|
||||
};
|
||||
|
||||
$scope.checkedAll = false;
|
||||
$scope.messageCheckedList = [];
|
||||
$scope.selectAll = function () {
|
||||
$scope.messageCheckedList = [];
|
||||
if ($scope.checkedAll == true) {
|
||||
angular.forEach($scope.messageShowList, function (item, index) {
|
||||
item.checked = true;
|
||||
$scope.messageCheckedList.push(item);
|
||||
});
|
||||
} else {
|
||||
angular.forEach($scope.messageShowList, function (item, index) {
|
||||
item.checked = false;
|
||||
});
|
||||
}
|
||||
checkBtn($scope.messageCheckedList)
|
||||
console.log($scope.messageCheckedList)
|
||||
}
|
||||
|
||||
$scope.selectItem = function () {
|
||||
var flag = true;
|
||||
$scope.messageCheckedList = [];
|
||||
angular.forEach($scope.messageShowList, function (item, index) {
|
||||
if (item.checked) {
|
||||
$scope.messageCheckedList.push(item);
|
||||
} else {
|
||||
flag = false;
|
||||
}
|
||||
})
|
||||
$scope.checkedAll = flag;
|
||||
checkBtn($scope.messageCheckedList)
|
||||
console.log($scope.messageCheckedList);
|
||||
}
|
||||
|
||||
function checkBtn(messageCheckList) {
|
||||
if (messageCheckList.length == 0) {
|
||||
$("#batchResendBtn").addClass("disabled");
|
||||
$("#batchExportBtn").addClass("disabled");
|
||||
} else {
|
||||
$("#batchResendBtn").removeClass("disabled");
|
||||
$("#batchExportBtn").removeClass("disabled");
|
||||
}
|
||||
}
|
||||
}]);
|
||||
@@ -111,5 +111,7 @@ var en = {
|
||||
"TRACE_TOPIC":"TraceTopic",
|
||||
"SELECT_TRACE_TOPIC":"selectTraceTopic",
|
||||
"EXPORT": "export",
|
||||
"NO_MATCH_RESULT": "no match result"
|
||||
"NO_MATCH_RESULT": "no match result",
|
||||
"BATCH_RESEND": "batchReSend",
|
||||
"BATCH_EXPORT": "batchExport"
|
||||
}
|
||||
@@ -112,5 +112,7 @@ var zh = {
|
||||
"TRACE_TOPIC":"消息轨迹主题",
|
||||
"SELECT_TRACE_TOPIC":"选择消息轨迹主题",
|
||||
"EXPORT": "导出",
|
||||
"NO_MATCH_RESULT": "没有查到符合条件的结果"
|
||||
"NO_MATCH_RESULT": "没有查到符合条件的结果",
|
||||
"BATCH_RESEND": "批量重发",
|
||||
"BATCH_EXPORT": "批量导出"
|
||||
}
|
||||
@@ -64,9 +64,22 @@
|
||||
ng-click="queryDlqMessageByConsumerGroup()">
|
||||
<span class="glyphicon glyphicon-search"></span> {{ 'SEARCH' | translate}}
|
||||
</button>
|
||||
<button type="button" id="batchResendBtn"
|
||||
class="btn btn-raised btn-sm btn-primary disabled"
|
||||
data-toggle="modal"
|
||||
ng-click="batchResendDlqMessage(selectedConsumerGroup)">
|
||||
<span class="glyphicon glyphicon-send"></span> {{ 'BATCH_RESEND' | translate}}
|
||||
</button>
|
||||
<button type="button" id="batchExportBtn"
|
||||
class="btn btn-raised btn-sm btn-primary disabled"
|
||||
data-toggle="modal"
|
||||
ng-click="batchExportDlqMessage(selectedConsumerGroup)">
|
||||
<span class="glyphicon glyphicon-export"></span> {{ 'BATCH_EXPORT' | translate}}
|
||||
</button>
|
||||
</form>
|
||||
<table class="table table-bordered text-middle">
|
||||
<tr>
|
||||
<th class="text-center"><input type="checkbox" ng-model='checkedAll' ng-change="selectAll()"/></th>
|
||||
<th class="text-center">Message ID</th>
|
||||
<th class="text-center">Tag</th>
|
||||
<th class="text-center">Key</th>
|
||||
@@ -77,6 +90,9 @@
|
||||
<td colspan="6" style="text-align: center">{{'NO_MATCH_RESULT' | translate}}</td>
|
||||
</tr>
|
||||
<tr ng-repeat="item in messageShowList">
|
||||
<td class="text-center">
|
||||
<input type="checkbox" ng-model='item.checked' ng-change="selectItem()"/>
|
||||
</td>
|
||||
<td class="text-center">{{item.msgId}}</td>
|
||||
<td class="text-center">{{item.properties.TAGS}}</td>
|
||||
<td class="text-center">{{item.properties.KEYS}}</td>
|
||||
@@ -192,7 +208,7 @@
|
||||
<label class="control-label col-sm-2">Properties:</label>
|
||||
<div class="col-sm-10">
|
||||
<textarea class="form-control"
|
||||
style="min-height:60px; resize: none"
|
||||
style="min-height:100px; resize: none"
|
||||
readonly>{{ngDialogData.messageView.properties}}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user