mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Add command and invocation counts to header
This commit is contained in:
@@ -12,6 +12,7 @@ class CommandLogger extends ScrollView
|
||||
@content: (rootView) ->
|
||||
@div class: 'command-logger', tabindex: -1, =>
|
||||
@h1 class: 'category-header', outlet: 'categoryHeader'
|
||||
@h1 class: 'category-summary', outlet: 'categorySummary'
|
||||
@div class: 'tree-map', outlet: 'treeMap'
|
||||
|
||||
@serialize: ->
|
||||
@@ -95,12 +96,22 @@ class CommandLogger extends ScrollView
|
||||
y = d3.scale.linear().range([0, h])
|
||||
color = d3.scale.category20()
|
||||
|
||||
setCategoryHeader = (node) =>
|
||||
updateCategoryHeader = (node) =>
|
||||
@categoryHeader.text("#{node.name} Commands")
|
||||
setCategoryHeader(root)
|
||||
reduceChildren = (previous, current) ->
|
||||
if current.size?
|
||||
previous + current.size
|
||||
else if current.children?.length > 0
|
||||
previous + current.children.reduce(reduceChildren, 0)
|
||||
else
|
||||
previous
|
||||
commandCount = node.children.length
|
||||
runCount = node.children.reduce(reduceChildren, 0)
|
||||
@categorySummary.text("#{_.pluralize(commandCount, 'command')}, #{_.pluralize(runCount, 'invocation')}")
|
||||
updateCategoryHeader(root)
|
||||
|
||||
zoom = (d) ->
|
||||
setCategoryHeader(d)
|
||||
updateCategoryHeader(d)
|
||||
kx = w / d.dx
|
||||
ky = h / d.dy
|
||||
x.domain([d.x, d.x + d.dx])
|
||||
|
||||
@@ -12,8 +12,15 @@
|
||||
}
|
||||
|
||||
.command-logger .category-header {
|
||||
text-align: center;
|
||||
padding-bottom: 5px;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.command-logger .category-summary {
|
||||
text-align: center;
|
||||
padding-bottom: 10px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.command-logger .tree-map {
|
||||
|
||||
@@ -63,6 +63,12 @@ _.mixin
|
||||
capitalize: (word) ->
|
||||
word[0].toUpperCase() + word[1..]
|
||||
|
||||
pluralize: (count=0, singular, plural=singular+'s') ->
|
||||
if count is 1
|
||||
"#{count} #{singular}"
|
||||
else
|
||||
"#{count} #{plural}"
|
||||
|
||||
losslessInvert: (hash) ->
|
||||
inverted = {}
|
||||
for key, value of hash
|
||||
|
||||
Reference in New Issue
Block a user