diff --git a/Gemfile.lock b/Gemfile.lock index 5e7114895..bbcc0f646 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -82,7 +82,7 @@ GEM ancestry (2.0.0) activerecord (>= 3.0.0) angular-i18n (0.1.2) - angularjs-rails (1.2.14) + angularjs-rails (1.2.16) arbre (1.0.1) activesupport (>= 3.0.0) arel (4.0.2) diff --git a/app/assets/javascripts/angularjs/controllers/build_list_controller.js.erb b/app/assets/javascripts/angularjs/controllers/build_list_controller.js.erb index 182206477..65b371bd2 100644 --- a/app/assets/javascripts/angularjs/controllers/build_list_controller.js.erb +++ b/app/assets/javascripts/angularjs/controllers/build_list_controller.js.erb @@ -21,22 +21,27 @@ RosaABF.controller('BuildListController', ['$scope', '$http', '$timeout', 'Sound }); } + $scope.canRefresh = function() { + if ($scope.attach_advisory != 'no') { return false; } + if (!$scope.build_list) { return true; } + + var show_dependent_projects = _.find($scope.build_list.packages, function(p){ + return p.show_dependent_projects; + }); + if (show_dependent_projects) { return false; } + if (!( + $scope.build_list.status == <%=BuildList::BUILD_PUBLISHED%> || + $scope.build_list.status == <%=BuildList::REJECTED_PUBLISH%> || + $scope.build_list.status == <%=BuildList::FAILED_PUBLISH%> || + $scope.build_list.status == <%=BuildList::BUILD_CANCELED%> || + $scope.build_list.status == <%=BuildList::BUILD_ERROR%> + )) { return true; } + return false; + } + $scope.cancelRefresh = null; $scope.refresh = function() { - if ( $scope.attach_advisory == 'no' && - ( - !$scope.build_list || - !( - $scope.build_list.status == <%=BuildList::BUILD_PUBLISHED%> || - $scope.build_list.status == <%=BuildList::REJECTED_PUBLISH%> || - $scope.build_list.status == <%=BuildList::FAILED_PUBLISH%> || - $scope.build_list.status == <%=BuildList::BUILD_CANCELED%> || - $scope.build_list.status == <%=BuildList::BUILD_ERROR%> - ) - ) - ) { - $scope.getBuildList(); - } + if ($scope.canRefresh()) { $scope.getBuildList(); } $scope.cancelRefresh = $timeout($scope.refresh, 10000); } $scope.refresh(); diff --git a/app/assets/stylesheets/design/custom.scss b/app/assets/stylesheets/design/custom.scss index 637213d62..9ef414fda 100644 --- a/app/assets/stylesheets/design/custom.scss +++ b/app/assets/stylesheets/design/custom.scss @@ -2048,7 +2048,7 @@ article .activity .top { } table tbody { - td.build-list-statuses { + td.build-list-statuses, td.package { background: #FFF; .status { diff --git a/app/helpers/build_lists_helper.rb b/app/helpers/build_lists_helper.rb index 37f754541..5cebbfd3c 100644 --- a/app/helpers/build_lists_helper.rb +++ b/app/helpers/build_lists_helper.rb @@ -18,6 +18,29 @@ module BuildListsHelper Platform.availables_main_platforms current_user, current_ability end + def dependent_projects(package) + return [] if package.dependent_packages.blank? + + packages = BuildList::Package. + select('build_list_packages.project_id, build_list_packages.name'). + joins(:build_list). + where( + platform_id: package.platform, + name: package.dependent_packages, + package_type: package.package_type, + build_lists: { status: BuildList::BUILD_PUBLISHED } + ). + group('build_list_packages.project_id, build_list_packages.name'). + reorder(:project_id).group_by(&:project_id) + + Project.where(id: packages.keys).recent.map do |project| + [ + project, + packages[project.id].map(&:name).sort + ] + end + end + def save_to_repositories(project) project.repositories.collect do |r| [ diff --git a/app/models/build_list/package.rb b/app/models/build_list/package.rb index 82e111ad2..a60dc30aa 100644 --- a/app/models/build_list/package.rb +++ b/app/models/build_list/package.rb @@ -6,7 +6,6 @@ class BuildList::Package < ActiveRecord::Base belongs_to :platform serialize :dependent_packages, Array - serialize :dependent_projects, Array attr_accessible :fullname, :name, :release, :version, :sha1, :epoch, :dependent_packages @@ -27,7 +26,6 @@ class BuildList::Package < ActiveRecord::Base before_create :set_epoch before_create :normalize_dependent_packages - after_commit(on: :create) { |p| p.find_dependent_projects if p.dependent_packages.present? } # later with resque def assignee project.maintainer @@ -50,11 +48,6 @@ class BuildList::Package < ActiveRecord::Base end end - def find_dependent_projects - # TODO - end - later :find_dependent_projects, queue: :middle - protected def normalize_dependent_packages diff --git a/app/views/projects/build_lists/show.html.haml b/app/views/projects/build_lists/show.html.haml index 22d79b83e..bd0873d0a 100644 --- a/app/views/projects/build_lists/show.html.haml +++ b/app/views/projects/build_lists/show.html.haml @@ -241,7 +241,7 @@ %div{'ng-show' => 'build_list.packages'} .hr - %h3= t("layout.build_lists.packages_header") + %h3= t('layout.build_lists.packages_header') %table.tablesorter.width565{cellpadding: "0", cellspacing: "0"} %thead %tr @@ -251,14 +251,38 @@ %th= t("activerecord.attributes.build_list/package.version") %th= t("activerecord.attributes.build_list/package.release") %tbody - %tr{'ng-repeat' => 'package in build_list.packages'} - %td{'ng-show' => 'package.url'} - %a{'ng-href' => "{{package.url}}" } {{package.fullname}} - %td{'ng-hide' => 'package.url'} {{package.fullname}} + %tr{'ng-repeat-start' => 'package in build_list.packages'} + %td.package + %a.expand{'ng-show' => 'package.dependent_projects' } + %span.icon-chevron-down{'ng-show' => 'package.show_dependent_projects', + 'ng-click' => 'package.show_dependent_projects = false' } + %span.icon-chevron-up{'ng-hide' => 'package.show_dependent_projects', + 'ng-click' => 'package.show_dependent_projects = true' } + %div{'ng-if' => '!package.url'} {{package.fullname}} + %a{ 'ng-if' => 'package.url', + 'ng-href' => "{{package.url}}" } + {{package.fullname}} + %td {{package.name}} %td {{package.epoch}} %td {{package.version}} %td {{package.release}} + + %tr{'ng-repeat-end' => '', + 'ng-show' => 'package.show_dependent_projects', + 'ng-repeat' => 'project in package.dependent_projects' } + %td + %a{'ng-href' => "{{project.url}}" } {{project.name}} + %td + %p{'ng-repeat' => 'package in project.dependent_packages'} + {{package}} + %td{ colspan: 3 } + %a{'ng-href' => '{{project.new_url}}' } + = t('layout.build_lists.create_build_list') + / .both + / %a{'ng-href' => '{{project.new_url}}' } + / = t('layout.build_lists.run_build_list') + .both - if @build_list.new_core? diff --git a/app/views/projects/build_lists/show.json.jbuilder b/app/views/projects/build_lists/show.json.jbuilder index 2282940e8..4516ad425 100644 --- a/app/views/projects/build_lists/show.json.jbuilder +++ b/app/views/projects/build_lists/show.json.jbuilder @@ -55,12 +55,16 @@ json.build_list do json.(package, :id, :name, :fullname, :release, :version, :sha1, :epoch) json.url "#{APP_CONFIG['file_store_url']}/api/v1/file_stores/#{package.sha1}" if package.sha1 - json.dependent_projects Project.where(id: package.dependent_projects).to_a do |project| - json.project_path project_path(project) - json.new_project_build_list_path new_project_build_list_path(@project) + json.dependent_projects dependent_projects(package) do |project, packages| + json.url project_path(project.name_with_owner) + json.name project.name_with_owner + json.dependent_packages packages + json.new_url new_project_build_list_path(project) end + end if @build_list.packages.present? + json.item_groups do |group| @item_groups.each_with_index do |group, level| json.group group do |item| diff --git a/config/locales/models/build_list.en.yml b/config/locales/models/build_list.en.yml index b6d94abc9..ceaa943f8 100644 --- a/config/locales/models/build_list.en.yml +++ b/config/locales/models/build_list.en.yml @@ -66,6 +66,8 @@ en: layout: build_lists: create_container: Create container + create_build_list: Create Build List + run_build_list: Run Build List platform_deleted: platform has been deleted filter_header: Filter current: Curent diff --git a/config/locales/models/build_list.ru.yml b/config/locales/models/build_list.ru.yml index f546c29a6..b1299c297 100644 --- a/config/locales/models/build_list.ru.yml +++ b/config/locales/models/build_list.ru.yml @@ -65,6 +65,8 @@ ru: layout: build_lists: create_container: Создать контейнер + create_build_list: Создать сборку + run_build_list: Запустить сборку platform_deleted: платформа была удалена filter_header: Фильтр current: Текущие diff --git a/db/migrate/20140612213342_remove_dependent_projects_from_build_list_packages.rb b/db/migrate/20140612213342_remove_dependent_projects_from_build_list_packages.rb new file mode 100644 index 000000000..04223ed8e --- /dev/null +++ b/db/migrate/20140612213342_remove_dependent_projects_from_build_list_packages.rb @@ -0,0 +1,9 @@ +class RemoveDependentProjectsFromBuildListPackages < ActiveRecord::Migration + def up + remove_column :build_list_packages, :dependent_projects + end + + def down + add_column :build_list_packages, :dependent_projects, :text + end +end diff --git a/db/schema.rb b/db/schema.rb index 3bc0ac99d..a4195f668 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20140606193047) do +ActiveRecord::Schema.define(version: 20140612213342) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -96,7 +96,6 @@ ActiveRecord::Schema.define(version: 20140606193047) do t.string "sha1" t.integer "epoch" t.text "dependent_packages" - t.text "dependent_projects" t.index ["actual", "platform_id"], :name => "index_build_list_packages_on_actual_and_platform_id" t.index ["build_list_id"], :name => "index_build_list_packages_on_build_list_id" t.index ["name", "project_id"], :name => "index_build_list_packages_on_name_and_project_id"