<commit_before>class TroubleshootModal extends KDModalView

  constructor: (options = {}, data) ->
    super options, data

    KD.troubleshoot()

    @init()
class TroubleshootStatus extends KDCustomHTMLView

  constructor: (options, data) ->
    data = KD.singleton("troubleshoot").getItems()
    super options, data

    @bongo = new TroubleshootItemView
      title: "Bongo"
    , @getData()["bongo"]

    @broker = new TroubleshootItemView
      title : "Broker"
    , @getData()["broker"]

    @kiteBroker = new TroubleshootItemView
      title : "Kite-Broker"
    , @getData()["kiteBroker"]

    @osKite = new TroubleshootItemView
      title : "OS-Kite"
    , @getData()["osKite"]

    @webServer = new TroubleshootItemView
      title : "Webserver"
    , @getData()["webServer"]

    @connection = new TroubleshootItemView
      title : "Internet Connection"
    , @getData()["connection"]

    @version = new KDCustomHTMLView
      title : "Build Version: #{KD.config.version}"

    @addSubView @bongo
    @addSubView @broker
    @addSubView @kiteBroker
    @addSubView @osKite
    @addSubView @webServer
    @addSubView @connection
    @addSubView @version


class TroubleshootItemView extends KDCustomHTMLView

  constructor: (options, data) ->

    super options, data

    @loader = new KDLoaderView
      size          : width : 16
      showLoader    : yes

    @getData().on "healthCheckCompleted", =>
      @loader.hide()
      @render()


  viewAppended: ->
    JView::viewAppended.call this


  getResponseTime: ->
    responseTime = @getData().getResponseTime()
    return "#{responseTime} ms" unless responseTime is ""

    responseTime


  pistachio:->
    {title} = @getOptions()
    """
      {{> @loader}}  #{title} : {{ #(status) }} {{@getResponseTime #(dummy) }}
    """

<commit_msg>Troubleshoot: TroubleshootModal now extends KDModalViewWithForms<commit_after>class TroubleshootModal extends KDModalViewWithForms

  constructor: (options = {}, data) ->
    troubleshoot = KD.singleton("troubleshoot")

    options =
        title                 : "Check Koding Status"
        overlay               : yes
        tabs                  :
          forms               :
            Troubleshoot      :
              callback        : =>
                {feedback} = @modalTabs.forms.Troubleshoot.customData
                KD.logToExternal "troubleshoot feedback", {failure:troubleshoot.getFailureFeedback(), feedback}
                @destroy()
              buttons         :
                sendFeedback    :
                  title       : "Send Feedback"
                  style       : "modal-clean-gray"
                  type        : "submit"
                  loader      :
                    color     : "#444444"
                    diameter  : 12
                  callback    : -> @hideLoader()
                close         :
                  title       : "Close"
                  style       : "modal-cancel"
                  callback    : => @destroy()
              fields          :
                check         :
                  label       : "System Status"
                  itemClass   : TroubleshootStatusView
                feedback      :
                  label       : "Feedback"
                  itemClass   : KDInputView
                  name        : "feedback"
                  placeholder : "Define the situation"

    super options, data

    KD.troubleshoot()

    @init()
class TroubleshootStatus extends KDCustomHTMLView

  constructor: (options, data) ->
    data = KD.singleton("troubleshoot").getItems()
    super options, data

    @bongo = new TroubleshootItemView
      title: "Bongo"
    , @getData()["bongo"]

    @broker = new TroubleshootItemView
      title : "Broker"
    , @getData()["broker"]

    @kiteBroker = new TroubleshootItemView
      title : "Kite-Broker"
    , @getData()["kiteBroker"]

    @osKite = new TroubleshootItemView
      title : "OS-Kite"
    , @getData()["osKite"]

    @webServer = new TroubleshootItemView
      title : "Webserver"
    , @getData()["webServer"]

    @connection = new TroubleshootItemView
      title : "Internet Connection"
    , @getData()["connection"]

    @version = new KDCustomHTMLView
      title : "Build Version: #{KD.config.version}"

    @addSubView @bongo
    @addSubView @broker
    @addSubView @kiteBroker
    @addSubView @osKite
    @addSubView @webServer
    @addSubView @connection
    @addSubView @version


class TroubleshootItemView extends KDCustomHTMLView

  constructor: (options, data) ->

    super options, data

    @loader = new KDLoaderView
      size          : width : 16
      showLoader    : yes

    @getData().on "healthCheckCompleted", =>
      @loader.hide()
      @render()


  viewAppended: ->
    JView::viewAppended.call this


  getResponseTime: ->
    responseTime = @getData().getResponseTime()
    return "#{responseTime} ms" unless responseTime is ""

    responseTime


  pistachio:->
    {title} = @getOptions()
    """
      {{> @loader}}  #{title} : {{ #(status) }} {{@getResponseTime #(dummy) }}
    """


{'fraction_non_alphanumeric': 0.10940876055784718, 'fraction_numerical': 0.002357100766057749, 'mean_word_length': 2.0112359550561796, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5392910', 'n_tokens_mistral': 1581, 'n_tokens_neox': 1501, 'n_words': 316}