Class: DashConfig

Inherits:
Object
  • Object
show all
Includes:
DataMapper::Resource
Defined in:
models/dashconfig.rb

Overview

Dashboard configuration - can be created/edited by admins and assigned to orgs. Two types of DashConfigs - declarative and custom. Declarative DashConfigs are configured through admin interface. Custom DashConfigs are code files registered on Vulnreport init. Custom DashConfigs can declare custom settings that will be editable via the admin interface.

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods included from DataMapper::Resource

#make_dirty

Class Method Details

+ (Boolean) active(repository = nil)

Returns True if this DashConfig is active and available for use

Returns:

  • (Boolean)

    True if this DashConfig is active and available for use



18
# File 'models/dashconfig.rb', line 18

property :active,			Boolean, :default => true

+ (Boolean) customCode(repository = nil)

Returns True if this dashconfig is custom code (registered on initialization).

Returns:

  • (Boolean)

    True if this dashconfig is custom code (registered on initialization).



24
# File 'models/dashconfig.rb', line 24

property :customCode,		Boolean, :default => false

+ (String) customKey(repository = nil)

Returns Unique key for this dashconfig. Used for custom code dashconfigs only.

Returns:

  • (String)

    Unique key for this dashconfig. Used for custom code dashconfigs only.



25
# File 'models/dashconfig.rb', line 25

property :customKey,		String

+ (Hash<Hash>) customSettings(repository = nil)

Returns Custom settings for this dashconfig. Used for custom code dashconfigs only. Hash is key => Hash of name, value

Returns:

  • (Hash<Hash>)

    Custom settings for this dashconfig. Used for custom code dashconfigs only. Hash is key => Hash of name, value



26
# File 'models/dashconfig.rb', line 26

property :customSettings,	Object

+ (String) description(repository = nil)

Returns User description of the Dashboard

Returns:

  • (String)

    User description of the Dashboard



17
# File 'models/dashconfig.rb', line 17

property :description,		Text

+ (Integer) id(repository = nil)

Returns Primary Key

Returns:

  • (Integer)

    Primary Key



15
# File 'models/dashconfig.rb', line 15

property :id,				Serial

+ (Name) name(repository = nil)

Returns Name of the Dashboard

Returns:

  • (Name)

    Name of the Dashboard



16
# File 'models/dashconfig.rb', line 16

property :name,				String

+ (Array<Hash>) panels(repository = nil)

Returns Data for panels. Array of hashes, each with keys type,rt,title,zerotext,maxwks. This is used for declarative dashconfigs only.

Returns:

  • (Array<Hash>)

    Data for panels. Array of hashes, each with keys type,rt,title,zerotext,maxwks. This is used for declarative dashconfigs only.



22
# File 'models/dashconfig.rb', line 22

property :panels,			Object

+ (Boolean) showStats(repository = nil)

Returns True if the stats bar should be shown. This is used for declarative dashconfigs only.

Returns:

  • (Boolean)

    True if the stats bar should be shown. This is used for declarative dashconfigs only.



20
# File 'models/dashconfig.rb', line 20

property :showStats,		Boolean, :default => true

+ (Array<Hash>) stats(repository = nil)

Returns Data for stats blocks. Array of hashes, each each with keys icon,text,color,type,rt. This is used for declarative dashconfigs only.

Returns:

  • (Array<Hash>)

    Data for stats blocks. Array of hashes, each each with keys icon,text,color,type,rt. This is used for declarative dashconfigs only.



21
# File 'models/dashconfig.rb', line 21

property :stats,			Object

Instance Method Details

- (Boolean) active

Returns True if this DashConfig is active and available for use

Returns:

  • (Boolean)

    True if this DashConfig is active and available for use



18
# File 'models/dashconfig.rb', line 18

property :active,			Boolean, :default => true

- (Boolean) active=(value)

Returns True if this DashConfig is active and available for use

Returns:

  • (Boolean)

    True if this DashConfig is active and available for use



18
# File 'models/dashconfig.rb', line 18

property :active,			Boolean, :default => true

- (Boolean) addPanel(panel)

Add a panel to the dashboard

Parameters:

  • panel (Hash)

    Hash representing the panel with keys :title, :type, :rt, :maxwks, and :zerotext

Returns:

  • (Boolean)

    True if successful



32
33
34
35
36
37
# File 'models/dashconfig.rb', line 32

def addPanel(panel)
	self.panels << panel
	self.make_dirty(:panels)
	
	return self.save
end

- (Boolean) customCode

Returns True if this dashconfig is custom code (registered on initialization).

Returns:

  • (Boolean)

    True if this dashconfig is custom code (registered on initialization).



24
# File 'models/dashconfig.rb', line 24

property :customCode,		Boolean, :default => false

- (Boolean) customCode=(value)

Returns True if this dashconfig is custom code (registered on initialization).

Returns:

  • (Boolean)

    True if this dashconfig is custom code (registered on initialization).



24
# File 'models/dashconfig.rb', line 24

property :customCode,		Boolean, :default => false

- (String) customKey

