dashing-contrib 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ec500df2f1e3dabe80001d360235bab603642512
4
- data.tar.gz: 5f27671229a2809906e0dd522b2767cf4fcd3372
3
+ metadata.gz: 64ef000ef09364cdc1fbfb35a9b15f08361500bf
4
+ data.tar.gz: e49c3b4c7787815e51240e235851edbce26278d2
5
5
  SHA512:
6
- metadata.gz: 6c41b316df3d7f77cac798f53414ca25c49e08ac195c192dd13c9510277703b21bbb4c2f383c320185c166cd98565a57b4f157e7a10fb19def458a0ebc04a7af
7
- data.tar.gz: e9ac3b976d43ecc3ea5929e9498c3f8f9dd9e5b128049a5e5740f7948ada8dc17e5f397424178866b64168d999ebe4b8d4bb5fa6e3ec9e8304dd0752bcadc13d
6
+ metadata.gz: 77815a412ae3ec39ce3584fd1c8ba84c54d3ec0669e9964d219130d881f111b819a83978575136d09b977ef9a2288c5d25ead52e210fe852f0dee0c65bca9ae5
7
+ data.tar.gz: 2a1d4d7d016078504f52d22a4a65147f03a3167b03cdc8976c42c9b051be49be41462175072867efddf46f91cd6af903bc6b02042e443e242076f3cc09c57258
data/README.md CHANGED
@@ -10,14 +10,15 @@ This project is an extension to Shopify's Dashing. Including this rubygem you wi
10
10
  * Built-in jobs are only a couple of lines implementation, no repetitive copy and paste
11
11
  * Existing secret parameters is automatically loaded from `.env` file
12
12
  * All jobs have a final state (ok, warning, critical)
13
- * Additional Rest API to get overall state summary
13
+ * Rest API to get overall state summary
14
+ * Rest API to trigger save history
14
15
 
15
16
  Read each individual widget documentation to use dashing-contrib built-in widgets after the installation steps.
16
17
 
17
18
  ## Installation
18
19
  Add this line to your Dashing's dashboard Gemfile:
19
20
 
20
- gem 'dashing-contrib', '~> 0.1.1'
21
+ gem 'dashing-contrib', '~> 0.1.2'
21
22
 
22
23
  Update dependencies:
23
24
 
