Skip to content

Commit

Permalink
786495 - When syncing repositories, UI will now show updated size and…
Browse files Browse the repository at this point in the history
… package counts for

repositories and products.
(cherry picked from commit ba2e72a)
  • Loading branch information
ehelms committed Mar 2, 2012
1 parent 7f2aee5 commit 891fac6
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/app/controllers/sync_management_controller.rb
Expand Up @@ -175,6 +175,7 @@ def format_sync_progress(sync_status, repo)
:duration => format_duration(sync_status.finish_time, sync_status.start_time),
:packages => sync_status.progress.total_count,
:size => number_to_human_size(sync_status.progress.total_size),
:product_size => number_to_human_size(repo.product.sync_size),
:is_running => !not_running_states.include?(sync_status.state.to_sym) && sync_status.finish_time.nil?,
:error_details => error_flag ? error_details : "No errors."
}
Expand Down
16 changes: 16 additions & 0 deletions src/lib/resources/pulp.rb
Expand Up @@ -281,7 +281,23 @@ def sync_status(repo_id)
path = Repository.repository_path + repo_id + "/sync/"
response = get(path, self.default_headers)
parsed = JSON.parse(response.body)

parsed.reject!{ |task| task['start_time'].nil? }

return parsed if parsed.empty?

parsed.sort!{|a,b|
if a['finish_time'].nil? && b['finish_time'].nil?
a['start_time'] <=> b['start_time']
elsif a['finish_time'].nil?
-1
elsif b['finish_time'].nil?
1
else
a['finish_time'] <=> b['finish_time']
end
}.reverse!

return parsed.first.with_indifferent_access
end

Expand Down
15 changes: 11 additions & 4 deletions src/public/javascripts/content.js
Expand Up @@ -135,6 +135,8 @@ KT.content_actions = (function(){
if (!repo.is_running && (repo.raw_state !== 'waiting')) {
removeSyncing(repo.id);
KT.content.finishRepo(repo.id, repo.state, repo.duration);
KT.content.updateRepo(repo.id, repo.start_time, repo.duration, repo.progress.progress, repo.size, repo.packages);
KT.content.updateProduct(repo.product_id, false, false, repo.product_size);
}
else {
KT.content.updateRepo( repo.id,
Expand Down Expand Up @@ -213,6 +215,7 @@ KT.content = (function(){
update_item = function(element, starttime, duration, progress, size, packages) {
var pg = element.find(".progress"),
value = pg.find(".ui-progressbar-value");

fadeUpdate(element.find(".start_time"), starttime);
// clear duration during active sync
fadeUpdate(element.find(".duration"), '');
Expand All @@ -221,10 +224,14 @@ KT.content = (function(){
value.animate({'width': progress },{ queue:false,
duration:"slow", easing:"easeInSine" });
},
updateProduct = function (prod_id, done, percent) {
var element = $("#product-" + prod_id).find(".result");
var oldpg = element.find('.progress');
if(done){
updateProduct = function (prod_id, done, percent, size) {
var product_element = $("#product-" + prod_id),
element = product_element.find(".result"),
oldpg = element.find('.progress');

if( size ){
fadeUpdate(product_element.find('.size'), size);
} else if(done){
element.html("");
}
else{
Expand Down

0 comments on commit 891fac6

Please sign in to comment.