Class: Lesli::Shared::DashboardsController
- Inherits:
-
ApplicationLesliController
- Object
- ActionController::Base
- ApplicationController
- ApplicationLesliController
- Lesli::Shared::DashboardsController
- Defined in:
- app/controllers/lesli/shared/dashboards_controller.rb
Instance Attribute Summary
Attributes inherited from ApplicationController
Instance Method Summary collapse
-
#create ⇒ Json
# Executing this controller’s action from javascript’s frontend let data = { dashboard: { name: “Sales Dashboard”, default: false, roles_id: 3, components_attributes: [ { name: ‘Projects Count’, component_id: projects_component, layout: 4, index: 3, configuration: {} }, { name: ‘New Customers Count’, component_id: new_customers_component, layout: 4, index: 3, configuration: {} } ] } }; this.http.post(‘127.0.0.1/help/dashboards’, data);.
-
#destroy ⇒ Json
Json that contains wheter the dashboard was successfully deleted or not.
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #options ⇒ Object
- #resource_component ⇒ Object
- #show ⇒ Object
-
#update ⇒ Json
# Executing this controller’s action from javascript’s frontend let dashboard_id = 4; let data = { dashboard: { name: “Sales Dashboard”, default: false, roles_id: 3, components_attributes: [ { name: ‘Projects Count’, component_id: projects_component, layout: 4, index: 3, configuration: {} }, { name: ‘New Customers Count’, component_id: new_customers_component, layout: 4, index: 3, configuration: {} } ] } }; this.http.put(‘127.0.0.1/help/dashboards/$dashboard_id`, data);.
Methods included from Interfaces::Application::Logger
#get_user_agent, #log_account_activity, #log_account_requests, #log_requests, #log_user_requests
Methods included from Interfaces::Application::Requester
#set_locale, #set_path, #set_requester
Methods included from Interfaces::Application::Responder
#respond_with_action, #respond_with_error, #respond_with_http, #respond_with_not_found, #respond_with_pagination, #respond_with_successful, #respond_with_unauthorized
Methods included from Interfaces::Application::Customization
Methods included from Interfaces::Application::Authorization
#authorize_privilege, #authorize_request
Methods inherited from ApplicationController
Constructor Details
This class inherits a constructor from Lesli::ApplicationController
Instance Method Details
#create ⇒ Json
# Executing this controller’s action from javascript’s frontend
let data = {
dashboard: {
name: "Sales Dashboard",
default: false,
roles_id: 3,
components_attributes: [
{
name: 'Projects Count',
component_id: projects_component,
layout: 4,
index: 3,
configuration: {}
}, {
name: 'New Customers Count',
component_id: new_customers_component,
layout: 4,
index: 3,
configuration: {}
}
]
}
};
this.http.post('127.0.0.1/help/dashboards', data);
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'app/controllers/lesli/shared/dashboards_controller.rb', line 105 def create dynamic_info = self.class.dynamic_info module_name = dynamic_info[:module_name] model = dynamic_info[:model] full_module_name = dynamic_info[:full_module_name].underscore dashboard = model.new(dashboard_params) dashboard["#{full_module_name}_account_id".to_sym] = current_user.account.id dashboard.user_creator = current_user if dashboard.save respond_with_successful(dashboard) else respond_with_error(dashboard.errors..to_sentence) end end |
#destroy ⇒ Json
Returns Json that contains wheter the dashboard was successfully deleted or not. If it it not successful, it returns an error message.
181 182 183 184 185 186 187 188 189 |
# File 'app/controllers/lesli/shared/dashboards_controller.rb', line 181 def destroy return respond_with_not_found unless @dashboard if @dashboard.destroy respond_with_successful else respond_with_error(@dashboard.errors..to_sentence) end end |
#edit ⇒ Object
63 64 |
# File 'app/controllers/lesli/shared/dashboards_controller.rb', line 63 def edit end |
#index ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/controllers/lesli/shared/dashboards_controller.rb', line 37 def index respond_to do |format| format.html {} format.json do dynamic_info = self.class.dynamic_info model = dynamic_info[:model] dashboards = model.list(current_user, @query) respond_with_successful(dashboards) end end end |
#new ⇒ Object
60 61 |
# File 'app/controllers/lesli/shared/dashboards_controller.rb', line 60 def new end |
#options ⇒ Object
191 192 193 194 195 196 |
# File 'app/controllers/lesli/shared/dashboards_controller.rb', line 191 def dynamic_info = self.class.dynamic_info model = dynamic_info[:module_model] respond_with_successful(model.(current_user, @query)) end |
#resource_component ⇒ Object
198 199 200 201 202 203 204 205 206 207 208 209 210 |
# File 'app/controllers/lesli/shared/dashboards_controller.rb', line 198 def resource_component dynamic_info = self.class.dynamic_info component_model = dynamic_info[:component_model] component_id = sanitize(params[:component_id].to_sym) # We verify if the method exists, and if it is in the available component list if component_model.respond_to?(component_id) && component_model.component_ids[component_id] respond_with_successful(component_model.public_send(component_id, current_user, @query)) else respond_with_not_found() end end |
#show ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'app/controllers/lesli/shared/dashboards_controller.rb', line 50 def show respond_to do |format| format.html {} format.json do return respond_with_not_found unless @dashboard respond_with_successful(@dashboard.show) end end end |
#update ⇒ Json
# Executing this controller’s action from javascript’s frontend let dashboard_id = 4; let data =
dashboard: {
name: "Sales Dashboard",
default: false,
roles_id: 3,
components_attributes: [
{
name: 'Projects Count',
component_id: projects_component,
layout: 4,
index: 3,
configuration: {
}, {
name: 'New Customers Count',
component_id: new_customers_component,
layout: 4,
index: 3,
configuration: {}
}
]
}
}; this.http.put(‘127.0.0.1/help/dashboards/${dashboard_id}`, data);
162 163 164 165 166 167 168 169 170 |
# File 'app/controllers/lesli/shared/dashboards_controller.rb', line 162 def update return respond_with_not_found unless @dashboard if @dashboard.update(dashboard_params) respond_with_successful(@dashboard.show) else respond_with_error(@dashboard.errors..to_sentence) end end |