Skip to content

Commit

Permalink
Only show the "Beta Analytics" checkbox if Kylin analytics is enabled.
Browse files Browse the repository at this point in the history
  • Loading branch information
GUI committed Jul 27, 2016
1 parent 53d1ef8 commit c606261
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
<a id="filter_toggle" {{action 'toggleFilters' target='view'}}><i class="fa fa-caret-right"></i>{{t 'admin.stats.filter_results'}}</a>
</div>
<div class="span8 filter-times">
<label class="checkbox" style="display: inline-block; font-size: 12px; margin: 0px 40px 0px 0px; color: #666; position: relative; top: 2px;">{{view Ember.Checkbox checkedBinding="view.isBetaAnalytics" action="toggleBetaAnalytics" target="view"}} Beta Analytics</label>
{{#if view.enableBetaAnalytics}}
<label class="checkbox" style="display: inline-block; font-size: 12px; margin: 0px 40px 0px 0px; color: #666; position: relative; top: 2px;">{{view Ember.Checkbox checkedBinding="view.isBetaAnalytics" action="toggleBetaAnalytics" target="view"}} Beta Analytics</label>
{{/if}}

{{#if view.enableInterval}}
<div id="interval_buttons" class="btn-group" data-toggle="buttons-radio">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Admin.StatsQueryFormView = Ember.View.extend({

enableInterval: false,

enableBetaAnalytics: enableBetaAnalytics,

datePickerRanges: {
'Today': [
moment().startOf('day'),
Expand Down
3 changes: 2 additions & 1 deletion src/api-umbrella/web-app/app/views/layouts/admin.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
<%= stylesheet_link_tag "admin" %>
<%= javascript_tag do %>
webAdminAjaxApiKey = <%= web_admin_ajax_api_user.api_key.to_json.html_safe %>;
currentAdmin = <%= current_admin.attributes.slice("username", "superuser").to_json.html_safe %>
currentAdmin = <%= current_admin.attributes.slice("username", "superuser").to_json.html_safe %>;
enableBetaAnalytics = <%= (ApiUmbrellaConfig[:analytics][:adapter] == "kylin" || (ApiUmbrellaConfig[:analytics][:outputs] && ApiUmbrellaConfig[:analytics][:outputs].include?("kylin"))).to_json.html_safe %>;
<% end %>
<link href='//fonts.googleapis.com/css?family=Oswald:400,700' rel='stylesheet' type='text/css'>
<%= javascript_include_tag "admin/locales/#{I18n.locale}" %>
Expand Down
1 change: 1 addition & 0 deletions src/api-umbrella/web-app/lib/tasks/jshint.rake
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ begin
"CommonValidations",
"currentAdmin",
"Ember",
"enableBetaAnalytics",
"google",
"ic",
"inflection",
Expand Down
18 changes: 18 additions & 0 deletions src/api-umbrella/web-app/spec/features/admin/stats_logs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,22 @@
page.response_headers["Content-Type"].should eql("text/csv")
end
end

describe "beta analytics option" do
it "doesn't show the beta analytics option by default" do
visit "/admin/#/stats/logs/tz=America%2FDenver&search=&start_at=2015-01-12&end_at=2015-01-18&interval=day"
page.should_not have_content("Beta Analytics")
end

it "shows the beta analytics toggle if kylin analytics are enabled" do
original = ApiUmbrellaConfig[:analytics][:outputs]
begin
ApiUmbrellaConfig[:analytics][:outputs] = ["kylin"]
visit "/admin/#/stats/logs/tz=America%2FDenver&search=&start_at=2015-01-12&end_at=2015-01-18&interval=day"
page.should have_content("Beta Analytics")
ensure
ApiUmbrellaConfig[:analytics][:outputs] = original
end
end
end
end

0 comments on commit c606261

Please sign in to comment.