diff options
Diffstat (limited to 'server')
3 files changed, 0 insertions, 405 deletions
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/columns_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/columns_controller.rb deleted file mode 100644 index 2e3655b2c7c..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/columns_controller.rb +++ /dev/null @@ -1,66 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2014 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 3 of the License, or (at your option) any later version. -# -# SonarQube 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 -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser 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. -# -class ColumnsController < ApplicationController - before_filter :admin_required - - before_filter :init - - def add - column = @components_configuration.find_available_column(@column_id) - @components_configuration.add_column(column) - redirect_to :controller => 'components', :action => 'index', :configuring => 'true', :id => params[:rid] - end - - def delete - column = @components_configuration.find_selected_column(@column_id) - @components_configuration.remove_column(column) - if column.sort_default? - @components_configuration.set_column_sort_default(Sonar::ColumnsView::TYPE_PROJECT) - end - redirect_to :controller => 'components', :action => 'index', :configuring => 'true', :id => params[:rid] - end - - def left - column = @components_configuration.find_selected_column(@column_id) - @components_configuration.move_column(column, "left") - redirect_to :controller => 'components', :action => 'index', :configuring => 'true', :id => params[:rid] - end - - def right - column = @components_configuration.find_selected_column(@column_id) - @components_configuration.move_column(column, "right") - redirect_to :controller => 'components', :action => 'index', :configuring => 'true', :id => params[:rid] - end - - def default_sorting - @components_configuration.set_column_sort_default(@column_id) - redirect_to :controller => 'components', :action => 'index', :configuring => 'true', :id => params[:rid] - end - - - private - - def init - @components_configuration = Sonar::ComponentsConfiguration.new - @column_id = params[:id] - end - - -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/sonar/columns_view.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/sonar/columns_view.rb deleted file mode 100644 index 1aa3c6f5802..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/sonar/columns_view.rb +++ /dev/null @@ -1,116 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2014 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 3 of the License, or (at your option) any later version. -# -# SonarQube 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 -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser 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. -# -class Sonar::ColumnsView - - TYPE_PROJECT = 'PROJECT' - TYPE_BUILD_TIME = 'BUILD_TIME' - TYPE_LINKS = 'LINKS' - TYPE_METRIC = 'METRIC' - TYPE_LANGUAGE = 'LANGUAGE' - TYPE_VERSION = 'VERSION' - - - attr_accessor :id, :name, :col_type, :position, :sort_default - - def name(translate=true) - return @name unless translate - - i18n_key = @id - return @name if i18n_key.nil? - - if metric_column? - i18n_key = 'metric.' + i18n_key + '.name' - end - - Api::Utils.message(i18n_key, :default => @name) - end - - def project_column? - @col_type == TYPE_PROJECT - end - - def links_column? - @col_type == TYPE_LINKS - end - - def build_time_column? - @col_type == TYPE_BUILD_TIME - end - - def metric_column? - @col_type == TYPE_METRIC - end - - def language_column? - @col_type == TYPE_LANGUAGE - end - - def version_column? - @col_type == TYPE_VERSION - end - - def text_column? - project_column? || links_column? || (get_metric && get_metric.val_type==Metric::VALUE_TYPE_STRING) - end - - def sort_default? - sort_default - end - - def get_metric - @metric ||= Metric.by_name(id) - end - - def sortable? - !links_column? - end - - def get_table_header_css - css_class = 'right ' - css_class = css_class + "nosort" if !sortable? - css_class = css_class + "text" if sortable? && text_column? - css_class = css_class + "number" if sortable? && !text_column? - css_class = get_default_css_sort + css_class - css_class - end - - def get_table_header_css_no_sort - css_class = 'right ' - if sort_default? - if build_time_column? - css_class = css_class + "sortfirstdesc " - elsif !metric_column? || get_metric.direction == 1 - css_class = css_class + "sortfirstasc " - elsif get_metric.direction == -1 - css_class = css_class + "sortfirstdesc " - end - end - css_class - end - - def get_default_css_sort - return "" if !sort_default? - return "sortfirstdesc " if build_time_column? - return "sortfirstasc " if !metric_column? || get_metric.direction == 1 - return "sortfirstdesc " if get_metric.direction == -1 - "" - end - -end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/sonar/components_configuration.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/sonar/components_configuration.rb deleted file mode 100644 index ec752384f81..00000000000 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/sonar/components_configuration.rb +++ /dev/null @@ -1,223 +0,0 @@ -# -# SonarQube, open source software quality management tool. -# Copyright (C) 2008-2014 SonarSource -# mailto:contact AT sonarsource DOT com -# -# SonarQube is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 3 of the License, or (at your option) any later version. -# -# SonarQube 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 -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser 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. -# -class Sonar::ComponentsConfiguration - - COLUMN_SEPARATOR = '.' - COLUMNS_SEPARATOR = ';' - - COLUMNS_SELECTED_KEY = 'sonar.core.projectsdashboard.columns' - COLUMNS_DEFAULT_SORT_KEY = 'sonar.core.projectsdashboard.defaultSortedColumn' - - def initialize - @sorted_column_id=Property.value(COLUMNS_DEFAULT_SORT_KEY) || Sonar::ColumnsView::TYPE_PROJECT - @text_columns=Property.value(COLUMNS_SELECTED_KEY) || default_text_columns - end - - def selected_columns - columns_from_text(@text_columns) - end - - def homepage_metrics() - metrics = selected_columns.select{|col| col.metric_column?}.collect{|col| Metric.by_name(col.id)} - metrics<<Metric.by_name(Metric::ALERT_STATUS) - metrics.uniq.compact - end - - def addeable_columns - addeable_columns = available_columns - addeable_columns.each_key { |domain| - domain_addeable_columns = addeable_columns[domain] - domain_addeable_columns.delete_if { |columns_view| - deleteable = false - selected_columns.each do |selected_column| - deleteable = true if columns_view.name == selected_column.name - end - deleteable - } - } - addeable_columns - end - - def find_selected_column(column_id) - selected_columns.detect {|column| column.id == column_id} - end - - def add_column(column) - columns = selected_columns + [column] - Property.set(COLUMNS_SELECTED_KEY, columns_to_text(columns)) - end - - def remove_column(column) - columns = selected_columns.reject {|col| col.id == column.id} - Property.set(COLUMNS_SELECTED_KEY, columns_to_text(columns)) - end - - def move_column(column, direction) - position = column.position - columns = selected_columns.reject {|col| col.id == column.id} - new_position = (direction == "left") ? position - 1 : position + 1 - columns = columns.insert(new_position, column) - Property.set(COLUMNS_SELECTED_KEY, columns_to_text(columns)) - end - - def find_available_column(column_id) - available_columns.each_pair do |domain, columns| - columns.each do |column| - if column.id == column_id - return column - end - end - end - nil - end - - def sorted_column_id - @sorted_column_id - end - - def sorted_by_project_name? - @sorted_column_id==Sonar::ColumnsView::TYPE_PROJECT - end - - def set_column_sort_default(column_id) - Property.set(COLUMNS_DEFAULT_SORT_KEY, column_id) - end - - - @@available_columns = nil - - DEFAULT_DOMAIN='General' - - def available_columns - if @@available_columns.nil? - @@available_columns = {} - - @@available_columns[DEFAULT_DOMAIN] = [] - col = Sonar::ColumnsView.new - col.name = "Links" - col.id = 'links' - col.col_type = Sonar::ColumnsView::TYPE_LINKS - @@available_columns[DEFAULT_DOMAIN] << col - - col = Sonar::ColumnsView.new - col.name = "Build time" - col.id = 'build_time' - col.col_type = Sonar::ColumnsView::TYPE_BUILD_TIME - @@available_columns[DEFAULT_DOMAIN] << col - - col = Sonar::ColumnsView.new - col.name = "Language" - col.id = 'language' - col.col_type = Sonar::ColumnsView::TYPE_LANGUAGE - @@available_columns[DEFAULT_DOMAIN] << col - - col = Sonar::ColumnsView.new - col.name = "Version" - col.id = 'version' - col.col_type = Sonar::ColumnsView::TYPE_VERSION - @@available_columns[DEFAULT_DOMAIN] << col - - Metric.all.select {|m| m.display?}.each do |metric| - col = Sonar::ColumnsView.new - col.name = metric.short_name - col.id = metric.name - col.col_type = Sonar::ColumnsView::TYPE_METRIC - - if col.name - if metric.domain - @@available_columns[metric.domain] ||= [] - @@available_columns[metric.domain] << col - end - end - end - - @@available_columns.each_value {|columns| - columns.sort! { |x, y| - x.name = "" if x.name.nil? - y.name = "" if y.name.nil? - x.name <=> y.name if x.name && y.name - } - } - - end - # must return a copy of the hash ! - available_columns_clone = {} - @@available_columns.each_pair {|domain, columns| - available_columns_clone[domain] = columns.clone - } - available_columns_clone - end - - - protected - - @@default_columns=nil - - def default_text_columns - unless @@default_columns - @@default_columns = "" - @@default_columns << Sonar::ColumnsView::TYPE_METRIC + COLUMN_SEPARATOR + Metric::TECH_DEBT + COLUMNS_SEPARATOR - @@default_columns << Sonar::ColumnsView::TYPE_METRIC + COLUMN_SEPARATOR + Metric::COVERAGE + COLUMNS_SEPARATOR - @@default_columns << Sonar::ColumnsView::TYPE_BUILD_TIME + COLUMN_SEPARATOR + 'build_time' + COLUMNS_SEPARATOR - @@default_columns << Sonar::ColumnsView::TYPE_LINKS + COLUMN_SEPARATOR + "links" - end - @@default_columns - end - - def columns_from_text(text) - columns = [] - text.split(COLUMNS_SEPARATOR).each_with_index do |column_text, position| - column = column_from_text(column_text) - if column - column.position = position - column.sort_default = (column.id==@sorted_column_id) - columns << column - end - end - columns - end - - def column_from_text(text) - column_split = text.split(COLUMN_SEPARATOR) - column = Sonar::ColumnsView.new - column.id = column_split[1] - column.col_type = column_split[0] - available_col=find_available_column(column.id) - if available_col - column.name = available_col.name - column - else - nil - end - end - - def columns_to_text(columns) - text = "" - columns.each do |column| - text << column_to_text(column) + COLUMNS_SEPARATOR - end - text - end - - def column_to_text(column) - text = column.col_type + COLUMN_SEPARATOR + column.id - end - -end |