From a4a4564f760bb1bcd541366186cd46488d5a569b Mon Sep 17 00:00:00 2001 From: Daniel Beauchamp Date: Tue, 30 Oct 2012 05:16:35 -0400 Subject: Added new widgets, and made them more flexible. Ready for 0.1.3! --- templates/dashboard/%name%.erb.tt | 1 - templates/project/Gemfile | 2 +- templates/project/README.md | 1 + templates/project/assets/images/logo.png | Bin 0 -> 68147 bytes .../project/assets/javascripts/application.coffee | 12 ++--- .../project/assets/stylesheets/application.scss | 40 ++++++++++++--- templates/project/dashboards/sample.erb | 6 +-- templates/project/dashboards/sampletv.erb | 56 +++++++++++++++++++++ templates/project/jobs/buzzwords.rb | 2 +- templates/project/jobs/convergence.rb | 1 + templates/project/jobs/sample.rb | 4 ++ templates/project/jobs/twitter.rb | 17 +++++++ templates/project/public/.empty_directory | 1 - templates/project/widgets/clock/clock.coffee | 18 +++++++ templates/project/widgets/clock/clock.html | 2 + templates/project/widgets/clock/clock.scss | 13 +++++ templates/project/widgets/comments/comments.coffee | 24 +++++++++ templates/project/widgets/comments/comments.html | 7 +++ templates/project/widgets/comments/comments.scss | 33 ++++++++++++ templates/project/widgets/graph/graph.coffee | 14 +++++- templates/project/widgets/graph/graph.html | 4 +- templates/project/widgets/graph/graph.scss | 36 +++++++++---- templates/project/widgets/iframe/iframe.coffee | 9 ++++ templates/project/widgets/iframe/iframe.html | 1 + templates/project/widgets/iframe/iframe.scss | 8 +++ templates/project/widgets/image/image.coffee | 9 ++++ templates/project/widgets/image/image.html | 1 + templates/project/widgets/image/image.scss | 13 +++++ templates/project/widgets/list/list.coffee | 15 ++---- templates/project/widgets/list/list.html | 5 +- templates/project/widgets/list/list.scss | 14 ++++-- templates/project/widgets/meter/meter.html | 4 +- templates/project/widgets/meter/meter.scss | 20 ++++---- templates/project/widgets/number/number.coffee | 8 +-- templates/project/widgets/number/number.html | 10 ++-- templates/project/widgets/number/number.scss | 14 ++++-- templates/project/widgets/text/text.html | 6 ++- templates/project/widgets/text/text.scss | 17 +++++-- 38 files changed, 364 insertions(+), 84 deletions(-) create mode 100644 templates/project/assets/images/logo.png create mode 100644 templates/project/dashboards/sampletv.erb create mode 100644 templates/project/jobs/twitter.rb delete mode 100644 templates/project/public/.empty_directory create mode 100644 templates/project/widgets/clock/clock.coffee create mode 100644 templates/project/widgets/clock/clock.html create mode 100644 templates/project/widgets/clock/clock.scss create mode 100644 templates/project/widgets/comments/comments.coffee create mode 100644 templates/project/widgets/comments/comments.html create mode 100644 templates/project/widgets/comments/comments.scss create mode 100644 templates/project/widgets/iframe/iframe.coffee create mode 100644 templates/project/widgets/iframe/iframe.html create mode 100644 templates/project/widgets/iframe/iframe.scss create mode 100644 templates/project/widgets/image/image.coffee create mode 100644 templates/project/widgets/image/image.html create mode 100644 templates/project/widgets/image/image.scss (limited to 'templates') diff --git a/templates/dashboard/%name%.erb.tt b/templates/dashboard/%name%.erb.tt index d96e164..aa735d6 100644 --- a/templates/dashboard/%name%.erb.tt +++ b/templates/dashboard/%name%.erb.tt @@ -1,4 +1,3 @@ -<% content_for(:title) { "My super sweet dashboard" } %>
Try this: curl -d '{ "auth_token": "YOUR_AUTH_TOKEN", "text": "Hey, Look what I can do!" }' \http://localhost:3000/widgets/welcome
diff --git a/templates/project/dashboards/sampletv.erb b/templates/project/dashboards/sampletv.erb new file mode 100644 index 0000000..b52eed7 --- /dev/null +++ b/templates/project/dashboards/sampletv.erb @@ -0,0 +1,56 @@ + + + +<% content_for(:title) { "1080p dashboard" } %> + +
+
    +
  • +
    + +
  • + +
  • +
    +
  • + +
  • +
    +
  • + +
  • +
    +
  • + +
  • +
    +
  • + +
  • +
    +
  • + +
  • +
    + +
  • + +
  • +
    +
  • + +
  • +
    + +
  • + +
