<commit_before>angular = require 'angular'
throttle = require 'lodash.throttle'

#=====================================================================

module.exports = angular.module 'xoWebApp.tree', [
  require 'angular-file-upload'
  require 'angular-ui-router'

  require 'xo-api'
  require 'xo-services'

  require '../delete-vms'
]
  .config ($stateProvider) ->
    $stateProvider.state 'tree',
      url: '/tree'
      controller: 'TreeCtrl'
      template: require './view'
  .controller 'TreeCtrl', (
    $scope
    $upload
    dateFilter
    deleteVmsModal
    modal
    notify
    xo
    xoApi
  ) ->
    Object.defineProperties($scope, {
      xo: { get: -> xoApi.byTypes.xo?[0] },
      pools: { get: -> xoApi.byTypes.pool },
      hosts: { get: -> xoApi.byTypes.host },
      VMs: { get: -> xoApi.byTypes.VM },
    })

    $scope.pool_disconnect = xo.pool.disconnect
    $scope.new_sr = xo.pool.new_sr

    $scope.pool_addHost = (id) ->
      xo.host.attach id

    $scope.enableHost = (id) ->
      xo.host.enable id
      notify.info {
        title: 'Host action'
        message: 'Host is enabled'
      }

    $scope.disableHost = (id) ->
      modal.confirm({
        title: 'Disable host'
        message: 'Are you sure you want to disable this host? In disabled state, no new VMs can be started and currently active VMs on the host continue to execute.'
      }).then ->
        xo.host.disable id
      .then ->
        notify.info {
          title: 'Host action'<commit_msg>Fix global stats on the tree view.<commit_after>angular = require 'angular'
throttle = require 'lodash.throttle'

#=====================================================================

module.exports = angular.module 'xoWebApp.tree', [
  require 'angular-file-upload'
  require 'angular-ui-router'

  require 'xo-api'
  require 'xo-services'

  require '../delete-vms'
]
  .config ($stateProvider) ->
    $stateProvider.state 'tree',
      url: '/tree'
      controller: 'TreeCtrl'
      template: require './view'
  .controller 'TreeCtrl', (
    $scope
    $upload
    dateFilter
    deleteVmsModal
    modal
    notify
    xo
    xoApi
  ) ->
    Object.defineProperties($scope, {
      xo: { get: -> xoApi.byTypes.xo?.xo },
      pools: { get: -> xoApi.byTypes.pool },
      hosts: { get: -> xoApi.byTypes.host },
      VMs: { get: -> xoApi.byTypes.VM },
    })

    $scope.pool_disconnect = xo.pool.disconnect
    $scope.new_sr = xo.pool.new_sr

    $scope.pool_addHost = (id) ->
      xo.host.attach id

    $scope.enableHost = (id) ->
      xo.host.enable id
      notify.info {
        title: 'Host action'
        message: 'Host is enabled'
      }

    $scope.disableHost = (id) ->
      modal.confirm({
        title: 'Disable host'
        message: 'Are you sure you want to disable this host? In disabled state, no new VMs can be started and currently active VMs on the host continue to execute.'
      }).then ->
        xo.host.disable id
      .then ->
        notify.info {
          title: 'Host action'
{'fraction_non_alphanumeric': 0.17146640185369083, 'fraction_numerical': 0.00033101621979476995, 'mean_word_length': 2.376536312849162, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, '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': '1437357', 'n_tokens_mistral': 984, 'n_tokens_neox': 961, 'n_words': 237}