Returns Unique key for this dashconfig. Used for custom code dashconfigs only.

Returns:

  • (String)

    Unique key for this dashconfig. Used for custom code dashconfigs only.



25
# File 'models/dashconfig.rb', line 25

property :customKey,		String

- (String) customKey=(value)

Returns Unique key for this dashconfig. Used for custom code dashconfigs only.

Returns:

  • (String)

    Unique key for this dashconfig. Used for custom code dashconfigs only.



25
# File 'models/dashconfig.rb', line 25

property :customKey,		String

- (Hash<Hash>) customSettings

Returns Custom settings for this dashconfig. Used for custom code dashconfigs only. Hash is key => Hash of name, value

Returns:

  • (Hash<Hash>)

    Custom settings for this dashconfig. Used for custom code dashconfigs only. Hash is key => Hash of name, value



26
# File 'models/dashconfig.rb', line 26

property :customSettings,	Object

- (Hash<Hash>) customSettings=(value)

Returns Custom settings for this dashconfig. Used for custom code dashconfigs only. Hash is key => Hash of name, value

Returns:

  • (Hash<Hash>)

    Custom settings for this dashconfig. Used for custom code dashconfigs only. Hash is key => Hash of name, value



26
# File 'models/dashconfig.rb', line 26

property :customSettings,	Object

- (String) description

Returns User description of the Dashboard

Returns:

  • (String)

    User description of the Dashboard



17
# File 'models/dashconfig.rb', line 17

property :description,		Text

- (String) description=(value)

Returns User description of the Dashboard

Returns:

  • (String)

    User description of the Dashboard



17
# File 'models/dashconfig.rb', line 17

property :description,		Text

- (Hash) getSettingsForDash

Get settings hash for dashboard (custom code only)

Returns:

  • (Hash)

    Settings



42
43
44
45
46
47
48
49
50
51
52
53
# File 'models/dashconfig.rb', line 42

def getSettingsForDash
	if(!self.customCode)
		return {}
	else
		settings = Hash.new
		customSettings.each do |k,v|
			settings[k] = v[:val]
		end

		return settings
	end
end

- (Integer) id

Returns Primary Key

Returns:

  • (Integer)

    Primary Key



15
# File 'models/dashconfig.rb', line 15

property :id,				Serial

- (Integer) id=(value)

Returns Primary Key

Returns:

  • (Integer)

    Primary Key



15
# File 'models/dashconfig.rb', line 15

property :id,				Serial

- (Name) name

Returns Name of the Dashboard

Returns:

  • (Name)

    Name of the Dashboard



16
# File 'models/dashconfig.rb', line 16

property :name,				String

- (Name) name=(value)

Returns Name of the Dashboard

Returns:

  • (Name)

    Name of the Dashboard



16
# File 'models/dashconfig.rb', line 16

property :name,				String

- (Array<Hash>) panels

Returns Data for panels. Array of hashes, each with keys type,rt,title,zerotext,maxwks. This is used for declarative dashconfigs only.

Returns:

  • (Array<Hash>)

    Data for panels. Array of hashes, each with keys type,rt,title,zerotext,maxwks. This is used for declarative dashconfigs only.



22
# File 'models/dashconfig.rb', line 22

property :panels,			Object

- (Array<Hash>) panels=(value)

Returns Data for panels. Array of hashes, each with keys type,rt,title,zerotext,maxwks. This is used for declarative dashconfigs only.

Returns:

  • (Array<Hash>)

    Data for panels. Array of hashes, each with keys type,rt,title,zerotext,maxwks. This is used for declarative dashconfigs only.



22
# File 'models/dashconfig.rb', line 22

property :panels,			Object

- (Boolean) showStats

Returns True if the stats bar should be shown. This is used for declarative dashconfigs only.

Returns:

  • (Boolean)

    True if the stats bar should be shown. This is used for declarative dashconfigs only.



20
# File 'models/dashconfig.rb', line 20

property :showStats,		Boolean, :default => true

- (Boolean) showStats=(value)

Returns True if the stats bar should be shown. This is used for declarative dashconfigs only.

Returns:

  • (Boolean)

    True if the stats bar should be shown. This is used for declarative dashconfigs only.



20
# File 'models/dashconfig.rb', line 20

property :showStats,		Boolean, :default => true

- (Array<Hash>) stats

Returns Data for stats blocks. Array of hashes, each each with keys icon,text,color,type,rt. This is used for declarative dashconfigs only.

Returns:

  • (Array<Hash>)

    Data for stats blocks. Array of hashes, each each with keys icon,text,color,type,rt. This is used for declarative dashconfigs only.



21
# File 'models/dashconfig.rb', line 21

property :stats,			Object

- (Array<Hash>) stats=(value)

Returns Data for stats blocks. Array of hashes, each each with keys icon,text,color,type,rt. This is used for declarative dashconfigs only.

Returns:

  • (Array<Hash>)

    Data for stats blocks. Array of hashes, each each with keys icon,text,color,type,rt. This is used for declarative dashconfigs only.



21
# File 'models/dashconfig.rb', line 21

property :stats,			Object