]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5616 DSM should show the files dependencies to cut found on modules
authorStas Vilchik <vilchiks@gmail.com>
Mon, 6 Oct 2014 10:30:28 +0000 (12:30 +0200)
committerStas Vilchik <vilchiks@gmail.com>
Mon, 6 Oct 2014 10:49:59 +0000 (12:49 +0200)
server/sonar-web/src/main/coffee/design/app.coffee
server/sonar-web/src/main/hbs/design/design.hbs
server/sonar-web/src/main/js/common/handlebars-extensions.js
server/sonar-web/src/main/less/dsm.less

index 278196d65ed2d28f984c3c7834dbb54d3da2bc1b..b5927ca6d6cd1204a4208bd568b57e1a25757099 100644 (file)
@@ -31,7 +31,16 @@ requirejs [
 
 
   App.addInitializer ->
-    $.get RESOURCES_URL, resource: window.resourceKey, metrics: 'dsm', (rawData) ->
+    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'
+
+    $.when(packageTanglesXHR, dsmXHR).done ->
+      rawData = dsmXHR.responseJSON
       data = JSON.parse rawData[0].msr[0].data
       data.forEach (row, rowIndex) ->
         row.v.forEach (cell, columnIndex) ->
@@ -40,7 +49,10 @@ requirejs [
               cell.status = 'cycle'
             else
               cell.status = 'dependency'
-      @view = new DesignView app: @, collection: new Backbone.Collection data
+      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
 
 
index f9a7b5230663adeaa884b33e3b68b90befe35244..b81223774e7fc86b25c92ff0d1d9683ee9fb06e6 100644 (file)
@@ -27,6 +27,9 @@
       <tr>
         <td class="dsm-body-title" title="{{t 'design.rowTooltip'}}">
           {{qualifierIcon q}} {{n}}
+          {{#gt pt 0}}
+            <span class="dsm-body-title-package-tangles" title="{{t 'metric.package_cycles.name'}}">{{pt}}</span>
+          {{/gt}}
           <span class="dsm-body-title-indicator"></span>
         </td>
         {{#eachIndex v}}
index 351f76a1d1673e920406f1fc096ecdacc010c3a0..f6ad6a80e727895ed29dd4a120f57a6bde3546fe 100644 (file)
@@ -116,6 +116,10 @@ define(['handlebars'], function (Handlebars) {
     return v1 != v2 ? options.fn(this) : options.inverse(this);
   });
 
+  Handlebars.registerHelper('gt', function(v1, v2, options) {
+    return v1 > v2 ? options.fn(this) : options.inverse(this);
+  });
+
   Handlebars.registerHelper('notNull', function(value, options) {
     return value != null ? options.fn(this) : options.inverse(this);
   });
index 35573bd08902d9079e5637416c703eedac385b28..3090de47e53b8958bd5d9107b10da550b7074444 100644 (file)
     &.changed { padding-top: 7px; }
   }
 }
+
+.dsm-body-title-package-tangles {
+  float: right;
+  margin: 0 -10px 0 10px;
+  padding: 2px 5px;
+  border-radius: 20px;
+  background: @red;
+  font-size: @smallFontSize;
+  color: #fff;
+}