Class: Marty::MainAuthApp

Inherits:
AuthApp show all
Extended by:
Permissions
Defined in:
app/components/marty/main_auth_app.rb

Constant Summary

Constants included from Permissions

Permissions::ALL_ROLES, Permissions::REQ_ROLES

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Permissions

can_perform_action?, can_perform_actions, current_user_roles, has_any_perm?, has_marty_permissions

Methods inherited from AuthApp

#user_menu

Methods inherited from SimpleApp

#configure, #js_component_html, #js_component_render, #main_panel_config, #menu_bar_config, #status_bar_config

Class Method Details

.has_posting_perm?Boolean

set of posting types user is allowed to post with

Returns:

  • (Boolean)


19
20
21
# File 'app/components/marty/main_auth_app.rb', line 19

def self.has_posting_perm?
  Marty::NewPostingForm.has_any_perm?
end

.has_scripting_perm?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'app/components/marty/main_auth_app.rb', line 23

def self.has_scripting_perm?
  self.has_admin_perm?
end

Instance Method Details

#api_menuObject



66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'app/components/marty/main_auth_app.rb', line 66

def api_menu
  [
    {
      text: 'API Management',
      icon:  icon_hack(:wrench),
      disabled: !self.class.has_admin_perm?,
      menu: [
        :api_auth_view,
        :api_config_view,
        :api_log_view,
      ]
    }
  ]
end

#app_monikerObject



129
130
131
# File 'app/components/marty/main_auth_app.rb', line 129

def app_moniker
  warped ? 0x231B.chr('utf-8') : 0x03FB.chr('utf-8')
end

#app_titleObject



133
134
135
136
137
138
139
140
# File 'app/components/marty/main_auth_app.rb', line 133

def app_title
  e = ENV['RAILS_ENV']

  title = "#{app_moniker} #{Rails.application.class.parent_name.titleize}"
  title += " - #{e.capitalize}" unless e == 'production'
  title += ' [TIME WARPED]' if warped
  title
end

#applications_menuObject



97
98
99
100
101
102
103
104
105
106
107
108
# File 'app/components/marty/main_auth_app.rb', line 97

def applications_menu
  {
    text: I18n.t("applications"),
    icon: icon_hack(:application_cascade),
    menu: [
      :data_grid_view,
      :reporting,
      :scripting,
      :promise_view,
    ],
  }
end

#background_jobs_menuObject



110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'app/components/marty/main_auth_app.rb', line 110

def background_jobs_menu
  [
    {
      text: 'Background Jobs',
      icon: icon_hack(:clock),
      disabled: !self.class.has_admin_perm?,
      menu: [
        :bg_status,
        :bg_stop,
        :bg_restart,
      ]
    },
  ]
end

#bg_command(param) ⇒ Object



299
300
301
302
303
304
305
306
307
308
# File 'app/components/marty/main_auth_app.rb', line 299

def bg_command(param)
  e, root, p = ENV['RAILS_ENV'], Rails.root, Marty::Config["RUBY_PATH"]
  dj_path = Marty::Config["DELAYED_JOB_PATH"] || 'bin/delayed_job'
  cmd = "export RAILS_ENV=#{e};"
  # FIXME: Environment looks to be setup incorrectly - this is a hack
  cmd += "export PATH=#{p}:$PATH;" if p
  # 2>&1 redirects STDERR to STDOUT since backticks only captures STDOUT
  cmd += "#{root}/#{dj_path} #{param} 2>&1"
  cmd
end

#data_menusObject



149
150
151
# File 'app/components/marty/main_auth_app.rb', line 149

def data_menus
  []
end

#icon_hack(name) ⇒ Object



31
32
33
34
35
# File 'app/components/marty/main_auth_app.rb', line 31

def icon_hack(name)
  # There's a Netzke bug whereby, using an icon name in a hash
  # doesn't generate a proper URL.
  "#{Netzke::Core.ext_uri}/../icons/#{name}.png"
end

#ident_menuObject



142
143
144
145
146
147
# File 'app/components/marty/main_auth_app.rb', line 142

def ident_menu
  "<span style='color:#3333FF;
      background-color:#{warped ? '#FBDF4F' : ''};
      font-size:120%;
      font-weight:bold;'>#{app_title}</span>"
end

#log_menuObject



52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'app/components/marty/main_auth_app.rb', line 52

def log_menu
  [
    {
      text: 'Log Maintenance',
      icon:  icon_hack(:wrench),
      disabled: !self.class.has_admin_perm?,
      menu: [
        :log_view,
        :log_cleanup,
      ]
    }
  ]
end


153
154
155
156
157
158
159
160
161
162
163
164
# File 'app/components/marty/main_auth_app.rb', line 153

def menu
  return super unless self.class.has_any_perm?

  [ident_menu, sep] +
    (self.class.has_admin_perm? ||
     self.class.has_user_manager_perm? ? [system_menu, sep] : []) +
    data_menus +
    [
     applications_menu, sep,
     posting_menu, sep,
    ] + super
end

#posting_menuObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'app/components/marty/main_auth_app.rb', line 37

def posting_menu
  {
    text:  warped ? "#{Marty::Util.get_posting.name}" : I18n.t("postings"),
    name:  "posting",
    tooltip: "Postings",
    icon:  icon_hack(:time),
    style: (warped ? "background-color: lightGrey;" : ""),
    menu:  [
      :new_posting,
      :select_posting,
      :select_now,
    ],
  }
end

#sepObject



27
28
29
# File 'app/components/marty/main_auth_app.rb', line 27

def sep
  { xtype: 'tbseparator' }
end

#system_menuObject



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'app/components/marty/main_auth_app.rb', line 81

def system_menu
  {
    text:  I18n.t("system"),
    icon:  icon_hack(:wrench),
    style: "",
    menu:  [
      :import_type_view,
      :user_view,
      :config_view,
      :event_view,
      :reload_scripts,
      :load_seed,
    ] + background_jobs_menu + log_menu + api_menu
  }
end

#warpedObject



125
126
127
# File 'app/components/marty/main_auth_app.rb', line 125

def warped
  Marty::Util.warped?
end