nutcracker-web 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +10 -0
  3. data/Gemfile.lock +63 -0
  4. data/README.md +56 -0
  5. data/Rakefile +26 -0
  6. data/assets/javascripts/application.js +10 -0
  7. data/assets/javascripts/collections/clusters.js.coffee +4 -0
  8. data/assets/javascripts/collections/nodes.js.coffee +19 -0
  9. data/assets/javascripts/models/cluster.js.coffee +16 -0
  10. data/assets/javascripts/models/node.js.coffee +14 -0
  11. data/assets/javascripts/models/overview.js.coffee +27 -0
  12. data/assets/javascripts/nutcracker.js.coffee +20 -0
  13. data/assets/javascripts/routers/nutcracker_router.js.coffee +29 -0
  14. data/assets/javascripts/utils/region_manager.js.coffee +12 -0
  15. data/assets/javascripts/utils/underscore_ext.js.coffee +6 -0
  16. data/assets/javascripts/vendor/backbone.js +1571 -0
  17. data/assets/javascripts/vendor/bootstrap.js +2276 -0
  18. data/assets/javascripts/vendor/google_chart.js.coffee +124 -0
  19. data/assets/javascripts/vendor/humanize.js +459 -0
  20. data/assets/javascripts/vendor/jquery.js +8842 -0
  21. data/assets/javascripts/vendor/underscore.js +1227 -0
  22. data/assets/javascripts/views/cluster.js.coffee +58 -0
  23. data/assets/javascripts/views/config.js.coffee +6 -0
  24. data/assets/javascripts/views/footer.js.coffee +8 -0
  25. data/assets/javascripts/views/navbar.js.coffee +28 -0
  26. data/assets/javascripts/views/node.js.coffee +54 -0
  27. data/assets/javascripts/views/overview.js.coffee +6 -0
  28. data/assets/stylesheets/application.css +24 -0
  29. data/assets/stylesheets/bootstrap-responsive.css +1109 -0
  30. data/assets/stylesheets/bootstrap.css +6158 -0
  31. data/assets/templates/cluster.jst.eco +87 -0
  32. data/assets/templates/config.jst.eco +15 -0
  33. data/assets/templates/footer.jst.eco +1 -0
  34. data/assets/templates/navbar.jst.eco +55 -0
  35. data/assets/templates/node.jst.eco +73 -0
  36. data/assets/templates/overview.jst.eco +32 -0
  37. data/lib/nutcracker/web/app.rb +51 -0
  38. data/lib/nutcracker/web/version.rb +5 -0
  39. data/lib/nutcracker/web.rb +29 -0
  40. metadata +122 -0
