Class: Admin::OutputsController

Inherits:
ApplicationController
  • Object
show all
Includes:
Stenographer::OutputsHelper
Defined in:
app/controllers/stenographer/admin/outputs_controller.rb

Instance Method Summary collapse

Methods included from Stenographer::OutputsHelper

#slack_channels

Instance Method Details

#createObject



32
33
34
35
36
37
38
39
40
41
42
# File 'app/controllers/stenographer/admin/outputs_controller.rb', line 32

def create
  @output = Output.new(output_params)
  @output.configuration = params[:configuration].to_json
  @output.filters = params[:filters].to_json

  if @output.save
    redirect_to admin_output_path(@output), notice: 'Output Created'
  else
    redirect_to admin_outputs_path, alert: @output.errors.full_messages.to_sentence
  end
end

#destroyObject



59
60
61
62
63
64
65
# File 'app/controllers/stenographer/admin/outputs_controller.rb', line 59

def destroy
  if @output.destroy
    redirect_to admin_outputs_path, notice: 'Output Destroyed'
  else
    redirect_to admin_output_path(@output), alert: @output.errors.full_messages.to_sentence
  end
end

#editObject



44
45
46
# File 'app/controllers/stenographer/admin/outputs_controller.rb', line 44

def edit
  @authentication = @output.authentication
end

#indexObject



11
12
13
14
15
16
17
# File 'app/controllers/stenographer/admin/outputs_controller.rb', line 11

def index
  @authentication_count = Authentication.count
  @providers = Authentication.providers

  page = params[:page] || 1
  @outputs = Output.order(id: :desc).paginate(page: page, per_page: Stenographer.per_page)
end

#newObject



21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/stenographer/admin/outputs_controller.rb', line 21

def new
  authentication_id = params[:output][:authentication_id]
  @authentication = Authentication.find_by(id: authentication_id)

  if @authentication.present?
    @output = Output.new(authentication_id: authentication_id)
  else
    redirect_to admin_outputs_path, alert: 'Cannot create an Output without a Provider'
  end
end

#showObject



19
# File 'app/controllers/stenographer/admin/outputs_controller.rb', line 19

def show; end

#updateObject



48
49
50
51
52
53
54
55
56
57
# File 'app/controllers/stenographer/admin/outputs_controller.rb', line 48

def update
  @output.configuration = params[:configuration].to_json
  @output.filters = params[:filters].to_json

  if @output.save
    redirect_to admin_output_path(@output), notice: 'Output Created'
  else
    redirect_to admin_outputs_path, alert: @output.errors.full_messages.to_sentence
  end
end