Class: VRDashConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/VRDashConfig.rb

Overview

VRDashConfig is the parent class for custom DashConfigs.

VRDashConfig subclasses must define vrdash_key, which is a custom key unique to the DashConfig. They can optionally declare vrdash_settings which are custom settings implemented by the dash.

VRDashConfig subclasses must finally define a generate() method which is what will be invoked when the dash is used and returns panels and statblocks. generate() takes in four parameters - the custom settings implemented for this VRDashConfig, the User ID of the user running the dashboard, the geo the user is currently viewing, and whether data should be cached (if implemented).

Class Method Summary (collapse)

Class Method Details

+ (Object) dashes



24
25
26
# File 'lib/VRDashConfig.rb', line 24

def dashes
	@dashes ||= []
end

+ (Object) each(&block)



43
44
45
46
47
# File 'lib/VRDashConfig.rb', line 43

def each(&block)
	dashes.each do |member|
		block.call(member)
	end
end

+ (Object) generate(dc_settings, uid, geo = GEO::USA, cache = true)

Called to generate panels and stat blocks when this dashboard is requested by a user.

Parameters:

  • dc_settings (Hash <String => Object>)

    Current values of custom settings implemented by this Dashboard

  • uid (Integer)

    UID of User requesting the dashboard

  • geo (Object) (defaults to: GEO::USA)

    Integer(s) of Geo user is currently set to view. Will either be an Integer or array of Integers. Note that this can be used without parsing/modification in database calls, e.g. application.geo => geo.

  • cache (Boolean) (defaults to: true)

    Passed boolean to override cache use, if you choose to implement it. If true, use cache.

Returns:

  • Hash of :success (Boolean) and :generatedDash (Array<Array<Hash>,Array<Hash>>). :generatedDash is an Array of Hashes, each representing one panel to display on the Dashboard. Each of these hashes should include the following keys: :title (String, title of panel), :color (String, color of panel chosen from primary (blue), success (green), warning (yellow), danger (red)), :records (Array of Hashes representing records that should be displayed in the panel. Each hash is made up of :app and :test which contain the Application and Test object for the row, respectively. :test can be nil), :maxwks (Integer, number of weeks at which a record should be highlighted as overdue), and :zerotext (String to display if there are no records for the panel). The key :fetch_time can also be included with a String representing the time this data was pulled from an external system, if you have implemented caching. :generatedDash is an Array of Hashes, each representing one stat box to display on the Dashboard. This Object can also be nil to not display stat boxes. Each Hash in the Array should contain keys :icon (String - Font Awesome icon ID to use), :text (String, text to use as label), :value (Integer or Float value to display in statbox), :color (String, color of stat box using same values as panels).



76
77
78
# File 'lib/VRDashConfig.rb', line 76

def generate(dc_settings, uid, geo=GEO::USA, cache=true)
	raise "NotImplemented"
end

+ (Object) getByKey(key)



49
50
51
52
53
54
55
56
57
# File 'lib/VRDashConfig.rb', line 49

def getByKey(key)
	dashes.each do |dash|
		if(dash.vrdash_key == key)
			return dash
		end
	end

	return nil
end

+ (Object) vrdash_key(key = nil)



28
29
30
31
# File 'lib/VRDashConfig.rb', line 28

def vrdash_key(key=nil)
	@vrdash_key = key.to_s if !key.nil?
	@vrdash_key ||= self.key
end

+ (Object) vrdash_name(name = nil)



33
34
35
36
# File 'lib/VRDashConfig.rb', line 33

def vrdash_name(name=nil)
	@vrdash_name = name.to_s if !name.nil?
	@vrdash_name ||= self.name
end

+ (Object) vrdash_settings(settings = nil)



38
39
40
41
# File 'lib/VRDashConfig.rb', line 38

def vrdash_settings(settings=nil)
	@vrdash_settings = settings if !settings.nil?
	@vrdash_settings ||= {}
end