@@ -0,0 +1,58 @@
1
+ class Nutcracker.Views.Cluster extends Backbone.View
2
+ template: JST['cluster']
3
+
4
+ render: ->
5
+ @curIndex = @collection.indexOf(@model)
6
+ @nextCluster = @collection.at @curIndex+1
7
+ @prevCluster = @collection.at @curIndex-1
8
+
9
+ @$el.html @template {@model, @nextCluster, @prevCluster}
10
+
11
+ options = {
12
+ is3D: true
13
+ titleTextStyle:
14
+ fontSize: 17.5
15
+ color: '#333333'
16
+ width: 300
17
+ height: 300
18
+ sliceVisibilityThreshold: 0
19
+ chartArea:
20
+ width: '100%'
21
+ height: '80%'
22
+ legend:
23
+ position: 'bottom'
24
+ }
25
+
26
+ data = [['Node','Node']]
27
+ @model.get("nodes").map (node)->
28
+ data.push [node.get("hostname"),node.get("info").max_memory]
29
+
30
+ chart = new Backbone.GoogleChart({
31
+ formatter:
32
+ callback: humanize.filesize
33
+ columns: [1]
34
+ chartType: 'PieChart'
35
+ options: options
36
+ dataTable: data
37
+ })
38
+
39
+ chart.on "select", (chart) =>
40
+ Nutcracker.router.navigate @model.get("nodes").at(
41
+ chart.getSelection()[0].row
42
+ ).get('routeURL'), trigger: true
43
+
44
+ @$el.find("#chart2").html chart.render().el
45
+ @$el.find("#chart1").html new Backbone.GoogleChart({
46
+ formatter:
47
+ callback: humanize.filesize
48
+ columns: [1]
49
+ chartType: 'PieChart'
50
+ options: options
51
+ dataTable: [
52
+ ['Memory', 'Memory']
53
+ ['Free', @model.get("nodes").freeMemory() ]
54
+ ['Used', @model.get('nodes').usedMemory() ]
55
+ ]
56
+ }).render().el
57
+
58
+ this
@@ -0,0 +1,6 @@
1
+ class Nutcracker.Views.Config extends Backbone.View
2
+ template: JST["config"]
3
+
4
+ render: ->
5
+ @$el.html @template {@model}
6
+ this
@@ -0,0 +1,8 @@
1
+ class Nutcracker.Views.Footer extends Backbone.View
2
+ className: "container navbar navbar-fixed-bottom navbar-inverse"
3
+ template: JST['footer']
4
+
5
+ render: ->
6
+ @$el.html @template({@model})
7
+ this
8
+
@@ -0,0 +1,28 @@
1
+ class Nutcracker.Views.Navbar extends Backbone.View
2
+ className: "navbar navbar-inverse navbar-fixed-top"
3
+ template: JST['navbar']
4
+
5
+ initialize: =>
6
+ Backbone.history.bind "all", @routeChange
7
+
8
+ render: ->
9
+ $(@el).html @template {@model}
10
+ this
11
+
12
+ resetButtons: ->
13
+ @$el.find("li").removeClass 'active'
14
+
15
+ activate: ( id )=>
16
+ @$(id).addClass 'active'
17
+
18
+ routeChange: (route, object, action, args) =>
19
+ @resetButtons()
20
+ if /showOverview/g.test action
21
+ @activate '#overview'
22
+ if /showConfig/.test action
23
+ @activate '#config'
24
+ else if /showCluster/ig.test action
25
+ @activate '#clusters'
26
+ else if /showNode/gi.test action
27
+ @activate '#nodes'
28
+
@@ -0,0 +1,54 @@
1
+ class Nutcracker.Views.Node extends Backbone.View
2
+ template: JST['node']
3
+
4
+ render: ->
5
+ @curIndex = @collection.indexOf(@model)
6
+ @nextNode = @collection.at @curIndex+1
7
+ @prevNode = @collection.at @curIndex-1
8
+
9
+ options = {
10
+ is3D: true
11
+ titleTextStyle:
12
+ fontSize: 17.5
13
+ color: '#333333'
14
+ titleTextStyle:
15
+ fontSize: 17.5
16
+ color: '#333333'
17
+ width: 300,
18
+ height: 300,
19
+ sliceVisibilityThreshold: 0
20
+ chartArea:
21
+ width: '100%'
22
+ height: '80%'
23
+ legend:
24
+ position: 'bottom'
25
+ }
26
+
27
+ @$el.html @template {@model,@nextNode,@prevNode}
28
+ @$el.find("#chart1").append new Backbone.GoogleChart({
29
+ chartType: 'PieChart'
30
+ formatter:
31
+ callback: humanize.filesize
32
+ columns: [1]
33
+ options: _(title: 'Memory').extend options
34
+ dataTable: [
35
+ ['Memory', 'Memory'],
36
+ ['Free', @model.get('freeMemory')],
37
+ ['Used', @model.get('usedMemory')]
38
+ ],
39
+ }).render().el
40
+
41
+ @$el.find("#chart2").append new Backbone.GoogleChart({
42
+ formatter:
43
+ callback: humanize.numberFormat
44
+ columns: [1]
45
+ chartType: 'PieChart'
46
+ options: _(title: 'Hits').extend options
47
+ dataTable: [
48
+ ['Memory', 'Memory'],
49
+ ['Hits', @model.get("info").hits],
50
+ ['Misses', @model.get("info").misses]
51
+ ],
52
+ }).render().el
53
+
54
+ this
@@ -0,0 +1,6 @@
1
+ class Nutcracker.Views.Overview extends Backbone.View
2
+ template: JST['overview']
3
+
4
+ render: ->
5
+ @$el.html @template({@model})
6
+ this
@@ -0,0 +1,24 @@
1
+ /*
2
+ *= require_self
3
+ *= require_tree .
4
+ */
5
+ body { padding-top: 60px; }
6
+
7
+ a.nextPrevButton,a.nextPrevButton:hover {
8
+ color: #333333;
9
+ }
10
+
11
+ .nosel {
12
+ user-select: none;
13
+ -webkit-user-select: none;
14
+ }
15
+ .chartsBox {
16
+ border-left:2px solid #dddddd;
17
+ border-right:2px solid #dddddd;
18
+ border-top:2px solid #dddddd;
19
+ border-bottom:2px solid #dddddd;
20
+ padding-top: 0px;
21
+ -webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
22
+ -moz-box-sizing: border-box; /* Firefox, other Gecko */
23
+ box-sizing: border-box; /* Opera/IE 8+ */
24
+ }