Skip to content

Commit

Permalink
heat circle added to status list
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrykLucka committed Jan 29, 2018
1 parent 877e68f commit 914fb5f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/GearmanUI/Resources/views/status.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
</tr>
</thead>
<tbody>
<tr ng-repeat="item in status | filter:search | orderBy:predicate:reverse">
<td>{{ "{{ item.function }}" }}</td>
<tr ng-repeat="item in status | filter:search | orderBy:predicate:reverse" style="">
<td> <div class="circle" style='opacity: {{ "{{ heat[item.function] }}" }}; display: inline-block;'></div> {{ "{{ item.function }}" }}</td>
<td>{{ "{{ item.server }}" }}</td>
<td>{{ "{{ item.queued }}" }}</td>
<td>{{ "{{ item.running }}" }}</td>
Expand Down
7 changes: 7 additions & 0 deletions web/gearmanui.css
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,11 @@ html, body {

.copyright {
float: right;
}

.circle {
border-radius: 50%;
width: 10px;
height: 10px;
background: red;
}
21 changes: 17 additions & 4 deletions web/gearmanui.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ var gearmanui = angular.module('gearmanui', ['ngResource', 'ngRoute'])
};

// Status table
wrapper.status = function(data) {
wrapper.status = function(data, heat) {
var f;
var counter = 0;
var statusTable = [];
Expand All @@ -106,7 +106,8 @@ var gearmanui = angular.module('gearmanui', ['ngResource', 'ngRoute'])
queued: parseInt(element.status[f].in_queue, 10),
running: parseInt(element.status[f].jobs_running, 10),
workers: parseInt(element.status[f].capable_workers, 10),
server: element.name
server: element.name,
heat: heat[f]
};
}
});
Expand Down Expand Up @@ -146,17 +147,29 @@ gearmanui.controller('InfoCtrl', function($scope, GearmanSettings, GearmanInfo,
GearmanInfo.query(function (data) {
// Update model with the massaged data.
$scope.errors = GearmanErrorHandler.get(data);
$scope.status = GearmanInfoHandler.status(data);
$scope.status = GearmanInfoHandler.status(data, $scope.heat);
$scope.workers = GearmanInfoHandler.workers(data);
$scope.servers = GearmanInfoHandler.servers(data);
data.forEach(function (element, index, array) {
for (f in element.status) {
if(!$scope.heat[f] && $scope.heat[f] !== 0) {
$scope.heat[f] = 0;
}
if ((parseInt(element.status[f].jobs_running) > 0 || parseInt(element.status[f].in_queue) > 0) && $scope.heat[f] < 1) {
$scope.heat[f] += 0.01;
} else if($scope.heat[f] > 0) {
$scope.heat[f] -= 0.01;
}
}
});
}, function (err) {
// Handle server errors
$scope.errors = GearmanErrorHandler.get(
[{'error': "Server Error while accessing URL '/info': "+ err.status + " - " + err.statusText}]
);
});
}

$scope.heat = [];
window.setInterval(setInfo, GearmanSettings.refreshInterval * 1000);
setInfo();
});

0 comments on commit 914fb5f

Please sign in to comment.