add show logs in real time

This commit is contained in:
Vokhmin Alexey V 2012-11-09 17:08:56 +04:00
parent 3d293b908d
commit b39ccea0d5
11 changed files with 65 additions and 39 deletions

View File

@ -11,12 +11,18 @@ class Platforms::ProductBuildListsController < Platforms::BaseController
before_filter :find_product_build_list, :only => [:status_build]
def new
@project = @product_build_list.product.project
raise ActiveRecord::RecordNotFound unless @project
@arches = Arch.recent.map{ |a| [a.name, a.id] }
product = @product_build_list.product
@product_build_list.params = product.params
@product_build_list.main_script = product.main_script
@product_build_list.project = product.project
unless @product_build_list.project
flash[:error] = t('flash.product_build_list.no_project')
redirect_to edit_platform_product_path(@platform, @product)
end
end
def show
@logs = JSON.parse(Resque.redis.get("abfworker::iso-worker-#{@product_build_list.id}") || '[]')
end
def create

View File

@ -8,7 +8,7 @@ class Product < ActiveRecord::Base
scope :recent, order("name ASC")
attr_accessible :name, :description, :project_id
attr_accessible :name, :description, :project_id, :main_script, :params
attr_readonly :platform_id
def full_clone(attrs = {})

View File

@ -63,8 +63,6 @@ class ProductBuildList < ActiveRecord::Base
protected
def xml_rpc_create
# TODO: run ISO worker
# result = ProductBuilder.create_product self
file_name = "#{project.owner.uname}-#{project.name}-#{commit_hash}"
srcpath = url_helpers.archive_url(
project.owner,
@ -75,29 +73,25 @@ class ProductBuildList < ActiveRecord::Base
)
options = {
:id => id,
:srcpath => 'http://dl.dropbox.com/u/945501/avokhmin-test-iso-script-f94caef701bf234505ef107a02e309037a9a57a4.tar.gz',
# TODO: revert changes
:srcpath => 'http://dl.dropbox.com/u/945501/avokhmin-test-iso-script-5d9b463d4e9c06ea8e7c89e1b7ff5cb37e99e27f.tar.gz',
:params => params,
:main_script => main_script
}
# if result == ProductBuilder::SUCCESS
Resque.push(
'iso_worker',
'class' => 'AbfWorker::IsoWorker',
'args' => [options]
)
return true
# if Resque.enqueue(AbfWorker::IsoWorker, options)
# return true
# else
# raise "Failed to create product_build_list #{id} inside platform #{product.platform.name} with params: #{options.inspect}"
# end
end
def xml_delete_iso_container
# TODO: write new worker for delete
# result = ProductBuilder.delete_iso_container self
result = ProductBuilder::SUCCESS
if project
raise "Failed to destroy product_build_list #{id} inside platform #{product.platform.name} (Not Implemented)."
else
result = ProductBuilder.delete_iso_container self
if result == ProductBuilder::SUCCESS
return true
else
@ -105,3 +99,4 @@ class ProductBuildList < ActiveRecord::Base
end
end
end
end

View File

@ -7,7 +7,7 @@
- else
%td= pbl.id
%td= pbl.human_status
%td= link_to nil, pbl.container_path
%td= link_to(nil, pbl.container_path) unless pbl.project
%td= link_to pbl.product.name, platform_product_path(platform, product)
%td= link_to image_tag('x.png'), platform_product_product_build_list_path(platform, product, pbl), :method => :delete, :confirm => t("layout.confirm") if can?(:destroy, pbl) && pbl.can_destroy?
%td= link_to image_tag('x.png'), platform_product_product_build_list_path(platform, product, pbl), :method => :delete, :confirm => t("layout.confirm") if can?(:destroy, pbl) && pbl.can_destroy? && !pbl.project
%td= l(pbl.updated_at, :format => :long)

View File

@ -2,14 +2,14 @@
= render 'submenu'
%h3= t("layout.product_build_lists.main_data")
= form_for @product_build_list, :url => platform_product_product_build_lists_path(@platform, @product), :html => {:class => :form} do |f|
- pbl = @product_build_list
= form_for pbl, :url => platform_product_product_build_lists_path(@platform, @product), :html => {:class => :form} do |f|
.leftlist= f.label :project, t("activerecord.attributes.product_build_list.project"), :class => :label
.rightlist= @product_build_list.product.project.try(:name_with_owner)
.rightlist= pbl.project.name_with_owner
.both
.leftlist= f.label :project_version, t("activerecord.attributes.product_build_list.project_version"), :class => :label
.rightlist= f.select :project_version, versions_for_group_select(@project), :selected => params[:product_build_lists].try(:fetch, :project_version) || "latest_" + @project.default_branch
.rightlist= f.select :project_version, versions_for_group_select(pbl.project), :selected => params[:product_build_lists].try(:fetch, :project_version) || "latest_" + pbl.project.default_branch
.both
.leftlist= f.label :main_script, t("activerecord.attributes.product_build_list.main_script"), :class => :label

