Class: Bigbluebutton::ServersController

Inherits:
ApplicationController
  • Object
show all
Includes:
BigbluebuttonRails::InternalControllerMethods
Defined in:
app/controllers/bigbluebutton/servers_controller.rb

Instance Method Summary collapse

Methods included from BigbluebuttonRails::InternalControllerMethods

included

Instance Method Details

#activityObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'app/controllers/bigbluebutton/servers_controller.rb', line 24

def activity
  error = false
  begin
    @server.fetch_meetings
    @server.meetings.each do |meeting|
      meeting.fetch_meeting_info
    end
  rescue BigBlueButton::BigBlueButtonException => e
    error = true
    message = e.to_s[0..200]
  end

  # update_list works only for html
  if params[:update_list] && (params[:format].nil? || params[:format].to_s == "html")
    render :partial => 'activity_list', :locals => { :server => @server }
    return
  end

  respond_with @server.meetings do |format|
    # we return/render the fetched meetings even in case of error
    # but we set the error message in the response
    if error
      flash[:error] = message
      format.html { render :activity }
      format.json {
        array = @server.meetings
        array.insert(0, { :message => message })
        render :json => array, :status => :error
      }
    else
      format.html
      format.json
    end
  end
end

#createObject



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'app/controllers/bigbluebutton/servers_controller.rb', line 60

def create
  @server = BigbluebuttonServer.new(server_params)

  respond_with @server do |format|
    if @server.save
      format.html {
        message = t('bigbluebutton_rails.servers.notice.create.success')
        redirect_to_using_params @server, :notice => message
      }
      format.json { render :json => @server, :status => :created }
    else
      format.html { redirect_to_params_or_render :new }
      format.json { render :json => @server.errors.full_messages, :status => :unprocessable_entity }
    end
  end
end

#destroyObject



92
93
94
95
96
97
98
99
100
# File 'app/controllers/bigbluebutton/servers_controller.rb', line 92

def destroy
  # TODO: what if it fails?
  @server.destroy

  respond_with do |format|
    format.html { redirect_to_using_params bigbluebutton_servers_url }
    format.json { render :json => true, :status => :ok }
  end
end

#editObject



20
21
22
# File 'app/controllers/bigbluebutton/servers_controller.rb', line 20

def edit
  respond_with(@server)
end

#fetch_recordingsObject

Accepts the following parameters in URL:

meetings

A list of meetingIDs to be used as filter.

meta_*

To filter by metadata, where “*” can be anything.

For example: fetch_recordings?meetings=meeting1,meeting2&meta_name=value



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'app/controllers/bigbluebutton/servers_controller.rb', line 123

def fetch_recordings
  error = false
  begin

    # accept meetingID and meta_* filters
    filter = {}
    filter.merge!({ :meetingID => params[:meetings] }) if params[:meetings]
    params.each do |key, value|
      filter.merge!({ key.to_sym => value }) if key.match(/^meta_/)
    end

    @server.fetch_recordings(filter)
    message = t('bigbluebutton_rails.servers.notice.fetch_recordings.success')
  rescue BigBlueButton::BigBlueButtonException => e
    error = true
    message = e.to_s[0..200]
  end

  respond_with do |format|
    format.html {
      flash[error ? :error : :notice] = message
      redirect_to bigbluebutton_server_path(@server)
    }
    format.json {
      if error
        render :json => { :message => message }, :status => :error
      else
        render :json => true, :status => :ok
      end
    }
  end
end

#indexObject



8
9
10
# File 'app/controllers/bigbluebutton/servers_controller.rb', line 8

def index
  respond_with(@servers = BigbluebuttonServer.all)
end

#newObject



16
17
18
# File 'app/controllers/bigbluebutton/servers_controller.rb', line 16

def new
  respond_with(@server = BigbluebuttonServer.new)
end

#publish_recordingsObject



110
111
112
# File 'app/controllers/bigbluebutton/servers_controller.rb', line 110

def publish_recordings
  self.publish_unpublish(params[:recordings], true)
end

#recordingsObject



102
103
104
# File 'app/controllers/bigbluebutton/servers_controller.rb', line 102

def recordings
  respond_with(@recordings = @server.recordings)
end

#roomsObject



106
107
108
# File 'app/controllers/bigbluebutton/servers_controller.rb', line 106

def rooms
  respond_with(@rooms = @server.rooms)
end

#showObject



12
13
14
# File 'app/controllers/bigbluebutton/servers_controller.rb', line 12

def show
  respond_with(@server)
end

#unpublish_recordingsObject



114
115
116
# File 'app/controllers/bigbluebutton/servers_controller.rb', line 114

def unpublish_recordings
  self.publish_unpublish(params[:recordings], false)
end

#updateObject



77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'app/controllers/bigbluebutton/servers_controller.rb', line 77

def update
  respond_with @server do |format|
    if @server.update_attributes(server_params)
      format.html {
        message = t('bigbluebutton_rails.servers.notice.update.success')
        redirect_to_using_params @server, :notice => message
      }
      format.json { render :json => true, :status => :ok }
    else
      format.html { redirect_to_params_or_render :edit }
      format.json { render :json => @server.errors.full_messages, :status => :unprocessable_entity }
    end
  end
end