aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/drilldown/app.js
blob: f5e606e1dde6ad079a9a9791703c493031281210 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import $ from 'jquery';
import Marionette from 'backbone.marionette';
import SourceViewer from '../../components/source-viewer/main';

var App = new Marionette.Application(),
    init = function () {
      let options = window.sonarqube;
      App.addRegions({ viewerRegion: options.el });
      $('.js-drilldown-link').on('click', function (e) {
        e.preventDefault();
        $(e.currentTarget).closest('table').find('.selected').removeClass('selected');
        $(e.currentTarget).closest('tr').addClass('selected');
        var uuid = $(e.currentTarget).data('uuid'),
            viewer = new SourceViewer();
        App.viewerRegion.show(viewer);
        viewer.open(uuid);
        if (window.drilldown.period != null) {
          viewer.on('loaded', function () {
            viewer.filterLinesByDate(window.drilldown.period, window.drilldown.periodName);
          });
        }
      });
    };

App.on('start', function (options) {
  init.call(App, options);
});

window.sonarqube.appStarted.then(options => App.start(options));