diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 05e9ea4..131d0be 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -3,6 +3,22 @@ module ApplicationHelper create_percentage_table_for(problem) {|notice| notice.message} end + def generate_problem_ical(notices) + RiCal.Calendar do |cal| + notices.each_with_index do |notice,idx| + cal.event do |event| + event.summary = "#{idx+1} #{notice.message.to_s}" + event.description = notice.request['url'] + event.dtstart = notice.created_at.utc + event.dtend = notice.created_at.utc + 60.minutes + event.organizer = notice.server_environment && notice.server_environment["hostname"] + event.location = notice.server_environment && notice.server_environment["project-root"] + event.url = app_err_url(:app_id => notice.problem.app.id, :id => notice.problem) + end + end + end.to_s + end + def generate_ical(deploys) RiCal.Calendar { |cal| deploys.each_with_index do |deploy,idx| diff --git a/app/views/errs/show.html.haml b/app/views/errs/show.html.haml index d880a7e..f3b3173 100644 --- a/app/views/errs/show.html.haml +++ b/app/views/errs/show.html.haml @@ -11,6 +11,8 @@ %strong Last Notice: = last_notice_at(@problem).to_s(:micro) - content_for :action_bar do + - if current_user.authentication_token + %span= link_to 'iCal', app_err_path(:app_id => @app.id, :id => @problem.id, :format => "ics", :auth_token => current_user.authentication_token), :class => "calendar_link" - if @problem.app.issue_tracker_configured? - if @problem.issue_link.blank? %span= link_to 'create issue', create_issue_app_err_path(@app, @problem), :method => :post, :class => "#{@app.issue_tracker.class::Label}_create create-issue" diff --git a/app/views/errs/show.ics.haml b/app/views/errs/show.ics.haml new file mode 100644 index 0000000..913dbf4 --- /dev/null +++ b/app/views/errs/show.ics.haml @@ -0,0 +1 @@ += generate_problem_ical(@problem.notices.order_by(:created_at.asc)) -- libgit2 0.21.2