prosperity 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/prosperity/application.css.scss +1 -1
- data/app/controllers/prosperity/dashboard_graphs_controller.rb +6 -2
- data/app/controllers/prosperity/graphs_controller.rb +9 -1
- data/app/models/prosperity/dashboard_graph.rb +2 -0
- data/app/views/layouts/prosperity/application.html.erb +1 -2
- data/app/views/prosperity/dashboards/show.html.erb +4 -0
- data/app/views/prosperity/graphs/_common_fields.html.erb +14 -0
- data/app/views/prosperity/graphs/edit.html.erb +2 -9
- data/app/views/prosperity/graphs/new.html.erb +1 -9
- data/app/views/prosperity/graphs/show.html.erb +6 -3
- data/lib/prosperity/version.rb +1 -1
- data/spec/controllers/prosperity/dashboard_graphs_controller_spec.rb +7 -0
- data/spec/controllers/prosperity/graphs_controller_spec.rb +6 -0
- data/spec/dummy/log/development.log +2863 -0
- data/spec/dummy/log/test.log +3900 -0
- data/spec/dummy/tmp/cache/assets/development/sass/34a577735054231563e7022ea73e1468db9203ba/application.css.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/210050da208fb75a75b701bfa4e8470f +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/a2b14d5c46db32da9183354fb3fcd0bf +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/a6d6196cfd275dea0718553a95f997a5 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sass/34a577735054231563e7022ea73e1468db9203ba/application.css.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/210050da208fb75a75b701bfa4e8470f +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/a2b14d5c46db32da9183354fb3fcd0bf +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/a6d6196cfd275dea0718553a95f997a5 +0 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f2eef9c17ac3662933cc06b450f81f8d750daa7
|
4
|
+
data.tar.gz: e0f0f2ffd626b476d0d39ff2323fa08dcb51cbfd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f5ed319d26cbfa9b49021f258d2b70c5628cd25e72d92bd0c0c675001c2350693e6ef15316a3ca060133d0c5187d29fd6667d862a0ec3157bbc469b16c58fa7
|
7
|
+
data.tar.gz: 1170f782cc52ecc0dfb604d9e7d6b717ff93f296946caaf3c5b19e233432c3d543fe334bea019b4c1f0cba21b2eae5f549c051cd47ec44e9567c9a55fcd5d342
|
@@ -4,8 +4,12 @@ module Prosperity
|
|
4
4
|
class DashboardGraphsController < ApplicationController
|
5
5
|
before_action :get_objs
|
6
6
|
def create
|
7
|
-
DashboardGraph.
|
8
|
-
|
7
|
+
dashboard_graph = DashboardGraph.new(graph: @graph, dashboard: @dashboard)
|
8
|
+
|
9
|
+
unless dashboard_graph.save
|
10
|
+
set_error(dashboard_graph)
|
11
|
+
end
|
12
|
+
redirect_to edit_dashboard_path(@dashboard)
|
9
13
|
end
|
10
14
|
|
11
15
|
def destroy
|
@@ -2,7 +2,7 @@ require_dependency "prosperity/application_controller"
|
|
2
2
|
|
3
3
|
module Prosperity
|
4
4
|
class GraphsController < ApplicationController
|
5
|
-
before_action :get_graph, only: [:edit, :update
|
5
|
+
before_action :get_graph, only: [:edit, :update]
|
6
6
|
def new
|
7
7
|
@graph = Graph.new
|
8
8
|
end
|
@@ -19,6 +19,7 @@ module Prosperity
|
|
19
19
|
def show
|
20
20
|
respond_to do |format|
|
21
21
|
format.json do
|
22
|
+
get_graph
|
22
23
|
render json: {
|
23
24
|
title: @graph.title,
|
24
25
|
graph_type: @graph.graph_type,
|
@@ -37,6 +38,13 @@ module Prosperity
|
|
37
38
|
end
|
38
39
|
|
39
40
|
format.html {
|
41
|
+
begin
|
42
|
+
get_graph
|
43
|
+
rescue ActiveRecord::RecordNotFound
|
44
|
+
@graph = nil
|
45
|
+
render layout: 'prosperity/embedabble', status: :not_found
|
46
|
+
return
|
47
|
+
end
|
40
48
|
render layout: 'prosperity/embedabble'
|
41
49
|
}
|
42
50
|
end
|
@@ -37,8 +37,7 @@
|
|
37
37
|
<div class="main">
|
38
38
|
<% flash.each do |name, msg| %>
|
39
39
|
<% if msg.is_a?(String) %>
|
40
|
-
<div class="alert alert-<%= name == :notice ? "success" : "
|
41
|
-
<a class="close" data-dismiss="alert">×</a>
|
40
|
+
<div class="alert alert-<%= name == :notice ? "success" : "danger" %>">
|
42
41
|
<%= content_tag :div, msg, :id => "flash_#{name}" %>
|
43
42
|
</div>
|
44
43
|
<% end %>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<div class="form-group">
|
2
|
+
<%= f.label :title %>
|
3
|
+
<%= f.text_field :title %>
|
4
|
+
</div>
|
5
|
+
|
6
|
+
<div class="form-group">
|
7
|
+
<%= f.label :graph_type %>
|
8
|
+
<%= f.select :graph_type, Prosperity::Graph::VALID_GRAPH_TYPES %>
|
9
|
+
</div>
|
10
|
+
|
11
|
+
<div class="form-group">
|
12
|
+
<%= f.label :period %>
|
13
|
+
<%= f.select :period, Prosperity::Periods::ALL.keys %>
|
14
|
+
</div>
|
@@ -3,15 +3,8 @@
|
|
3
3
|
<div class="row">
|
4
4
|
<div class="span6">
|
5
5
|
<%= form_for @graph, data: {metric_options: @options} do |f| %>
|
6
|
-
|
7
|
-
|
8
|
-
<%= f.text_field :title %>
|
9
|
-
</div>
|
10
|
-
|
11
|
-
<div class="form-group">
|
12
|
-
<%= f.label :graph_type %>
|
13
|
-
<%= f.select :graph_type, Prosperity::Graph::VALID_GRAPH_TYPES %>
|
14
|
-
</div>
|
6
|
+
|
7
|
+
<%= render partial: 'common_fields', locals: {f: f} %>
|
15
8
|
|
16
9
|
<h4>Lines</h4>
|
17
10
|
<%= f.fields_for :graph_lines do |l| %>
|
@@ -1,15 +1,7 @@
|
|
1
1
|
<h1>New Graph</h1>
|
2
2
|
|
3
3
|
<%= form_for @graph, html: {role: 'form'} do |f| %>
|
4
|
-
|
5
|
-
<%= f.label :title %>
|
6
|
-
<%= f.text_field :title %>
|
7
|
-
</div>
|
8
|
-
|
9
|
-
<div class="form-group">
|
10
|
-
<%= f.label :period %>
|
11
|
-
<%= f.select :period, Prosperity::Periods::ALL.keys %>
|
12
|
-
</div>
|
4
|
+
<%= render partial: 'common_fields', locals: {f: f} %>
|
13
5
|
|
14
6
|
<%= f.submit "Save", class: 'btn btn-success' %>
|
15
7
|
<% end %>
|
@@ -1,3 +1,6 @@
|
|
1
|
-
|
2
|
-
<div class=
|
3
|
-
|
1
|
+
<% if @graph %>
|
2
|
+
<div class='metric-title'><%= @graph.title %></div>
|
3
|
+
<div class="metric dashboard" data-url="<%= graph_path(@graph) %>"></div>
|
4
|
+
<% else %>
|
5
|
+
<p>No such graph</p>
|
6
|
+
<% end %>
|
data/lib/prosperity/version.rb
CHANGED
@@ -25,6 +25,13 @@ module Prosperity
|
|
25
25
|
dg.graph.should == graph
|
26
26
|
dg.dashboard.should == dashboard
|
27
27
|
end
|
28
|
+
|
29
|
+
it "errors if you try to add the same graph twice" do
|
30
|
+
post :create, dashboard_id: dashboard.id, graph_id: graph.id
|
31
|
+
post :create, dashboard_id: dashboard.id, graph_id: graph.id
|
32
|
+
response.should redirect_to(edit_dashboard_path(dashboard))
|
33
|
+
flash[:error].should be_present
|
34
|
+
end
|
28
35
|
end
|
29
36
|
|
30
37
|
describe "DELETE 'destroy'" do
|
@@ -81,6 +81,12 @@ module Prosperity
|
|
81
81
|
it "should render the embedabble layout" do
|
82
82
|
response.body.should_not include('navbar')
|
83
83
|
end
|
84
|
+
|
85
|
+
it "404 with custom page when graph is not found" do
|
86
|
+
get :show, id: :unknown_id, format: 'html'
|
87
|
+
response.status.should == 404
|
88
|
+
response.body.should include("No such graph")
|
89
|
+
end
|
84
90
|
end
|
85
91
|
end
|
86
92
|
|