Class: Lesli::Shared::Dashboard

Inherits:
ApplicationLesliRecord show all
Defined in:
app/models/lesli/shared/dashboard.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.initialize_dashboard(modelo, account, components) ⇒ void

This method returns an undefined value.

Examples:

# Imagine you are adding a new engine to your instance (CloudProposal)
# To execute this function, you must only do
 = Account.first
.proposal = CloudProposal::Account.new

Parameters:

  • account (LesliEngine::Account)


55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'app/models/lesli/shared/dashboard.rb', line 55

def self.initialize_dashboard(modelo, , components)

    components.unshift({
        name: "Engine version",
        component_id: "engine-version",
        layout: 2,
        query_configuration: {},
        custom_configuration: {}
    })

    modelo.create_with(
        default: true,
        main: false,
        components_attributes: components
    ).find_or_create_by!(
        account: ,
        name: "Default Dashboard"
    )
end

.options(current_user, query) ⇒ Hash

Returns Hash containing the options to create and manage dashboards.

Examples:

CloudHouse::Dashboard.options(User.find(2), nil)

Parameters:

  • current_user (User)

    The user that made this request

  • query (Hash)

    Query containing filters. Currently unused, but required

Returns:

  • (Hash)

    Hash containing the options to create and manage dashboards



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'app/models/lesli/shared/dashboard.rb', line 104

def self.options(current_user, query)
    dynamic_info = self.dynamic_info
    component_model = dynamic_info[:module_model_component]

    component_ids = component_model.component_ids.map do |comp|
        {
            value: comp,
            text: comp
        }
    end

    options = {
        component_ids: component_ids,
        #components_configuration_options: component_model.configuration_options,
        descriptions: {}
    }

    if block_given?
        yield(options)
    else
        return options
    end
end

Instance Method Details

#showHash

Returns Hash of containing the information of the dashboard and its components.

Examples:

respond_with_successful(CloudHelp::Dashboard.first.show)

Returns:

  • (Hash)

    Hash of containing the information of the dashboard and its components.



81
82
83
84
85
86
87
88
89
90
91
92
# File 'app/models/lesli/shared/dashboard.rb', line 81

def show
    attributes.merge({
        components: components.order(index: :asc)
        # components: [{
        #     name: "ticket",
        #     component_id: "ticket"
        # },{
        #     name: "ticket",
        #     component_id: "ticket"
        # }]
    })
end