+
Try this: curl -d '{ "auth_token": "YOUR_AUTH_TOKEN", "text": "Hey, Look what I can do!" }' \http://localhost:3000/widgets/welcome
+
\ No newline at end of file diff --git a/templates/project/jobs/buzzwords.rb b/templates/project/jobs/buzzwords.rb index 109dc60..2668d5a 100644 --- a/templates/project/jobs/buzzwords.rb +++ b/templates/project/jobs/buzzwords.rb @@ -3,7 +3,7 @@ buzzword_counts = Hash.new({ value: 0 }) SCHEDULER.every '2s' do random_buzzword = buzzwords.sample - buzzword_counts[random_buzzword] = { label: random_buzzword, value: buzzword_counts[random_buzzword][:value] + 1 } + buzzword_counts[random_buzzword] = { label: random_buzzword, value: (buzzword_counts[random_buzzword][:value] + 1) % 30 } send_event('buzzwords', { items: buzzword_counts.values }) end \ No newline at end of file diff --git a/templates/project/jobs/convergence.rb b/templates/project/jobs/convergence.rb index f66b6a5..1da2a5b 100644 --- a/templates/project/jobs/convergence.rb +++ b/templates/project/jobs/convergence.rb @@ -1,3 +1,4 @@ +# Populate the graph with some random points points = [] (1..10).each do |i| points << { x: i, y: rand(50) } diff --git a/templates/project/jobs/sample.rb b/templates/project/jobs/sample.rb index 2314dc2..1fe008d 100644 --- a/templates/project/jobs/sample.rb +++ b/templates/project/jobs/sample.rb @@ -1,9 +1,13 @@ current_valuation = 0 +current_karma = 0 SCHEDULER.every '2s' do last_valuation = current_valuation + last_karma = current_karma current_valuation = rand(100) + current_karma = rand(200000) send_event('valuation', { current: current_valuation, last: last_valuation }) + send_event('karma', { current: current_karma, last: last_karma }) send_event('synergy', { value: rand(100) }) end \ No newline at end of file diff --git a/templates/project/jobs/twitter.rb b/templates/project/jobs/twitter.rb new file mode 100644 index 0000000..9359a89 --- /dev/null +++ b/templates/project/jobs/twitter.rb @@ -0,0 +1,17 @@ +require 'net/http' +require 'json' + +search_term = URI::encode('#todayilearned') + +SCHEDULER.every '10m', :first_in => 0 do |job| + http = Net::HTTP.new('search.twitter.com') + response = http.request(Net::HTTP::Get.new("/search.json?q=#{search_term}")) + tweets = JSON.parse(response.body)["results"] + if tweets + tweets.map! do |tweet| + { name: tweet['from_user'], body: tweet['text'], avatar: tweet['profile_image_url_https'] } + end + + send_event('twitter_mentions', comments: tweets) + end +end \ No newline at end of file diff --git a/templates/project/public/.empty_directory b/templates/project/public/.empty_directory deleted file mode 100644 index 3da7f49..0000000 --- a/templates/project/public/.empty_directory +++ /dev/null @@ -1 +0,0 @@ -.empty_directory \ No newline at end of file diff --git a/templates/project/widgets/clock/clock.coffee b/templates/project/widgets/clock/clock.coffee new file mode 100644 index 0000000..cd6b116 --- /dev/null +++ b/templates/project/widgets/clock/clock.coffee @@ -0,0 +1,18 @@ +class Dashing.Clock extends Dashing.Widget + + ready: -> + setInterval(@startTime, 500) + + startTime: => + today = new Date() + + h = today.getHours() + m = today.getMinutes() + s = today.getSeconds() + m = @formatTime(m) + s = @formatTime(s) + @set('time', h + ":" + m + ":" + s) + @set('date', today.toDateString()) + + formatTime: (i) -> + if i < 10 then "0" + i else i \ No newline at end of file diff --git a/templates/project/widgets/clock/clock.html b/templates/project/widgets/clock/clock.html new file mode 100644 index 0000000..06759d4 --- /dev/null +++ b/templates/project/widgets/clock/clock.html @@ -0,0 +1,2 @@ +

