<commit_before>#
#   Copyright 2011 Red Hat, Inc.
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.
#

class InstancesController < ApplicationController
  before_filter :require_user
  before_filter :load_instance, :only => [:show, :key, :edit, :update, :stop, :reboot]
  before_filter :set_view_vars, :only => [:show, :index, :export_events]
  before_filter :check_inaccessible_instances, :only => [:stop, :multi_stop]

  def index
    @params = params
    @title = t("instances.instances.other")
    save_breadcrumb(instances_path(:viewstate => viewstate_id))
    load_instances

    respond_to do |format|
      format.html
      format.js { render :partial => 'list' }
      format.json { render :json => @instances.map{ |instance| view_context.instance_for_mustache(instance) } }
    end
  end

  def new
    respond_to do |format|
      format.js
      format.json
    end
  end

  def create
  end

  def show
    load_instances
    save_breadcrumb(instance_path(@instance), @instance.name)
    @events = @instance.events.paginate(:page => params[:page] || 1)
    @view = params[:details_tab].blank? ? 'properties' : params[:details_tab]
    @details_tab = 'properties' unless ['properties', 'history',
                                        'parameters', 'permissions'].include?(@details_tab)
    @tabs = [
      {:name => t('properties'), :view => @view, :id => 'properties'},
      {:name => t('instances.parameters.config_parameters'), :view => 'parameters', :id => 'parameters'},
      {:name => t('history'), :view => 'history', :id => 'history'}
    ]
    @details_tab = @tabs.find {|t| t[:view] == @view}
    respond_to do |format|
      format.html { render :action => 'show'}
      format.js do
        if params.delete :details_pane
          render :partial => 'layouts/details_pane' and return
        end
        render :partial => @details_tab[:view] and return
      end
      format.json { render :json => @instance }
    end
  end

  def edit
    require_privilege(Privilege::MODIFY, @instance)<commit_msg>remove unused methods<commit_after>#
#   Copyright 2011 Red Hat, Inc.
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.
#

class InstancesController < ApplicationController
  before_filter :require_user
  before_filter :load_instance, :only => [:show, :key, :edit, :update, :stop, :reboot]
  before_filter :set_view_vars, :only => [:show, :index, :export_events]
  before_filter :check_inaccessible_instances, :only => [:stop, :multi_stop]

  def index
    @params = params
    @title = t("instances.instances.other")
    save_breadcrumb(instances_path(:viewstate => viewstate_id))
    load_instances

    respond_to do |format|
      format.html
      format.js { render :partial => 'list' }
      format.json { render :json => @instances.map{ |instance| view_context.instance_for_mustache(instance) } }
    end
  end

  def show
    load_instances
    save_breadcrumb(instance_path(@instance), @instance.name)
    @events = @instance.events.paginate(:page => params[:page] || 1)
    @view = params[:details_tab].blank? ? 'properties' : params[:details_tab]
    @details_tab = 'properties' unless ['properties', 'history',
                                        'parameters', 'permissions'].include?(@details_tab)
    @tabs = [
      {:name => t('properties'), :view => @view, :id => 'properties'},
      {:name => t('instances.parameters.config_parameters'), :view => 'parameters', :id => 'parameters'},
      {:name => t('history'), :view => 'history', :id => 'history'}
    ]
    @details_tab = @tabs.find {|t| t[:view] == @view}
    respond_to do |format|
      format.html { render :action => 'show'}
      format.js do
        if params.delete :details_pane
          render :partial => 'layouts/details_pane' and return
        end
        render :partial => @details_tab[:view] and return
      end
      format.json { render :json => @instance }
    end
  end

  def edit
    require_privilege(Privilege::MODIFY, @instance)
{'fraction_non_alphanumeric': 0.12535042050460551, 'fraction_numerical': 0.003604325190228274, 'mean_word_length': 3.3624454148471616, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5314899', 'n_tokens_mistral': 1491, 'n_tokens_neox': 1471, 'n_words': 437}