Class: Faalis::DashboardController

Inherits:
ApplicationController show all
Includes:
Faalis::Dashboard::Controller
Defined in:
app/controllers/faalis/dashboard_controller.rb

Instance Method Summary collapse

Methods included from Faalis::Dashboard::Controller

included

Methods inherited from ApplicationController

#set_locale

Instance Method Details

#indexObject



22
23
24
# File 'app/controllers/faalis/dashboard_controller.rb', line 22

def index
  @jstemplates_path = "/templates"
end

#jstemplateObject



14
15
16
17
18
19
20
# File 'app/controllers/faalis/dashboard_controller.rb', line 14

def jstemplate
  if user_signed_in?
    render :template => "angularjs_templates/#{params[:path]}", :layout => nil
  else
    render :login_required_page
  end
end

#modulesObject



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/faalis/dashboard_controller.rb', line 26

def modules
  dashboard_modules = []
  Faalis::Engine.dashboard_modules.each do |module_name, attrs|
    if not attrs.include? :title
      attrs[:title] = _(module_name.to_s)
    end

    if not attrs.include? :resource
      attrs[:resource] = module_name.to_s
    end

    # If class did not given by user in settings
    # Faalis tries to guess the class name
    if not attrs.include? :model
      begin
        klass = attrs[:resource].camelize.constantize

        if klass.respond_to? :possible_permissions
          attrs[:model] = attrs[:resource].camelize
        else
          attrs[:model] = ""
        end

      rescue NameError
        attrs[:model] = ""
      end
    end

    dashboard_modules << attrs
  end
  dashboard_modules = {:modules => dashboard_modules}
  respond_with dashboard_modules
end