+

\ No newline at end of file diff --git a/templates/project/widgets/clock/clock.scss b/templates/project/widgets/clock/clock.scss new file mode 100644 index 0000000..831ea94 --- /dev/null +++ b/templates/project/widgets/clock/clock.scss @@ -0,0 +1,13 @@ +// ---------------------------------------------------------------------------- +// Sass declarations +// ---------------------------------------------------------------------------- +$background-color: #dc5945; + +// ---------------------------------------------------------------------------- +// Widget-clock styles +// ---------------------------------------------------------------------------- +.widget-clock { + + background-color: $background-color; + +} \ No newline at end of file diff --git a/templates/project/widgets/comments/comments.coffee b/templates/project/widgets/comments/comments.coffee new file mode 100644 index 0000000..1e81b56 --- /dev/null +++ b/templates/project/widgets/comments/comments.coffee @@ -0,0 +1,24 @@ +class Dashing.Comments extends Dashing.Widget + + @accessor 'quote', -> + "“#{@get('current_comment')?.body}”" + + ready: -> + @currentIndex = 0 + @commentElem = $(@node).find('.comment-container') + @nextComment() + @startCarousel() + + onData: (data) -> + @currentIndex = 0 + + startCarousel: -> + setInterval(@nextComment, 8000) + + nextComment: => + comments = @get('comments') + if comments + @commentElem.fadeOut => + @currentIndex = (@currentIndex + 1) % comments.length + @set 'current_comment', comments[@currentIndex] + @commentElem.fadeIn() \ No newline at end of file diff --git a/templates/project/widgets/comments/comments.html b/templates/project/widgets/comments/comments.html new file mode 100644 index 0000000..844800f --- /dev/null +++ b/templates/project/widgets/comments/comments.html @@ -0,0 +1,7 @@ +

+
+

+

+
+ +

\ No newline at end of file diff --git a/templates/project/widgets/comments/comments.scss b/templates/project/widgets/comments/comments.scss new file mode 100644 index 0000000..40e2a6b --- /dev/null +++ b/templates/project/widgets/comments/comments.scss @@ -0,0 +1,33 @@ +// ---------------------------------------------------------------------------- +// Sass declarations +// ---------------------------------------------------------------------------- +$background-color: #eb9c3c; + +$title-color: rgba(255, 255, 255, 0.7); +$moreinfo-color: rgba(255, 255, 255, 0.7); + +// ---------------------------------------------------------------------------- +// Widget-comment styles +// ---------------------------------------------------------------------------- +.widget-comments { + + background-color: $background-color; + + .title { + color: $title-color; + margin-bottom: 15px; + } + + .name { + padding-left: 5px; + } + + .comment-container { + display: none; + } + + .more-info { + color: $moreinfo-color; + } + +} \ No newline at end of file diff --git a/templates/project/widgets/graph/graph.coffee b/templates/project/widgets/graph/graph.coffee index 8b56a87..9b2eeec 100644 --- a/templates/project/widgets/graph/graph.coffee +++ b/templates/project/widgets/graph/graph.coffee @@ -1,22 +1,32 @@ class Dashing.Graph extends Dashing.Widget @accessor 'current', -> + return @get('displayedValue') if @get('displayedValue') points = @get('points') if points points[points.length - 1].y ready: -> + container = $(@node).parent() + # Gross hacks. Let's fix this. + width = (Dashing.widget_base_dimensions[0] * container.data("sizex")) + Dashing.widget_margins[0] * 2 * (container.data("sizex") - 1) + height = (Dashing.widget_base_dimensions[1] * container.data("sizey")) @graph = new Rickshaw.Graph( element: @node - width: $(@node).parent().width() + width: width + height: height series: [ { color: "#fff", - data: [{ x: 0, y: 0}] + data: [{x:0, y:0}] } ] ) + + @graph.series[0].data = @get('points') if @get('points') + x_axis = new Rickshaw.Graph.Axis.Time(graph: @graph) + y_axis = new Rickshaw.Graph.Axis.Y(graph: @graph, tickFormat: Rickshaw.Fixtures.Number.formatKMBT) @graph.render() onData: (data) -> diff --git a/templates/project/widgets/graph/graph.html b/templates/project/widgets/graph/graph.html index 8680efb..d1794db 100644 --- a/templates/project/widgets/graph/graph.html +++ b/templates/project/widgets/graph/graph.html @@ -1,5 +1,5 @@

