NO-JIRA Fix indention in browser.js

This commit is contained in:
Sebastian Thomschke 2019-11-06 13:50:33 +01:00 committed by GitHub
parent b733ea4c79
commit a1266e63f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 437 additions and 460 deletions

View File

@ -19,69 +19,59 @@
*/ */
var ARTEMIS = (function(ARTEMIS) { var ARTEMIS = (function(ARTEMIS) {
ARTEMIS.BrowseQueueController = function ($scope, workspace, ARTEMISService, jolokia, localStorage, artemisMessage, $location, $timeout) { ARTEMIS.BrowseQueueController = function($scope, workspace, ARTEMISService, jolokia, localStorage, artemisMessage, $location, $timeout) {
var defaultAttributes = [ var defaultAttributes = [{
{
field: 'messageID', field: 'messageID',
displayName: 'Message ID', displayName: 'Message ID',
cellTemplate: '<div class="ngCellText"><a ng-click="openMessageDialog(row)">{{row.entity.messageID}}</a></div>', cellTemplate: '<div class="ngCellText"><a ng-click="openMessageDialog(row)">{{row.entity.messageID}}</a></div>',
// for ng-grid // for ng-grid
width: '10%' width: '10%'
}, }, {
{
field: 'userID', field: 'userID',
displayName: 'User ID', displayName: 'User ID',
width: '10%' width: '10%'
}, }, {
{
field: 'type', field: 'type',
displayName: 'Type', displayName: 'Type',
width: '10%' width: '10%'
}, }, {
{
field: 'durable', field: 'durable',
displayName: 'Durable', displayName: 'Durable',
width: '10%' width: '10%'
}, }, {
{
field: 'priority', field: 'priority',
displayName: 'Priority', displayName: 'Priority',
width: '7%' width: '7%'
}, }, {
{
field: 'timestamp', field: 'timestamp',
displayName: 'Timestamp', displayName: 'Timestamp',
width: '19%' width: '19%'
}, }, {
{
field: 'expiration', field: 'expiration',
displayName: 'Expires', displayName: 'Expires',
width: '10%' width: '10%'
}, }, {
{
field: 'redelivered', field: 'redelivered',
displayName: 'Redelivered', displayName: 'Redelivered',
width: '10%' width: '10%'
}, }, {
{
field: 'largeMessage', field: 'largeMessage',
displayName: 'Large', displayName: 'Large',
width: '10%' width: '10%'
} }];
];
var attributes = defaultAttributes; var attributes = defaultAttributes;
if (sessionStorage.getItem('browseColumnDefs')) { if (sessionStorage.getItem('browseColumnDefs')) {
attributes = JSON.parse(sessionStorage.getItem('browseColumnDefs')); attributes = JSON.parse(sessionStorage.getItem('browseColumnDefs'));
} }
$scope.$on('ngGridEventColumns', function (newColumns) { $scope.$on('ngGridEventColumns', function(newColumns) {
ARTEMIS.log.debug('ngGridEventColumns:', newColumns); ARTEMIS.log.debug('ngGridEventColumns:', newColumns);
var visibles = newColumns.targetScope.columns.reduce(function (visibles, column) { var visibles = newColumns.targetScope.columns.reduce(function(visibles, column) {
visibles[column.field] = column.visible; visibles[column.field] = column.visible;
return visibles; return visibles;
}, {}); }, {});
ARTEMIS.log.debug('ngGridEventColumns: visibles =', visibles); ARTEMIS.log.debug('ngGridEventColumns: visibles =', visibles);
attributes.forEach(function (attribute) { attributes.forEach(function(attribute) {
attribute.visible = visibles[attribute.field]; attribute.visible = visibles[attribute.field];
}); });
sessionStorage.setItem('browseColumnDefs', JSON.stringify(attributes)); sessionStorage.setItem('browseColumnDefs', JSON.stringify(attributes));
@ -125,17 +115,17 @@ var ARTEMIS = (function(ARTEMIS) {
$scope.showMessageDetails = false; $scope.showMessageDetails = false;
var ignoreColumns = ["PropertiesText", "BodyPreview", "text"]; var ignoreColumns = ["PropertiesText", "BodyPreview", "text"];
var flattenColumns = ["BooleanProperties", "ByteProperties", "ShortProperties", "IntProperties", "LongProperties", "FloatProperties", "DoubleProperties", "StringProperties"]; var flattenColumns = ["BooleanProperties", "ByteProperties", "ShortProperties", "IntProperties", "LongProperties", "FloatProperties", "DoubleProperties", "StringProperties"];
$scope.$watch('workspace.selection', function () { $scope.$watch('workspace.selection', function() {
if (workspace.moveIfViewInvalid()) { if (workspace.moveIfViewInvalid()) {
return; return;
} }
// lets defer execution as we may not have the selection just yet // lets defer execution as we may not have the selection just yet
setTimeout(loadTable, 50); setTimeout(loadTable, 50);
}); });
$scope.$watch('gridOptions.filterOptions.filterText', function (filterText) { $scope.$watch('gridOptions.filterOptions.filterText', function(filterText) {
filterMessages(filterText); filterMessages(filterText);
}); });
$scope.$watch('pagingOptions', function (newVal, oldVal) { $scope.$watch('pagingOptions', function(newVal, oldVal) {
if (parseInt(newVal.currentPage) && newVal !== oldVal && newVal.currentPage !== oldVal.currentPage) { if (parseInt(newVal.currentPage) && newVal !== oldVal && newVal.currentPage !== oldVal.currentPage) {
loadTable(); loadTable();
} }
@ -144,7 +134,7 @@ var ARTEMIS = (function(ARTEMIS) {
loadTable(); loadTable();
} }
}, true); }, true);
$scope.openMessageDialog = function (message) { $scope.openMessageDialog = function(message) {
ARTEMIS.selectCurrentMessage(message, "messageID", $scope); ARTEMIS.selectCurrentMessage(message, "messageID", $scope);
if ($scope.row) { if ($scope.row) {
$scope.mode = CodeEditor.detectTextFormat($scope.row.Text); $scope.mode = CodeEditor.detectTextFormat($scope.row.Text);
@ -153,13 +143,13 @@ var ARTEMIS = (function(ARTEMIS) {
}; };
$scope.refresh = loadTable; $scope.refresh = loadTable;
ARTEMIS.decorate($scope); ARTEMIS.decorate($scope);
$scope.moveMessages = function () { $scope.moveMessages = function() {
var selection = workspace.selection; var selection = workspace.selection;
var mbean = selection.objectName; var mbean = selection.objectName;
if (mbean && selection) { if (mbean && selection) {
var selectedItems = $scope.gridOptions.selectedItems; var selectedItems = $scope.gridOptions.selectedItems;
$scope.message = "Moved " + Core.maybePlural(selectedItems.length, "message" + " to " + $scope.queueName); $scope.message = "Moved " + Core.maybePlural(selectedItems.length, "message" + " to " + $scope.queueName);
angular.forEach(selectedItems, function (item, idx) { angular.forEach(selectedItems, function(item, idx) {
var id = item.messageID; var id = item.messageID;
if (id) { if (id) {
var callback = (idx + 1 < selectedItems.length) ? intermediateResult : moveSuccess; var callback = (idx + 1 < selectedItems.length) ? intermediateResult : moveSuccess;
@ -168,23 +158,23 @@ var ARTEMIS = (function(ARTEMIS) {
}); });
} }
}; };
$scope.resendMessage = function () { $scope.resendMessage = function() {
var selection = workspace.selection; var selection = workspace.selection;
var mbean = selection.objectName; var mbean = selection.objectName;
if (mbean && selection) { if (mbean && selection) {
var selectedItems = $scope.gridOptions.selectedItems; var selectedItems = $scope.gridOptions.selectedItems;
//always assume a single message // always assume a single message
artemisMessage.message = selectedItems[0]; artemisMessage.message = selectedItems[0];
$location.path('artemis/sendMessage'); $location.path('artemis/sendMessage');
} }
}; };
$scope.deleteMessages = function () { $scope.deleteMessages = function() {
var selection = workspace.selection; var selection = workspace.selection;
var mbean = selection.objectName; var mbean = selection.objectName;
if (mbean && selection) { if (mbean && selection) {
var selectedItems = $scope.gridOptions.selectedItems; var selectedItems = $scope.gridOptions.selectedItems;
$scope.message = "Deleted " + Core.maybePlural(selectedItems.length, "message"); $scope.message = "Deleted " + Core.maybePlural(selectedItems.length, "message");
angular.forEach(selectedItems, function (item, idx) { angular.forEach(selectedItems, function(item, idx) {
var id = item.messageID; var id = item.messageID;
if (id) { if (id) {
var callback = (idx + 1 < selectedItems.length) ? intermediateResult : operationSuccess; var callback = (idx + 1 < selectedItems.length) ? intermediateResult : operationSuccess;
@ -193,13 +183,13 @@ var ARTEMIS = (function(ARTEMIS) {
}); });
} }
}; };
$scope.retryMessages = function () { $scope.retryMessages = function() {
var selection = workspace.selection; var selection = workspace.selection;
var mbean = selection.objectName; var mbean = selection.objectName;
if (mbean && selection) { if (mbean && selection) {
var selectedItems = $scope.gridOptions.selectedItems; var selectedItems = $scope.gridOptions.selectedItems;
$scope.message = "Retry " + Core.maybePlural(selectedItems.length, "message"); $scope.message = "Retry " + Core.maybePlural(selectedItems.length, "message");
angular.forEach(selectedItems, function (item, idx) { angular.forEach(selectedItems, function(item, idx) {
var id = item.messageID; var id = item.messageID;
if (id) { if (id) {
var callback = (idx + 1 < selectedItems.length) ? intermediateResult : operationSuccess; var callback = (idx + 1 < selectedItems.length) ? intermediateResult : operationSuccess;
@ -208,18 +198,17 @@ var ARTEMIS = (function(ARTEMIS) {
}); });
} }
}; };
$scope.queueNames = function (completionText) { $scope.queueNames = function(completionText) {
var queuesFolder = ARTEMIS.getSelectionQueuesFolder(workspace); var queuesFolder = ARTEMIS.getSelectionQueuesFolder(workspace);
if (queuesFolder) { if (queuesFolder) {
var selectedQueue = workspace.selection.key; var selectedQueue = workspace.selection.key;
var otherQueues = queuesFolder.children.exclude(function (child) { var otherQueues = queuesFolder.children.exclude(function(child) {
return child.key == selectedQueue; return child.key == selectedQueue;
}); });
return (otherQueues) ? otherQueues.map(function (n) { return (otherQueues) ? otherQueues.map(function(n) {
return n.title; return n.title;
}) : []; }) : [];
} } else {
else {
return []; return [];
} }
}; };
@ -229,14 +218,13 @@ var ARTEMIS = (function(ARTEMIS) {
if (!angular.isArray(data)) { if (!angular.isArray(data)) {
$scope.allMessages = []; $scope.allMessages = [];
angular.forEach(data, function (value, idx) { angular.forEach(data, function(value, idx) {
$scope.allMessages.push(value); $scope.allMessages.push(value);
}); });
} } else {
else {
$scope.allMessages = data; $scope.allMessages = data;
} }
angular.forEach($scope.allMessages, function (message) { angular.forEach($scope.allMessages, function(message) {
message.headerHtml = createHeaderHtml(message); message.headerHtml = createHeaderHtml(message);
message.bodyText = createBodyText(message); message.bodyText = createBodyText(message);
}); });
@ -256,15 +244,14 @@ var ARTEMIS = (function(ARTEMIS) {
var lenTxt = "" + body.length; var lenTxt = "" + body.length;
message.textMode = "text (" + lenTxt + " chars)"; message.textMode = "text (" + lenTxt + " chars)";
return body; return body;
} } else if (message.BodyPreview) {
else if (message.BodyPreview) {
var code = Core.parseIntValue(localStorage["ARTEMISBrowseBytesMessages"] || "1", "browse bytes messages"); var code = Core.parseIntValue(localStorage["ARTEMISBrowseBytesMessages"] || "1", "browse bytes messages");
var body; var body;
message.textMode = "bytes (turned off)"; message.textMode = "bytes (turned off)";
if (code != 99) { if (code != 99) {
var bytesArr = []; var bytesArr = [];
var textArr = []; var textArr = [];
message.BodyPreview.forEach(function (b) { message.BodyPreview.forEach(function(b) {
if (code === 1 || code === 2) { if (code === 1 || code === 2) {
// text // text
textArr.push(String.fromCharCode(b)); textArr.push(String.fromCharCode(b));
@ -276,8 +263,7 @@ var ARTEMIS = (function(ARTEMIS) {
s = "0" + s; s = "0" + s;
} }
bytesArr.push(s); bytesArr.push(s);
} } else {
else {
// just show as is without spacing out, as that is usually more used for hex than decimal // just show as is without spacing out, as that is usually more used for hex than decimal
var s = b.toString(10); var s = b.toString(10);
bytesArr.push(s); bytesArr.push(s);
@ -291,8 +277,7 @@ var ARTEMIS = (function(ARTEMIS) {
var lenTxt = "" + textArr.length; var lenTxt = "" + textArr.length;
body = "bytes:\n" + bytesData + "\n\ntext:\n" + textData; body = "bytes:\n" + bytesData + "\n\ntext:\n" + textData;
message.textMode = "bytes (" + len + " bytes) and text (" + lenTxt + " chars)"; message.textMode = "bytes (" + len + " bytes) and text (" + lenTxt + " chars)";
} } else {
else {
// bytes only // bytes only
var len = message.BodyPreview.length; var len = message.BodyPreview.length;
body = bytesData; body = bytesData;
@ -300,8 +285,7 @@ var ARTEMIS = (function(ARTEMIS) {
} }
} }
return body; return body;
} } else {
else {
message.textMode = "unsupported"; message.textMode = "unsupported";
return "Unsupported message body type which cannot be displayed by hawtio"; return "Unsupported message body type which cannot be displayed by hawtio";
} }
@ -325,7 +309,7 @@ var ARTEMIS = (function(ARTEMIS) {
} }
var propertiesKeys = Object.extended(properties).keys().sort(sort); var propertiesKeys = Object.extended(properties).keys().sort(sort);
var jmsHeaders = headerKeys.filter(function (key) { var jmsHeaders = headerKeys.filter(function(key) {
return key.startsWith("JMS"); return key.startsWith("JMS");
}).sort(sort); }).sort(sort);
var remaining = headerKeys.subtract(jmsHeaders, propertiesKeys).sort(sort); var remaining = headerKeys.subtract(jmsHeaders, propertiesKeys).sort(sort);
@ -355,7 +339,7 @@ var ARTEMIS = (function(ARTEMIS) {
function createHeaders(row) { function createHeaders(row) {
var answer = {}; var answer = {};
angular.forEach(row, function (value, key) { angular.forEach(row, function(value, key) {
if (!ignoreColumns.any(key) && !flattenColumns.any(key)) { if (!ignoreColumns.any(key) && !flattenColumns.any(key)) {
answer[Core.escapeHtml(key)] = Core.escapeHtml(value); answer[Core.escapeHtml(key)] = Core.escapeHtml(value);
} }
@ -366,9 +350,9 @@ var ARTEMIS = (function(ARTEMIS) {
function createProperties(row) { function createProperties(row) {
ARTEMIS.log.debug("properties: ", row); ARTEMIS.log.debug("properties: ", row);
var answer = {}; var answer = {};
angular.forEach(row, function (value, key) { angular.forEach(row, function(value, key) {
if (!ignoreColumns.any(key) && flattenColumns.any(key)) { if (!ignoreColumns.any(key) && flattenColumns.any(key)) {
angular.forEach(value, function (v2, k2) { angular.forEach(value, function(v2, k2) {
answer['<span class="green">' + key.replace('Properties', ' Property') + '</span> - ' + Core.escapeHtml(k2)] = Core.escapeHtml(v2); answer['<span class="green">' + key.replace('Properties', ' Property') + '</span> - ' + Core.escapeHtml(k2)] = Core.escapeHtml(v2);
}); });
} }
@ -382,8 +366,7 @@ var ARTEMIS = (function(ARTEMIS) {
$scope.gridOptions.selectedItems.length = 0; $scope.gridOptions.selectedItems.length = 0;
if (workspace.selection) { if (workspace.selection) {
objName = workspace.selection.objectName; objName = workspace.selection.objectName;
} } else {
else {
// in case of refresh // in case of refresh
var key = location.search()['nid']; var key = location.search()['nid'];
var node = workspace.keyToNodeMap[key]; var node = workspace.keyToNodeMap[key];
@ -398,8 +381,7 @@ var ARTEMIS = (function(ARTEMIS) {
ARTEMIS.log.info("loading table" + artemisExpiryQueue); ARTEMIS.log.info("loading table" + artemisExpiryQueue);
if (queueName == artemisDLQ || queueName == artemisExpiryQueue) { if (queueName == artemisDLQ || queueName == artemisExpiryQueue) {
onDlq(true); onDlq(true);
} } else {
else {
onDlq(false); onDlq(false);
} }
jolokia.request({ type: 'exec', mbean: objName, operation: 'countMessages()'}, onSuccess(function(response) {$scope.totalServerItems = response.value;})); jolokia.request({ type: 'exec', mbean: objName, operation: 'countMessages()'}, onSuccess(function(response) {$scope.totalServerItems = response.value;}));
@ -437,17 +419,15 @@ var ARTEMIS = (function(ARTEMIS) {
function evalFilter(searchConditions) { function evalFilter(searchConditions) {
if (!searchConditions || searchConditions.length === 0) { if (!searchConditions || searchConditions.length === 0) {
$scope.messages = $scope.allMessages; $scope.messages = $scope.allMessages;
} } else {
else {
ARTEMIS.log.debug("Filtering conditions:", searchConditions); ARTEMIS.log.debug("Filtering conditions:", searchConditions);
$scope.messages = $scope.allMessages.filter(function (message) { $scope.messages = $scope.allMessages.filter(function(message) {
ARTEMIS.log.debug("Message:", message); ARTEMIS.log.debug("Message:", message);
var matched = true; var matched = true;
$.each(searchConditions, function (index, condition) { $.each(searchConditions, function(index, condition) {
if (!condition.column) { if (!condition.column) {
matched = matched && evalMessage(message, condition.regex); matched = matched && evalMessage(message, condition.regex);
} } else {
else {
matched = matched && (message[condition.column] && condition.regex.test(message[condition.column])) || (message.StringProperties && message.StringProperties[condition.column] && condition.regex.test(message.StringProperties[condition.column])); matched = matched && (message[condition.column] && condition.regex.test(message[condition.column])) || (message.StringProperties && message.StringProperties[condition.column] && condition.regex.test(message.StringProperties[condition.column]));
} }
}); });
@ -465,7 +445,7 @@ var ARTEMIS = (function(ARTEMIS) {
} }
} }
if (message.StringProperties) { if (message.StringProperties) {
for (var property in message.StringProperties) { for ( var property in message.StringProperties) {
if (regex.test(message.StringProperties[property])) { if (regex.test(message.StringProperties[property])) {
return true; return true;
} }
@ -480,8 +460,7 @@ var ARTEMIS = (function(ARTEMIS) {
function getRegExp(str, modifiers) { function getRegExp(str, modifiers) {
try { try {
return new RegExp(str, modifiers); return new RegExp(str, modifiers);
} } catch (err) {
catch (err) {
return new RegExp(str.replace(/(\^|\$|\(|\)|<|>|\[|\]|\{|\}|\\|\||\.|\*|\+|\?)/g, '\\$1')); return new RegExp(str.replace(/(\^|\$|\(|\)|<|>|\[|\]|\{|\}|\\|\||\.|\*|\+|\?)/g, '\\$1'));
} }
} }
@ -505,8 +484,7 @@ var ARTEMIS = (function(ARTEMIS) {
regex: getRegExp(columnValue, 'i') regex: getRegExp(columnValue, 'i')
}); });
} }
} } else {
else {
var val = $.trim(args[0]); var val = $.trim(args[0]);
if (val) { if (val) {
searchConditions.push({ searchConditions.push({
@ -523,8 +501,7 @@ var ARTEMIS = (function(ARTEMIS) {
if (checkAll === void 0) { if (checkAll === void 0) {
// then row was clicked, not select-all checkbox // then row was clicked, not select-all checkbox
$scope.gridOptions['$gridScope'].allSelected = rowItem.config.selectedItems.length == $scope.messages.length; $scope.gridOptions['$gridScope'].allSelected = rowItem.config.selectedItems.length == $scope.messages.length;
} } else {
else {
$scope.gridOptions['$gridScope'].allSelected = checkAll; $scope.gridOptions['$gridScope'].allSelected = checkAll;
} }
} }
@ -535,4 +512,4 @@ var ARTEMIS = (function(ARTEMIS) {
} }
return ARTEMIS; return ARTEMIS;
} (ARTEMIS || {})); }(ARTEMIS || {}));