Adapt dashboard to show idle and used runners
This commit is contained in:
@@ -68,7 +68,7 @@ $(document).on('turbolinks:load', function() {
|
||||
_.each(response.docker, function(data) {
|
||||
groups.update({
|
||||
id: data.id,
|
||||
visible: data.pool_size > 0
|
||||
visible: data.prewarmingPoolSize > 0
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -78,26 +78,27 @@ $(document).on('turbolinks:load', function() {
|
||||
dataset.add({
|
||||
group: data.id,
|
||||
x: vis.moment(),
|
||||
y: data.quantity
|
||||
y: data.usedRunners
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
var updateProgressBar = function(progress_bar, data) {
|
||||
var percentage = Math.min(Math.round(data.quantity / data.pool_size * 100), 100);
|
||||
var percentage = Math.min(Math.round(data.idleRunners / data.prewarmingPoolSize * 100), 100);
|
||||
progress_bar.attr({
|
||||
'aria-valuemax': data.pool_size,
|
||||
'aria-valuenow': data.quantity,
|
||||
'aria-valuemax': data.prewarmingPoolSize,
|
||||
'aria-valuenow': data.idleRunners,
|
||||
style: 'width: ' + percentage + '%'
|
||||
});
|
||||
progress_bar.html(data.quantity);
|
||||
progress_bar.html(data.idleRunners);
|
||||
};
|
||||
|
||||
var updateTable = function(response) {
|
||||
_.each(response.docker, function(data) {
|
||||
var row = $('tbody tr[data-id=' + data.id + ']');
|
||||
$('.pool-size', row).html(data.pool_size);
|
||||
var progress_bar = $('.quantity .progress .progress-bar', row);
|
||||
$('.prewarming-pool-size', row).html(data.prewarmingPoolSize);
|
||||
$('.used-runners', row).html(`+ ${data.usedRunners}`);
|
||||
var progress_bar = $('.idle-runners .progress .progress-bar', row);
|
||||
updateProgressBar(progress_bar, data);
|
||||
});
|
||||
};
|
||||
|
@@ -15,7 +15,18 @@ module Admin
|
||||
end
|
||||
|
||||
ExecutionEnvironment.order(:id).select(:id, :pool_size).map do |execution_environment|
|
||||
execution_environment.attributes.merge(quantity: pool_size[execution_environment.id])
|
||||
# Fetch the actual values (ID is stored as a symbol) or get an empty hash for merge
|
||||
actual = pool_size[execution_environment.id.to_s.to_sym] || {}
|
||||
|
||||
template = {
|
||||
id: execution_environment.id,
|
||||
prewarmingPoolSize: execution_environment.pool_size,
|
||||
idleRunners: 0,
|
||||
usedRunners: 0,
|
||||
}
|
||||
|
||||
# Existing values in the template get replaced with actual values
|
||||
template.merge(actual)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -10,33 +10,38 @@ h1 = t('breadcrumbs.dashboard.show')
|
||||
h2 Version
|
||||
|
||||
div.mb-4
|
||||
= "CodeOcean Release:"
|
||||
= application_name
|
||||
=< t("admin.dashboard.show.release")
|
||||
| :
|
||||
pre = Sentry.configuration.release
|
||||
|
||||
- if Runner.management_active?
|
||||
div.mb-4
|
||||
= Runner.strategy_class.name.demodulize
|
||||
=< "Release:"
|
||||
=< t("admin.dashboard.show.release")
|
||||
| :
|
||||
pre = Runner.strategy_class.release
|
||||
|
||||
h2 Docker
|
||||
|
||||
- if Runner.management_active?
|
||||
h3 = t('.current')
|
||||
h3 = t('admin.dashboard.show.current')
|
||||
.table-responsive
|
||||
table.table
|
||||
thead
|
||||
tr
|
||||
th = t('activerecord.models.execution_environment.one')
|
||||
th = t('activerecord.attributes.execution_environment.pool_size')
|
||||
th = t('.quantity')
|
||||
th = t('admin.dashboard.show.idleRunners')
|
||||
th = t('admin.dashboard.show.usedRunners')
|
||||
tbody
|
||||
- ExecutionEnvironment.order(:name).each do |execution_environment|
|
||||
tr data-id=execution_environment.id
|
||||
td.name = link_to_if(policy(execution_environment).show?, execution_environment, execution_environment)
|
||||
td.pool-size
|
||||
td.quantity = progress_bar(0)
|
||||
h3 = t('.history')
|
||||
td.prewarming-pool-size
|
||||
td.idle-runners = progress_bar(0)
|
||||
td.used-runners
|
||||
h3 = t('admin.dashboard.show.history')
|
||||
#graph
|
||||
- else
|
||||
p = t('.inactive')
|
||||
p = t('admin.dashboard.show.inactive')
|
||||
|
Reference in New Issue
Block a user