<commit_before>activeLogs = new ReactiveVar null

Template.instances.helpers
  instances: ->
    if Session.get('queryName')?.length
      Instances.find {name: {$regex: Session.get('queryName'), $options: 'i'}}, sort: key: 1
    else
      Instances.find {}, sort: key: 1
  activityIcon: ->
    if @meta.state is 'active'
      'ok-sign'
    else if "#{@meta.state}".match /loading|activating/
      'play-circle'
    else if "#{@meta.state}".match /pulling/
      'download'
    else if "#{@meta.state}".match /stopping/
      'collapse-down'
    else
      'exclamation-sign'
  showProgressbar: -> "#{@meta.state}".match /loading|activating|pulling|stopping/
  totalSteps: -> @meta.totalSteps
  progress: -> @meta.progress
  progressPercentage: ->
    if "#{@meta.state}".match /stopping/
      # let the percentage count down
      ((parseInt(@meta.totalSteps)-parseInt(@meta.progress))/parseInt(@meta.totalSteps))*100
    else
      (parseInt(@meta.progress)/parseInt(@meta.totalSteps))*100
  stopButtonText: -> if @meta.state isnt 'active' then 'Destroy' else 'Stop'
  instanceLink: ->
    endpoint = @services?.www?.endpoint or ":" + findWebPort @services?.www
    protocol = @services?.www?.protocol or determineProtocol port
    if @services?.www?.hostname
      "#{protocol}://#{@services?.www?.hostname}#{endpoint}"
  params: -> key: k, value: v for k, v of @parameters when k isnt 'tags' if @parameters
  services: -> {name: k, data: v} for k, v of @services
  pretify: (json) -> JSON.stringify json, undefined, 2
  isSearching: -> Session.get('queryName')?.length
  instanceHash: -> CryptoJS.MD5 "#{@key}"
  searchTerms: -> Session.get 'queryName'

Template.instances.events
  'click .stop-instance': ->
    Meteor.call 'stopInstance', @name
  'click .clear-instance': ->
    Meteor.call 'clearInstance', @project, @name<commit_msg>Fix port problem<commit_after>activeLogs = new ReactiveVar null

Template.instances.helpers
  instances: ->
    if Session.get('queryName')?.length
      Instances.find {name: {$regex: Session.get('queryName'), $options: 'i'}}, sort: key: 1
    else
      Instances.find {}, sort: key: 1
  activityIcon: ->
    if @meta.state is 'active'
      'ok-sign'
    else if "#{@meta.state}".match /loading|activating/
      'play-circle'
    else if "#{@meta.state}".match /pulling/
      'download'
    else if "#{@meta.state}".match /stopping/
      'collapse-down'
    else
      'exclamation-sign'
  showProgressbar: -> "#{@meta.state}".match /loading|activating|pulling|stopping/
  totalSteps: -> @meta.totalSteps
  progress: -> @meta.progress
  progressPercentage: ->
    if "#{@meta.state}".match /stopping/
      # let the percentage count down
      ((parseInt(@meta.totalSteps)-parseInt(@meta.progress))/parseInt(@meta.totalSteps))*100
    else
      (parseInt(@meta.progress)/parseInt(@meta.totalSteps))*100
  stopButtonText: -> if @meta.state isnt 'active' then 'Destroy' else 'Stop'
  instanceLink: ->
    port = findWebPort @services?.www
    endpoint = @services?.www?.endpoint or ":" + port
    protocol = @services?.www?.protocol or determineProtocol port
    if @services?.www?.hostname
      "#{protocol}://#{@services?.www?.hostname}#{endpoint}"
  params: -> key: k, value: v for k, v of @parameters when k isnt 'tags' if @parameters
  services: -> {name: k, data: v} for k, v of @services
  pretify: (json) -> JSON.stringify json, undefined, 2
  isSearching: -> Session.get('queryName')?.length
  instanceHash: -> CryptoJS.MD5 "#{@key}"
  searchTerms: -> Session.get 'queryName'

Template.instances.events
  'click .stop-instance': ->
    Meteor.call 'stopInstance', @name
  'click .clear-instance': ->
    Meteor.call 'clearInstance', @project, @name
{'fraction_non_alphanumeric': 0.16527365866810462, 'fraction_numerical': 0.005392289026691831, 'mean_word_length': 3.580246913580247, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 8, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2751121', 'n_tokens_mistral': 1204, 'n_tokens_neox': 1203, 'n_words': 281}