Welcome to mirror list, hosted at ThFree Co, Russian Federation.

build.js « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ba255f681b36f488479eafdf7ab9fce885a20252 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
// Generated by CoffeeScript 1.10.0
(function() {
  var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };

  this.Build = (function() {
    Build.interval = null;

    Build.state = null;

    function Build(page_url, build_url, build_status, state1) {
      this.page_url = page_url;
      this.build_url = build_url;
      this.build_status = build_status;
      this.state = state1;
      this.hideSidebar = bind(this.hideSidebar, this);
      this.toggleSidebar = bind(this.toggleSidebar, this);
      clearInterval(Build.interval);
      this.bp = Breakpoints.get();
      this.hideSidebar();
      $('.js-build-sidebar').niceScroll();
      $(document).off('click', '.js-sidebar-build-toggle').on('click', '.js-sidebar-build-toggle', this.toggleSidebar);
      $(window).off('resize.build').on('resize.build', this.hideSidebar);
      this.updateArtifactRemoveDate();
      if ($('#build-trace').length) {
        this.getInitialBuildTrace();
        this.initScrollButtonAffix();
      }
      if (this.build_status === "running" || this.build_status === "pending") {
        $('#autoscroll-button').on('click', function() {
          var state;
          state = $(this).data("state");
          if ("enabled" === state) {
            $(this).data("state", "disabled");
            return $(this).text("enable autoscroll");
          } else {
            $(this).data("state", "enabled");
            return $(this).text("disable autoscroll");
          }
        });
        Build.interval = setInterval((function(_this) {
          return function() {
            if (window.location.href.split("#").first() === _this.page_url) {
              return _this.getBuildTrace();
            }
          };
        })(this), 4000);
      }
    }

    Build.prototype.getInitialBuildTrace = function() {
      return $.ajax({
        url: this.build_url,
        dataType: 'json',
        success: function(build_data) {
          $('.js-build-output').html(build_data.trace_html);
          if (build_data.status === 'success' || build_data.status === 'failed') {
            return $('.js-build-refresh').remove();
          }
        }
      });
    };

    Build.prototype.getBuildTrace = function() {
      return $.ajax({
        url: this.page_url + "/trace.json?state=" + (encodeURIComponent(this.state)),
        dataType: "json",
        success: (function(_this) {
          return function(log) {
            if (log.state) {
              _this.state = log.state;
            }
            if (log.status === "running") {
              if (log.append) {
                $('.js-build-output').append(log.html);
              } else {
                $('.js-build-output').html(log.html);
              }
              return _this.checkAutoscroll();
            } else if (log.status !== _this.build_status) {
              return Turbolinks.visit(_this.page_url);
            }
          };
        })(this)
      });
    };

    Build.prototype.checkAutoscroll = function() {
      if ("enabled" === $("#autoscroll-button").data("state")) {
        return $("html,body").scrollTop($("#build-trace").height());
      }
    };

    Build.prototype.initScrollButtonAffix = function() {
      var $body, $buildScroll, $buildTrace;
      $buildScroll = $('#js-build-scroll');
      $body = $('body');
      $buildTrace = $('#build-trace');
      return $buildScroll.affix({
        offset: {
          bottom: function() {
            return $body.outerHeight() - ($buildTrace.outerHeight() + $buildTrace.offset().top);
          }
        }
      });
    };

    Build.prototype.shouldHideSidebar = function() {
      var bootstrapBreakpoint;
      bootstrapBreakpoint = this.bp.getBreakpointSize();
      return bootstrapBreakpoint === 'xs' || bootstrapBreakpoint === 'sm';
    };

    Build.prototype.toggleSidebar = function() {
      if (this.shouldHideSidebar()) {
        return $('.js-build-sidebar').toggleClass('right-sidebar-expanded right-sidebar-collapsed');
      }
    };

    Build.prototype.hideSidebar = function() {
      if (this.shouldHideSidebar()) {
        return $('.js-build-sidebar').removeClass('right-sidebar-expanded').addClass('right-sidebar-collapsed');
      } else {
        return $('.js-build-sidebar').removeClass('right-sidebar-collapsed').addClass('right-sidebar-expanded');
      }
    };

    Build.prototype.updateArtifactRemoveDate = function() {
      var $date, date;
      $date = $('.js-artifacts-remove');
      if ($date.length) {
        date = $date.text();
        return $date.text($.timefor(new Date(date), ' '));
      }
    };

    return Build;

  })();

}).call(this);