Class: Marty::AuthApp

Inherits:
SimpleApp show all
Defined in:
app/components/marty/auth_app.rb

Direct Known Subclasses

MainAuthApp

Instance Method Summary collapse

Methods inherited from SimpleApp

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

Methods inherited from Netzke::Base

#root_sess

Instance Method Details

#configure(c) ⇒ Object



8
9
10
11
12
13
# File 'app/components/marty/auth_app.rb', line 8

def configure(c)
  super

  enable_action_cable = Rails.application.config.marty.enable_action_cable
  client_config[:marty_enable_action_cable] = enable_action_cable
end

#current_user_menu_item(user) ⇒ Object



38
39
40
41
42
43
44
45
# File 'app/components/marty/auth_app.rb', line 38

def current_user_menu_item(user)
  {
    text: user.name,
    tooltip: 'Current user',
    menu: user_menu,
    name: 'sign_out',
  }
end

Set the Logout button if current_user is set



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/components/marty/auth_app.rb', line 20

def menu
  [].tap do |menu|
    user = Mcfly.whodunnit
    if !user.nil?
      menu <<
        '->' <<
        notification_menu_item <<
        current_user_menu_item(user)
    else
      menu << '->' << :sign_in
    end
  end
end

#notification_menu_itemObject



34
35
36
# File 'app/components/marty/auth_app.rb', line 34

def notification_menu_item
  :notifications_window
end

#unread_notifications_countObject



51
52
53
54
55
56
57
# File 'app/components/marty/auth_app.rb', line 51

def unread_notifications_count
  user = Mcfly.whodunnit

  return 0 if user.blank?

  user.unread_web_notifications_count
end

#user_menuObject



47
48
49
# File 'app/components/marty/auth_app.rb', line 47

def user_menu
  [:sign_out, :toggle_dark_mode]
end