View File

@ -15,16 +15,12 @@
.rightlist= pbl.human_status
.both
.leftlist= t("activerecord.attributes.product_build_list.container_path")
.rightlist= link_to nil, pbl.container_path
.both
.leftlist= t("activerecord.attributes.product_build_list.product")
.rightlist= link_to pbl.product.name, platform_product_path(platform, product)
.both
.leftlist= t("activerecord.attributes.product_build_list.project")
.rightlist= pbl.project.name_with_owner
.rightlist= link_to pbl.project.name_with_owner, project_path(pbl.project)
.both
.leftlist= t("activerecord.attributes.product_build_list.project_version")
@ -39,14 +35,25 @@
.rightlist= pbl.params
.both
.leftlist= t("layout.product_build_lists.action")
.rightlist= link_to image_tag('x.png'), platform_product_product_build_list_path(platform, product, pbl), :method => :delete, :confirm => t("layout.confirm") if can?(:destroy, pbl) && pbl.can_destroy?
.both
.leftlist= t("activerecord.attributes.product_build_list.notified_at")
.rightlist= l(pbl.updated_at, :format => :long)
.both
- if @logs.present?
%h3= t("layout.product_build_lists.logs")
%table.tablesorter.width565{:cellpadding => "0", :cellspacing => "0"}
%thead
%tr
%th= '#'
%th
%tbody
- @logs.each do |item|
%tr
%td= item[0]
%td= item[1]
.both
%h3= t("layout.product_build_lists.results")
- unless pbl.results.present?
%h4.nomargin= t("layout.product_build_lists.no_results")
@ -56,14 +63,12 @@
%tr
%th= t("activerecord.attributes.product_build_list/results.file_name")
%th= t("activerecord.attributes.product_build_list/results.sha1")
%th= t("activerecord.attributes.product_build_list/results.link")
%tbody
- pbl.results.each do |item|
%tr
%td= item['file_name']
- sha1 = item['sha1']
%td= link_to item['file_name'], "http://file-store.rosalinux.ru/api/v1/file_stores/#{sha1}"
%td= sha1
%td= link_to t("activerecord.attributes.product_build_list/results.link"), "http://file-store.rosalinux.ru/api/v1/file_stores/#{sha1}"
.both

View File

@ -10,6 +10,14 @@
.rightlist= f.autocomplete_field :project, autocomplete_project_platform_products_path(@platform), :id_element => 'src_project_id', :name => 'src_project', :value => @product.project.try(:name_with_owner)
.both
.leftlist= f.label :main_script, t("activerecord.attributes.product_build_list.main_script"), :class => :label
.rightlist= f.text_field :main_script
.both
.leftlist= f.label :params, t("activerecord.attributes.product_build_list.params"), :class => :label
.rightlist= f.text_field :params
.both
.button_block
= submit_tag t("layout.save")
%span.text_button_padding= t("layout.or")

View File

@ -1,6 +1,7 @@
en:
layout:
product_build_lists:
logs: Logs
results: Results
work_env: Work environment
iso_builder_folder: folder with contents of the GIT project
@ -42,9 +43,9 @@ en:
product_build_list/results:
file_name: File name
sha1: SHA1
link: Link
flash:
product_build_list:
no_project: Project for build should be exist
delete: Product build list deleted
delete_error: Unable to delete product build list

View File

@ -1,6 +1,7 @@
ru:
layout:
product_build_lists:
logs: Логи
results: Результаты
work_env: Рабочее пространство
iso_builder_folder: папка с содержимым GIT проекта
@ -42,10 +43,10 @@ ru:
product_build_list/results:
file_name: Имя файла
sha1: SHA1
link: Ссылка
flash:
product_build_list:
no_project: Проект для сборки должен присутствовать
delete: Сборочный лист продукта удален
delete_error: Не удалось удалить cборочный лист продукта

View File

@ -18,7 +18,11 @@ class IntegrateNewIsoBuilderWithProducts < ActiveRecord::Migration
add_column :product_build_lists, :commit_hash, :string
add_column :product_build_lists, :params, :string
add_column :products, :params, :string
add_column :product_build_lists, :main_script, :string
add_column :products, :main_script, :string
add_column :product_build_lists, :results, :text
end
@ -41,7 +45,11 @@ class IntegrateNewIsoBuilderWithProducts < ActiveRecord::Migration
remove_column :product_build_lists, :commit_hash
remove_column :product_build_lists, :params
remove_column :products, :params
remove_column :product_build_lists, :main_script
remove_column :products, :main_script
remove_column :product_build_lists, :results
end
end

View File

@ -298,6 +298,8 @@ ActiveRecord::Schema.define(:version => 20121106113338) do
t.datetime "updated_at"
t.text "description"
t.integer "project_id"
t.string "params"
t.string "main_script"
end
create_table "project_imports", :force => true do |t|