-

+

-

\ No newline at end of file +

\ No newline at end of file diff --git a/templates/project/widgets/graph/graph.scss b/templates/project/widgets/graph/graph.scss index f2a1e21..71cd4d4 100644 --- a/templates/project/widgets/graph/graph.scss +++ b/templates/project/widgets/graph/graph.scss @@ -1,13 +1,12 @@ // ---------------------------------------------------------------------------- // Sass declarations // ---------------------------------------------------------------------------- -$background-color: #2e864f; -$value-color: #fff; +$background-color: #dc5945; -$title-color: lighten($background-color, 75%); -$moreinfo-color: lighten($background-color, 45%); +$title-color: rgba(255, 255, 255, 0.7); +$moreinfo-color: rgba(255, 255, 255, 0.3); +$tick-color: rgba(0, 0, 0, 0.4); -$graph_color: lighten($background-color, 75%); // ---------------------------------------------------------------------------- // Widget-graph styles @@ -17,14 +16,13 @@ $graph_color: lighten($background-color, 75%); background-color: $background-color; position: relative; + svg { - color: $graph_color; + position: absolute; opacity: 0.4; fill-opacity: 0.4; - position: absolute; - bottom: 0; - left: 0; - right: 0; + left: 0px; + top: 0px; } .title, .value { @@ -36,7 +34,7 @@ $graph_color: lighten($background-color, 75%); color: $title-color; } - .text-moreinfo { + .more-info { color: $moreinfo-color; font-weight: 600; font-size: 20px; @@ -46,6 +44,22 @@ $graph_color: lighten($background-color, 75%); .x_tick { position: absolute; bottom: 0; + .title { + font-size: 20px; + color: $tick-color; + opacity: 0.5; + padding-bottom: 3px; + } + } + + .y_ticks { + font-size: 20px; + fill: $tick-color; + fill-opacity: 1; + } + + .domain { + display: none; } } \ No newline at end of file diff --git a/templates/project/widgets/iframe/iframe.coffee b/templates/project/widgets/iframe/iframe.coffee new file mode 100644 index 0000000..4d4ca9a --- /dev/null +++ b/templates/project/widgets/iframe/iframe.coffee @@ -0,0 +1,9 @@ +class Dashing.Iframe extends Dashing.Widget + + ready: -> + # This is fired when the widget is done being rendered + + onData: (data) -> + # Handle incoming data + # You can access the html node of this widget with `@node` + # Example: $(@node).fadeOut().fadeIn() will make the node flash each time data comes in. \ No newline at end of file diff --git a/templates/project/widgets/iframe/iframe.html b/templates/project/widgets/iframe/iframe.html new file mode 100644 index 0000000..bfccba4 --- /dev/null +++ b/templates/project/widgets/iframe/iframe.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/templates/project/widgets/iframe/iframe.scss b/templates/project/widgets/iframe/iframe.scss new file mode 100644 index 0000000..7c757bf --- /dev/null +++ b/templates/project/widgets/iframe/iframe.scss @@ -0,0 +1,8 @@ +.widget-iframe { + padding: 3px 0px 0px 0px !important; + + iframe { + width: 100%; + height: 100%; + } +} \ No newline at end of file diff --git a/templates/project/widgets/image/image.coffee b/templates/project/widgets/image/image.coffee new file mode 100644 index 0000000..418e385 --- /dev/null +++ b/templates/project/widgets/image/image.coffee @@ -0,0 +1,9 @@ +class Dashing.Image extends Dashing.Widget + + ready: -> + # This is fired when the widget is done being rendered + + onData: (data) -> + # Handle incoming data + # You can access the html node of this widget with `@node` + # Example: $(@node).fadeOut().fadeIn() will make the node flash each time data comes in. \ No newline at end of file diff --git a/templates/project/widgets/image/image.html b/templates/project/widgets/image/image.html new file mode 100644 index 0000000..cf2b228 --- /dev/null +++ b/templates/project/widgets/image/image.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/templates/project/widgets/image/image.scss b/templates/project/widgets/image/image.scss new file mode 100644 index 0000000..10ca81d --- /dev/null +++ b/templates/project/widgets/image/image.scss @@ -0,0 +1,13 @@ +// ---------------------------------------------------------------------------- +// Sass declarations +// ---------------------------------------------------------------------------- +$background-color: #4b4b4b; + +// ---------------------------------------------------------------------------- +// Widget-image styles +// ---------------------------------------------------------------------------- +.widget-image { + + background-color: $background-color; + +} \ No newline at end of file diff --git a/templates/project/widgets/list/list.coffee b/templates/project/widgets/list/list.coffee index 3ca892b..3cbf7a1 100644 --- a/templates/project/widgets/list/list.coffee +++ b/templates/project/widgets/list/list.coffee @@ -1,13 +1,6 @@ class Dashing.List extends Dashing.Widget - @accessor 'current', Dashing.AnimatedValue - - @accessor 'arrow', -> - if @get('last') - if parseInt(@get('current')) > parseInt(@get('last')) then 'arrow-up' else 'arrow-down' - ready: -> - Batman.setImmediate => - if @get('unordered') - $(@node).find('ol').remove() - else - $(@node).find('ul').remove() \ No newline at end of file + if @get('unordered') + $(@node).find('ol').remove() + else + $(@node).find('ul').remove() \ No newline at end of file diff --git a/templates/project/widgets/list/list.html b/templates/project/widgets/list/list.html index cc90d42..86752bf 100644 --- a/templates/project/widgets/list/list.html +++ b/templates/project/widgets/list/list.html @@ -12,4 +12,7 @@ - \ No newline at end of file + + +

