Class: GoodData::Dashboard
- Inherits:
-
MdObject
- Object
- Rest::Object
- Rest::Resource
- MdObject
- GoodData::Dashboard
- Includes:
- Mixin::Lockable
- Defined in:
- lib/gooddata/models/metadata/dashboard.rb
Constant Summary collapse
- EMPTY_OBJECT =
{ 'projectDashboard' => { 'content' => { 'tabs' => [], 'filters' => [] }, 'meta' => { 'tags' => '', 'summary' => '', 'title' => '' } } }
- ASSIGNABLE_MEMBERS =
[ :filters, :tabs, :tags, :summary, :title ]
Constants inherited from MdObject
MdObject::IDENTIFIERS_CFG, MdObject::MD_OBJ_CTG
Constants included from Mixin::MdIdToUri
Mixin::MdIdToUri::IDENTIFIERS_CFG
Constants included from Mixin::MdObjectIndexer
Mixin::MdObjectIndexer::MD_OBJ_CTG
Constants included from Mixin::MdObjectQuery
Mixin::MdObjectQuery::ERROR_MESSAGE_NO_PROJECT
Instance Attribute Summary
Attributes inherited from Rest::Object
Class Method Summary collapse
-
.all(options = { :client => GoodData.connection, :project => GoodData.project }) ⇒ Array<GoodData::MdObject> | Array<Hash>
Method intended to get all objects of that type in a specified project.
- .create(dashboard = {}, options = { :client => GoodData.client, :project => GoodData.project }) ⇒ Object
Instance Method Summary collapse
- #add_tab(tab) ⇒ Object (also: #create_tab)
- #export(format, options = {}) ⇒ Object
- #exportable? ⇒ Boolean
-
#replace(mapping) ⇒ GoodData::Dashboard
Method used for replacing values in their state according to mapping.
- #tabs ⇒ Object
- #tabs_ids ⇒ Object
Methods included from Mixin::Lockable
#lock, #lock!, #lock_with_dependencies!, #locked?, #unlock, #unlock!, #unlock_with_dependencies!, #unlocked?
Methods inherited from MdObject
#==, #add_tag, #browser_uri, #delete, #deprecated, #deprecated=, find_replaceable_values, #get_flag?, #initialize, #listed?, #production, #production=, #project, #reload!, #remove_tag, replace, #replace!, replace_bracketed, replace_quoted, #restricted, #restricted=, #save, #save_as, #set_flag, #tag_set, #unlisted, #unlisted=, #validate
Methods included from Mixin::MdIdToUri
Methods included from Mixin::MdObjectIndexer
Methods included from Mixin::MdObjectQuery
#all, #dependency, #dependency?, #query, #usedby, #usedby?, #using, #using?
Methods included from Mixin::MdFinders
#find_by_identifier, #find_by_tag, #find_by_title, #find_first_by_identifier, #find_first_by_title
Methods included from Mixin::MdObjId
Methods included from Mixin::MdGrantees
#change_permission, #grant, #grantees, #revoke
Methods included from Mixin::MdRelations
#dependency, #dependency?, #usedby, #usedby?, #using, #using?
Methods included from Mixin::ObjId
Methods included from Mixin::Links
Methods inherited from Rest::Resource
Methods inherited from Rest::Object
client, default_client, #initialize, #saved?
Methods included from Mixin::DataPropertyReader
Methods included from Mixin::DataPropertyWriter
Methods included from Mixin::MetaPropertyReader
Methods included from Mixin::MetaPropertyWriter
Methods included from Mixin::MetaGetter
Methods included from Mixin::DataGetter
Methods included from Mixin::RootKeyGetter
Methods included from Mixin::ContentGetter
Constructor Details
This class inherits a constructor from GoodData::MdObject
Class Method Details
.all(options = { :client => GoodData.connection, :project => GoodData.project }) ⇒ Array<GoodData::MdObject> | Array<Hash>
Method intended to get all objects of that type in a specified project
decide to pull in full objects. This is desirable from the usability POV but unfortunately has negative impact on performance so it is not the default.
54 55 56 |
# File 'lib/gooddata/models/metadata/dashboard.rb', line 54 def all( = { :client => GoodData.connection, :project => GoodData.project }) query('projectDashboard', Dashboard, ) end |
.create(dashboard = {}, options = { :client => GoodData.client, :project => GoodData.project }) ⇒ Object
58 59 60 61 62 63 64 65 66 |
# File 'lib/gooddata/models/metadata/dashboard.rb', line 58 def create(dashboard = {}, = { :client => GoodData.client, :project => GoodData.project }) client, project = GoodData.get_client_and_project(GoodData::Helpers.symbolize_keys()) res = client.create(Dashboard, GoodData::Helpers.deep_dup(GoodData::Helpers.stringify_keys(EMPTY_OBJECT)), :project => project) dashboard.each do |k, v| res.send("#{k}=", v) if ASSIGNABLE_MEMBERS.include? k end res end |
Instance Method Details
#add_tab(tab) ⇒ Object Also known as: create_tab
69 70 71 72 73 |
# File 'lib/gooddata/models/metadata/dashboard.rb', line 69 def add_tab(tab) new_tab = GoodData::DashboardTab.create(self, tab) content['tabs'] << new_tab.json new_tab end |
#export(format, options = {}) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/gooddata/models/metadata/dashboard.rb', line 81 def export(format, = {}) supported_formats = [:pdf] fail "Wrong format provied \"#{format}\". Only supports formats #{supported_formats.join(', ')}" unless supported_formats.include?(format) tab = [:tab] || '' req_uri = "/gdc/projects/#{project.pid}/clientexport" x = client.post( req_uri, 'clientExport' => { 'url' => "#{client.connection.server_url}/dashboard.html#project=" \ "#{project.uri}&dashboard=#{uri}&tab=#{tab}&export=1", 'name' => title } ) client.poll_on_code(x['asyncTask']['link']['poll'], .merge(process: false)) end |
#exportable? ⇒ Boolean
77 78 79 |
# File 'lib/gooddata/models/metadata/dashboard.rb', line 77 def exportable? true end |
#replace(mapping) ⇒ GoodData::Dashboard
Method used for replacing values in their state according to mapping. Can be used to replace any values but it is typically used to replace the URIs. Returns a new object of the same type.
104 105 106 107 108 |
# File 'lib/gooddata/models/metadata/dashboard.rb', line 104 def replace(mapping) x = GoodData::MdObject.replace_quoted(self, mapping) vals = GoodData::MdObject.find_replaceable_values(self, mapping) GoodData::MdObject.replace_quoted(x, vals) end |
#tabs ⇒ Object
110 111 112 113 114 |
# File 'lib/gooddata/models/metadata/dashboard.rb', line 110 def tabs content['tabs'].map do |tab| GoodData::DashboardTab.new(self, tab) end end |
#tabs_ids ⇒ Object
116 117 118 |
# File 'lib/gooddata/models/metadata/dashboard.rb', line 116 def tabs_ids tabs.map { |t| t['identifier'] } end |