Module: MnoEnterprise::Concerns::Controllers::Jpi::V1::Impac::DashboardsController

Extended by:
ActiveSupport::Concern
Included in:
Jpi::V1::Impac::DashboardsController
Defined in:
lib/mno_enterprise/concerns/controllers/jpi/v1/impac/dashboards_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /mnoe/jpi/v1/impac/dashboards

-> POST /api/mnoe/v1/users/1/dashboards


30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/mno_enterprise/concerns/controllers/jpi/v1/impac/dashboards_controller.rb', line 30

def create
  # TODO: dashboards.build breaks as dashboard.organization_ids returns nil, instead of an
  #       empty array. (see MnoEnterprise::Impac::Dashboard #organizations)
  # @dashboard = dashboards.build(dashboard_create_params)
  # TODO: enable authorization
  # authorize! :manage_dashboard, @dashboard
  # if @dashboard.save
  if @dashboard = dashboards.create(dashboard_create_params)
    MnoEnterprise::EventLogger.info('dashboard_create', current_user.id, 'Dashboard Creation', @dashboard)

    render 'show'
  else
    render_bad_request('create dashboard', @dashboard.errors)
  end
end

#destroyObject

DELETE /mnoe/jpi/v1/impac/dashboards/1

-> DELETE /api/mnoe/v1/dashboards/1


63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/mno_enterprise/concerns/controllers/jpi/v1/impac/dashboards_controller.rb', line 63

def destroy
  return render_not_found('dashboard') unless dashboard

  # TODO: enable authorization
  # authorize! :manage_dashboard, dashboard

  if dashboard.destroy
    MnoEnterprise::EventLogger.info('dashboard_delete', current_user.id, 'Dashboard Deletion', dashboard)
    head status: :ok
  else
    render_bad_request('destroy dashboard', 'Unable to destroy dashboard')
  end
end

#indexObject

Instance methods

GET /mnoe/jpi/v1/impac/dashboards



17
18
19
# File 'lib/mno_enterprise/concerns/controllers/jpi/v1/impac/dashboards_controller.rb', line 17

def index
  dashboards
end

#showObject

GET /mnoe/jpi/v1/impac/dashboards/1

-> GET /api/mnoe/v1/users/1/dashboards


23
24
25
26
# File 'lib/mno_enterprise/concerns/controllers/jpi/v1/impac/dashboards_controller.rb', line 23

def show
  dashboard
  render_not_found('dashboard') unless @dashboard
end

#updateObject

PUT /mnoe/jpi/v1/impac/dashboards/1

-> PUT /api/mnoe/v1/dashboards/1


48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/mno_enterprise/concerns/controllers/jpi/v1/impac/dashboards_controller.rb', line 48

def update
  return render_not_found('dashboard') unless dashboard

  # TODO: enable authorization
  # authorize! :manage_dashboard, dashboard

  if dashboard.update(dashboard_update_params)
    render 'show'
  else
    render_bad_request('update dashboard', dashboard.errors)
  end
end