From e06ba27404127cfe01c2e926c86c6028758e6b82 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Wed, 16 Apr 2014 17:18:23 +0600 Subject: [PATCH] Component Viewer: add options --- .../coffee/component-viewer/header.coffee | 29 ++++++++ .../main/coffee/component-viewer/main.coffee | 66 ++++++++++++------ .../coffee/component-viewer/source.coffee | 9 ++- .../src/main/hbs/component-viewer/header.hbs | 7 ++ .../src/main/hbs/component-viewer/layout.hbs | 1 + .../src/main/less/component-viewer.less | 23 ++++++ sonar-server/src/main/less/icons.less | 8 +++ sonar-server/src/main/less/ui.less | 2 +- sonar-server/src/main/webapp/fonts/sonar.eot | Bin 15356 -> 15856 bytes sonar-server/src/main/webapp/fonts/sonar.svg | 6 +- sonar-server/src/main/webapp/fonts/sonar.ttf | Bin 15200 -> 15700 bytes sonar-server/src/main/webapp/fonts/sonar.woff | Bin 15176 -> 15704 bytes 12 files changed, 125 insertions(+), 26 deletions(-) create mode 100644 sonar-server/src/main/coffee/component-viewer/header.coffee create mode 100644 sonar-server/src/main/hbs/component-viewer/header.hbs diff --git a/sonar-server/src/main/coffee/component-viewer/header.coffee b/sonar-server/src/main/coffee/component-viewer/header.coffee new file mode 100644 index 00000000000..0e2dbd7040a --- /dev/null +++ b/sonar-server/src/main/coffee/component-viewer/header.coffee @@ -0,0 +1,29 @@ +define [ + 'backbone.marionette' + 'templates/component-viewer' +], ( + Marionette + Templates +) -> + + $ = jQuery + + + class HeaderView extends Marionette.ItemView + template: Templates['header'] + + + events: + 'click [data-option=coverage]': 'toggleCoverage' + + + onRender: -> + @delegateEvents() + + + toggleCoverage: (e) -> + el = $(e.currentTarget) + active = el.is '.active' + el.toggleClass 'active' + if active then @options.main.hideCoverage() else @options.main.showCoverage() + diff --git a/sonar-server/src/main/coffee/component-viewer/main.coffee b/sonar-server/src/main/coffee/component-viewer/main.coffee index e89ff2ac96f..3eef7c58c28 100644 --- a/sonar-server/src/main/coffee/component-viewer/main.coffee +++ b/sonar-server/src/main/coffee/component-viewer/main.coffee @@ -2,11 +2,13 @@ define [ 'backbone' 'backbone.marionette' 'templates/component-viewer' + 'component-viewer/header' 'component-viewer/source' ], ( Backbone Marionette Templates + HeaderView SourceView ) -> @@ -22,46 +24,70 @@ define [ regions: + headerRegion: '.component-viewer-header' sourceRegion: '.component-viewer-source' initialize: -> + @component = new Backbone.Model() + @headerView = new HeaderView model: @component, main: @ + @source = new Backbone.Model() - @sourceView = new SourceView model: @source + @sourceView = new SourceView model: @source, main: @ onRender: -> + @headerRegion.show @headerView @sourceRegion.show @sourceView + requestComponent: (key, metrics) -> + $.get API_RESOURCES, resource: key, metrics: metrics, (data) => + @component.set data[0] + + requestSource: (key) -> $.get API_SOURCES, resource: key, (data) => - @source.set { source: data[0] }, { silent: true } + @source.set source: data[0] - requestCoverage: (key) -> - metrics = 'coverage_line_hits_data,covered_conditions_by_line,conditions_by_line' - - toObj = (data) -> + extractCoverage: (data) -> + toObj = (d) -> q = {} - data.split(';').forEach (item) -> + d.split(';').forEach (item) -> tokens = item.split '=' q[tokens[0]] = tokens[1] q - - $.get API_RESOURCES, resource: key, metrics: metrics, (data) => - msr = data[0].msr - coverage = toObj _.findWhere(msr, key: 'coverage_line_hits_data').data - coverageConditions = toObj _.findWhere(msr, key: 'covered_conditions_by_line').data - conditions = toObj _.findWhere(msr, key: 'conditions_by_line').data - @source.set { - coverage: coverage, - coverageConditions: coverageConditions - conditions: conditions - }, { silent: true } + msr = data[0].msr + coverage = toObj _.findWhere(msr, key: 'coverage_line_hits_data').data + coverageConditions = toObj _.findWhere(msr, key: 'covered_conditions_by_line').data + conditions = toObj _.findWhere(msr, key: 'conditions_by_line').data + @source.set + coverage: coverage + coverageConditions: coverageConditions + conditions: conditions open: (key) -> - $.when(@requestSource(key), @requestCoverage(key)).done => - @sourceView.render() \ No newline at end of file + @key = key + @sourceView.showSpinner() + source = @requestSource key + component = @requestComponent key + $.when(source, component).done => + @render() + @hideCoverage() + + + showCoverage: -> + unless @source.has 'coverage' + metrics = 'coverage_line_hits_data,covered_conditions_by_line,conditions_by_line' + @requestComponent(@key, metrics).done (data) => + @extractCoverage data + @sourceView.render() + else + @sourceView.render() + + + hideCoverage: -> + @sourceView.hideCoverage() \ No newline at end of file diff --git a/sonar-server/src/main/coffee/component-viewer/source.coffee b/sonar-server/src/main/coffee/component-viewer/source.coffee index b6c25ba860d..ae09ad17837 100644 --- a/sonar-server/src/main/coffee/component-viewer/source.coffee +++ b/sonar-server/src/main/coffee/component-viewer/source.coffee @@ -11,8 +11,12 @@ define [ template: Templates['source'] - modelEvents: - 'change': 'render' + showSpinner: -> + @$el.html '
' + + + hideCoverage: -> + @$('.coverage').hide() serializeData: -> @@ -31,7 +35,6 @@ define [ lineCoverageConditionsStatus = 'orange' if lineCoverageConditions > 0 && lineCoverageConditions < lineConditions lineCoverageConditionsStatus = 'green' if lineCoverageConditions == lineConditions - lineNumber: line code: code coverage: lineCoverage diff --git a/sonar-server/src/main/hbs/component-viewer/header.hbs b/sonar-server/src/main/hbs/component-viewer/header.hbs new file mode 100644 index 00000000000..454b8519022 --- /dev/null +++ b/sonar-server/src/main/hbs/component-viewer/header.hbs @@ -0,0 +1,7 @@ +

{{name}}

+ +
+ + + +
\ No newline at end of file diff --git a/sonar-server/src/main/hbs/component-viewer/layout.hbs b/sonar-server/src/main/hbs/component-viewer/layout.hbs index 27a90824099..78b06dad147 100644 --- a/sonar-server/src/main/hbs/component-viewer/layout.hbs +++ b/sonar-server/src/main/hbs/component-viewer/layout.hbs @@ -1 +1,2 @@ +
\ No newline at end of file diff --git a/sonar-server/src/main/less/component-viewer.less b/sonar-server/src/main/less/component-viewer.less index 7bfd425373f..e6700dac01a 100644 --- a/sonar-server/src/main/less/component-viewer.less +++ b/sonar-server/src/main/less/component-viewer.less @@ -5,6 +5,29 @@ .component-viewer { width: 100%; min-width: 600px; + border: 1px solid @barBorderColor; +} + + +.component-viewer-header { + height: 40px; + padding: 0 10px; + border-bottom: 1px solid @barBorderColor; + background-color: @barBackgroundColor; +} + + +.component-viewer-component { + float: left; + line-height: 40px; + font-weight: bold; +} + + +.component-viewer-options { + float: right; + line-height: 1; + padding-top: 9px; } diff --git a/sonar-server/src/main/less/icons.less b/sonar-server/src/main/less/icons.less index 0042c5b31fe..c2a8a7024c8 100644 --- a/sonar-server/src/main/less/icons.less +++ b/sonar-server/src/main/less/icons.less @@ -411,6 +411,14 @@ a[class^="icon-"], a[class*=" icon-"] { color: @darkGrey; font-size: @iconFontSize; } +.icon-coverage:before { + content: "\f091"; + font-size: @iconSmallFontSize; +} +.icon-duplications:before { + content: "\f0c5"; + font-size: @iconSmallFontSize; +} /* diff --git a/sonar-server/src/main/less/ui.less b/sonar-server/src/main/less/ui.less index 47468a8a12a..9d904c6aeaa 100644 --- a/sonar-server/src/main/less/ui.less +++ b/sonar-server/src/main/less/ui.less @@ -61,7 +61,7 @@ input[type=button] { color: #fff; } - &:active { + &:active, &.active { border-color: #2790c0; background: #78bdea; color: #fff; diff --git a/sonar-server/src/main/webapp/fonts/sonar.eot b/sonar-server/src/main/webapp/fonts/sonar.eot index c1f7f3604c07da2932998b35c42eb8d41f902c47..0ac2e08c0dc6b532de69f887a1f7ca986a8a9e90 100755 GIT binary patch delta 991 zcmYjQO>7%Q6rN{qcWuYXtp9fW6W42}-i@OKLKDx{PC}w6gxKq#8#4~ zB#@#4fdhzBRCjZzDg@={)(Q@W79kF$Es9h?9FRbQV+0hG!&o9cK#3VAATdwx=bL$N z^u4E<2dnJ7$OaIa8mNd=c=uy-voiG3TJFQaPZ5GvuEK0_c?lsTBV<##cg)VeczUDb z_%z4u2pQXRr;5+o#)~@$W&Qk|&hZULlaS-M!11BEg_UzZmBkYrH|}{bf97QIons$8 zhfv=<$FD9F&n=-mJjU@h$LeBnA$02Y6A#@(sNc;A=u2moSCE|_p@Cj&3eI;i9v(p| z5>OBUQh#wVku@{I;;fTp*>N__o?<82EPI~4&MMZQkU3UiU$8IP5A1%;UrW@q+Hmd7 z`rq|Bg8Eiikg@EN9k`Bn@Nf7V{5Adx-^H8wGkg_a!DsOzp25R7iGw)M@>k1s&IGL2 zY`xY6+kxsQwqNmD{igkfeU%T$;B0$!P0}PW;3o>922F!s5_R!m5G76DlXS1a_YF!Y z&)^d9OWfElnr69FFwH`#Y?_c%lxQq)=kzNRrb%f`Rb!Nz=ES6#r&LuRzY~C;%lV@K zNAu;}?W7$hzdcTHW%E zf|c=Isip#DvWAdzuL%e8pcA|eO>dJL^pbj;C^h&RM3nv~L?lYjVV)oq){e;*Z~!Qv@vcg!9`e0jT>ng{iW12Q z;Fa4u5-I?Qf^%1M3K9?Fi4NW41#n6v8XD@$rrLwNYw+OU`v9$B9me!<1mJ@p_5f_o ztkSOTZqM6vb;i@(-IdFwQmJ@CA@+ko-`v#8-=by&?JE%!$yi4@$O3UZ}d29QK0fW||%!t>11Mx?? zulup}LguWsm6%recQ(++@MxKn^=YImB!RqDg GGw=^<66x>& delta 478 zcmexR{imGmk2M2Bg7ri;GnQ`-7q(4wsHrdPRQtfdz$nAO!0;zMvA6(83otM+NdRe% z^qk7Hm;ZOk0{IFI3}!qTsfj5}4k`W&3>G>-d9w_l00%dVJCL6O~&!58|&F{dk%rC|- z%=eRT%j5&<(ap7T%MAi+C1Re089f6-}^*Gh10{x9stxcRAQmiXpsJzE|bnI-a@ z;`wd9GH|ni+{SP|hyNvvo_xj1oY8hNkG0F>3Tu8&pi3ECnN=C=CoixTpWJL6F!{Q5 zSgajKAIBF?GtM;5Rh&P#Vz_2;z2X+(zQkj~Q^U)^TfqB-?+(8c{~duKfk%Qtf*S~j97!%67hNBza&y5MWn=}a-`XSLBhabySdLMi4g#4 CbC0h8 diff --git a/sonar-server/src/main/webapp/fonts/sonar.svg b/sonar-server/src/main/webapp/fonts/sonar.svg index a42e8c96720..a0159d70fe4 100755 --- a/sonar-server/src/main/webapp/fonts/sonar.svg +++ b/sonar-server/src/main/webapp/fonts/sonar.svg @@ -19,10 +19,11 @@ - - + + + @@ -50,6 +51,7 @@ + diff --git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