Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
#282 - jms scheduler support
  • Loading branch information
dejanb committed Dec 2, 2013
1 parent 5eeca20 commit c1f3623
Show file tree
Hide file tree
Showing 4 changed files with 167 additions and 2 deletions.
31 changes: 31 additions & 0 deletions hawtio-web/src/main/webapp/app/activemq/html/jobs.html
@@ -0,0 +1,31 @@
<div ng-controller="ActiveMQ.JobSchedulerController">

<div class="row-fluid">
<div class="span12">
<div class="pull-right">
<form class="form-inline">
<button class="btn" ng-disabled="!gridOptions.selectedItems.length"
ng-click="deleteJobsDialog.open()"
title="Delete the selected jobs">
<i class="icon-remove"></i> Delete
</button>
<button class="btn" ng-click="refresh()"
title="Refreshes the list of subscribers">
<i class="icon-refresh"></i>
</button>
</form>
</div>
</div>
</div>

<div class="row-fluid">
<div class="gridStyle" ng-grid="gridOptions"></div>
</div>

<div hawtio-confirm-dialog="deleteJobsDialog.show" ok-button-text="Yes" cancel-button-text="No" on-ok="deleteJobs()">
<div class="dialog-body">
<p>Are you sure you want to delete the jobs</p>
</div>
</div>

</div>
14 changes: 13 additions & 1 deletion hawtio-web/src/main/webapp/app/activemq/js/activemqPlugin.ts
Expand Up @@ -12,7 +12,8 @@ module ActiveMQ {
when('/activemq/deleteQueue', {templateUrl: 'app/activemq/html/deleteQueue.html'}).
when('/activemq/deleteTopic', {templateUrl: 'app/activemq/html/deleteTopic.html'}).
when('/activemq/sendMessage', {templateUrl: 'app/camel/html/sendMessage.html'}).
when('/activemq/durableSubscribers', {templateUrl: 'app/activemq/html/durableSubscribers.html'})
when('/activemq/durableSubscribers', {templateUrl: 'app/activemq/html/durableSubscribers.html'}).
when('/activemq/jobs', {templateUrl: 'app/activemq/html/jobs.html'})
}).
run(($location:ng.ILocationService, workspace:Workspace, viewRegistry, helpRegistry) => {

Expand Down Expand Up @@ -140,6 +141,13 @@ module ActiveMQ {
href: () => "#/activemq/durableSubscribers"
});

workspace.subLevelTabs.push({
content: '<i class="icon-list"></i> Jobs',
title: "Manage jobs",
isValid: (workspace:Workspace) => isJobScheduler(workspace),
href: () => "#/activemq/jobs"
});

function postProcessTree(tree) {
var activemq = tree.get("org.apache.activemq");
setConsumerType(activemq);
Expand Down Expand Up @@ -207,6 +215,10 @@ module ActiveMQ {
return workspace.selectionHasDomainAndLastFolderName(jmxDomain, 'Topic');
}

export function isJobScheduler(workspace:Workspace) {
return workspace.hasDomainAndProperties(jmxDomain, {'service': 'JobScheduler'}, 4);
}

export function isBroker(workspace:Workspace) {
if (workspace.selectionHasDomainAndType(jmxDomain, 'Broker')) {
var parent = workspace.selection.parent;
Expand Down
122 changes: 122 additions & 0 deletions hawtio-web/src/main/webapp/app/activemq/js/jobs.ts
@@ -0,0 +1,122 @@
module ActiveMQ {
export function JobSchedulerController($scope, workspace:Workspace, jolokia) {

$scope.refresh = loadTable;

$scope.jobs = [];
$scope.deleteJobsDialog = new Core.Dialog();

$scope.gridOptions = {
selectedItems: [],
data: 'jobs',
displayFooter: false,
showFilter: false,
showColumnMenu: true,
enableColumnResize: true,
enableColumnReordering: true,
filterOptions: {
filterText: ''
},
selectWithCheckboxOnly: true,
showSelectionCheckbox: true,
maintainColumnRatios: false,
columnDefs: [
{
field: 'jobId',
displayName: 'Job ID',
width: '25%'
},
{
field: 'cronEntry',
displayName: 'Cron Entry',
width: '10%'
},
{
field: 'delay',
displayName: 'Delay',
width: '5%'
},
{
field: 'repeat',
displayName: 'repeat',
width: '5%'
},
{
field: 'period',
displayName: 'period',
width: '5%'
},
{
field: 'start',
displayName: 'Start',
width: '25%'
},
{
field: 'next',
displayName: 'Next',
width: '25%'
}
]
};

$scope.$watch('workspace.selection', function () {
if (workspace.moveIfViewInvalid()) return;

// lets defer execution as we may not have the selection just yet
setTimeout(loadTable, 50);
});

function loadTable() {
var selection = workspace.selection;
if (selection) {
var mbean = selection.objectName;
if (mbean) {
jolokia.request(
{type: 'read', mbean: mbean, attribute: "AllJobs"},
onSuccess(populateTable));
}
}
Core.$apply($scope);
}

function populateTable(response) {
var data = response.value;
if (!angular.isArray(data)) {
$scope.jobs = [];
angular.forEach(data, (value, idx) => {
$scope.jobs.push(value);
});
} else {
$scope.jobs = data
}
Core.$apply($scope);
}

$scope.deleteJobs = () => {
var selection = workspace.selection;
var mbean = selection.objectName;
if (mbean && selection) {
var selectedItems = $scope.gridOptions.selectedItems;
$scope.message = "Deleted " + Core.maybePlural(selectedItems.length, "job");
var operation = "removeJob(java.lang.String)";
angular.forEach(selectedItems, (item, idx) => {
var id = item.jobId;
if (id) {
var callback = (idx + 1 < selectedItems.length) ? intermediateResult : operationSuccess;
jolokia.execute(mbean, operation, id, onSuccess(callback));
}
});
}
}

function intermediateResult() {
}

function operationSuccess() {
$scope.gridOptions.selectedItems.splice(0);
notification("success", $scope.message);
setTimeout(loadTable, 50);
}

}
}
2 changes: 1 addition & 1 deletion hawtio-web/src/test/resources/applicationContext.xml
Expand Up @@ -19,7 +19,7 @@
init-method="start" destroy-method="stop"/>

<!-- This creates an embedded ActiveMQ Broker -->
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="broker1" useJmx="true">
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="broker1" useJmx="true" schedulerSupport="true">
<networkConnectors>
<networkConnector uri="static:(tcp://localhost:31317)" userName="admin" password="admin"/>
</networkConnectors>
Expand Down

0 comments on commit c1f3623

Please sign in to comment.