diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2015-03-09 10:46:14 +0100 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2015-03-09 10:46:14 +0100 |
commit | 8260aba269d3d8815d3c0e2716732b8db6db1880 (patch) | |
tree | 7d16078bc692f738c861f4849fd94b7861e1966a /server/sonar-web/src/main/coffee | |
parent | 1c2a7ac3b8da5dbe4efaace5893db1f595ae173e (diff) | |
download | sonarqube-8260aba269d3d8815d3c0e2716732b8db6db1880.tar.gz sonarqube-8260aba269d3d8815d3c0e2716732b8db6db1880.zip |
rewrite dsm app
Diffstat (limited to 'server/sonar-web/src/main/coffee')
-rw-r--r-- | server/sonar-web/src/main/coffee/design/app.coffee | 77 | ||||
-rw-r--r-- | server/sonar-web/src/main/coffee/design/info-view.coffee | 33 | ||||
-rw-r--r-- | server/sonar-web/src/main/coffee/design/view.coffee | 155 |
3 files changed, 0 insertions, 265 deletions
diff --git a/server/sonar-web/src/main/coffee/design/app.coffee b/server/sonar-web/src/main/coffee/design/app.coffee deleted file mode 100644 index 1a54425acd4..00000000000 --- a/server/sonar-web/src/main/coffee/design/app.coffee +++ /dev/null @@ -1,77 +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. -# - -requirejs.config - baseUrl: "#{baseUrl}/js" - - -requirejs [ - 'design/view' -], ( - DesignView -) -> - - $ = jQuery - RESOURCES_URL = "#{baseUrl}/api/resources" - App = new Marionette.Application - - - App.noDataAvailable = -> - message = t 'design.noData' - $('#project-design').html "<p class=\"message-alert\"><i class=\"icon-alert-warn\"></i> #{message}</p>" - - - App.addInitializer -> - packageTangles = {} - - packageTanglesXHR = $.get RESOURCES_URL, resource: window.resourceKey, depth: 1, metrics: 'package_tangles', (data) -> - data.forEach (component) -> - packageTangles[component.id] = component.msr[0].frmt_val - - dsmXHR = $.get RESOURCES_URL, resource: window.resourceKey, metrics: 'dsm' - dsmXHR.fail -> App.noDataAvailable() - - $.when(packageTanglesXHR, dsmXHR).done -> - rawData = dsmXHR.responseJSON - unless _.isArray(rawData) && rawData.length == 1 && _.isArray(rawData[0].msr) - App.noDataAvailable() - return - data = JSON.parse rawData[0].msr[0].data - data.forEach (row, rowIndex) -> - row.v.forEach (cell, columnIndex) -> - if cell.w? && cell.w > 0 - if rowIndex < columnIndex - cell.status = 'cycle' - else - cell.status = 'dependency' - data = data.map (row) -> - _.extend row, empty: row.q == 'DIR' && row.v.every (item) -> !item.w? - collection = new Backbone.Collection data - collection.forEach (model) -> - model.set 'pt', packageTangles[model.get 'i'] - @view = new DesignView app: @, collection: collection - $('#project-design').empty().append @view.render().el - - - # Message bundles - l10nXHR = window.requestMessages() - - - jQuery.when(l10nXHR).done -> App.start() diff --git a/server/sonar-web/src/main/coffee/design/info-view.coffee b/server/sonar-web/src/main/coffee/design/info-view.coffee deleted file mode 100644 index b626ce86099..00000000000 --- a/server/sonar-web/src/main/coffee/design/info-view.coffee +++ /dev/null @@ -1,33 +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. -# - -define [ - 'templates/design' -], -> - - - class extends Marionette.ItemView - template: Templates['dsm-info'] - - - serializeData: -> - _.extend super, - first: @options.first - second: @options.second diff --git a/server/sonar-web/src/main/coffee/design/view.coffee b/server/sonar-web/src/main/coffee/design/view.coffee deleted file mode 100644 index 44c57a6976a..00000000000 --- a/server/sonar-web/src/main/coffee/design/view.coffee +++ /dev/null @@ -1,155 +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. -# - -define [ - 'design/info-view', - 'templates/design' -], (InfoView) -> - $ = jQuery - API_DEPENDECIES = "#{baseUrl}/api/dependencies" - - - class extends Marionette.Layout - template: Templates['design'] - className: 'dsm' - - - regions: - infoRegion: '.dsm-info' - - - ui: - titles: '.dsm-body-title' - cells: '.dsm-body-cell' - dependencies: '.dsm-body-dependency' - - - events: - 'click @ui.titles': 'highlightComponent' - 'dblclick @ui.titles': 'goToComponent' - 'click @ui.cells': 'highlightCell' - 'dblclick @ui.dependencies': 'showDependencies' - 'change .js-hide-dir': 'toggleDirDisplay' - - - onRender: -> - @toggleDirDisplay() - - - clearCells: -> - @ui.titles.removeClass 'dsm-body-highlighted dsm-body-usage dsm-body-dependency' - @ui.cells.removeClass 'dsm-body-highlighted dsm-body-usage dsm-body-dependency' - - - highlightComponent: (e) -> - index = @ui.titles.index $(e.currentTarget) - @clearCells() - @highlightRow index - @highlightColumn index - @highlightUsages index - @highlightDependencies index - - - highlightCell: (e) -> - cell = $(e.currentTarget) - column = cell.parent().children().index(cell) - 1 - row = cell.parent().parent().children().index cell.parent() - @clearCells() - if row == column - @highlightRow row - @highlightColumn row - @highlightUsages row - @highlightDependencies row - else - @highlightRow column, 'dsm-body-usage' - @highlightColumn column, 'dsm-body-usage' - @highlightRow row, 'dsm-body-dependency' - @highlightColumn row, 'dsm-body-dependency' - - - highlightRow: (index, c = 'dsm-body-highlighted') -> - @$(".dsm-body tr:eq(#{index}) td").addClass c - - - highlightColumn: (index, c = 'dsm-body-highlighted') -> - @$(".dsm-body tr").each -> - $(this).find("td:eq(#{index + 1})").addClass c - - - highlightUsages: (index) -> - @collection.at(index).get('v').forEach (d, i) => - if i < index && d.w? - @$("tr:eq(#{i}) .dsm-body-title").addClass 'dsm-body-usage' - - - highlightDependencies: (index) -> - @collection.forEach (model, i) => - if model.get('v')[index].w? - @$("tr:eq(#{i}) .dsm-body-title").addClass 'dsm-body-dependency' - - - goToComponent: (e) -> - cell = $(e.currentTarget) - row = cell.parent().parent().children().index cell.parent() - model = @collection.at(row) - page = if model.get('q') == 'CLA' || model.get('q') == 'FIL' then 'dashboard' else 'design' - window.location = "#{baseUrl}/#{page}/index/#{model.get 'i'}" - - - showDependencies: (e) -> - cell = $(e.currentTarget) - column = cell.parent().children().index(cell) - 1 - row = cell.parent().parent().children().index cell.parent() - id = @collection.at(row).get('v')[column].i - return unless id - @showInfoViewSpinner() - @scrollToInfoView() - $.get API_DEPENDECIES, parent: id, (data) => - @infoRegion.show new InfoView - collection: new Backbone.Collection data - first: @collection.at(column).toJSON() - second: @collection.at(row).toJSON() - @scrollToInfoView() - - - showInfoViewSpinner: -> - @infoRegion.reset() - @$(@infoRegion.el).html '<i class="spinner"></i>' - - - scrollToInfoView: -> - delta = @$(@infoRegion.el).offset().top - 40 - $('html, body').animate { scrollTop: delta }, 500 - - - toggleDirDisplay: -> - rows = @$('tr') - rows.each (index) -> - if $(@).data('empty')? - $(@).toggleClass 'hidden' - rows.each -> - $(@).find('td').eq(index + 1).toggleClass 'hidden' - - - serializeData: -> - hasDirectories = @collection.some (model) -> model.get('q') == 'DIR' - _.extend super, - hasDirectories: hasDirectories - |