This is an automated email from the ASF dual-hosted git repository.
vongosling pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-dashboard.git
The following commit(s) were added to refs/heads/master by this push:
new 1a75109 [ISSUE #5]Different pages are displayed based on the user
role. (#7)
1a75109 is described below
commit 1a751091b399f9d2ee0a3fa40eb07453c72a59fe
Author: zhangjidi2016 <[email protected]>
AuthorDate: Thu Aug 19 12:29:16 2021 +0800
[ISSUE #5]Different pages are displayed based on the user role. (#7)
* [ISSUE #5]Different pages are displayed based on the user role.
* Put the role judgment logic into js
Co-authored-by: zhangjidi <[email protected]>
---
.../dashboard/controller/LoginController.java | 12 +-
.../rocketmq/dashboard/model/LoginResult.java | 36 +++
src/main/resources/static/src/consumer.js | 190 ++++++++--------
src/main/resources/static/src/i18n/en.js | 3 +
src/main/resources/static/src/i18n/zh.js | 3 +
src/main/resources/static/src/login.js | 27 +--
src/main/resources/static/src/message.js | 87 ++++----
src/main/resources/static/src/ops.js | 18 +-
src/main/resources/static/src/topic.js | 241 +++++++++++----------
src/main/resources/static/view/pages/consumer.html | 72 +++---
src/main/resources/static/view/pages/message.html | 13 +-
src/main/resources/static/view/pages/ops.html | 21 +-
src/main/resources/static/view/pages/topic.html | 21 +-
.../dashboard/controller/LoginControllerTest.java | 2 +-
14 files changed, 413 insertions(+), 333 deletions(-)
diff --git
a/src/main/java/org/apache/rocketmq/dashboard/controller/LoginController.java
b/src/main/java/org/apache/rocketmq/dashboard/controller/LoginController.java
index be92456..916d68e 100644
---
a/src/main/java/org/apache/rocketmq/dashboard/controller/LoginController.java
+++
b/src/main/java/org/apache/rocketmq/dashboard/controller/LoginController.java
@@ -19,6 +19,7 @@ package org.apache.rocketmq.dashboard.controller;
import org.apache.rocketmq.dashboard.config.RMQConfigure;
import org.apache.rocketmq.dashboard.model.LoginInfo;
+import org.apache.rocketmq.dashboard.model.LoginResult;
import org.apache.rocketmq.dashboard.model.User;
import org.apache.rocketmq.dashboard.model.UserInfo;
import org.apache.rocketmq.dashboard.service.UserService;
@@ -65,10 +66,10 @@ public class LoginController {
@RequestMapping(value = "/login.do", method = RequestMethod.POST)
@ResponseBody
- public JsonResult<String> login(@RequestParam("username") String username,
- @RequestParam(value = "password") String password,
- HttpServletRequest request,
- HttpServletResponse response) throws Exception {
+ public Object login(@RequestParam("username") String username,
+ @RequestParam(value = "password") String password,
+ HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
logger.info("user:{} login", username);
User user = userService.queryByUsernameAndPassword(username, password);
@@ -80,7 +81,8 @@ public class LoginController {
WebUtil.setSessionValue(request, WebUtil.USER_INFO, userInfo);
WebUtil.setSessionValue(request, WebUtil.USER_NAME, username);
userInfo.setSessionId(WebUtil.getSessionId(request));
- return new JsonResult<>(contextPath);
+ LoginResult result = new LoginResult(username, user.getType(),
contextPath);
+ return result;
}
}
diff --git a/src/main/java/org/apache/rocketmq/dashboard/model/LoginResult.java
b/src/main/java/org/apache/rocketmq/dashboard/model/LoginResult.java
new file mode 100644
index 0000000..96769de
--- /dev/null
+++ b/src/main/java/org/apache/rocketmq/dashboard/model/LoginResult.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.rocketmq.dashboard.model;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class LoginResult {
+
+ private String loginUserName;
+
+ /**
+ * 0: normal 1: admin
+ */
+ private int loginUserRole;
+
+ private String contextPath;
+}
\ No newline at end of file
diff --git a/src/main/resources/static/src/consumer.js
b/src/main/resources/static/src/consumer.js
index fef1f43..0059192 100644
--- a/src/main/resources/static/src/consumer.js
+++ b/src/main/resources/static/src/consumer.js
@@ -17,7 +17,7 @@
var module = app;
-module.controller('consumerController', ['$scope', 'ngDialog',
'$http','Notification',function ($scope, ngDialog, $http,Notification) {
+module.controller('consumerController', ['$scope', 'ngDialog', '$http',
'Notification', '$window', function ($scope, ngDialog, $http, Notification,
$window) {
$scope.paginationConf = {
currentPage: 1,
totalItems: 0,
@@ -26,34 +26,44 @@ module.controller('consumerController', ['$scope',
'ngDialog', '$http','Notifica
perPageOptions: [10],
rememberPerPage: 'perPageItems',
onChange: function () {
- $scope.showConsumerGroupList(this.currentPage,this.totalItems);
+ $scope.showConsumerGroupList(this.currentPage, this.totalItems);
}
};
$scope.sortKey = null;
- $scope.sortOrder=1;
+ $scope.sortOrder = 1;
$scope.intervalProcessSwitch = false;
$scope.intervalProcess = null;
$scope.allConsumerGrouopList = [];
$scope.consumerGroupShowList = [];
$scope.sortByKey = function (key) {
- $scope.paginationConf.currentPage=1;
+ $scope.paginationConf.currentPage = 1;
$scope.sortOrder = -$scope.sortOrder;
$scope.sortKey = key;
$scope.doSort();
};
+ $scope.userRole = $window.sessionStorage.getItem("userrole");
+ $scope.writeOperationEnabled = $scope.userRole == null ? true :
($scope.userRole == 1 ? true : false);
- $scope.doSort = function (){// todo how to change this fe's code ? (it's
dirty)
- if($scope.sortKey == 'diffTotal'){
- $scope.allConsumerGrouopList.sort(function(a,b) {return
(a.diffTotal > b.diffTotal) ? $scope.sortOrder : ((b.diffTotal > a.diffTotal) ?
-$scope.sortOrder : 0);} );
+ $scope.doSort = function () {// todo how to change this fe's code ? (it's
dirty)
+ if ($scope.sortKey == 'diffTotal') {
+ $scope.allConsumerGrouopList.sort(function (a, b) {
+ return (a.diffTotal > b.diffTotal) ? $scope.sortOrder :
((b.diffTotal > a.diffTotal) ? -$scope.sortOrder : 0);
+ });
}
- if($scope.sortKey == 'group'){
- $scope.allConsumerGrouopList.sort(function(a,b) {return (a.group >
b.group) ? $scope.sortOrder : ((b.group > a.group) ? -$scope.sortOrder : 0);} );
+ if ($scope.sortKey == 'group') {
+ $scope.allConsumerGrouopList.sort(function (a, b) {
+ return (a.group > b.group) ? $scope.sortOrder : ((b.group >
a.group) ? -$scope.sortOrder : 0);
+ });
}
- if($scope.sortKey == 'count'){
- $scope.allConsumerGrouopList.sort(function(a,b) {return (a.count >
b.count) ? $scope.sortOrder : ((b.count > a.count) ? -$scope.sortOrder : 0);} );
+ if ($scope.sortKey == 'count') {
+ $scope.allConsumerGrouopList.sort(function (a, b) {
+ return (a.count > b.count) ? $scope.sortOrder : ((b.count >
a.count) ? -$scope.sortOrder : 0);
+ });
}
- if($scope.sortKey == 'consumeTps'){
- $scope.allConsumerGrouopList.sort(function(a,b) {return
(a.consumeTps > b.consumeTps) ? $scope.sortOrder : ((b.consumeTps >
a.consumeTps) ? -$scope.sortOrder : 0);} );
+ if ($scope.sortKey == 'consumeTps') {
+ $scope.allConsumerGrouopList.sort(function (a, b) {
+ return (a.consumeTps > b.consumeTps) ? $scope.sortOrder :
((b.consumeTps > a.consumeTps) ? -$scope.sortOrder : 0);
+ });
}
$scope.filterList($scope.paginationConf.currentPage)
};
@@ -65,31 +75,31 @@ module.controller('consumerController', ['$scope',
'ngDialog', '$http','Notifica
method: "GET",
url: "consumer/groupList.query"
}).success(function (resp) {
- if(resp.status ==0){
+ if (resp.status == 0) {
$scope.allConsumerGrouopList = resp.data;
console.log($scope.allConsumerGrouopList);
console.log(JSON.stringify(resp));
-
$scope.showConsumerGroupList($scope.paginationConf.currentPage,$scope.allConsumerGrouopList.length);
+
$scope.showConsumerGroupList($scope.paginationConf.currentPage,
$scope.allConsumerGrouopList.length);
//Hide loader
$('#loaderConsumer').addClass("hide-myloader");
- }else {
+ } else {
Notification.error({message: resp.errMsg, delay: 2000});
}
});
};
- $scope.monitor = function(consumerGroupName){
+ $scope.monitor = function (consumerGroupName) {
$http({
method: "GET",
url: "monitor/consumerMonitorConfigByGroupName.query",
- params:{consumeGroupName:consumerGroupName}
+ params: {consumeGroupName: consumerGroupName}
}).success(function (resp) {
// if(resp.status ==0){
- ngDialog.open({
- template: 'consumerMonitorDialog',
- controller: 'consumerMonitorDialogController',
- data:{consumerGroupName:consumerGroupName,data:resp.data}
- });
+ ngDialog.open({
+ template: 'consumerMonitorDialog',
+ controller: 'consumerMonitorDialogController',
+ data: {consumerGroupName: consumerGroupName, data: resp.data}
+ });
// }else {
// Notification.error({message: resp.errMsg, delay: 2000});
// }
@@ -109,35 +119,35 @@ module.controller('consumerController', ['$scope',
'ngDialog', '$http','Notifica
$scope.refreshConsumerData();
- $scope.filterStr="";
- $scope.$watch('filterStr', function() {
- $scope.paginationConf.currentPage=1;
+ $scope.filterStr = "";
+ $scope.$watch('filterStr', function () {
+ $scope.paginationConf.currentPage = 1;
$scope.filterList(1)
});
$scope.filterList = function (currentPage) {
- var lowExceptStr = $scope.filterStr.toLowerCase();
+ var lowExceptStr = $scope.filterStr.toLowerCase();
var canShowList = [];
- $scope.allConsumerGrouopList.forEach(function(element) {
+ $scope.allConsumerGrouopList.forEach(function (element) {
console.log(element)
- if (element.group.toLowerCase().indexOf(lowExceptStr) != -1){
+ if (element.group.toLowerCase().indexOf(lowExceptStr) != -1) {
canShowList.push(element);
}
});
- $scope.paginationConf.totalItems =canShowList.length;
+ $scope.paginationConf.totalItems = canShowList.length;
var perPage = $scope.paginationConf.itemsPerPage;
var from = (currentPage - 1) * perPage;
- var to = (from + perPage)>canShowList.length?canShowList.length:from +
perPage;
+ var to = (from + perPage) > canShowList.length ? canShowList.length :
from + perPage;
$scope.consumerGroupShowList = canShowList.slice(from, to);
};
- $scope.showConsumerGroupList = function (currentPage,totalItem) {
+ $scope.showConsumerGroupList = function (currentPage, totalItem) {
var perPage = $scope.paginationConf.itemsPerPage;
var from = (currentPage - 1) * perPage;
- var to = (from + perPage)>totalItem?totalItem:from + perPage;
+ var to = (from + perPage) > totalItem ? totalItem : from + perPage;
$scope.consumerGroupShowList =
$scope.allConsumerGrouopList.slice(from, to);
- $scope.paginationConf.totalItems = totalItem ;
+ $scope.paginationConf.totalItems = totalItem;
console.log($scope.consumerGroupShowList)
console.log($scope.paginationConf.totalItems)
$scope.doSort()
@@ -145,9 +155,9 @@ module.controller('consumerController', ['$scope',
'ngDialog', '$http','Notifica
$scope.openAddDialog = function () {
$scope.openCreateOrUpdateDialog(null);
};
- $scope.openCreateOrUpdateDialog = function(request){
+ $scope.openCreateOrUpdateDialog = function (request) {
var bIsUpdate = true;
- if(request == null){
+ if (request == null) {
request = [{
brokerNameList: [],
subscriptionGroupConfig: {
@@ -168,123 +178,126 @@ module.controller('consumerController', ['$scope',
'ngDialog', '$http','Notifica
method: "GET",
url: "cluster/list.query"
}).success(function (resp) {
- if(resp.status ==0){
+ if (resp.status == 0) {
console.log(resp);
ngDialog.open({
- preCloseCallback: function(value) {
+ preCloseCallback: function (value) {
// Refresh topic list
$scope.refreshConsumerData();
},
template: 'consumerModifyDialog',
controller: 'consumerModifyDialogController',
- data:{
- consumerRequestList:request,
-
allClusterNameList:Object.keys(resp.data.clusterInfo.clusterAddrTable),
- allBrokerNameList:Object.keys(resp.data.brokerServer),
- bIsUpdate:bIsUpdate
+ data: {
+ consumerRequestList: request,
+ allClusterNameList:
Object.keys(resp.data.clusterInfo.clusterAddrTable),
+ allBrokerNameList: Object.keys(resp.data.brokerServer),
+ bIsUpdate: bIsUpdate,
+ writeOperationEnabled: $scope.writeOperationEnabled
}
});
- }else {
+ } else {
Notification.error({message: resp.errMsg, delay: 2000});
}
});
};
- $scope.detail = function(consumerGroupName){
+ $scope.detail = function (consumerGroupName) {
$http({
method: "GET",
url: "consumer/queryTopicByConsumer.query",
- params:{consumerGroup:consumerGroupName}
+ params: {consumerGroup: consumerGroupName}
}).success(function (resp) {
- if(resp.status ==0){
+ if (resp.status == 0) {
console.log(resp);
ngDialog.open({
template: 'consumerTopicViewDialog',
controller: 'consumerTopicViewDialogController',
- data:{consumerGroupName:consumerGroupName,data:resp.data}
+ data: {consumerGroupName: consumerGroupName, data:
resp.data}
});
- }else {
+ } else {
Notification.error({message: resp.errMsg, delay: 2000});
}
});
};
- $scope.client = function(consumerGroupName){
+ $scope.client = function (consumerGroupName) {
$http({
method: "GET",
url: "consumer/consumerConnection.query",
- params:{consumerGroup:consumerGroupName}
+ params: {consumerGroup: consumerGroupName}
}).success(function (resp) {
- if(resp.status ==0){
+ if (resp.status == 0) {
console.log(resp);
ngDialog.open({
template: 'clientInfoDialog',
// controller: 'addTopicDialogController',
- data:{data:resp.data,consumerGroupName:consumerGroupName}
+ data: {data: resp.data, consumerGroupName:
consumerGroupName}
});
- }else {
+ } else {
Notification.error({message: resp.errMsg, delay: 2000});
}
});
};
- $scope.updateConfigDialog = function(consumerGroupName){
+ $scope.updateConfigDialog = function (consumerGroupName) {
$http({
method: "GET",
url: "consumer/examineSubscriptionGroupConfig.query",
- params:{consumerGroup:consumerGroupName}
+ params: {consumerGroup: consumerGroupName}
}).success(function (resp) {
- if(resp.status ==0){
+ if (resp.status == 0) {
console.log(resp);
$scope.openCreateOrUpdateDialog(resp.data);
- }else {
+ } else {
Notification.error({message: resp.errMsg, delay: 2000});
}
});
};
- $scope.delete = function(consumerGroupName){
+ $scope.delete = function (consumerGroupName) {
$http({
method: "GET",
url: "consumer/fetchBrokerNameList.query",
- params:{
- consumerGroup:consumerGroupName
+ params: {
+ consumerGroup: consumerGroupName
}
}).success(function (resp) {
- if(resp.status ==0){
+ if (resp.status == 0) {
console.log(resp);
ngDialog.open({
- preCloseCallback: function(value) {
+ preCloseCallback: function (value) {
// Refresh topic list
$scope.refreshConsumerData();
},
template: 'deleteConsumerDialog',
controller: 'deleteConsumerDialogController',
- data:{
+ data: {
//
allClusterList:Object.keys(resp.data.clusterInfo.clusterAddrTable),
- allBrokerNameList:resp.data,
- consumerGroupName:consumerGroupName
+ allBrokerNameList: resp.data,
+ consumerGroupName: consumerGroupName
}
});
- }else {
+ } else {
Notification.error({message: resp.errMsg, delay: 2000});
}
});
}
}])
-module.controller('consumerMonitorDialogController', function ($scope,
ngDialog, $http,Notification) {
+module.controller('consumerMonitorDialogController', function ($scope,
ngDialog, $http, Notification) {
$scope.createOrUpdateConsumerMonitor = function () {
$http({
method: "POST",
url: "monitor/createOrUpdateConsumerMonitor.do",
- params:{consumeGroupName:$scope.ngDialogData.consumerGroupName,
- minCount:$scope.ngDialogData.data.minCount,
- maxDiffTotal:$scope.ngDialogData.data.maxDiffTotal}
+ params: {
+ consumeGroupName: $scope.ngDialogData.consumerGroupName,
+ minCount: $scope.ngDialogData.data.minCount,
+ maxDiffTotal: $scope.ngDialogData.data.maxDiffTotal
+ }
}).success(function (resp) {
- if(resp.status ==0){
+ if (resp.status == 0) {
Notification.info({message: "update success!", delay:
2000});
- }else {
+ } else {
Notification.error({message: resp.errMsg, delay: 2000});
}
});
@@ -293,7 +306,7 @@ module.controller('consumerMonitorDialogController',
function ($scope, ngDialog,
);
-module.controller('deleteConsumerDialogController', ['$scope', 'ngDialog',
'$http','Notification',function ($scope, ngDialog, $http,Notification) {
+module.controller('deleteConsumerDialogController', ['$scope', 'ngDialog',
'$http', 'Notification', function ($scope, ngDialog, $http, Notification) {
$scope.selectedClusterList = [];
$scope.selectedBrokerNameList = [];
$scope.delete = function () {
@@ -303,13 +316,15 @@ module.controller('deleteConsumerDialogController',
['$scope', 'ngDialog', '$htt
$http({
method: "POST",
url: "consumer/deleteSubGroup.do",
- data:{groupName:$scope.ngDialogData.consumerGroupName,
- brokerNameList:$scope.selectedBrokerNameList}
+ data: {
+ groupName: $scope.ngDialogData.consumerGroupName,
+ brokerNameList: $scope.selectedBrokerNameList
+ }
}).success(function (resp) {
- if(resp.status ==0){
+ if (resp.status == 0) {
Notification.info({message: "delete success!", delay:
2000});
ngDialog.close(this);
- }else {
+ } else {
Notification.error({message: resp.errMsg, delay: 2000});
}
});
@@ -317,19 +332,19 @@ module.controller('deleteConsumerDialogController',
['$scope', 'ngDialog', '$htt
}]
);
-module.controller('consumerModifyDialogController', ['$scope', 'ngDialog',
'$http','Notification',function ($scope, ngDialog, $http,Notification) {
+module.controller('consumerModifyDialogController', ['$scope', 'ngDialog',
'$http', 'Notification', function ($scope, ngDialog, $http, Notification) {
$scope.postConsumerRequest = function (consumerRequest) {
var request = JSON.parse(JSON.stringify(consumerRequest));
console.log(request);
$http({
method: "POST",
url: "consumer/createOrUpdate.do",
- data:request
+ data: request
}).success(function (resp) {
- if(resp.status ==0){
+ if (resp.status == 0) {
Notification.info({message: "update success!", delay:
2000});
ngDialog.close(this);
- }else {
+ } else {
Notification.error({message: resp.errMsg, delay: 2000});
}
});
@@ -351,8 +366,10 @@ module.controller('consumerTopicViewDialogController',
['$scope', 'ngDialog', '$
if (resp.status == 0) {
ngDialog.open({
template: 'consumerClientDialog',
- data:{consumerClientInfo:resp.data,
- clientId:clientId}
+ data: {
+ consumerClientInfo: resp.data,
+ clientId: clientId
+ }
});
} else {
Notification.error({message: resp.errMsg, delay: 2000});
@@ -360,7 +377,4 @@ module.controller('consumerTopicViewDialogController',
['$scope', 'ngDialog', '$
});
};
}]
-);
-
-
-
+);
\ No newline at end of file
diff --git a/src/main/resources/static/src/i18n/en.js
b/src/main/resources/static/src/i18n/en.js
index ea98267..52a10b5 100644
--- a/src/main/resources/static/src/i18n/en.js
+++ b/src/main/resources/static/src/i18n/en.js
@@ -20,6 +20,9 @@ var en = {
"CONSUMER":"Consumer",
"PRODUCER":"Producer",
"MESSAGE":"Message",
+ "MESSAGE_DETAIL":"Message Detail",
+ "RESEND_MESSAGE":"Resend Message",
+ "VIEW_EXCEPTION":"View Exception",
"MESSAGETRACE":"MessageTrace",
"COMMIT": "Commit",
"OPERATION": "Operation",
diff --git a/src/main/resources/static/src/i18n/zh.js
b/src/main/resources/static/src/i18n/zh.js
index 8286054..5aa9c46 100644
--- a/src/main/resources/static/src/i18n/zh.js
+++ b/src/main/resources/static/src/i18n/zh.js
@@ -21,6 +21,9 @@ var zh = {
"CONSUMER":"消费者",
"PRODUCER":"生产者",
"MESSAGE":"消息",
+ "MESSAGE_DETAIL":"消息详情",
+ "RESEND_MESSAGE":"重新消费",
+ "VIEW_EXCEPTION":"查看异常",
"MESSAGETRACE":"消息轨迹",
"OPERATION": "操作",
"ADD": "新增",
diff --git a/src/main/resources/static/src/login.js
b/src/main/resources/static/src/login.js
index cd7e56c..5a5cbe3 100644
--- a/src/main/resources/static/src/login.js
+++ b/src/main/resources/static/src/login.js
@@ -15,28 +15,29 @@
* limitations under the License.
*/
-app.controller('loginController',
['$scope','$location','$http','Notification','$cookies','$window', function
($scope,$location,$http,Notification,$cookies, $window) {
+app.controller('loginController', ['$scope', '$location', '$http',
'Notification', '$cookies', '$window', function ($scope, $location, $http,
Notification, $cookies, $window) {
$scope.login = function () {
- if(!$("#username").val()) {
- alert("用户名不能为空");
- return;
- }
- if(!$("#password").val()) {
- alert("密码不能为空");
- return;
- }
+ if (!$("#username").val()) {
+ alert("用户名不能为空");
+ return;
+ }
+ if (!$("#password").val()) {
+ alert("密码不能为空");
+ return;
+ }
$http({
method: "POST",
url: "login/login.do",
- params:{username:$("#username").val(),
password:$("#password").val()}
+ params: {username: $("#username").val(), password:
$("#password").val()}
}).success(function (resp) {
if (resp.status == 0) {
Notification.info({message: 'Login successful, redirect now',
delay: 2000});
- $window.sessionStorage.setItem("username",
$("#username").val());
- window.location = resp.data;
+ $window.sessionStorage.setItem("username",
resp.data.loginUserName);
+ $window.sessionStorage.setItem("userrole",
resp.data.loginUserRole);
+ window.location = resp.data.contextPath;
initFlag = false;
- } else{
+ } else {
Notification.error({message: resp.errMsg, delay: 2000});
}
});
diff --git a/src/main/resources/static/src/message.js
b/src/main/resources/static/src/message.js
index d2de6d9..18f88c2 100644
--- a/src/main/resources/static/src/message.js
+++ b/src/main/resources/static/src/message.js
@@ -17,14 +17,14 @@
var module = app;
-module.controller('messageController', ['$scope', 'ngDialog',
'$http','Notification',function ($scope, ngDialog, $http,Notification) {
+module.controller('messageController', ['$scope', 'ngDialog', '$http',
'Notification', function ($scope, ngDialog, $http, Notification) {
$scope.allTopicList = [];
- $scope.selectedTopic =[];
- $scope.key ="";
- $scope.messageId ="";
- $scope.queryMessageByTopicResult=[];
- $scope.queryMessageByTopicAndKeyResult=[];
- $scope.queryMessageByMessageIdResult={};
+ $scope.selectedTopic = [];
+ $scope.key = "";
+ $scope.messageId = "";
+ $scope.queryMessageByTopicResult = [];
+ $scope.queryMessageByTopicAndKeyResult = [];
+ $scope.queryMessageByMessageIdResult = {};
$http({
method: "GET",
url: "topic/list.query",
@@ -32,16 +32,16 @@ module.controller('messageController', ['$scope',
'ngDialog', '$http','Notificat
skipSysProcess: 'true'
}
}).success(function (resp) {
- if(resp.status ==0){
+ if (resp.status == 0) {
$scope.allTopicList = resp.data.topicList.sort();
console.log($scope.allTopicList);
- }else {
+ } else {
Notification.error({message: resp.errMsg, delay: 2000});
}
});
- $scope.timepickerBegin = moment().subtract(1, 'hour').format('YYYY-MM-DD
HH:mm');
- $scope.timepickerEnd = moment().add(1,'hour').format('YYYY-MM-DD HH:mm');
- $scope.timepickerOptions ={format: 'YYYY-MM-DD HH:mm', showClear: true};
+ $scope.timepickerBegin = moment().subtract(3, 'hour').format('YYYY-MM-DD
HH:mm');
+ $scope.timepickerEnd = moment().format('YYYY-MM-DD HH:mm');
+ $scope.timepickerOptions = {format: 'YYYY-MM-DD HH:mm', showClear: true};
$scope.taskId = "";
@@ -62,7 +62,7 @@ module.controller('messageController', ['$scope', 'ngDialog',
'$http','Notificat
Notification.error({message: "endTime is later than beginTime!",
delay: 2000});
return
}
- if( $scope.selectedTopic === [] || (typeof $scope.selectedTopic) ==
"object"){
+ if ($scope.selectedTopic === [] || (typeof $scope.selectedTopic) ==
"object") {
return
}
$http({
@@ -80,13 +80,13 @@ module.controller('messageController', ['$scope',
'ngDialog', '$http','Notificat
if (resp.status === 0) {
console.log(resp);
$scope.messageShowList = resp.data.page.content;
- if(resp.data.page.first){
+ if (resp.data.page.first) {
$scope.paginationConf.currentPage = 1;
}
$scope.paginationConf.currentPage = resp.data.page.number + 1;
$scope.paginationConf.totalItems =
resp.data.page.totalElements;
$scope.taskId = resp.data.taskId
- }else {
+ } else {
Notification.error({message: resp.errMsg, delay: 2000});
}
});
@@ -114,10 +114,10 @@ module.controller('messageController', ['$scope',
'ngDialog', '$http','Notificat
if (resp.status == 0) {
console.log(resp);
$scope.queryMessageByTopicResult = resp.data;
-
$scope.changeShowMessageList(1,$scope.queryMessageByTopicResult.length);
+ $scope.changeShowMessageList(1,
$scope.queryMessageByTopicResult.length);
// todo
// console.log($scope.queryMessageByTopicResult);
- }else {
+ } else {
Notification.error({message: resp.errMsg, delay: 2000});
}
});
@@ -131,26 +131,26 @@ module.controller('messageController', ['$scope',
'ngDialog', '$http','Notificat
url: "message/queryMessageByTopicAndKey.query",
params: {
topic: $scope.selectedTopic,
- key:$scope.key
+ key: $scope.key
}
}).success(function (resp) {
if (resp.status == 0) {
console.log(resp);
$scope.queryMessageByTopicAndKeyResult = resp.data;
console.log($scope.queryMessageByTopicAndKeyResult);
- }else {
+ } else {
Notification.error({message: resp.errMsg, delay: 2000});
}
});
};
- $scope.queryMessageByBrokerAndOffset = function
(storeHost,commitLogOffset) {
+ $scope.queryMessageByBrokerAndOffset = function (storeHost,
commitLogOffset) {
$http({
method: "GET",
url: "message/viewMessageByBrokerAndOffset.query",
params: {
brokerHost: storeHost.address,
- port:storeHost.port,
+ port: storeHost.port,
offset: commitLogOffset
}
}).success(function (resp) {
@@ -167,13 +167,13 @@ module.controller('messageController', ['$scope',
'ngDialog', '$http','Notificat
});
};
- $scope.queryMessageByMessageId = function (messageId,topic) {
+ $scope.queryMessageByMessageId = function (messageId, topic) {
$http({
method: "GET",
url: "message/viewMessage.query",
params: {
msgId: messageId,
- topic:topic
+ topic: topic
}
}).success(function (resp) {
if (resp.status == 0) {
@@ -181,23 +181,23 @@ module.controller('messageController', ['$scope',
'ngDialog', '$http','Notificat
ngDialog.open({
template: 'messageDetailViewDialog',
controller: 'messageDetailViewDialogController',
- data:resp.data
+ data: resp.data
});
- }else {
+ } else {
Notification.error({message: resp.errMsg, delay: 2000});
}
});
};
- $scope.changeShowMessageList = function (currentPage,totalItem) {
+ $scope.changeShowMessageList = function (currentPage, totalItem) {
var perPage = $scope.paginationConf.itemsPerPage;
var from = (currentPage - 1) * perPage;
- var to = (from + perPage)>totalItem?totalItem:from + perPage;
+ var to = (from + perPage) > totalItem ? totalItem : from + perPage;
$scope.messageShowList = $scope.queryMessageByTopicResult.slice(from,
to);
- $scope.paginationConf.totalItems = totalItem ;
+ $scope.paginationConf.totalItems = totalItem;
};
- $scope.onChangeQueryCondition = function (){
+ $scope.onChangeQueryCondition = function () {
console.log("change")
$scope.taskId = "";
$scope.paginationConf.currentPage = 1;
@@ -205,12 +205,12 @@ module.controller('messageController', ['$scope',
'ngDialog', '$http','Notificat
}
}]);
-module.controller('messageDetailViewDialogController',['$scope', 'ngDialog',
'$http','Notification', function ($scope, ngDialog, $http,Notification) {
+module.controller('messageDetailViewDialogController', ['$scope', 'ngDialog',
'$http', 'Notification', function ($scope, ngDialog, $http, Notification) {
- $scope.resendMessage = function (messageView,consumerGroup) {
+ $scope.resendMessage = function (messageView, consumerGroup) {
var topic = messageView.topic;
var msgId = messageView.msgId;
- console.log('==='+topic+'==='+msgId);
+ console.log('===' + topic + '===' + msgId);
if (topic.startsWith('%DLQ%')) {
if (messageView.properties.hasOwnProperty("RETRY_TOPIC")) {
topic = messageView.properties.RETRY_TOPIC;
@@ -220,42 +220,41 @@
module.controller('messageDetailViewDialogController',['$scope', 'ngDialog', '$h
}
}
- console.log('==='+topic+'==='+msgId);
+ console.log('===' + topic + '===' + msgId);
$http({
method: "POST",
url: "message/consumeMessageDirectly.do",
params: {
msgId: msgId,
- consumerGroup:consumerGroup,
- topic:topic
+ consumerGroup: consumerGroup,
+ topic: topic
}
}).success(function (resp) {
if (resp.status == 0) {
ngDialog.open({
template: 'operationResultDialog',
- data:{
- result:resp.data
+ data: {
+ result: resp.data
}
});
- }
- else {
+ } else {
ngDialog.open({
template: 'operationResultDialog',
- data:{
- result:resp.errMsg
+ data: {
+ result: resp.errMsg
}
});
}
});
};
$scope.showExceptionDesc = function (errmsg) {
- if(errmsg == null){
+ if (errmsg == null) {
errmsg = "Don't have Exception"
}
ngDialog.open({
template: 'operationResultDialog',
- data:{
- result:errmsg
+ data: {
+ result: errmsg
}
});
};
diff --git a/src/main/resources/static/src/ops.js
b/src/main/resources/static/src/ops.js
index e4fb60c..8338b06 100644
--- a/src/main/resources/static/src/ops.js
+++ b/src/main/resources/static/src/ops.js
@@ -15,10 +15,12 @@
* limitations under the License.
*/
-app.controller('opsController',
['$scope','$location','$http','Notification','remoteApi','tools', function
($scope,$location,$http,Notification,remoteApi,tools) {
+app.controller('opsController', ['$scope', '$location', '$http',
'Notification', 'remoteApi', 'tools', '$window', function ($scope, $location,
$http, Notification, remoteApi, tools, $window) {
$scope.namesvrAddrList = "";
$scope.useVIPChannel = true;
$scope.useTLS = false;
+ $scope.userRole = $window.sessionStorage.getItem("userrole");
+ $scope.writeOperationEnabled = $scope.userRole == null ? true :
($scope.userRole == 1 ? true : false);
$http({
method: "GET",
url: "ops/homePage.query"
@@ -27,7 +29,7 @@ app.controller('opsController',
['$scope','$location','$http','Notification','re
$scope.namesvrAddrList = resp.data.namesvrAddrList.join(";");
$scope.useVIPChannel = resp.data.useVIPChannel;
$scope.useTLS = resp.data.useTLS;
- }else{
+ } else {
Notification.error({message: resp.errMsg, delay: 2000});
}
});
@@ -36,11 +38,11 @@ app.controller('opsController',
['$scope','$location','$http','Notification','re
$http({
method: "POST",
url: "ops/updateNameSvrAddr.do",
- params:{nameSvrAddrList:$scope.namesvrAddrList}
+ params: {nameSvrAddrList: $scope.namesvrAddrList}
}).success(function (resp) {
if (resp.status == 0) {
Notification.info({message: "SUCCESS", delay: 2000});
- }else{
+ } else {
Notification.error({message: resp.errMsg, delay: 2000});
}
});
@@ -49,11 +51,11 @@ app.controller('opsController',
['$scope','$location','$http','Notification','re
$http({
method: "POST",
url: "ops/updateIsVIPChannel.do",
- params:{useVIPChannel:$scope.useVIPChannel}
+ params: {useVIPChannel: $scope.useVIPChannel}
}).success(function (resp) {
if (resp.status == 0) {
Notification.info({message: "SUCCESS", delay: 2000});
- }else{
+ } else {
Notification.error({message: resp.errMsg, delay: 2000});
}
});
@@ -62,11 +64,11 @@ app.controller('opsController',
['$scope','$location','$http','Notification','re
$http({
method: "POST",
url: "ops/updateUseTLS.do",
- params:{useTLS:$scope.useTLS}
+ params: {useTLS: $scope.useTLS}
}).success(function (resp) {
if (resp.status == 0) {
Notification.info({message: "SUCCESS", delay: 2000});
- }else{
+ } else {
Notification.error({message: resp.errMsg, delay: 2000});
}
});
diff --git a/src/main/resources/static/src/topic.js
b/src/main/resources/static/src/topic.js
index 7450f1a..28c3555 100644
--- a/src/main/resources/static/src/topic.js
+++ b/src/main/resources/static/src/topic.js
@@ -4,20 +4,20 @@
var module = app;
module.directive('ngConfirmClick', [
- function(){
+ function () {
return {
link: function (scope, element, attr) {
var msg = attr.ngConfirmClick || "Are you sure?";
var clickAction = attr.confirmedClick;
- element.bind('click',function (event) {
- if ( window.confirm(msg) ) {
+ element.bind('click', function (event) {
+ if (window.confirm(msg)) {
scope.$eval(clickAction)
}
});
}
};
}]);
-module.controller('topicController', ['$scope', 'ngDialog',
'$http','Notification',function ($scope, ngDialog, $http,Notification) {
+module.controller('topicController', ['$scope', 'ngDialog', '$http',
'Notification', '$window', function ($scope, ngDialog, $http, Notification,
$window) {
$scope.paginationConf = {
currentPage: 1,
totalItems: 0,
@@ -26,7 +26,7 @@ module.controller('topicController', ['$scope', 'ngDialog',
'$http','Notificatio
perPageOptions: [10],
rememberPerPage: 'perPageItems',
onChange: function () {
- $scope.showTopicList(this.currentPage,this.totalItems);
+ $scope.showTopicList(this.currentPage, this.totalItems);
}
};
@@ -36,19 +36,21 @@ module.controller('topicController', ['$scope', 'ngDialog',
'$http','Notificatio
$scope.filterSystem = false
$scope.allTopicList = [];
$scope.topicShowList = [];
+ $scope.userRole = $window.sessionStorage.getItem("userrole");
+ $scope.writeOperationEnabled = $scope.userRole == null ? true :
($scope.userRole == 1 ? true : false);
$scope.refreshTopicList = function () {
$http({
method: "GET",
url: "topic/list.query"
}).success(function (resp) {
- if(resp.status ==0){
+ if (resp.status == 0) {
$scope.allTopicList = resp.data.topicList.sort();
console.log($scope.allTopicList);
console.log(JSON.stringify(resp));
- $scope.showTopicList(1,$scope.allTopicList.length);
+ $scope.showTopicList(1, $scope.allTopicList.length);
- }else {
+ } else {
Notification.error({message: resp.errMsg, delay: 5000});
}
});
@@ -56,93 +58,93 @@ module.controller('topicController', ['$scope', 'ngDialog',
'$http','Notificatio
$scope.refreshTopicList();
- $scope.filterStr="";
- $scope.$watch('filterStr', function() {
+ $scope.filterStr = "";
+ $scope.$watch('filterStr', function () {
$scope.filterList(1);
});
- $scope.$watch('filterNormal', function() {
+ $scope.$watch('filterNormal', function () {
$scope.filterList(1);
});
- $scope.$watch('filterRetry', function() {
+ $scope.$watch('filterRetry', function () {
$scope.filterList(1);
});
- $scope.$watch('filterDLQ', function() {
+ $scope.$watch('filterDLQ', function () {
$scope.filterList(1);
});
- $scope.$watch('filterSystem', function() {
+ $scope.$watch('filterSystem', function () {
$scope.filterList(1);
});
$scope.filterList = function (currentPage) {
- var lowExceptStr = $scope.filterStr.toLowerCase();
+ var lowExceptStr = $scope.filterStr.toLowerCase();
var canShowList = [];
- $scope.allTopicList.forEach(function(element) {
- if($scope.filterByType(element)){
- if (element.toLowerCase().indexOf(lowExceptStr) != -1){
+ $scope.allTopicList.forEach(function (element) {
+ if ($scope.filterByType(element)) {
+ if (element.toLowerCase().indexOf(lowExceptStr) != -1) {
canShowList.push(element);
}
}
});
- $scope.paginationConf.totalItems =canShowList.length;
+ $scope.paginationConf.totalItems = canShowList.length;
var perPage = $scope.paginationConf.itemsPerPage;
var from = (currentPage - 1) * perPage;
- var to = (from + perPage)>canShowList.length?canShowList.length:from +
perPage;
+ var to = (from + perPage) > canShowList.length ? canShowList.length :
from + perPage;
$scope.topicShowList = canShowList.slice(from, to);
};
- $scope.filterByType = function(str){
- if($scope.filterRetry){
- if(str.startsWith("%R")){
+ $scope.filterByType = function (str) {
+ if ($scope.filterRetry) {
+ if (str.startsWith("%R")) {
return true
}
}
- if($scope.filterDLQ){
- if(str.startsWith("%D")){
+ if ($scope.filterDLQ) {
+ if (str.startsWith("%D")) {
return true
}
}
- if($scope.filterSystem){
- if(str.startsWith("%S")){
+ if ($scope.filterSystem) {
+ if (str.startsWith("%S")) {
return true
}
}
- if($scope.filterNormal){
- if(str.startsWith("%") == false){
+ if ($scope.filterNormal) {
+ if (str.startsWith("%") == false) {
return true
}
}
return false;
};
- $scope.showTopicList = function (currentPage,totalItem) {
- if($scope.filterStr != ""){
+ $scope.showTopicList = function (currentPage, totalItem) {
+ if ($scope.filterStr != "") {
$scope.filterList(currentPage);
return;
}
var perPage = $scope.paginationConf.itemsPerPage;
var from = (currentPage - 1) * perPage;
- var to = (from + perPage)>totalItem?totalItem:from + perPage;
+ var to = (from + perPage) > totalItem ? totalItem : from + perPage;
console.log($scope.allTopicList);
console.log(from)
console.log(to)
$scope.topicShowList = $scope.allTopicList.slice(from, to);
- $scope.paginationConf.totalItems = totalItem ;
+ $scope.paginationConf.totalItems = totalItem;
console.log($scope.topicShowList)
console.log($scope.paginationConf.totalItems)
$scope.filterList(currentPage);
};
- $scope.deleteTopic= function (topic) {
+ $scope.deleteTopic = function (topic) {
$http({
method: "POST",
url: "topic/deleteTopic.do",
- params:{
- topic:topic
+ params: {
+ topic: topic
}
}).success(function (resp) {
- if(resp.status ==0){
+ if (resp.status == 0) {
Notification.info({message: "delete success!", delay: 2000});
$scope.refreshTopicList();
- }else {
+ } else {
Notification.error({message: resp.errMsg, delay: 2000});
}
});
@@ -157,13 +159,13 @@ module.controller('topicController', ['$scope',
'ngDialog', '$http','Notificatio
console.log(JSON.stringify(resp));
ngDialog.open({
template: 'statsViewDialog',
- trapFocus:false,
- data:{
- topic:topic,
- statsData:resp.data
+ trapFocus: false,
+ data: {
+ topic: topic,
+ statsData: resp.data
}
});
- }else {
+ } else {
Notification.error({message: resp.errMsg, delay: 2000});
}
})
@@ -179,13 +181,13 @@ module.controller('topicController', ['$scope',
'ngDialog', '$http','Notificatio
ngDialog.open({
template: 'routerViewDialog',
controller: 'routerViewDialogController',
- trapFocus:false,
- data:{
- topic:topic,
- routeData:resp.data
+ trapFocus: false,
+ data: {
+ topic: topic,
+ routeData: resp.data
}
});
- }else {
+ } else {
Notification.error({message: resp.errMsg, delay: 2000});
}
})
@@ -202,13 +204,13 @@ module.controller('topicController', ['$scope',
'ngDialog', '$http','Notificatio
console.log(JSON.stringify(resp));
ngDialog.open({
template: 'consumerViewDialog',
- data:{
- topic:topic,
- consumerData:resp.data,
- consumerGroupCount:Object.keys(resp.data).length
+ data: {
+ topic: topic,
+ consumerData: resp.data,
+ consumerGroupCount: Object.keys(resp.data).length
}
});
- }else {
+ } else {
Notification.error({message: resp.errMsg, delay: 2000});
}
})
@@ -217,9 +219,9 @@ module.controller('topicController', ['$scope', 'ngDialog',
'$http','Notificatio
ngDialog.open({
template: 'deleteTopicDialog',
controller: 'deleteTopicDialogController',
- data:{
- topic:topic,
- consumerData:"asd"
+ data: {
+ topic: topic,
+ consumerData: "asd"
}
});
};
@@ -229,25 +231,25 @@ module.controller('topicController', ['$scope',
'ngDialog', '$http','Notificatio
$http({
method: "GET",
url: "topic/queryTopicConsumerInfo.query",
- params:{
- topic:topic
+ params: {
+ topic: topic
}
}).success(function (resp) {
- if(resp.status ==0){
- if(resp.data.groupList == null){
+ if (resp.status == 0) {
+ if (resp.data.groupList == null) {
Notification.error({message: "don't have consume group!",
delay: 2000});
return
}
ngDialog.open({
template: 'consumerResetOffsetDialog',
controller: 'consumerResetOffsetDialogController',
- data:{
+ data: {
topic: topic,
- selectedConsumerGroup:[],
- allConsumerGroupList:resp.data.groupList
+ selectedConsumerGroup: [],
+ allConsumerGroupList: resp.data.groupList
}
});
- }else {
+ } else {
Notification.error({message: resp.errMsg, delay: 2000});
}
});
@@ -258,25 +260,25 @@ module.controller('topicController', ['$scope',
'ngDialog', '$http','Notificatio
$http({
method: "GET",
url: "topic/queryTopicConsumerInfo.query",
- params:{
- topic:topic
+ params: {
+ topic: topic
}
}).success(function (resp) {
- if(resp.status ==0){
- if(resp.data.groupList == null){
+ if (resp.status == 0) {
+ if (resp.data.groupList == null) {
Notification.error({message: "don't have consume group!",
delay: 2000});
return
}
ngDialog.open({
template: 'skipMessageAccumulateDialog',
controller: 'skipMessageAccumulateDialogController',
- data:{
+ data: {
topic: topic,
- selectedConsumerGroup:[],
- allConsumerGroupList:resp.data.groupList
+ selectedConsumerGroup: [],
+ allConsumerGroupList: resp.data.groupList
}
});
- }else {
+ } else {
Notification.error({message: resp.errMsg, delay: 2000});
}
});
@@ -296,13 +298,13 @@ module.controller('topicController', ['$scope',
'ngDialog', '$http','Notificatio
$http({
method: "GET",
url: "topic/examineTopicConfig.query",
- params:{
- topic:topic
+ params: {
+ topic: topic
}
}).success(function (resp) {
- if(resp.status ==0){
+ if (resp.status == 0) {
$scope.openCreateOrUpdateDialog(resp.data, sysFlag);
- }else {
+ } else {
Notification.error({message: resp.errMsg, delay: 2000});
}
});
@@ -310,14 +312,14 @@ module.controller('topicController', ['$scope',
'ngDialog', '$http','Notificatio
$scope.openCreateOrUpdateDialog = function (request, sysFlag) {
var bIsUpdate = true;
- if(request == null){
+ if (request == null) {
request = [{
- writeQueueNums:16,
- readQueueNums:16,
- perm:6,
- order:false,
- topicName:"",
- brokerNameList:[]
+ writeQueueNums: 16,
+ readQueueNums: 16,
+ perm: 6,
+ order: false,
+ topicName: "",
+ brokerNameList: []
}];
bIsUpdate = false;
}
@@ -325,21 +327,22 @@ module.controller('topicController', ['$scope',
'ngDialog', '$http','Notificatio
method: "GET",
url: "cluster/list.query"
}).success(function (resp) {
- if(resp.status ==0){
+ if (resp.status == 0) {
console.log(resp);
ngDialog.open({
- preCloseCallback: function(value) {
+ preCloseCallback: function (value) {
// Refresh topic list
$scope.refreshTopicList();
},
template: 'topicModifyDialog',
controller: 'topicModifyDialogController',
- data:{
- sysFlag:sysFlag,
- topicRequestList:request,
-
allClusterNameList:Object.keys(resp.data.clusterInfo.clusterAddrTable),
- allBrokerNameList:Object.keys(resp.data.brokerServer),
- bIsUpdate:bIsUpdate
+ data: {
+ sysFlag: sysFlag,
+ topicRequestList: request,
+ allClusterNameList:
Object.keys(resp.data.clusterInfo.clusterAddrTable),
+ allBrokerNameList: Object.keys(resp.data.brokerServer),
+ bIsUpdate: bIsUpdate,
+ writeOperationEnabled: $scope.writeOperationEnabled
}
});
}
@@ -352,7 +355,7 @@ module.controller('topicController', ['$scope', 'ngDialog',
'$http','Notificatio
}]);
-module.controller('topicModifyDialogController', ['$scope', 'ngDialog',
'$http','Notification',function ($scope, ngDialog, $http,Notification) {
+module.controller('topicModifyDialogController', ['$scope', 'ngDialog',
'$http', 'Notification', function ($scope, ngDialog, $http, Notification) {
$scope.postTopicRequest = function (topicRequestItem) {
console.log(topicRequestItem);
var request = JSON.parse(JSON.stringify(topicRequestItem));
@@ -360,19 +363,19 @@ module.controller('topicModifyDialogController',
['$scope', 'ngDialog', '$http',
$http({
method: "POST",
url: "topic/createOrUpdate.do",
- data:request
+ data: request
}).success(function (resp) {
- if(resp.status ==0){
+ if (resp.status == 0) {
Notification.info({message: "success!", delay: 2000});
ngDialog.close(this);
- }else {
+ } else {
Notification.error({message: resp.errMsg, delay: 2000});
}
});
}
}]
);
-module.controller('consumerResetOffsetDialogController',['$scope', 'ngDialog',
'$http','Notification', function ($scope, ngDialog, $http,Notification) {
+module.controller('consumerResetOffsetDialogController', ['$scope',
'ngDialog', '$http', 'Notification', function ($scope, ngDialog, $http,
Notification) {
$scope.timepicker = {};
$scope.timepicker.date = moment().format('YYYY-MM-DD HH:mm');
$scope.timepicker.options = {format: 'YYYY-MM-DD HH:mm', showClear:
true};
@@ -386,19 +389,19 @@
module.controller('consumerResetOffsetDialogController',['$scope', 'ngDialog', '
data: {
resetTime: $scope.timepicker.date.valueOf(),
consumerGroupList:
$scope.ngDialogData.selectedConsumerGroup,
- topic:$scope.ngDialogData.topic,
- force:true
+ topic: $scope.ngDialogData.topic,
+ force: true
}
}).success(function (resp) {
- if(resp.status ==0){
+ if (resp.status == 0) {
ngDialog.open({
template: 'resetOffsetResultDialog',
- data:{
- result:resp.data
+ data: {
+ result: resp.data
}
});
ngDialog.close(this);
- }else {
+ } else {
Notification.error({message: resp.errMsg, delay: 2000});
}
})
@@ -406,7 +409,7 @@
module.controller('consumerResetOffsetDialogController',['$scope', 'ngDialog', '
}]
);
-module.controller('skipMessageAccumulateDialogController',['$scope',
'ngDialog', '$http','Notification', function ($scope, ngDialog,
$http,Notification) {
+module.controller('skipMessageAccumulateDialogController', ['$scope',
'ngDialog', '$http', 'Notification', function ($scope, ngDialog, $http,
Notification) {
$scope.skipAccumulate = function () {
console.log($scope.ngDialogData.selectedConsumerGroup);
$http({
@@ -415,19 +418,19 @@
module.controller('skipMessageAccumulateDialogController',['$scope', 'ngDialog',
data: {
resetTime: -1,
consumerGroupList:
$scope.ngDialogData.selectedConsumerGroup,
- topic:$scope.ngDialogData.topic,
- force:true
+ topic: $scope.ngDialogData.topic,
+ force: true
}
}).success(function (resp) {
- if(resp.status ==0){
+ if (resp.status == 0) {
ngDialog.open({
template: 'resetOffsetResultDialog',
- data:{
- result:resp.data
+ data: {
+ result: resp.data
}
});
ngDialog.close(this);
- }else {
+ } else {
Notification.error({message: resp.errMsg, delay: 2000});
}
})
@@ -435,7 +438,7 @@
module.controller('skipMessageAccumulateDialogController',['$scope', 'ngDialog',
}]
);
-module.controller('sendTopicMessageDialogController', ['$scope', 'ngDialog',
'$http','Notification',function ($scope, ngDialog, $http,Notification) {
+module.controller('sendTopicMessageDialogController', ['$scope', 'ngDialog',
'$http', 'Notification', function ($scope, ngDialog, $http, Notification) {
$scope.sendTopicMessage = {
topic: $scope.ngDialogData.topic,
key: "key",
@@ -449,37 +452,35 @@ module.controller('sendTopicMessageDialogController',
['$scope', 'ngDialog', '$h
url: "topic/sendTopicMessage.do",
data: $scope.sendTopicMessage
}).success(function (resp) {
- if(resp.status ==0){
+ if (resp.status == 0) {
ngDialog.open({
template: 'sendResultDialog',
- data:{
- result:resp.data
+ data: {
+ result: resp.data
}
});
ngDialog.close(this);
- }else {
+ } else {
Notification.error({message: resp.errMsg, delay: 2000});
}
})
}
}]
-
);
-module.controller('routerViewDialogController', ['$scope', 'ngDialog',
'$http','Notification',function ($scope, ngDialog, $http,Notification) {
+module.controller('routerViewDialogController', ['$scope', 'ngDialog',
'$http', 'Notification', function ($scope, ngDialog, $http, Notification) {
$scope.deleteTopicByBroker = function (broker) {
$http({
method: "POST",
url: "topic/deleteTopicByBroker.do",
- params:
{brokerName:broker.brokerName,topic:$scope.ngDialogData.topic}
+ params: {brokerName: broker.brokerName, topic:
$scope.ngDialogData.topic}
}).success(function (resp) {
- if(resp.status ==0){
+ if (resp.status == 0) {
Notification.info({message: "delete success", delay:
2000});
- }else {
+ } else {
Notification.error({message: resp.errMsg, delay: 2000});
}
})
};
}]
-
);
\ No newline at end of file
diff --git a/src/main/resources/static/view/pages/consumer.html
b/src/main/resources/static/view/pages/consumer.html
index cc2fc39..b973ad8 100644
--- a/src/main/resources/static/view/pages/consumer.html
+++ b/src/main/resources/static/view/pages/consumer.html
@@ -25,13 +25,11 @@
<input type="text" class="form-control"
ng-model="filterStr">
</div>
<div class="form-group form-group-sm">
-
- <button class="btn btn-raised btn-sm btn-primary"
type="button" ng-click="openAddDialog()">{{'ADD' |
- translate}}/ {{'UPDATE' | translate}}
+ <button class="btn btn-raised btn-sm btn-primary"
type="button" ng-show="{{writeOperationEnabled}}"
+ ng-click="openAddDialog()">{{'ADD' | translate}}/
{{'UPDATE' | translate}}
</button>
</div>
<div class="form-group form-group-sm">
-
<button class="btn btn-raised btn-sm btn-primary"
type="button" ng-click="refreshConsumerData()">
{{'REFRESH' | translate}}
</button>
@@ -48,8 +46,7 @@
<div id="deployList" class="row">
<table class="table table-bordered">
<tr>
- <th class="text-center"><a
ng-click="sortByKey('group')">{{ 'SUBSCRIPTION_GROUP' |
- translate}}</a></th>
+ <th class="text-center"><a
ng-click="sortByKey('group')">{{ 'SUBSCRIPTION_GROUP' | translate}}</a></th>
<th class="text-center"><a
ng-click="sortByKey('count')">{{ 'QUANTITY' | translate}}</a></th>
<th class="text-center">{{ 'VERSION' | translate}}</th>
<th class="text-center">{{ 'TYPE' | translate}}</th>
@@ -83,6 +80,7 @@
<!--</button>-->
<button name="client"
ng-click="delete(consumerGroup.group)"
class="btn btn-raised btn-sm btn-danger"
+ ng-show="{{writeOperationEnabled}}"
type="button">{{'DELETE' | translate}}
</button>
@@ -242,25 +240,28 @@
<div class="form-group">
<label class="control-label
col-sm-4">consumeEnable:</label>
<div class="col-sm-8">
- <md-switch class="md-primary" md-no-ink
aria-label="Switch No Ink"
ng-model="item.subscriptionGroupConfig.consumeEnable">
+ <md-switch class="md-primary"
ng-disabled="{{!ngDialogData.writeOperationEnabled}}" md-no-ink
+ aria-label="Switch No Ink"
ng-model="item.subscriptionGroupConfig.consumeEnable">
</md-switch>
<!--<input class="form-control"
ng-model="item.subscriptionGroupConfig.consumeEnable"-->
- <!--type="text"-->
- <!--required/>-->
+ <!--type="text"-->
+ <!--required/>-->
<!--<span class="text-danger"
ng-show="addAppForm.name.$error.required">编号不能为空.</span>-->
</div>
</div>
<!--<div class="form-group">-->
- <!--<label class="control-label
col-sm-4">consumeFromMinEnable:</label>-->
- <!--<div class="col-sm-8">-->
- <!--<md-switch class="md-primary" md-no-ink
aria-label="Switch No Ink"
ng-model="item.subscriptionGroupConfig.consumeFromMinEnable">-->
- <!--</md-switch>-->
- <!--</div>-->
+ <!--<label class="control-label
col-sm-4">consumeFromMinEnable:</label>-->
+ <!--<div class="col-sm-8">-->
+ <!--<md-switch class="md-primary" md-no-ink
aria-label="Switch No Ink"
ng-model="item.subscriptionGroupConfig.consumeFromMinEnable">-->
+ <!--</md-switch>-->
+ <!--</div>-->
<!--</div>-->
<div class="form-group">
<label class="control-label
col-sm-4">consumeBroadcastEnable:</label>
<div class="col-sm-8">
- <md-switch class="md-primary" md-no-ink
aria-label="Switch No Ink"
ng-model="item.subscriptionGroupConfig.consumeBroadcastEnable">
+ <md-switch class="md-primary"
ng-disabled="{{!ngDialogData.writeOperationEnabled}}" md-no-ink
+ aria-label="Switch No Ink"
+
ng-model="item.subscriptionGroupConfig.consumeBroadcastEnable">
</md-switch>
</div>
</div>
@@ -268,25 +269,25 @@
<label class="control-label
col-sm-4">retryQueueNums:</label>
<div class="col-sm-8">
<input class="form-control"
ng-model="item.subscriptionGroupConfig.retryQueueNums"
- type="text"
+ type="text"
ng-disabled="{{!ngDialogData.writeOperationEnabled}}"
required/>
<span class="text-danger"
ng-show="addAppForm.name.$error.required">编号不能为空.</span>
</div>
</div>
<!--<div class="form-group">-->
- <!--<label class="control-label
col-sm-4">retryMaxTimes:</label>-->
- <!--<div class="col-sm-8">-->
- <!--<input class="form-control"
ng-model="item.subscriptionGroupConfig.retryMaxTimes"-->
- <!--type="text"-->
- <!--required/>-->
- <!--<span class="text-danger"
ng-show="addAppForm.name.$error.required">编号不能为空.</span>-->
- <!--</div>-->
+ <!--<label class="control-label
col-sm-4">retryMaxTimes:</label>-->
+ <!--<div class="col-sm-8">-->
+ <!--<input class="form-control"
ng-model="item.subscriptionGroupConfig.retryMaxTimes"-->
+ <!--type="text"-->
+ <!--required/>-->
+ <!--<span class="text-danger"
ng-show="addAppForm.name.$error.required">编号不能为空.</span>-->
+ <!--</div>-->
<!--</div>-->
<div class="form-group">
<label class="control-label col-sm-4">brokerId:</label>
<div class="col-sm-8">
<input class="form-control"
ng-model="item.subscriptionGroupConfig.brokerId" type="text"
- required/>
+
ng-disabled="{{!ngDialogData.writeOperationEnabled}}" required/>
<span class="text-danger"
ng-show="addAppForm.name.$error.required">编号不能为空.</span>
</div>
</div>
@@ -295,18 +296,26 @@
<div class="col-sm-8">
<input class="form-control"
ng-model="item.subscriptionGroupConfig.whichBrokerWhenConsumeSlowly" type="text"
- required/>
+
ng-disabled="{{!ngDialogData.writeOperationEnabled}}" required/>
<span class="text-danger"
ng-show="addAppForm.name.$error.required">编号不能为空.</span>
</div>
</div>
</form>
<div class="modal-footer">
- <button type="button" class="btn btn-raised btn-primary"
ng-disabled="addAppForm.$invalid"
- ng-click="postConsumerRequest(item)">{{ 'COMMIT' |
translate }}
- </button>
+ <div class="ngdialog-buttons">
+ <button type="button" class="ngdialog-button
ngdialog-button-primary"
+ ng-disabled="addAppForm.$invalid"
+
ng-show="{{ngDialogData.writeOperationEnabled}}"
+ ng-click="postConsumerRequest(item)">{{
'COMMIT' | translate }}
+ </button>
+ <button type="button" class="ngdialog-button
ngdialog-button-secondary"
+ ng-click="closeThisDialog('Cancel')">{{
'CLOSE' | translate }}
+ </button>
+ </div>
</div>
</div>
</div>
+ </div>
</div>
</script>
@@ -396,7 +405,9 @@
<td><label>{{ 'DELAY' | translate }}</label></td>
<td>{{consumeDetail.diffTotal}}</td>
<td><label>{{ 'LAST_CONSUME_TIME' | translate
}}</label></td>
- <td>{{(consumeDetail.lastTimestamp ==
0)?"N/A":consumeDetail.lastTimestamp | date:'yyyy-MM-dd HH:mm:ss'}}</td>
+ <td>{{(consumeDetail.lastTimestamp ==
0)?"N/A":consumeDetail.lastTimestamp |
+ date:'yyyy-MM-dd HH:mm:ss'}}
+ </td>
</tr>
</table>
</td>
@@ -422,7 +433,8 @@
<td class="text-center">{{item.brokerOffset}}</td>
<td
class="text-center">{{item.consumerOffset}}</td>
<td
class="text-center">{{item.brokerOffset-item.consumerOffset}}</td>
- <td class="text-center">{{(item.lastTimestamp ==
0)?"N/A":item.lastTimestamp | date:'yyyy-MM-dd HH:mm:ss'}}</td>
+ <td class="text-center">{{(item.lastTimestamp ==
0)?"N/A":item.lastTimestamp | date:'yyyy-MM-dd HH:mm:ss'}}
+ </td>
</tr>
</table>
</td>
diff --git a/src/main/resources/static/view/pages/message.html
b/src/main/resources/static/view/pages/message.html
index 54d9b95..2c200b6 100644
--- a/src/main/resources/static/view/pages/message.html
+++ b/src/main/resources/static/view/pages/message.html
@@ -41,7 +41,8 @@
<div class="form-group ">
<label>{{'BEGIN' | translate}}:</label>
<div class="input-group">
- <input class="form-control"
datetimepicker ng-change="onChangeQueryCondition()" ng-model="timepickerBegin"
+ <input class="form-control"
datetimepicker
+
ng-change="onChangeQueryCondition()" ng-model="timepickerBegin"
options="timepickerOptions"/>
<span
class="input-group-addon"><span
class="glyphicon
glyphicon-calendar"></span></span>
@@ -50,7 +51,8 @@
<div class="form-group">
<label>{{'END' | translate}}:</label>
<div class="input-group">
- <input class="form-control"
datetimepicker ng-change="onChangeQueryCondition()" ng-model="timepickerEnd"
+ <input class="form-control"
datetimepicker
+
ng-change="onChangeQueryCondition()" ng-model="timepickerEnd"
options="timepickerOptions"/>
<span
class="input-group-addon"><span
class="glyphicon
glyphicon-calendar"></span></span>
@@ -79,8 +81,7 @@
</td>
<td class="text-center">
<button class="btn btn-raised
btn-sm btn-primary" type="button"
-
ng-click="queryMessageByMessageId(item.msgId,item.topic)">Message
- Detail
+
ng-click="queryMessageByMessageId(item.msgId,item.topic)">{{'MESSAGE_DETAIL' |
translate}}
</button>
</td>
</tr>
@@ -237,11 +238,11 @@
<td class="text-center">
<button class="btn btn-raised btn-sm btn-primary"
type="button"
ng-click="resendMessage(ngDialogData.messageView,item.consumerGroup)">
- Resend Message
+ {{ 'RESEND_MESSAGE' | translate}}
</button>
<button class="btn btn-raised btn-sm btn-primary"
type="button"
ng-click="showExceptionDesc(item.exceptionDesc)">
- View Exception
+ {{ 'VIEW_EXCEPTION' | translate}}
</button>
</td>
</tr>
diff --git a/src/main/resources/static/view/pages/ops.html
b/src/main/resources/static/view/pages/ops.html
index ba8c098..97c7b56 100644
--- a/src/main/resources/static/view/pages/ops.html
+++ b/src/main/resources/static/view/pages/ops.html
@@ -18,21 +18,24 @@
<div class="page-content">
<h2 class="md-title">NameServerAddressList</h2>
<div class="pull-left">
- <input type="text" class="form-control" ng-model="namesvrAddrList"
/>
+ <input type="text" class="form-control" ng-model="namesvrAddrList"
ng-disabled="{{!writeOperationEnabled}}"/>
</div>
<div class="pull-left">
- <button class="btn btn-raised btn-sm btn-primary" type="button"
ng-click="updateNameSvrAddr()">{{'UPDATE' | translate}}
+ <button class="btn btn-raised btn-sm btn-primary" type="button"
ng-show="{{writeOperationEnabled}}"
+ ng-click="updateNameSvrAddr()">{{'UPDATE' | translate}}
</button>
</div>
<br/>
<br/>
<h2 class="md-title">IsUseVIPChannel</h2>
- <div class="pull-left">
- <md-switch class="md-primary" md-no-ink aria-label="Switch No Ink"
ng-model="useVIPChannel">
+ <div class="pull-left">
+ <md-switch class="md-primary"
ng-disabled="{{!writeOperationEnabled}}" md-no-ink aria-label="Switch No Ink"
+ ng-model="useVIPChannel">
</md-switch>
</div>
<div class="pull-left">
- <button class="btn btn-raised btn-sm btn-primary" type="button"
ng-click="updateIsVIPChannel()">{{'UPDATE' | translate}}
+ <button class="btn btn-raised btn-sm btn-primary" type="button"
ng-show="{{writeOperationEnabled}}"
+ ng-click="updateIsVIPChannel()">{{'UPDATE' | translate}}
</button>
</div>
@@ -40,12 +43,14 @@
<br/>
<br/>
<h2 class="md-title">useTLS</h2>
- <div class="pull-left">
- <md-switch class="md-primary" md-no-ink aria-label="Switch No Ink"
ng-model="useTLS">
+ <div class="pull-left">
+ <md-switch class="md-primary"
ng-disabled="{{!writeOperationEnabled}}" md-no-ink aria-label="Switch No Ink"
+ ng-model="useTLS">
</md-switch>
</div>
<div class="pull-left">
- <button class="btn btn-raised btn-sm btn-primary" type="button"
ng-click="updateUseTLS()">{{'UPDATE' | translate}}
+ <button class="btn btn-raised btn-sm btn-primary" type="button"
ng-show="{{writeOperationEnabled}}"
+ ng-click="updateUseTLS()">{{'UPDATE' | translate}}
</button>
</div>
</div>
diff --git a/src/main/resources/static/view/pages/topic.html
b/src/main/resources/static/view/pages/topic.html
index f74c3e8..d28f676 100644
--- a/src/main/resources/static/view/pages/topic.html
+++ b/src/main/resources/static/view/pages/topic.html
@@ -30,8 +30,8 @@
</md-checkbox>
<md-checkbox aria-label="Checkbox" ng-model="filterSystem"
class="md-primary">{{'SYSTEM' | translate}}
</md-checkbox>
- <button class="btn btn-raised btn-sm btn-primary"
type="button" ng-click="openAddDialog()">{{'ADD' |
- translate}}/ {{'UPDATE' | translate}}
+ <button class="btn btn-raised btn-sm btn-primary"
type="button" ng-show="{{writeOperationEnabled}}"
+ ng-click="openAddDialog()">{{'ADD' | translate}}/
{{'UPDATE' | translate}}
</button>
<button class="btn btn-raised btn-sm btn-primary"
type="button" ng-click="refreshTopicList()">
{{'REFRESH' | translate}}
@@ -68,15 +68,16 @@
ng-click="openSendTopicMessageDialog(topic)">{{'SEND_MSG' | translate}}
</button>
<button class="btn btn-raised btn-sm btn-danger"
type="button"
- ng-show="{{!sysFlag}}"
+ ng-show="{{!sysFlag &&
writeOperationEnabled}}"
ng-click="openConsumerResetOffsetDialog(topic)">{{'RESET_CUS_OFFSET' |
translate}}
</button>
<button class="btn btn-raised btn-sm btn-danger"
type="button"
- ng-show="{{!sysFlag}}"
-
ng-click="openSkipMessageAccumulateDialog(topic)">{{'SKIP_MESSAGE_ACCUMULATE' |
translate}}
+ ng-show="{{!sysFlag &&
writeOperationEnabled}}"
+
ng-click="openSkipMessageAccumulateDialog(topic)">{{'SKIP_MESSAGE_ACCUMULATE' |
+ translate}}
</button>
<button class="btn btn-raised btn-sm btn-danger"
type="button"
- ng-show="{{!sysFlag}}"
+ ng-show="{{!sysFlag &&
writeOperationEnabled}}"
ng-confirm-click="Are you sure to delete?"
confirmed-click="deleteTopic(topic)">{{'DELETE' | translate}}
</button>
@@ -192,7 +193,7 @@
<label class="control-label
col-sm-2">{{'WRITE_QUEUE_NUMS'|translate}}:</label>
<div class="col-sm-10">
<input class="form-control" ng-model="item.writeQueueNums"
name="writeQueueNums" type="text"
- required/>
+
ng-disabled="{{!ngDialogData.writeOperationEnabled}}" required/>
<span class="text-danger"
ng-show="addAppForm.writeQueueNums.$error.required">{{'WRITE_QUEUE_NUMS'|translate}}不能为空.</span>
</div>
</div>
@@ -200,7 +201,7 @@
<label class="control-label
col-sm-2">{{'READ_QUEUE_NUMS'|translate}}:</label>
<div class="col-sm-10">
<input class="form-control" ng-model="item.readQueueNums"
name="readQueueNums" type="text"
- required/>
+
ng-disabled="{{!ngDialogData.writeOperationEnabled}}" required/>
<span class="text-danger"
ng-show="addAppForm.readQueueNums.$error.required">{{'READ_QUEUE_NUMS'|translate}}不能为空.</span>
</div>
</div>
@@ -208,7 +209,7 @@
<label class="control-label
col-sm-2">{{'PERM'|translate}}:</label>
<div class="col-sm-10">
<input class="form-control" ng-model="item.perm"
name="perm" type="text"
- required/>
+
ng-disabled="{{!ngDialogData.writeOperationEnabled}}" required/>
<span class="text-danger"
ng-show="addAppForm.perm.$error.required">{{'PERM'|translate}}不能为空.</span>
</div>
</div>
@@ -216,7 +217,7 @@
<div class="modal-footer">
<div class="ngdialog-buttons">
<button type="button" class="ngdialog-button
ngdialog-button-primary"
- ng-show="{{!ngDialogData.sysFlag}}"
+ ng-show="{{!ngDialogData.sysFlag &&
ngDialogData.writeOperationEnabled}}"
ng-click="postTopicRequest(item)">{{ 'COMMIT' |
translate }}
</button>
<button type="button" class="ngdialog-button
ngdialog-button-secondary"
diff --git
a/src/test/java/org/apache/rocketmq/dashboard/controller/LoginControllerTest.java
b/src/test/java/org/apache/rocketmq/dashboard/controller/LoginControllerTest.java
index dac3a2d..538bdca 100644
---
a/src/test/java/org/apache/rocketmq/dashboard/controller/LoginControllerTest.java
+++
b/src/test/java/org/apache/rocketmq/dashboard/controller/LoginControllerTest.java
@@ -96,7 +96,7 @@ public class LoginControllerTest extends BaseControllerTest {
.param("password", rightPwd);
perform = mockMvc.perform(requestBuilder);
perform.andExpect(status().isOk())
- .andExpect(jsonPath("$.data").value(contextPath));
+ .andExpect(jsonPath("$.data.contextPath").value(contextPath));
}