Class: Impac::Dashboard

Inherits:
BaseResource
  • Object
show all
Defined in:
app/models/mno_enterprise/impac/dashboard.rb

Instance Method Summary collapse

Instance Method Details

#copy(owner, name, organization_ids) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
# File 'app/models/mno_enterprise/impac/dashboard.rb', line 50

def copy(owner, name, organization_ids)
  owner_type = owner.class.name.demodulize
  attrs = {
    id: self.id,
    name: name,
    organization_ids: organization_ids,
    owner_type: owner_type,
    owner_id: owner.id
  }
  self.class.copy(attrs)
end

#filtered_widgets_templatesObject

Filter widgets list based on config



36
37
38
39
40
41
42
43
44
# File 'app/models/mno_enterprise/impac/dashboard.rb', line 36

def filtered_widgets_templates
  if MnoEnterprise.widgets_templates_listing
    return self.widgets_templates.select do |t|
      MnoEnterprise.widgets_templates_listing.include?(t[:path])
    end
  else
    return self.widgets_templates
  end
end

#full_nameObject

Instance methods

Return the full name of this dashboard Currently a simple accessor to the dashboard name (used to include the company name)



20
21
22
# File 'app/models/mno_enterprise/impac/dashboard.rb', line 20

def full_name
  self.name
end

#organizations(org_list = nil) ⇒ Object

Return all the organizations linked to this dashboard and to which the user has access If the dashboard is a template, return all the current user’s organizations



26
27
28
29
30
31
32
33
# File 'app/models/mno_enterprise/impac/dashboard.rb', line 26

def organizations(org_list = nil)
  if org_list
    return org_list if dashboard_type == 'template'
    org_list.to_a.select { |e| organization_ids.include?(e.uid) || organization_ids.include?(e.id) }
  else
    MnoEnterprise::Organization.where('uid.in' => organization_ids).to_a
  end
end

#to_audit_eventObject



46
47
48
# File 'app/models/mno_enterprise/impac/dashboard.rb', line 46

def to_audit_event
  { name: name }
end