<commit_before>class IDE.VMItemView extends NFileItemView

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

    options.cssClass or= "vm"

    super options, data

    @vmInfo         = new KDCustomHTMLView
      tagName       : 'span'
      cssClass      : 'vm-info'
      partial       : "#{data.vmName}"

    @terminalButton = new KDButtonView
      cssClass      : 'terminal'
      callback      : =>
        data        = @getData()
        data.treeController.emit 'TerminalRequested', data.vm

    @folderSelector = new KDSelectBox
      selectOptions : @createSelectOptions()
      callback      : @bound 'updateVMRoot'

    @vm = KD.getSingleton 'vmController'
    @vm.on 'StateChanged', @bound 'checkVMState'

    @vm.fetchVMDomains data.vmName, (err, domains) =>
      if not err and domains.length > 0
        @vmInfo.updatePartial domains.first

  updateVMRoot: (path) ->
    data    = @getData()
    vm      = data.vmName
    finder  = data.treeController.getDelegate()

    finder?.updateVMRoot vm, path

  createSelectOptions: ->
    currentPath = @getData().path
    nickname    = KD.nick()
    parents     = []
    nodes       = currentPath.split '/'

    for x in [ 0...nodes.length ]
      nodes = currentPath.split '/'
      path  = nodes.splice(1,x).join '/'
      parents.push "/#{path}"

    parents.reverse()

    items = []

    for path in parents when path
      items.push title: path, value: path

    return items

  pistachio:->
    return """
      <div class="vm-header">
        {{> @vmInfo}}
        <div class="buttons">
          {{> @terminalButton}}
          <span class='chevron'></span>
        </div><commit_msg>Put checkVMState method back for IDEVMItem.<commit_after>class IDE.VMItemView extends NFileItemView

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

    options.cssClass or= "vm"

    super options, data

    @vmInfo         = new KDCustomHTMLView
      tagName       : 'span'
      cssClass      : 'vm-info'
      partial       : "#{data.vmName}"

    @terminalButton = new KDButtonView
      cssClass      : 'terminal'
      callback      : =>
        data        = @getData()
        data.treeController.emit 'TerminalRequested', data.vm

    @folderSelector = new KDSelectBox
      selectOptions : @createSelectOptions()
      callback      : @bound 'updateVMRoot'

    @vm = KD.getSingleton 'vmController'
    @vm.on 'StateChanged', @bound 'checkVMState'

    @vm.fetchVMDomains data.vmName, (err, domains) =>
      if not err and domains.length > 0
        @vmInfo.updatePartial domains.first

  updateVMRoot: (path) ->
    data    = @getData()
    vm      = data.vmName
    finder  = data.treeController.getDelegate()

    finder?.updateVMRoot vm, path

  createSelectOptions: ->
    currentPath = @getData().path
    nickname    = KD.nick()
    parents     = []
    nodes       = currentPath.split '/'

    for x in [ 0...nodes.length ]
      nodes = currentPath.split '/'
      path  = nodes.splice(1,x).join '/'
      parents.push "/#{path}"

    parents.reverse()

    items = []

    for path in parents when path
      items.push title: path, value: path

    return items

  checkVMState:(err, vm, info)->
    return unless vm is @getData().vmName

    if err or not info
      @unsetClass 'online'
      return warn err

    if info.state is "RUNNING"
    then @setClass 'online'
    else @unsetClass 'online'

  pistachio:->
    return """
      <div class="vm-header">
        {{> @vmInfo}}
        <div class="buttons">
          {{> @terminalButton}}
          <span class='chevron'></span>
        </div>
{'fraction_non_alphanumeric': 0.12180746561886051, 'fraction_numerical': 0.0016839741790625876, 'mean_word_length': 2.168, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 32, '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': '5981822', 'n_tokens_mistral': 1120, 'n_tokens_neox': 1072, 'n_words': 262}