Skip to content

Commit

Permalink
add next/previous/first/last buttons when viewing the detail view of …
Browse files Browse the repository at this point in the history
…a table
  • Loading branch information
jstrachan committed Apr 30, 2013
1 parent 58b7f25 commit 4a096e5
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 23 deletions.
14 changes: 7 additions & 7 deletions hawtio-web/src/main/webapp/app/activemq/html/browseQueue.html
Expand Up @@ -31,18 +31,18 @@
</div>
</div>
<div ng-switch-when="true">
<form class="form-horizontal no-bottom-margin" ng-submit="messageDialog.close()">
<form class="form-horizontal no-bottom-margin">
<div class="row-fluid">
<div class="span8">
<h4>Message {{row.JMSMessageID}}</h4>
</div>
<div class="pull-right">
<button class="btn" ng-click="messageDialog.first()"><i class="icon-fast-backward"></i></button>
<button class="btn" ng-click="messageDialog.previous()"><i class="icon-step-backward"></i></button>
<button class="btn" ng-click="messageDialog.next()"><i class="icon-step-forward"></i></button>
<button class="btn" ng-click="messageDialog.last()"><i class="icon-fast-forward"></i></button>
<button class="btn" ng-click="messageDialog.close()" title="Closes the message detail view"><i
class="icon-eject"></i></button>
<button class="btn" ng-disabled="messageDialog.isEmptyOrFirst()" ng-click="messageDialog.first()"><i class="icon-fast-backward"></i></button>
<button class="btn" ng-disabled="messageDialog.isEmptyOrFirst()" ng-click="messageDialog.previous()"><i class="icon-step-backward"></i></button>
<button class="btn" ng-disabled="messageDialog.isEmptyOrLast()" ng-click="messageDialog.next()"><i class="icon-step-forward"></i></button>
<button class="btn" ng-disabled="messageDialog.isEmptyOrLast()" ng-click="messageDialog.last()"><i class="icon-fast-forward"></i></button>
<button class="btn" ng-click="messageDialog.close()" title="Closes the message detail view">
<i class="icon-eject"></i></button>
</div>
</div>
<div class="row-fluid">
Expand Down
25 changes: 9 additions & 16 deletions hawtio-web/src/main/webapp/app/activemq/js/browse.ts
@@ -1,16 +1,13 @@
module ActiveMQ {
export function BrowseQueueController($scope, workspace:Workspace) {
export function BrowseQueueController($scope, workspace:Workspace, jolokia) {

$scope.searchText = '';

$scope.messages = [];
$scope.headers = {};

$scope.deleteDialog = false
$scope.messageDialog = new Core.Dialog();
$scope.moveDialog = false

$scope.showMoveDialog = false;
$scope.deleteDialog = false;
$scope.moveDialog = false;

$scope.gridOptions = {
selectedItems: [],
Expand Down Expand Up @@ -66,11 +63,10 @@ module ActiveMQ {
displayName: 'Correlation ID',
width: '10%'
}
]//,
/*
rowDetailTemplateId: "activemqMessageTemplate"*/
]
};

$scope.messageDialog = new Core.TableDetailDialog($scope, $scope.gridOptions);

var ignoreColumns = ["PropertiesText", "BodyPreview", "Text"];
var flattenColumns = ["BooleanProperties", "ByteProperties", "ShortProperties", "IntProperties", "LongProperties", "FloatProperties",
Expand All @@ -84,20 +80,20 @@ module ActiveMQ {
});

$scope.openMessageDialog = (message) => {
$scope.rowIndex = Core.pathGet(message, ["rowIndex"]);
$scope.row = Core.pathGet(message, ["entity"]);
if ($scope.row) {
$scope.messageDialog.open();
}
};

$scope.moveMessages = () => {
var jolokia = workspace.jolokia;
var selection = workspace.selection;
var mbean = selection.objectName;
if (mbean && selection && jolokia) {
if (mbean && selection) {
var selectedItems = $scope.gridOptions.selectedItems;
$scope.message = "Moved " + Core.maybePlural(selectedItems.length, "message" + " to " + $scope.queueName);
var operation = "moveMessageTo(java.lang.String, java.lang.String)"
var operation = "moveMessageTo(java.lang.String, java.lang.String)";
angular.forEach(selectedItems, (item, idx) => {
var id = item.JMSMessageID;
if (id) {
Expand All @@ -109,10 +105,9 @@ module ActiveMQ {
};

$scope.deleteMessages = () => {
var jolokia = workspace.jolokia;
var selection = workspace.selection;
var mbean = selection.objectName;
if (mbean && selection && jolokia) {
if (mbean && selection) {
var selectedItems = $scope.gridOptions.selectedItems;
$scope.message = "Deleted " + Core.maybePlural(selectedItems.length, "message");
var operation = "removeMessage(java.lang.String)";
Expand Down Expand Up @@ -172,8 +167,6 @@ module ActiveMQ {
if (selection) {
var mbean = selection.objectName;
if (mbean) {
var jolokia = workspace.jolokia;

jolokia.request(
{type: 'exec', mbean: mbean, operation: 'browse()'},
onSuccess(populateTable));
Expand Down
75 changes: 75 additions & 0 deletions hawtio-web/src/main/webapp/app/core/js/tableDetail.ts
@@ -0,0 +1,75 @@
module Core {

/**
* Provides an abstraction for stepping through a table in a detail view with next/previous/first/last options
*/
export class TableDetailDialog extends Dialog {
constructor(public $scope, public gridOptions) {
super();
}

public first() {
this.goToIndex(0);
}

public last() {
this.goToIndex(this.tableLength() - 1);
}

public previous() {
this.goToIndex(this.rowIndex() - 1);
}

public next() {
this.goToIndex(this.rowIndex() + 1);
}

public isEmptyOrFirst() {
var idx = this.rowIndex();
var length = this.tableLength();
return length <= 0 || idx <= 0;
}

public isEmptyOrLast() {
var idx = this.rowIndex();
var length = this.tableLength();
return length < 1 || idx + 1 >= length;
}

public rowIndex() {
return this.$scope.rowIndex;
}

public tableLength() {
var name = this.gridOptions.data;
if (name) {
return Core.pathGet(this.$scope, [name, "length"]);
}
return 0;
}

public tableData() {
var name = this.gridOptions.data;
if (name) {
return Core.pathGet(this.$scope, [name]);
}
return null;
}

public goToIndex(idx:number) {
if (idx >= 0 && idx < this.tableLength()) {
var data = this.tableData();
var scope = this.$scope;
if (data && idx < data.length) {
//console.log("Navigating to index: " + idx);
scope.row = data[idx];
scope.rowIndex = idx;
} else {
console.log("No data for idx: " + idx);
}
} else {
console.log("Ignoring idx out of range: " + idx);
}
}
}
}

0 comments on commit 4a096e5

Please sign in to comment.