Class: Marty::MainAuthApp

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

Constant Summary

Constants included from Permissions

Permissions::NETZKE_ENDPOINTS

Constants included from Extras::Misc

Extras::Misc::MM_OPTIONS

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Permissions

can_call_endpoint?, can_perform_action?, can_perform_actions, current_user_roles, extended, has_any_perm?, has_marty_permissions, has_perm?

Methods included from Extras::Misc

#icon_hack, numberfield_cfg, #sep

Methods inherited from AuthApp

#configure, #current_user_menu_item, #notification_menu_item, #unread_notifications_count, #user_menu

Methods inherited from SimpleApp

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

Methods inherited from Netzke::Base

#root_sess

Class Method Details

.has_posting_perm?Boolean

set of posting types user is allowed to post with

Returns:

  • (Boolean)


29
30
31
# File 'app/components/marty/main_auth_app.rb', line 29

def self.has_posting_perm?
  Marty::Postings::NewForm.has_any_perm?
end

.has_scripting_perm?Boolean

Returns:

  • (Boolean)


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

def self.has_scripting_perm?
  has_perm?(:admin)
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_cls: 'fa fa-fighter-jet glyph',
      disabled: !self.class.has_perm?(:admin),
      menu: [
        :api_auth_view,
        :api_config_view,
        :api_log_view,
      ]
    }
  ]
end

#app_monikerObject



166
167
168
# File 'app/components/marty/main_auth_app.rb', line 166

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

#app_titleObject



170
171
172
173
174
175
176
177
# File 'app/components/marty/main_auth_app.rb', line 170

def app_title
  e = ENV['RAILS_ENV']

  title = "#{app_moniker} #{::Marty::RailsApp.application_name.titleize}"
  title += " - #{e.capitalize}" unless e == 'production'
  title += ' [TIME WARPED]' if warped
  title
end

#applications_menuObject



114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'app/components/marty/main_auth_app.rb', line 114

def applications_menu
  {
    text: I18n.t('applications'),
      icon_cls: 'fa fa-window-restore glyph',
    menu: [
      :data_grid_view,
      :data_grid_user_view,
      :reporting,
      :scripting,
      :promise_view,
    ],
  }
end

#background_jobs_menuObject



128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'app/components/marty/main_auth_app.rb', line 128

def background_jobs_menu
  [
    {
      text: 'Background Jobs',
      icon_cls: 'fa fa-user-clock glyph',
      disabled: !self.class.has_perm?(:admin),
      menu: [
        :bg_status,
        :bg_stop,
        :bg_restart,
        :delayed_jobs_grid,
        :schedule_jobs_dashboard,
        :schedule_jobs_logs,
      ]
    },
  ]
end

#bg_command(subcmd) ⇒ Object



396
397
398
399
400
401
402
403
404
405
406
# File 'app/components/marty/main_auth_app.rb', line 396

def bg_command(subcmd)
  params = Marty::Config['DELAYED_JOB_PARAMS'] || ''
  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} #{subcmd} #{params} 2>&1"
  cmd
end

#data_menusObject



186
187
188
# File 'app/components/marty/main_auth_app.rb', line 186

def data_menus
  []
end

#ident_menuObject



179
180
181
182
183
184
# File 'app/components/marty/main_auth_app.rb', line 179

def ident_menu
  "<span style='color:#157fcc;
      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_cls: 'fa fa-wrench glyph',
      disabled: !(self.class.has_perm?(:admin) || self.class.has_perm?(:dev)),
      menu: [
        :log_view,
        :log_cleanup,
      ]
    }
  ]
end


190
191
192
193
194
195
196
197
198
199
200
201
# File 'app/components/marty/main_auth_app.rb', line 190

def menu
  return super unless self.class.has_any_perm?

  [ident_menu, sep] +
    (self.class.has_perm?(:admin) || self.class.has_perm?(:dev) ||
     self.class.has_perm?(:user_manager) ? [system_menu, sep] : []) +
    data_menus +
    [
      applications_menu, sep,
      posting_menu, sep,
    ] + super
end

#misc_menuObject



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

def misc_menu
  [
    {
      text: 'Miscellaneous Views',
      icon_cls: 'fa fa-window-restore glyph',
      disabled: !self.class.has_perm?(:admin),
      menu: [
        :show_env,
      ],
    },
  ]
end

#notifications_menuObject



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'app/components/marty/main_auth_app.rb', line 146

def notifications_menu
  disabled = !(self.class.has_perm?(:admin) ||
               self.class.has_perm?(:user_manager))
  [
    {
      text: 'Notifications',
      icon_cls: 'fa fa-bell glyph',
      disabled: disabled,
      menu: [
        :notifications_config_view,
        :notifications_deliveries_view,
      ]
    },
  ]
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.to_s : I18n.t('postings'),
    name:  'posting',
    tooltip: 'Postings',
    icon_cls: 'fa fa-clock glyph',
    style: (warped ? 'background-color: lightGrey;' : ''),
    menu:  [
      :new_posting,
      :select_posting,
      :select_now,
    ],
  }
end

#system_menuObject



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'app/components/marty/main_auth_app.rb', line 94

def system_menu
  {
    text:  I18n.t('system'),
    icon_cls: 'fa fa-wrench glyph',
    style: '',
    menu:  [
      :import_type_view,
      :user_view,
      :config_view,
      :reload_scripts,
      :load_seed,
    ] +
    background_jobs_menu  +
    notifications_menu    +
    log_menu              +
    api_menu              +
    misc_menu
  }
end

#warpedObject



162
163
164
# File 'app/components/marty/main_auth_app.rb', line 162

def warped
  Marty::Util.warped?
end