class @Utils @navigatePath: (path) -> path = "/" + path unless path.match(/^\//) window.location.href = path @currentPath: -> window.location.href.replace(/https?:\/\/.*?\//g, '') @registerPage: (klass, options = {}) -> if options.forPathsMatching? if Utils.currentPath().match(options.forPathsMatching) window.currentPage = new klass() else new klass() @showDynamicModal: (content = '', { title, body, onHide } = {}) -> $("body").append """ """ modal = document.querySelector('#dynamic-modal') $(modal).find('.modal-title').text(title || '').end().on 'hidden.bs.modal', -> $('#dynamic-modal').remove() onHide?() body?(modal.querySelector('.modal-body')) $(modal).modal('show') @handleDryRunButton: (button, data = $(button.form).serialize()) -> $(button).prop('disabled', true) $('body').css(cursor: 'progress') $.ajax type: 'POST', url: $(button).data('action-url'), dataType: 'json', data: data .always => $('body').css(cursor: 'auto') .done (json) => Utils.showDynamicModal """
Log

          
Events

          
Memory

          """,
          body: (body) ->
            $(body).
              find('.agent-dry-run-log').text(json.log).end().
              find('.agent-dry-run-events').text(json.events).end().
              find('.agent-dry-run-memory').text(json.memory)
          title: 'Dry Run Results',
          onHide: -> $(button).prop('disabled', false)
      .fail (xhr, status, error) ->
        alert('Error: ' + error)
        $(button).prop('disabled', false)