2019-03-16 10:37:35 +01:00
|
|
|
# frozen_string_literal: true
|
2019-03-15 02:32:57 +01:00
|
|
|
|
2011-04-01 16:34:44 +02:00
|
|
|
# Redmine - project management software
|
2024-02-26 23:55:54 +01:00
|
|
|
# Copyright (C) 2006- Jean-Philippe Lang
|
2011-04-01 16:34:44 +02:00
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
# of the License, or (at your option) any later version.
|
2011-08-30 15:07:12 +02:00
|
|
|
#
|
2011-04-01 16:34:44 +02:00
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
2011-08-30 15:07:12 +02:00
|
|
|
#
|
2011-04-01 16:34:44 +02:00
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
2010-04-28 17:54:46 +02:00
|
|
|
class GanttsController < ApplicationController
|
2010-11-07 23:38:10 +01:00
|
|
|
menu_item :gantt
|
2016-07-14 09:27:31 +02:00
|
|
|
before_action :find_optional_project
|
2010-04-28 17:54:46 +02:00
|
|
|
|
|
|
|
rescue_from Query::StatementInvalid, :with => :query_statement_invalid
|
|
|
|
|
2010-09-10 05:09:02 +02:00
|
|
|
helper :gantt
|
2010-04-28 17:54:46 +02:00
|
|
|
helper :issues
|
|
|
|
helper :projects
|
|
|
|
helper :queries
|
|
|
|
include QueriesHelper
|
|
|
|
include Redmine::Export::PDF
|
2011-08-30 15:07:12 +02:00
|
|
|
|
2010-04-28 17:54:46 +02:00
|
|
|
def show
|
|
|
|
@gantt = Redmine::Helpers::Gantt.new(params)
|
2010-09-10 05:09:02 +02:00
|
|
|
@gantt.project = @project
|
2010-04-28 17:54:46 +02:00
|
|
|
retrieve_query
|
|
|
|
@query.group_by = nil
|
2010-09-10 05:09:02 +02:00
|
|
|
@gantt.query = @query if @query.valid?
|
2011-08-30 15:07:12 +02:00
|
|
|
|
2010-04-28 17:54:46 +02:00
|
|
|
basename = (@project ? "#{@project.identifier}-" : '') + 'gantt'
|
2011-08-30 15:07:12 +02:00
|
|
|
|
2010-04-28 17:54:46 +02:00
|
|
|
respond_to do |format|
|
2020-10-24 16:39:39 +02:00
|
|
|
format.html {render :action => "show", :layout => !request.xhr?}
|
2021-12-29 07:12:27 +01:00
|
|
|
if @gantt.respond_to?(:to_image)
|
2020-10-24 16:39:39 +02:00
|
|
|
format.png do
|
|
|
|
send_data(@gantt.to_image,
|
|
|
|
:disposition => 'inline', :type => 'image/png',
|
|
|
|
:filename => "#{basename}.png")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
format.pdf do
|
|
|
|
send_data(@gantt.to_pdf,
|
|
|
|
:type => 'application/pdf',
|
|
|
|
:filename => "#{basename}.pdf")
|
|
|
|
end
|
2010-04-28 17:54:46 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|