summaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/coffee/libraries/app.coffee
blob: d1cc1534f874dde842bbc38f7f6e4fbf48d6b0dd (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
30
31
32
33
34
35
36
37
38
requirejs.config
  baseUrl: "#{baseUrl}/js"


requirejs [
  'libraries/view'
], (
  LibrariesView
) ->

  $ = jQuery
  RESOURCES_URL = "#{baseUrl}/api/resources"
  DEPENDENCY_TREE_URL = "#{baseUrl}/api/dependency_tree"
  App = new Marionette.Application


  App.addInitializer ->
    $.get RESOURCES_URL, resource: window.resourceKey, scopes: 'PRJ', depth: -1, (rawData) ->
      components = new Backbone.Collection rawData
      requests = components.map (component) ->
        id = component.get 'id'
        $.get DEPENDENCY_TREE_URL, resource: id, scopes: 'PRJ', (data) ->
          component.set 'libraries', data

      $.when.apply($, requests).done =>
        components.reset components.reject (model) ->
          (model.get('id') == window.resourceKey || model.get('key') == window.resourceKey) &&
              model.get('libraries').length == 0

        @view = new LibrariesView app: @, collection: components
        $('#project-libraries').empty().append @view.render().el


  # Message bundles
  l10nXHR = window.requestMessages()


  jQuery.when(l10nXHR).done -> App.start()