From 372d7dac4d638e118eed1aec34e37199a87e02dd Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Sat, 29 Oct 2011 14:35:45 +0400 Subject: [PATCH 1/6] [refs #2161] Fix categories group by and select --- app/controllers/categories_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb index 66913f11c..96f8d13f4 100644 --- a/app/controllers/categories_controller.rb +++ b/app/controllers/categories_controller.rb @@ -13,7 +13,7 @@ class CategoriesController < ApplicationController def index if @platform @categories = Category.joins(:projects => :repositories).where('repositories.platform_id = ?', @platform.id). - having('count(projects.id) > 0').group('categories.id').default_order + having('count(projects.id) > 0').group('categories.id, categories.name, categories.ancestry, categories.projects_count, categories.created_at, categories.updated_at').default_order @categories_count = @categories.count render 'index2' else From 4e0617a722adf15f4835d663bb5864bf5da841f2 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Sat, 29 Oct 2011 16:18:41 +0400 Subject: [PATCH 2/6] [refs #2161] Swap bpl and pl fields into BuildList --- app/controllers/projects_controller.rb | 20 ++++++++++---------- app/models/build_list.rb | 2 +- app/views/projects/build.html.haml | 12 ++++++------ public/javascripts/application.js | 26 +++++++++++++------------- 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 0cea2ace8..8891f5955 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -58,8 +58,8 @@ class ProjectsController < ApplicationController def build @arches = Arch.recent - @pls = Platform.main - @bpls = @project.repositories.collect { |rep| ["#{rep.platform.name}/#{rep.unixname}", rep.platform.id] } + @bpls = Platform.main + @pls = @project.repositories.collect { |rep| ["#{rep.platform.name}/#{rep.unixname}", rep.platform.id] } @project_versions = @project.project_versions.collect { |tag| [tag.name, tag.name.gsub(/^\w+\./, "")] }.select { |pv| pv[0] =~ /^v\./ } end @@ -69,10 +69,10 @@ class ProjectsController < ApplicationController @project_version = params[:build][:project_version] - pls_ids = params[:build][:pl].blank? ? [] : params[:build][:pl].select{|_,v| v == "1"}.collect{|x| x[0].to_i } - pls = Platform.where(:id => pls_ids) + bpls_ids = params[:build][:bpl].blank? ? [] : params[:build][:bpl].select{|_,v| v == "1"}.collect{|x| x[0].to_i } + bpls = Platform.where(:id => bpls_ids) - bpl = Platform.find params[:build][:bpl] + pl = Platform.find params[:build][:pl] update_type = params[:build][:update_type] build_requires = params[:build][:build_requires] @@ -80,20 +80,20 @@ class ProjectsController < ApplicationController if !check_arches || !check_project_versions @arches = Arch.recent - @pls = Platform.main - @bpls = @project.repositories.collect { |rep| ["#{rep.platform.name}/#{rep.unixname}", rep.platform.id] } + @bpls = Platform.main + @pls = @project.repositories.collect { |rep| ["#{rep.platform.name}/#{rep.unixname}", rep.platform.id] } render :action => "build" else flash[:notice], flash[:error] = "", "" @arches.each do |arch| - pls.each do |pl| + bpls.each do |bpl| build_list = @project.build_lists.new(:arch => arch, :project_version => @project_version, :pl => pl, :bpl => bpl, :update_type => update_type, :build_requires => build_requires) if build_list.save - flash[:notice] += t("flash.build_list.saved", :project_version => @project_version, :arch => arch.name, :pl => pl.name, :bpl => bpl) + flash[:notice] += t("flash.build_list.saved", :project_version => @project_version, :arch => arch.name, :bpl => bpl.name, :pl => pl) else - flash[:error] += t("flash.build_list.save_error", :project_version => @project_version, :arch => arch.name, :pl => pl.name, :bpl => bpl) + flash[:error] += t("flash.build_list.save_error", :project_version => @project_version, :arch => arch.name, :bpl => bpl.name, :pl => pl) end end end diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 76e4eaf9c..1496e8c15 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -14,7 +14,7 @@ class BuildList < ActiveRecord::Base validates :update_type, :inclusion => UPDATE_TYPES validate lambda { - errors.add(:pl, I18n.t('flash.build_list.wrong_platform')) if bpl.platform_type == 'main' && pl_id != bpl_id + errors.add(:bpl, I18n.t('flash.build_list.wrong_platform')) if pl.platform_type == 'main' && pl_id != bpl_id } BUILD_CANCELED = 5000 diff --git a/app/views/projects/build.html.haml b/app/views/projects/build.html.haml index 2e33f6356..8c770455a 100644 --- a/app/views/projects/build.html.haml +++ b/app/views/projects/build.html.haml @@ -19,10 +19,10 @@ = f.select :project_version, @project_versions .group.pl_ids_container - = f.label :pl, t("activerecord.attributes.build_list.pl"), :class => :label - - @pls.each do |pl| - = f.check_box "pl[#{pl.id}]", :pl_id => pl.id, :class => 'build_pl_ids' - = pl.name + = f.label :bpl, t("activerecord.attributes.build_list.bpl"), :class => :label + - @bpls.each do |bpl| + = f.check_box "bpl[#{bpl.id}]", :bpl_id => bpl.id, :class => 'build_bpl_ids' + = bpl.name %br .group @@ -43,8 +43,8 @@ %br .group - = f.label :bpl, t("activerecord.attributes.build_list.bpl"), :class => :label - = f.select :bpl, @bpls + = f.label :pl, t("activerecord.attributes.build_list.pl"), :class => :label + = f.select :pl, @pls .group.navform.wat-cf %button.button{:type => "submit"} diff --git a/public/javascripts/application.js b/public/javascripts/application.js index 25b7fc15d..fa61f223f 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -15,26 +15,26 @@ function uncheck_by_ids(ids) { $(document).ready(function() { $('.pl_ids_container input[type="hidden"]').remove(); - $('select#build_bpl').change(function() { - var is_bpl_main = false; - var granted_pl_id = ''; - var bpl_id = $('select#build_bpl').val(); + $('select#build_pl').change(function() { + var is_pl_main = false; + var granted_bpl_id = ''; + var pl_id = $('select#build_pl').val(); - $('input.build_pl_ids').each(function(i,el) { - var pl_id = $(el).attr('pl_id'); + $('input.build_bpl_ids').each(function(i,el) { + var bpl_id = $(el).attr('bpl_id'); if (pl_id == bpl_id) { - is_bpl_main = true; - //granted_pl_id = $(el).attr('pl_id'); + is_pl_main = true; + //granted_bpl_id = $(el).attr('bpl_id'); } }); - if (is_bpl_main) { - $('input.build_pl_ids').attr('disabled', 'disabled'); - $('input.build_pl_ids[pl_id="'+bpl_id+'"]').removeAttr('disabled'); + if (is_pl_main) { + $('input.build_bpl_ids').attr('disabled', 'disabled'); + $('input.build_bpl_ids[bpl_id="'+pl_id+'"]').removeAttr('disabled'); } else { - $('input.build_pl_ids').removeAttr('disabled'); + $('input.build_bpl_ids').removeAttr('disabled'); } }); - $('select#build_bpl').trigger('change'); + $('select#build_pl').trigger('change'); }); From 33ebe192c54656097b30686537fd2b51061d480e Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Sat, 29 Oct 2011 16:29:47 +0400 Subject: [PATCH 3/6] [refs #2161] Fix bpl and pl translates --- config/locales/ru.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/config/locales/ru.yml b/config/locales/ru.yml index e48df7820..b5a4a8dff 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -305,8 +305,8 @@ ru: destroyed: Платформа успешно удалена build_list: - saved: Билд лист для версии '%{project_version}', платформу '%{pl}' и архитектуры '%{arch}' создан успешно - save_error: Не удалось сохранить билд лист для версии '%{project_version}', платформу '%{pl}' и архитектуры '%{arch}' + saved: Билд лист для версии '%{project_version}', платформы '%{bpl}' и архитектуры '%{arch}' создан успешно + save_error: Не удалось сохранить билд лист для версии '%{project_version}', платформы '%{bpl}' и архитектуры '%{arch}' no_project_version_selected: Выберите какую-нибудь версию no_project_version_found: Выбранная версия '%{project_version}' не найдена no_arch_selected: Выберите хотя бы одну ахритектуру @@ -465,10 +465,10 @@ ru: additional_repos: Дополнительные репозитории updated_at: Обновлен created_at: Создан - bpl: Репозиторий для сохранения пакетов - bpl_id: Репозиторий для сохранения пакетов - pl: Платформа - pl_id: Платформа + pl: Репозиторий для сохранения пакетов + pl_id: Репозиторий для сохранения пакетов + bpl: Платформа + bpl_id: Платформа update_type: Критичность обновления build_requires: Пересборка с зависимостями project_version: Версия From 8b2fdd71c700da269a7414c566767834a4bb37ec Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Sat, 29 Oct 2011 16:40:37 +0400 Subject: [PATCH 4/6] [refs #2161] Add new fields to show.html for BuildList --- app/views/build_lists/show.html.haml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/views/build_lists/show.html.haml b/app/views/build_lists/show.html.haml index edaaa3785..c13aeca09 100644 --- a/app/views/build_lists/show.html.haml +++ b/app/views/build_lists/show.html.haml @@ -22,6 +22,26 @@ = t("activerecord.attributes.build_list.container_path") \: = @build_list.container_path + %p + %b + = t("activerecord.attributes.build_list.bpl") + \: + = @build_list.bpl.name + %p + %b + = t("activerecord.attributes.build_list.pl") + \: + = @build_list.pl.name + %p + %b + = t("activerecord.attributes.build_list.update_type") + \: + = @build_list.update_type + %p + %b + = t("activerecord.attributes.build_list.build_requires") + \: + = @build_list.build_requires %p %b = t("activerecord.attributes.build_list.status") From 6b993db2fc1a89870b353851c027b9648023cb2b Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Sat, 29 Oct 2011 16:21:04 +0300 Subject: [PATCH 5/6] Fix ssh key update logic. Refs #2162 --- app/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 7db305aad..ac7a909f6 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -41,7 +41,7 @@ class User < ActiveRecord::Base create_ssh_key ssh_key elsif ssh_key_was.present? and ssh_key.blank? destroy_ssh_key ssh_key_was - elsif ssh_key_changed? + elsif ssh_key_changed? and ssh_key.present? and ssh_key_was.present? update_ssh_key ssh_key_was, ssh_key end } From 512364be3243ed0f26085ffaf40141dfb0581c43 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Sat, 29 Oct 2011 17:38:01 +0400 Subject: [PATCH 6/6] [refs #2161] Add get_status call --- app/controllers/build_lists_controller.rb | 5 ++++- app/views/build_lists/index.html.haml | 14 +++++++++++++- config/locales/ru.yml | 6 ++++++ lib/build_server.rb | 4 ++++ 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/app/controllers/build_lists_controller.rb b/app/controllers/build_lists_controller.rb index d6476b809..9132b6ade 100644 --- a/app/controllers/build_lists_controller.rb +++ b/app/controllers/build_lists_controller.rb @@ -16,7 +16,10 @@ class BuildListsController < ApplicationController @build_lists = BuildList.paginate :page => params[:page] end @action_url = all_build_lists_path - + + @build_server_status = BuildServer.get_status + #@build_server_status = {:client_count => '1', :count_new_task => '2', :count_build_task => 3} + render :action => 'index' end diff --git a/app/views/build_lists/index.html.haml b/app/views/build_lists/index.html.haml index 3805cf804..ffde34897 100644 --- a/app/views/build_lists/index.html.haml +++ b/app/views/build_lists/index.html.haml @@ -6,7 +6,19 @@ %li.active= link_to t("layout.build_lists.all"), project_build_lists_path(@project) .content - + - if controller.action_name == 'all' + .inner + %h2= t('layout.build_lists.build_server_status.header') + .field + %span= t('layout.build_lists.build_server_status.client_count') + ":" + %span= @build_server_status[:client_count] + .field + %span= t('layout.build_lists.build_server_status.count_new_task') + ":" + %span= @build_server_status[:count_new_task] + .field + %span= t('layout.build_lists.build_server_status.count_build_task') + ":" + %span= @build_server_status[:count_build_task] + .inner = render :partial => "build_lists/filter", :action_url => @action_url diff --git a/config/locales/ru.yml b/config/locales/ru.yml index b5a4a8dff..374c3590e 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -229,6 +229,12 @@ ru: cancel_successed: 'Сборка отменена.' cancel_failed: 'При отмене сборки произошла ошибка!' + build_server_status: + header: Статус сборочного сервера + client_count: Число клиентов + count_new_task: Число заданий в очереди + count_build_task: Число выполняемых заданий + items: statuses: build_error: ошибка сборки diff --git a/lib/build_server.rb b/lib/build_server.rb index 22993a0e9..8447bcef0 100644 --- a/lib/build_server.rb +++ b/lib/build_server.rb @@ -75,6 +75,10 @@ class BuildServer def self.delete_build_list idlist self.client.call('delete_build_list', idlist) end + + def get_status + self.client.call('get_status') + end def self.freeze platform_name, new_repo_name = nil self.client.call('freeze_platform', platform_name, new_repo_name)