Commit e0bd77bf by Johannes Edmeier

Wrap acitivti module.js with a scope

The 'use strict' in the activit module affected the global scope and broke the ui for some orderings of the modules. With this commit the module is wrapped into a function so the global scope isn't affected. fixes #294
parent 16fe9947
...@@ -13,80 +13,82 @@ ...@@ -13,80 +13,82 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
'use strict';
var module = angular.module('sba-applications-activiti', [ 'sba-applications' ]); (function (sbaModules, angular) {
sbaModules.push(module.name); 'use strict';
var module = angular.module('sba-applications-activiti', ['sba-applications']);
sbaModules.push(module.name);
module.controller('activitiCtrl', [ '$scope', '$http', 'application', function($scope, $http, application) { module.controller('activitiCtrl', ['$scope', '$http', 'application', function ($scope, $http, application) {
$scope.application = application; $scope.application = application;
$http.get('api/applications/' + application.id + '/activiti').then(function(response) { $http.get('api/applications/' + application.id + '/activiti').then(function (response) {
var activiti = response.data; var activiti = response.data;
$scope.summary = []; $scope.summary = [];
$scope.summary.push({ $scope.summary.push({
key : 'Completed Task Count Today', key: 'Completed Task Count Today',
value : activiti.completedTaskCountToday value: activiti.completedTaskCountToday
}); });
$scope.summary.push({ $scope.summary.push({
key : 'Process Definition Count', key: 'Process Definition Count',
value : activiti.processDefinitionCount value: activiti.processDefinitionCount
}); });
$scope.summary.push({ $scope.summary.push({
key : 'Cached Process Definition Count', key: 'Cached Process Definition Count',
value : activiti.cachedProcessDefinitionCount value: activiti.cachedProcessDefinitionCount
}); });
$scope.summary.push({ $scope.summary.push({
key : 'Completed Task Count', key: 'Completed Task Count',
value : activiti.completedTaskCount value: activiti.completedTaskCount
});
$scope.summary.push({
key : 'Completed Activities',
value : activiti.completedActivities
});
$scope.summary.push({
key : 'Open Task Count',
value : activiti.openTaskCount
});
$scope.processes = [];
for (var i = 0; i < activiti.deployedProcessDefinitions.length; i++) {
var process = activiti.deployedProcessDefinitions[i];
var runningProcessInstanceCount = activiti.runningProcessInstanceCount[process];
var completedProcessInstanceCount = activiti.completedProcessInstanceCount[process];
$scope.processes.push({
name : process,
running : runningProcessInstanceCount,
completed : completedProcessInstanceCount
}); });
} $scope.summary.push({
}).catch(function(response) { key: 'Completed Activities',
$scope.error = response.data; value: activiti.completedActivities
}); });
}]); $scope.summary.push({
key: 'Open Task Count',
value: activiti.openTaskCount
});
$scope.processes = [];
for (var i = 0; i < activiti.deployedProcessDefinitions.length; i++) {
var process = activiti.deployedProcessDefinitions[i];
var runningProcessInstanceCount = activiti.runningProcessInstanceCount[process];
var completedProcessInstanceCount = activiti.completedProcessInstanceCount[process];
$scope.processes.push({
name: process,
running: runningProcessInstanceCount,
completed: completedProcessInstanceCount
});
}
}).catch(function (response) {
$scope.error = response.data;
});
}]);
module.config([ '$stateProvider', function($stateProvider) { module.config(['$stateProvider', function ($stateProvider) {
$stateProvider.state('applications.activiti', { $stateProvider.state('applications.activiti', {
url : '/activiti', url: '/activiti',
templateUrl : 'applications-activiti/activiti.html', templateUrl: 'applications-activiti/activiti.html',
controller : 'activitiCtrl' controller: 'activitiCtrl'
}); });
}]); }]);
module.run([ 'ApplicationViews', '$http', function(ApplicationViews, $http) { module.run(['ApplicationViews', '$http', function (ApplicationViews, $http) {
ApplicationViews.register({ ApplicationViews.register({
order : 100, order: 100,
title : 'Activiti', title: 'Activiti',
state : 'applications.activiti', state: 'applications.activiti',
show : function(application) { show: function (application) {
if (!application.managementUrl || !application.statusInfo.status || application.statusInfo.status === 'OFFLINE') { if (!application.managementUrl || !application.statusInfo.status || application.statusInfo.status === 'OFFLINE') {
return false; return false;
} }
return $http.get('api/applications/' + application.id + '/configprops').then( return $http.get('api/applications/' + application.id + '/configprops').then(
function(response) { function (response) {
return response.data.processEngineEndpoint !== undefined; return response.data.processEngineEndpoint !== undefined;
}).catch(function() { }).catch(function () {
return false; return false;
}); });
} }
}); });
}]); }]);
})(sbaModules, angular);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment