appboard 1.0.7 → 1.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -72,68 +72,110 @@ This will automatically create you an appboard.me account and create an default
72
72
  Usage
73
73
  -----
74
74
 
75
- There is several options how you could use API:
76
75
 
76
+ **Setup Dashboard**
77
+
78
+ After creating account (or deploying addon on Heroku) simple dashboard will be created for you with clocks :)
79
+
80
+ In order to update or create new dashboard you will need to setup it, and the moment this supported only via Ruby GEM.
81
+
82
+ Supported widget sizes are: 1x1, 1x2, 1x3, 2x1, 2x2, 2x3, 3x1, 3x2 and 3x3.
83
+ Supported widget types are: Clock, Single Number, Alert, Bubble Chart, Funnel Chart, Line Chart, Bar Chart, Column Chart, Pie Chart, Radial Gauge, Filler Gauge. Check out [list of available widgets](http://appboard.me/docs/widgets). We are continue working over new nice widgets!
84
+
85
+ There is simple example that updates default dashboard with new configuration:
77
86
 
78
- *Option 1.* Setup new dashboard and pushing data to widget:
79
87
 
80
88
  require 'rubygems'
81
89
  require 'appboard'
82
-
83
- Appboard.setup {
84
- apiKey "zxcv1234"
85
-
86
- widget('My Clock') {
87
- type "clock"
88
- size "1x1"
89
- }
90
-
91
- widget('First Indicator') {
92
- type "singlenumber"
93
- size "1x1"
94
- }
95
- }
96
-
97
- Appboard.widget('First Indicator') {
98
- data do
99
- {
100
- :current => 10
90
+
91
+ Appboard.settings = { :apiKey => '...' } # required only for local environment
92
+ # for Heroku will be taken from environment variables
93
+ Appboard.setup() {
94
+ dashboard('My Dashboard') {
95
+ width 5 # defines widht of dashboard as 5 widgets
96
+
97
+ widget('clock') {
98
+ type "Clock"
99
+ size "1x1"
100
+ }
101
+
102
+ widget('my indicator 1') {
103
+ type "Single Number"
104
+ size "1x1"
105
+ }
106
+
107
+ widget('my indicator 2') {
108
+ type "Alert"
109
+ size "1x1"
110
+ }
101
111
  }
102
- end
103
112
  }
104
-
105
- puts Appboard.widget('First Indicator').uid # prints widget uid
106
113
 
107
114
 
108
- After seting up dashboard configuration is stored in Appboard class, and widget could be easily accessed by name.
109
- For already configured dashboards you could push your data by widget uid.
115
+ As result of this operation dashboard with three widgets (Clock, Simple Number and Alert) will be set. Server will return in result widget's uid (unique identifier) and this data will be stored in Appboard class.
116
+
117
+ You can access this data easily:
118
+
119
+ uidMyIndicator1 = Appboard.widget('my indicator1').uid
110
120
 
121
+ Note: If you are running this on local environment you will need to define _*apiKey*_ before calling Appboard.setup, on Heroku apiKey will be injected during deploying appboard addon.
111
122
 
112
- *Option 2.* Pushing data to widget by widget UID
123
+ Appboard.settings = { :apiKey => '...', :debug => true }
124
+
125
+ You can find more examples in our Git repository: [one](https://github.com/appboard/appboard/blob/master/examples/setupdashboard1.rb), [two](https://github.com/appboard/appboard/blob/master/examples/setupdashboard2.rb) and [three](https://github.com/appboard/appboard/blob/master/examples/setupdashboard3.rb)
126
+
127
+ **Pushing your data to Widget**
128
+
129
+ _in context of Appboard_ - after dashboard is set by Appboard.setup configuration is stored in Appboard class, and you can easily push data to widget by widget name:
113
130
 
114
131
  require 'rubygems'
115
132
  require 'appboard'
116
-
117
- Appboard.push {
118
- apiKey "zxcv1234"
119
-
120
- widget('widget1') {
121
- uid "abcd1234"
122
-
123
- data do
124
- # Data is here
125
- end
126
- }
127
-
128
- widget('widget2') {
129
- uid "poiu4321"
130
133
 
134
+ Appboard.settings = { :apiKey => '...' }
135
+
136
+ Appboard.setup() {
137
+ dashboard('My Dashboard') {
138
+ widget('clock') {
139
+ type "Clock"
140
+ size "1x1"
141
+ }
142
+
143
+ widget('my indicator 1') {
144
+ type "Single Number"
145
+ size "1x1"
146
+ }
147
+ }
148
+ }
149
+
150
+ Appboard.widget('my indicator 1') {
131
151
  data do
132
- # Data is here
152
+ {
153
+ :current => 100
154
+ }
133
155
  end
134
- }
135
156
  }
136
157
 
158
+ _by widget uid (unique identifier)_ - other way to push data to widget is define widget *uid*:
159
+
160
+ require 'rubygems'
161
+ require 'appboard'
162
+
163
+ Appboard.settings = { :apiKey => '...' }
164
+
165
+ Appboard.push {
166
+ widget() {
167
+ uid "[widgetUid]"
168
+ data do
169
+ {
170
+ ...
171
+ }
172
+ end
173
+ }
174
+ }
175
+
176
+ Each widget has its own page on this site. That page contains all the information you need in order to start working with the widget, including descriptions of data model (a piece that represents some kind of data).
177
+
178
+ More examples for different widgets you could find in "our repository":https://github.com/appboard/appboard/tree/master/examples on GitHub.
137
179
 
138
180
 
139
181
  NOTE: Don't forget to specify your apiKey and widget identifier.
data/examples/alert.rb CHANGED
@@ -5,51 +5,51 @@ require 'appboard'
5
5
  # Updates Alert Widget on Dashboard (see http://appboard.me/docs/alert)
6
6
  # Don't forget to specify your apiKey and widget identifier.
7
7
  #
8
- Appboard.push {
9
- apiKey 'wOUpOJeOozcgPdZa'
8
+ Appboard.settings = { :apiKey => 'wOUpOJeOozcgPdZa', :debug => true }
10
9
 
11
- widget('some name here') {
12
- uid "gFMndwmrtZzAWWYB"
13
- data do
14
- [
15
- {
16
- :current => 0,
17
- :label => 'server 1',
18
- :boundaries => [
19
- {
20
- :shape => "triangledown",
21
- :color => "#fd1d25",
22
- :range => 0,
23
- :title => "Down"
24
- },
25
- {
26
- :shape => "triangleup",
27
- :color => "#9ac736",
28
- :range => 1,
29
- :title => "Up"
30
- }
31
- ]
32
- },
33
- {
34
- :current => 1,
35
- :label => 'server 2',
36
- :boundaries => [
37
- {
38
- :shape => "triangledown",
39
- :color => "#fd1d25",
40
- :range => 0,
41
- :title => "Down"
42
- },
43
- {
44
- :shape => "triangleup",
45
- :color => "#9ac736",
46
- :range => 1,
47
- :title => "Up"
48
- }
49
- ]
50
- }
51
- ]
52
- end
53
- }
10
+ Appboard.push {
11
+ widget() {
12
+ uid "gFMndwmrtZzAWWYB"
13
+ data do
14
+ [
15
+ {
16
+ :current => 0,
17
+ :label => 'server 1',
18
+ :boundaries => [
19
+ {
20
+ :shape => "triangledown",
21
+ :color => "#fd1d25",
22
+ :range => 0,
23
+ :title => "Down"
24
+ },
25
+ {
26
+ :shape => "triangleup",
27
+ :color => "#9ac736",
28
+ :range => 1,
29
+ :title => "Up"
30
+ }
31
+ ]
32
+ },
33
+ {
34
+ :current => 1,
35
+ :label => 'server 2',
36
+ :boundaries => [
37
+ {
38
+ :shape => "triangledown",
39
+ :color => "#fd1d25",
40
+ :range => 0,
41
+ :title => "Down"
42
+ },
43
+ {
44
+ :shape => "triangleup",
45
+ :color => "#9ac736",
46
+ :range => 1,
47
+ :title => "Up"
48
+ }
49
+ ]
50
+ }
51
+ ]
52
+ end
53
+ }
54
54
  }
55
55
 
data/examples/barchart.rb CHANGED
@@ -5,31 +5,31 @@ require 'appboard'
5
5
  # Updates Bar Chart on Dashboard (see http://appboard.me/docs/barchart)
6
6
  # Don't forget to specify your apiKey and widget identifier.
7
7
  #
8
- Appboard.push {
9
- apiKey 'wOUpOJeOozcgPdZa'
8
+ Appboard.settings = { :apiKey => 'wOUpOJeOozcgPdZa', :debug => true }
10
9
 
11
- widget('some name here') {
12
- uid "ULcgjwNlKgqNPEpz"
13
- data do
14
- {
15
- :xAxis => ["Jan", "Feb", "Mar", "Apr"],
16
- :series => [
17
- {
18
- :name => "A",
19
- :entries => [2, 3, 4, 1]
20
- },
21
- {
22
- :name => "B",
23
- :entries => [1, 2, 3, 4]
24
- },
25
- {
26
- :name => "C",
27
- :entries => [2, 4, 2, 2]
28
- }
29
- ]
30
- }
31
- end
32
- }
10
+ Appboard.push {
11
+ widget() {
12
+ uid "ULcgjwNlKgqNPEpz"
13
+ data do
14
+ {
15
+ :xAxis => ["Jan", "Feb", "Mar", "Apr"],
16
+ :series => [
17
+ {
18
+ :name => "A",
19
+ :entries => [2, 3, 4, 1]
20
+ },
21
+ {
22
+ :name => "B",
23
+ :entries => [1, 2, 3, 4]
24
+ },
25
+ {
26
+ :name => "C",
27
+ :entries => [2, 4, 2, 2]
28
+ }
29
+ ]
30
+ }
31
+ end
32
+ }
33
33
  }
34
34
 
35
35
 
@@ -5,29 +5,29 @@ require 'appboard'
5
5
  # Updates Bubble Chart on Dashboard (see http://appboard.me/docs/bubblechart)
6
6
  # Don't forget to specify your apiKey and widget identifier.
7
7
  #
8
- Appboard.push {
9
- apiKey 'wOUpOJeOozcgPdZa'
8
+ Appboard.settings = { :apiKey => 'wOUpOJeOozcgPdZa', :debug => true }
10
9
 
11
- widget('some name here') {
12
- uid "dwTgneCxzCOlFTjI"
13
- data do
14
- {
15
- :series => [
16
- {
17
- :name => "A",
18
- :entries => 10
19
- },
20
- {
21
- :name => "B",
22
- :entries => 15
23
- },
24
- {
25
- :name => "C",
26
- :entries => 60
27
- }
28
- ]
29
- }
30
- end
31
- }
10
+ Appboard.push {
11
+ widget() {
12
+ uid "dwTgneCxzCOlFTjI"
13
+ data do
14
+ {
15
+ :series => [
16
+ {
17
+ :name => "A",
18
+ :entries => 10
19
+ },
20
+ {
21
+ :name => "B",
22
+ :entries => 15
23
+ },
24
+ {
25
+ :name => "C",
26
+ :entries => 60
27
+ }
28
+ ]
29
+ }
30
+ end
31
+ }
32
32
  }
33
33
 
@@ -5,31 +5,31 @@ require 'appboard'
5
5
  # Updates Column Chart on Dashboard (see http://appboard.me/docs/columnchart)
6
6
  # Don't forget to specify your apiKey and widget identifier.
7
7
  #
8
- Appboard.push {
9
- apiKey 'wOUpOJeOozcgPdZa'
8
+ Appboard.settings = { :apiKey => 'wOUpOJeOozcgPdZa', :debug => true }
10
9
 
11
- widget('some name here') {
12
- uid "HkGIhTInYAwwwXbQ"
13
- data do
14
- {
15
- :xAxis => ["Jan", "Feb", "Mar", "Apr"],
16
- :series => [
17
- {
18
- :name => "A",
19
- :entries => [2, 3, 4, 1]
20
- },
21
- {
22
- :name => "B",
23
- :entries => [3, 4, 2, 1]
24
- },
25
- {
26
- :name => "C",
27
- :entries => [5, 2, 1, 3]
28
- }
29
- ]
30
- }
31
- end
32
- }
10
+ Appboard.push {
11
+ widget() {
12
+ uid "HkGIhTInYAwwwXbQ"
13
+ data do
14
+ {
15
+ :xAxis => ["Jan", "Feb", "Mar", "Apr"],
16
+ :series => [
17
+ {
18
+ :name => "A",
19
+ :entries => [2, 3, 4, 1]
20
+ },
21
+ {
22
+ :name => "B",
23
+ :entries => [3, 4, 2, 1]
24
+ },
25
+ {
26
+ :name => "C",
27
+ :entries => [5, 2, 1, 3]
28
+ }
29
+ ]
30
+ }
31
+ end
32
+ }
33
33
  }
34
34
 
35
35
 
@@ -5,23 +5,23 @@ require 'appboard'
5
5
  # Updates Filler Gauge on Dashboard (see http://appboard.me/docs/gauge)
6
6
  # Don't forget to specify your apiKey and widget identifier.
7
7
  #
8
- Appboard.push {
9
- apiKey 'wOUpOJeOozcgPdZa'
8
+ Appboard.settings = { :apiKey => 'wOUpOJeOozcgPdZa', :debug => true }
10
9
 
11
- widget('some name here') {
12
- uid "vCmpsvRHKoLBZTBN"
13
- data do
14
- {
15
- :value => 80,
16
- :minimum => 0,
17
- :maximum => 100,
18
- :ranges => [
19
- {:range => 80, :fillColor => "#9ac736"},
20
- {:range => 15, :fillColor => "#e06f0f"},
21
- {:range => 5, :fillColor => "#fd1d25"}
22
- ]
23
- }
24
- end
25
- }
10
+ Appboard.push {
11
+ widget() {
12
+ uid "vCmpsvRHKoLBZTBN"
13
+ data do
14
+ {
15
+ :value => 80,
16
+ :minimum => 0,
17
+ :maximum => 100,
18
+ :ranges => [
19
+ {:range => 80, :fillColor => "#9ac736"},
20
+ {:range => 15, :fillColor => "#e06f0f"},
21
+ {:range => 5, :fillColor => "#fd1d25"}
22
+ ]
23
+ }
24
+ end
25
+ }
26
26
  }
27
27
 
@@ -5,29 +5,29 @@ require 'appboard'
5
5
  # Updates Funnel Chart on Dashboard (see http://appboard.me/docs/funnelchart)
6
6
  # Don't forget to specify your apiKey and widget identifier.
7
7
  #
8
- Appboard.push {
9
- apiKey 'wOUpOJeOozcgPdZa'
8
+ Appboard.settings = { :apiKey => 'wOUpOJeOozcgPdZa', :debug => true }
10
9
 
11
- widget('some name here') {
12
- uid "wyKUysnPLOmXpLcC"
13
- data do
14
- {
15
- :series => [
16
- {
17
- :name => "A",
18
- :entries => 1
19
- },
20
- {
21
- :name => "B",
22
- :entries => 20
23
- },
24
- {
25
- :name => "C",
26
- :entries => 5
27
- }
28
- ]
29
- }
30
- end
31
- }
10
+ Appboard.push {
11
+ widget() {
12
+ uid "wyKUysnPLOmXpLcC"
13
+ data do
14
+ {
15
+ :series => [
16
+ {
17
+ :name => "A",
18
+ :entries => 1
19
+ },
20
+ {
21
+ :name => "B",
22
+ :entries => 20
23
+ },
24
+ {
25
+ :name => "C",
26
+ :entries => 5
27
+ }
28
+ ]
29
+ }
30
+ end
31
+ }
32
32
  }
33
33
 
@@ -5,30 +5,30 @@ require 'appboard'
5
5
  # Updates Line Chart on Dashboard (see http://appboard.me/docs/linechart)
6
6
  # Don't forget to specify your apiKey and widget identifier.
7
7
  #
8
- Appboard.push {
9
- apiKey 'wOUpOJeOozcgPdZa'
8
+ Appboard.settings = { :apiKey => 'wOUpOJeOozcgPdZa', :debug => true }
10
9
 
11
- widget('some name here') {
12
- uid "CrnBIfRFvkFcNKPX"
13
- data do
14
- {
15
- :xAxis => ["Jan", "Feb", "Mar", "Apr"],
16
- :series => [
17
- {
18
- :name => "A",
19
- :entries => [1, 2, 3, 4]
20
- },
21
- {
22
- :name => "B",
23
- :entries => [10, 15, 20, 10]
24
- },
25
- {
26
- :name => "C",
27
- :entries => [20, 10, 5, 5]
28
- }
29
- ]
30
- }
31
- end
32
- }
10
+ Appboard.push {
11
+ widget() {
12
+ uid "CrnBIfRFvkFcNKPX"
13
+ data do
14
+ {
15
+ :xAxis => ["Jan", "Feb", "Mar", "Apr"],
16
+ :series => [
17
+ {
18
+ :name => "A",
19
+ :entries => [1, 2, 3, 4]
20
+ },
21
+ {
22
+ :name => "B",
23
+ :entries => [10, 15, 20, 10]
24
+ },
25
+ {
26
+ :name => "C",
27
+ :entries => [20, 10, 5, 5]
28
+ }
29
+ ]
30
+ }
31
+ end
32
+ }
33
33
  }
34
34
 
data/examples/piechart.rb CHANGED
@@ -5,29 +5,29 @@ require 'appboard'
5
5
  # Updates Pie Chart on Dashboard (see http://appboard.me/docs/piechart)
6
6
  # Don't forget to specify your apiKey and widget identifier.
7
7
  #
8
- Appboard.push {
9
- apiKey 'wOUpOJeOozcgPdZa'
8
+ Appboard.settings = { :apiKey => 'wOUpOJeOozcgPdZa', :debug => true }
10
9
 
11
- widget('some name here') {
12
- uid "QHKUBwxBPpiaAinB"
13
- data do
14
- {
15
- :series => [
16
- {
17
- :name => "A",
18
- :entries => 1
19
- },
20
- {
21
- :name => "B",
22
- :entries => 2
23
- },
24
- {
25
- :name => "C",
26
- :entries => 3
27
- }
28
- ]
29
- }
30
- end
31
- }
10
+ Appboard.push {
11
+ widget() {
12
+ uid "QHKUBwxBPpiaAinB"
13
+ data do
14
+ {
15
+ :series => [
16
+ {
17
+ :name => "A",
18
+ :entries => 1
19
+ },
20
+ {
21
+ :name => "B",
22
+ :entries => 2
23
+ },
24
+ {
25
+ :name => "C",
26
+ :entries => 3
27
+ }
28
+ ]
29
+ }
30
+ end
31
+ }
32
32
  }
33
33
 
@@ -5,23 +5,23 @@ require 'appboard'
5
5
  # Updates Radial Gauge on Dashboard (see http://appboard.me/docs/gauge)
6
6
  # Don't forget to specify your apiKey and widget identifier.
7
7
  #
8
- Appboard.push {
9
- apiKey 'wOUpOJeOozcgPdZa'
8
+ Appboard.settings = { :apiKey => 'wOUpOJeOozcgPdZa', :debug => true }
10
9
 
11
- widget('some name here') {
12
- uid "BEMTCnwSYHQntaBS"
13
- data do
14
- {
15
- :value => 80,
16
- :minimum => 0,
17
- :maximum => 100,
18
- :ranges => [
19
- {:range => 80, :fillColor => "#9ac736"},
20
- {:range => 15, :fillColor => "#e06f0f"},
21
- {:range => 5, :fillColor => "#fd1d25"}
22
- ]
23
- }
24
- end
25
- }
10
+ Appboard.push {
11
+ widget() {
12
+ uid "BEMTCnwSYHQntaBS"
13
+ data do
14
+ {
15
+ :value => 80,
16
+ :minimum => 0,
17
+ :maximum => 100,
18
+ :ranges => [
19
+ {:range => 80, :fillColor => "#9ac736"},
20
+ {:range => 15, :fillColor => "#e06f0f"},
21
+ {:range => 5, :fillColor => "#fd1d25"}
22
+ ]
23
+ }
24
+ end
25
+ }
26
26
  }
27
27
 
@@ -0,0 +1,80 @@
1
+ require 'rubygems'
2
+ require 'appboard'
3
+
4
+ #
5
+ # Creates dashboard with four widgets (Clock, Single Number, Radial Gauge and Pie Chart) and push some random data to widgets.
6
+ # Don't forget to specify your apiKey.
7
+ #
8
+ Appboard.settings = { :apiKey => 'wOUpOJeOozcgPdZa', :debug => true }
9
+
10
+ # Dashboard configuration
11
+ Appboard.setup() {
12
+ dashboard('My Dashboard') {
13
+ widget('clock') {
14
+ type "Clock"
15
+ size "1x1"
16
+ }
17
+
18
+ widget('indicator 1') {
19
+ type "Single Number"
20
+ size "1x1"
21
+ }
22
+
23
+ widget('indicator 2') {
24
+ type "Radial Gauge"
25
+ size "1x1"
26
+ }
27
+
28
+ widget('indicator 3') {
29
+ type "Pie Chart"
30
+ size "1x1"
31
+ }
32
+ }
33
+ }
34
+
35
+
36
+ # Pushing some demo data to widgets separately
37
+ Appboard.widget('indicator 1') {
38
+ data do
39
+ {
40
+ :current => Random.rand(100)
41
+ }
42
+ end
43
+ }
44
+
45
+ Appboard.widget('indicator 2') {
46
+ data do
47
+ {
48
+ :value => Random.rand(100),
49
+ :minimum => 0,
50
+ :maximum => 100,
51
+ :ranges => [
52
+ {:range => 80, :fillColor => "#9ac736"},
53
+ {:range => 15, :fillColor => "#e06f0f"},
54
+ {:range => 5, :fillColor => "#fd1d25"}
55
+ ]
56
+ }
57
+ end
58
+ }
59
+
60
+ Appboard.widget('indicator 3') {
61
+ data do
62
+ {
63
+ :series => [
64
+ {
65
+ :name => "A",
66
+ :entries => Random.rand(100)
67
+ },
68
+ {
69
+ :name => "B",
70
+ :entries => Random.rand(100)
71
+ },
72
+ {
73
+ :name => "C",
74
+ :entries => Random.rand(100)
75
+ }
76
+ ]
77
+ }
78
+ end
79
+ }
80
+
@@ -0,0 +1,115 @@
1
+ require 'rubygems'
2
+ require 'appboard'
3
+
4
+ #
5
+ # Creates dashboard with four widgets (Clock, Alert, Filler Gauge and Bubble Chart) and push some random data to widgets.
6
+ # Don't forget to specify your apiKey.
7
+ #
8
+ Appboard.settings = { :apiKey => 'wOUpOJeOozcgPdZa', :debug => true }
9
+
10
+ # Dashboard configuration
11
+ Appboard.setup() {
12
+ dashboard('My Dashboard') {
13
+ widget('clock') {
14
+ type "Clock"
15
+ size "1x1"
16
+ }
17
+
18
+ widget('indicator 1') {
19
+ type "Alert"
20
+ size "1x1"
21
+ }
22
+
23
+ widget('indicator 2') {
24
+ type "Filler Gauge"
25
+ size "1x1"
26
+ }
27
+
28
+ widget('indicator 3') {
29
+ type "Bubble Chart"
30
+ size "1x1"
31
+ }
32
+ }
33
+ }
34
+
35
+
36
+ # Pushing some demo data to widgets by widget name
37
+ Appboard.push {
38
+ widget('indicator 1') {
39
+ data do
40
+ [
41
+ {
42
+ :current => Random.rand(1),
43
+ :label => 'Example 1',
44
+ :boundaries => [
45
+ {
46
+ :shape => "rectangle",
47
+ :color => "#00FF00",
48
+ :range => 0,
49
+ :title => "Down"
50
+ },{
51
+ :shape => "rhombus",
52
+ :color => "#FF0000",
53
+ :range => 1,
54
+ :title => "Up"
55
+ }
56
+ ]
57
+ },
58
+ {
59
+ :current => Random.rand(1),
60
+ :label => 'Example 2',
61
+ :boundaries => [
62
+ {
63
+ :shape => "triangledown",
64
+ :color => "#fd1d25",
65
+ :range => 0,
66
+ :title => "Down"
67
+ },{
68
+ :shape => "triangleup",
69
+ :color => "#9ac736",
70
+ :range => 1,
71
+ :title => "Up"
72
+ }
73
+ ]
74
+ }
75
+ ]
76
+ end
77
+ }
78
+
79
+ widget('indicator 2') {
80
+ data do
81
+ {
82
+ :value => Random.rand(100),
83
+ :minimum => 0,
84
+ :maximum => 100,
85
+ :ranges => [
86
+ {:range => 80, :fillColor => "#9ac736"},
87
+ {:range => 15, :fillColor => "#e06f0f"},
88
+ {:range => 5, :fillColor => "#fd1d25"}
89
+ ]
90
+ }
91
+ end
92
+ }
93
+
94
+ widget('indicator 3') {
95
+ data do
96
+ {
97
+ :series => [
98
+ {
99
+ :name => "Example 1",
100
+ :entries => Random.rand(100),
101
+ },
102
+ {
103
+ :name => "Example 2",
104
+ :entries => Random.rand(100),
105
+ },
106
+ {
107
+ :name => "Example 3",
108
+ :entries => Random.rand(100),
109
+ }
110
+ ]
111
+ }
112
+ end
113
+ }
114
+ }
115
+
@@ -0,0 +1,112 @@
1
+ require 'rubygems'
2
+ require 'appboard'
3
+
4
+ #
5
+ # Creates dashboard with four widgets (Clock, Line Chart, Bar Chart and Column Chart) and push some random data to widgets.
6
+ # Don't forget to specify your apiKey.
7
+ #
8
+ Appboard.settings = { :apiKey => 'wOUpOJeOozcgPdZa', :debug => true }
9
+
10
+ # Dashboard configuration
11
+ Appboard.setup() {
12
+ dashboard('My Dashboard') {
13
+ widget('clock') {
14
+ type "clock"
15
+ size "1x1"
16
+ }
17
+
18
+ widget('indicator 1') {
19
+ type "linechart"
20
+ size "3x1"
21
+ }
22
+
23
+ widget('indicator 2') {
24
+ type "barchart"
25
+ size "2x2"
26
+ }
27
+
28
+ widget('indicator 3') {
29
+ type "columnchart"
30
+ size "2x2"
31
+ }
32
+ }
33
+ }
34
+
35
+ i1Uid = Appboard.widget('indicator 1').uid
36
+ i2Uid = Appboard.widget('indicator 2').uid
37
+ i3Uid = Appboard.widget('indicator 3').uid
38
+
39
+ # Pushing some demo data to widgets by widget uid
40
+ Appboard.push {
41
+ widget() {
42
+ uid i1Uid
43
+
44
+ data do
45
+ {
46
+ :xAxis => ["Jan", "Feb", "Mar", "Apr"],
47
+ :series => [
48
+ {
49
+ :name => "Example 1",
50
+ :entries => [Random.rand(10), Random.rand(10), Random.rand(10), Random.rand(10)]
51
+ },
52
+ {
53
+ :name => "Example 2",
54
+ :entries => [Random.rand(20), Random.rand(20), Random.rand(20), Random.rand(20)]
55
+ },
56
+ {
57
+ :name => "Example 3",
58
+ :entries => [Random.rand(40), Random.rand(40), Random.rand(40), Random.rand(40)]
59
+ }
60
+ ]
61
+ }
62
+ end
63
+ }
64
+
65
+ widget() {
66
+ uid i2Uid
67
+
68
+ data do
69
+ {
70
+ :xAxis => ["Jan", "Feb", "Mar", "Apr"],
71
+ :series => [
72
+ {
73
+ :name => "Example 1",
74
+ :entries => [Random.rand(10), Random.rand(10), Random.rand(10), Random.rand(10)]
75
+ },
76
+ {
77
+ :name => "Example 2",
78
+ :entries => [Random.rand(20), Random.rand(20), Random.rand(20), Random.rand(20)]
79
+ },
80
+ {
81
+ :name => "Example 3",
82
+ :entries => [Random.rand(40), Random.rand(40), Random.rand(40), Random.rand(40)]
83
+ }
84
+ ]
85
+ }
86
+ end
87
+ }
88
+
89
+ widget() {
90
+ uid i3Uid
91
+
92
+ data do
93
+ {
94
+ :xAxis => ["Jan", "Feb", "Mar", "Apr"],
95
+ :series => [
96
+ {
97
+ :name => "Example 1",
98
+ :entries => [Random.rand(10), Random.rand(10), Random.rand(10), Random.rand(10)]
99
+ },
100
+ {
101
+ :name => "Example 2",
102
+ :entries => [Random.rand(20), Random.rand(20), Random.rand(20), Random.rand(20)]
103
+ },
104
+ {
105
+ :name => "Example 3",
106
+ :entries => [Random.rand(40), Random.rand(40), Random.rand(40), Random.rand(40)]
107
+ }
108
+ ]
109
+ }
110
+ end
111
+ }
112
+ }
@@ -0,0 +1,19 @@
1
+ require 'rubygems'
2
+ require 'appboard'
3
+
4
+ #
5
+ # Updates Singge Number on Dashboard (see http://appboard.me/docs/singlenumber)
6
+ # Don't forget to specify your apiKey and widget identifier.
7
+ #
8
+ Appboard.settings = { :apiKey => 'wOUpOJeOozcgPdZa', :url => 'http://localhost:9000', :debug => true }
9
+
10
+ Appboard.push {
11
+ widget() {
12
+ uid "weXtrkUwSeZGvcRK"
13
+ data do
14
+ {
15
+ :current => 100
16
+ }
17
+ end
18
+ }
19
+ }
@@ -2,7 +2,7 @@ module Appboard
2
2
  # Dashboard configuration
3
3
  class DashboardSetup
4
4
  # Defines dashboard
5
- class Dashboard
5
+ class Dashboard
6
6
  def initialize(name, &block)
7
7
  @widgets = {}
8
8
  @width = 5
@@ -2,7 +2,7 @@ module Appboard #:nodoc:
2
2
  module Version #:nodoc:
3
3
  MAJOR = 1
4
4
  MINOR = 0
5
- TINY = 7
5
+ TINY = 8
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -43,13 +43,11 @@ module Appboard
43
43
  # end
44
44
  # }
45
45
  #
46
- def widget(widget_name)
46
+ def widget(widget_name = nil)
47
47
  if block_given?
48
48
  block = Proc.new
49
49
  widget = Widget.new(widget_name, &block)
50
-
51
- raise ArgumentError, "Widget 'uid' is not defined" if widget.uid.nil?
52
-
50
+
53
51
  (@widgets ||= []) << widget
54
52
  self
55
53
  else
data/lib/appboard.rb CHANGED
@@ -100,6 +100,22 @@ module Appboard
100
100
  pusher = WidgetPusher.new.instance_eval(&block)
101
101
 
102
102
  pusher.get_widgets.each do |widget|
103
+ dashboard = nil
104
+
105
+ if widget.name
106
+ @@dashboards.each do |name, db|
107
+ dashboard = db if db.has_widget(widget.name)
108
+ break if dashboard
109
+ end
110
+
111
+ if dashboard
112
+ widget_tmpl = dashboard.get_widget(widget.name)
113
+ widget.uid(widget_tmpl.uid)
114
+ end
115
+ end
116
+
117
+ raise ArgumentError, "Widget 'uid' and 'name' are not defined" if widget.uid.nil? && widget.name.nil?
118
+
103
119
  apiKey = pusher.apiKey || config[:apiKey]
104
120
  url = "#{config[:url]}/#{config[:version]}/#{apiKey}/data/#{widget.uid}"
105
121
 
@@ -124,7 +140,7 @@ module Appboard
124
140
 
125
141
  @@dashboards.each do |name, db|
126
142
  dashboard = db if db.has_widget(widget_name)
127
- break if dashboard.nil?
143
+ break if dashboard
128
144
  end
129
145
 
130
146
  raise ArgumentError, "Widget '#{widget_name}' is not defined, to use this method setup dashboard with Appboard.setup()" if dashboard.nil?
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appboard
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 7
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 7
10
- version: 1.0.7
9
+ - 8
10
+ version: 1.0.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - appboard.me
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-07-19 00:00:00 -04:00
18
+ date: 2011-07-20 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -100,7 +100,10 @@ files:
100
100
  - examples/piechart.rb
101
101
  - examples/radialgauge.rb
102
102
  - examples/setupdashboard.rb
103
- - examples/singlenumner.rb
103
+ - examples/setupdashboard1.rb
104
+ - examples/setupdashboard2.rb
105
+ - examples/setupdashboard3.rb
106
+ - examples/singlenumber.rb
104
107
  - lib/appboard.rb
105
108
  - lib/appboard/bootstrap.rb
106
109
  - lib/appboard/dashboardsetup.rb
@@ -1,19 +0,0 @@
1
- require 'rubygems'
2
- require 'appboard'
3
-
4
- #
5
- # Updates Singge Number on Dashboard (see http://appboard.me/docs/singlenumber)
6
- # Don't forget to specify your apiKey and widget identifier.
7
- #
8
- Appboard.push {
9
- apiKey 'wOUpOJeOozcgPdZa'
10
-
11
- widget('some name here') {
12
- uid "weXtrkUwSeZGvcRK"
13
- data do
14
- {
15
- :current => 100
16
- }
17
- end
18
- }
19
- }