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/282/dashboards


29
30
31
32
33
34
35
36
37
# File 'lib/mno_enterprise/concerns/controllers/jpi/v1/impac/dashboards_controller.rb', line 29

def create
  if @dashboard = dashboards.create(dashboard_create_params)
    # authorize! :create, @dashboard
    MnoEnterprise::EventLogger.info('dashboard_create', current_user.id, 'Dashboard Creation', nil, @dashboard)
    render 'show'
  else
    render json: @dashboard.errors, status: :bad_request
  end
end

#destroyObject

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



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

def destroy
  # authorize! :destroy, @dashboard
  if dashboard.destroy
    MnoEnterprise::EventLogger.info('dashboard_delete', current_user.id, 'Dashboard Deletion', nil, dashboard)
    head status: :ok
  else
    render json: 'Unable to destroy dashboard', status: :bad_request
  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



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

def show
  dashboard
  render json: { errors: "Dashboard id #{params[:id]} doesn't exist" }, status: :not_found unless @dashboard
end

#updateObject

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



40
41
42
43
44
45
46
47
48
# File 'lib/mno_enterprise/concerns/controllers/jpi/v1/impac/dashboards_controller.rb', line 40

def update
  if dashboard.update(dashboard_update_params)
    # dashboard.assign_attributes(attrs)
    # authorize! :update, dashboard
    render 'show'
  else
    render json: @dashboard.errors, status: :bad_request
  end
end