+

\ No newline at end of file diff --git a/templates/project/widgets/list/list.scss b/templates/project/widgets/list/list.scss index 098200d..90b6c84 100644 --- a/templates/project/widgets/list/list.scss +++ b/templates/project/widgets/list/list.scss @@ -1,12 +1,12 @@ // ---------------------------------------------------------------------------- // Sass declarations // ---------------------------------------------------------------------------- - $background-color: #12b0c5; $value-color: #fff; -$title-color: lighten($background-color, 45%); -$label-color: lighten($background-color, 45%); +$title-color: rgba(255, 255, 255, 0.7); +$label-color: rgba(255, 255, 255, 0.7); +$moreinfo-color: rgba(255, 255, 255, 0.7); // ---------------------------------------------------------------------------- // Widget-list styles @@ -49,4 +49,12 @@ $label-color: lighten($background-color, 45%); color: $value-color; } + .updated-at { + color: rgba(0, 0, 0, 0.3); + } + + .more-info { + color: $moreinfo-color; + } + } \ No newline at end of file diff --git a/templates/project/widgets/meter/meter.html b/templates/project/widgets/meter/meter.html index 6051d2f..7d51b15 100644 --- a/templates/project/widgets/meter/meter.html +++ b/templates/project/widgets/meter/meter.html @@ -2,4 +2,6 @@ -

\ No newline at end of file +

+ +