@@ -45,6 +46,7 @@ Now you will be able to use the following widgets, click to see individual docum
45
46
  * [Pingdom Uptime](https://github.com/QubitProducts/dashing-contrib/wiki/Widget:-Pingdom-Uptime)
46
47
  * [Kue Status](https://github.com/QubitProducts/dashing-contrib/wiki/Widget:-Kue-Status)
47
48
  * [Nagios List](https://github.com/QubitProducts/dashing-contrib/wiki/Widget:-Nagios-List)
49
+ * [Switcher](https://github.com/QubitProducts/dashing-contrib/wiki/Widget:-Switcher)
48
50
  * Dashing State (global alert if any widget is under critical state)
49
51
 
50
52
  ## dotenv
@@ -0,0 +1,101 @@
1
+ # Switcher widget written by Juha Mustonen / SC5
2
+
3
+ # Switches (reloads to another address) the dashboards in periodic manner
4
+ # <div id="container" data-switcher-interval="10000" data-switcher-dashboards="dashboard1 dashboard2">
5
+ # <%= yield %>
6
+ # </div>
7
+ #
8
+ class DashboardSwitcher
9
+ constructor: () ->
10
+ @dashboardNames = []
11
+ # Collect the dashboard names from attribute, if provided (otherwise skip switching)
12
+ names = $('[data-switcher-dashboards]').first().attr('data-switcher-dashboards') || ''
13
+ if names.length > 1
14
+ # Get names separated with comma or space
15
+ @dashboardNames = (name.trim() for name in names.sub(' ', ',').split(','))
16
+
17
+ start: (interval=60000) ->
18
+ self = @
19
+ @maxPos = @dashboardNames.length - 1
20
+
21
+ # Skip switching if no names defined
22
+ if @dashboardNames.length == 0
23
+ return
24
+
25
+ # Take the dashboard name from that last part of the path
26
+ pathParts = window.location.pathname.split('/')
27
+ @curName = pathParts[pathParts.length - 1]
28
+ @curPos = @dashboardNames.indexOf(@curName)
29
+
30
+ # If not found, default to first
31
+ if @curPos == -1
32
+ @curPos = 0
33
+ @curName = @dashboardNames[@curPos]
34
+
35
+ # Start loop
36
+ @handle = setTimeout(() ->
37
+ # Increase the position or reset back to zero
38
+ self.curPos += 1
39
+ if self.curPos > self.maxPos
40
+ self.curPos = 0
41
+
42
+ # Switch to new dashboard
43
+ self.curName = self.dashboardNames[self.curPos]
44
+ window.location.pathname = "/#{self.curName}"
45
+
46
+ , parseInt(interval, 10))
47
+
48
+
49
+ # Switches (hides and shows) elements within on list item
50
+ # <li switcher-interval="3000">
51
+ # <div widget-1></div>
52
+ # <div widget-2></div>
53
+ # <div widget-3></div>
54
+ # </li>
55
+ #
56
+ # Supports optional switcher interval, defaults to 5sec
57
+ class WidgetSwitcher
58
+ constructor: (@elements) ->
59
+ @$elements = $(elements)
60
+
61
+ start: (interval=5000) ->
62
+ self = @
63
+ @maxPos = @$elements.length - 1;
64
+ @curPos = 0
65
+
66
+ # Show only first at start
67
+ self.$elements.slice(1).hide()
68
+
69
+ # Start loop
70
+ @handle = setInterval(()->
71
+ # Hide all at first - then show the current and ensure it uses table-cell display type
72
+ self.$elements.hide()
73
+ $(self.$elements[self.curPos]).show().css('display', 'table-cell')
74
+
75
+ # Increase the position or reset back to zero
76
+ self.curPos += 1
77
+ if self.curPos > self.maxPos
78
+ self.curPos = 0
79
+
80
+ , parseInt(interval, 10))
81
+
82
+ stop: () ->
83
+ clearInterval(@handle)
84
+
85
+
86
+ # Dashboard loaded and ready
87
+ Dashing.on 'ready', ->
88
+ # If multiple widgets per list item, switch them periodically
89
+ $('.gridster li').each (index, listItem) ->
90
+ $listItem = $(listItem)
91
+ # Take the element(s) right under the li
92
+ $widgets = $listItem.children('div')
93
+ if $widgets.length > 1
94
+ switcher = new WidgetSwitcher $widgets
95
+ switcher.start($listItem.attr('data-switcher-interval') or 5000)
96
+
97
+ # If multiple dashboards defined (using data-swticher-dashboards="board1 board2")
98
+ $container = $('#container')
99
+ ditcher = new DashboardSwitcher()
100
+ ditcher.start($container.attr('data-switcher-interval') or 60000)
101
+
@@ -1,3 +1,3 @@
1
1
  module DashingContrib
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dashing-contrib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jing Dong
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-27 00:00:00.000000000 Z
11
+ date: 2014-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv
@@ -229,6 +229,7 @@ files:
229
229
  - lib/dashing-contrib/assets/widgets/sidekiq/sidekiq.coffee
230
230
  - lib/dashing-contrib/assets/widgets/sidekiq/sidekiq.html
231
231
  - lib/dashing-contrib/assets/widgets/sidekiq/sidekiq.scss
232
+ - lib/dashing-contrib/assets/widgets/switcher/switcher.coffee
232
233
  - lib/dashing-contrib/bottles/dashing.rb
233
234
  - lib/dashing-contrib/bottles/kue.rb
234
235
  - lib/dashing-contrib/bottles/kue/client.rb