\ No newline at end of file diff --git a/templates/project/widgets/meter/meter.scss b/templates/project/widgets/meter/meter.scss index dec0cc6..98cf638 100644 --- a/templates/project/widgets/meter/meter.scss +++ b/templates/project/widgets/meter/meter.scss @@ -1,15 +1,12 @@ // ---------------------------------------------------------------------------- // Sass declarations // ---------------------------------------------------------------------------- - $background-color: #9c4274; -$value-color: #fff; -$title-color: lighten($background-color, 75%); -$moreinfo-color: lighten($background-color, 45%); +$title-color: rgba(255, 255, 255, 0.7); +$moreinfo-color: rgba(255, 255, 255, 0.3); -$meter-background: darken($background-color, 10%); -$meter-foreground: lighten($background-color, 75%); +$meter-background: darken($background-color, 15%); // ---------------------------------------------------------------------------- // Widget-meter styles @@ -20,18 +17,19 @@ $meter-foreground: lighten($background-color, 75%); input.meter { background-color: $meter-background; - color: $meter-foreground; + color: #fff; } .title { color: $title-color; } - .text-moreinfo { + .more-info { color: $moreinfo-color; - font-weight: 600; - font-size: 20px; - margin-top: 0; + } + + .updated-at { + color: rgba(0, 0, 0, 0.3); } } \ No newline at end of file diff --git a/templates/project/widgets/number/number.coffee b/templates/project/widgets/number/number.coffee index 78e7523..46cd6c2 100644 --- a/templates/project/widgets/number/number.coffee +++ b/templates/project/widgets/number/number.coffee @@ -8,17 +8,13 @@ class Dashing.Number extends Dashing.Widget if last != 0 diff = Math.abs(Math.round((current - last) / last * 100)) "#{diff}%" + else + "" @accessor 'arrow', -> if @get('last') if parseInt(@get('current')) > parseInt(@get('last')) then 'icon-arrow-up' else 'icon-arrow-down' - @accessor 'statusStyle', -> - "status-#{@get('status')}" - - @accessor 'needsAttention', -> - @get('status') == 'warning' || @get('status') == 'danger' - onData: (data) -> if data.status $(@get('node')).addClass("status-#{data.status}") \ No newline at end of file diff --git a/templates/project/widgets/number/number.html b/templates/project/widgets/number/number.html index 6e9a03e..d7eeab9 100644 --- a/templates/project/widgets/number/number.html +++ b/templates/project/widgets/number/number.html @@ -1,9 +1,11 @@ -

+

-

+

- 50% +

-

2012-07-26 10:59AM

\ No newline at end of file +

+ +

diff --git a/templates/project/widgets/number/number.scss b/templates/project/widgets/number/number.scss index d134561..608624b 100644 --- a/templates/project/widgets/number/number.scss +++ b/templates/project/widgets/number/number.scss @@ -1,11 +1,11 @@ // ---------------------------------------------------------------------------- // Sass declarations // ---------------------------------------------------------------------------- -$background-color: #00b1a4; +$background-color: #47bbb3; $value-color: #fff; -$title-color: lighten($background-color, 75%); -$moreinfo-color: lighten($background-color, 45%); +$title-color: rgba(255, 255, 255, 0.7);; +$moreinfo-color: rgba(255, 255, 255, 0.7);; // ---------------------------------------------------------------------------- // Widget-number styles @@ -23,13 +23,17 @@ $moreinfo-color: lighten($background-color, 45%); } .change-rate { - font-weight: 300; + font-weight: 500; font-size: 30px; color: $value-color; } - .text-moreinfo { + .more-info { color: $moreinfo-color; } + + .updated-at { + color: rgba(0, 0, 0, 0.3); + } } \ No newline at end of file diff --git a/templates/project/widgets/text/text.html b/templates/project/widgets/text/text.html index 02bd0f7..45322ca 100644 --- a/templates/project/widgets/text/text.html +++ b/templates/project/widgets/text/text.html @@ -1,5 +1,7 @@

-

+

-

2012-07-26 10:59AM

\ No newline at end of file +

+ +

\ No newline at end of file diff --git a/templates/project/widgets/text/text.scss b/templates/project/widgets/text/text.scss index 4293602..4e6c6e3 100644 --- a/templates/project/widgets/text/text.scss +++ b/templates/project/widgets/text/text.scss @@ -1,11 +1,10 @@ // ---------------------------------------------------------------------------- // Sass declarations // ---------------------------------------------------------------------------- -$background-color: #ec663c;; -$value-color: #fff; +$background-color: #ec663c; -$title-color: lighten($background-color, 40%); -$moreinfo-color: lighten($background-color, 30%); +$title-color: rgba(255, 255, 255, 0.7); +$moreinfo-color: rgba(255, 255, 255, 0.7); // ---------------------------------------------------------------------------- // Widget-text styles @@ -18,8 +17,16 @@ $moreinfo-color: lighten($background-color, 30%); color: $title-color; } - .text-moreinfo { + .more-info { color: $moreinfo-color; } + + .updated-at { + color: rgba(255, 255, 255, 0.7); + } + + &.large h3 { + font-size: 65px; + } } \ No newline at end of file -- cgit v1.2.3