From 6e7b402a6a2822bd614143ac71803ec9f7ee06f1 Mon Sep 17 00:00:00 2001 From: Andrew Mason Date: Tue, 21 Jan 2020 14:18:32 -0500 Subject: [PATCH 1/2] add in new metabase dashboard --- .env-example | 1 + .../publisher_dashboards_controller.rb | 15 +++++++++++- app/views/publisher_dashboards/show.html.erb | 24 ++++++++++--------- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/.env-example b/.env-example index d36a0600e..974c46c2e 100644 --- a/.env-example +++ b/.env-example @@ -33,6 +33,7 @@ export LINKEDIN_SECRET= export MAILGUN_API_KEY= export MAILGUN_DOMAIN= export METABASE_CAMPAIGN_DASHBOARD_ID= +export METABASE_PUBLISHER_DASHBOARD_ID= export METABASE_PROPERTY_DASHBOARD_ID= export METABASE_SECRET_KEY= export METABASE_SITE_URL= diff --git a/app/controllers/publisher_dashboards_controller.rb b/app/controllers/publisher_dashboards_controller.rb index 5d848f95c..bd4ad35d8 100644 --- a/app/controllers/publisher_dashboards_controller.rb +++ b/app/controllers/publisher_dashboards_controller.rb @@ -2,6 +2,19 @@ class PublisherDashboardsController < ApplicationController before_action :authenticate_user! def show - @properties = current_user.properties.active.includes(:screenshot_attachment).order("status, name") + # @properties = current_user.properties.active.includes(:screenshot_attachment).order("status, name") + + payload = { + resource: { + dashboard: ENV["METABASE_PUBLISHER_DASHBOARD_ID"].to_i, + }, + params: { + "publisher_id" => current_user.id, + "date_filter" => "#{@start_date.strftime("%F")}~#{@end_date.strftime("%F")}", + }, + } + token = JWT.encode payload, ENV["METABASE_SECRET_KEY"] + + @iframe_url = ENV["METABASE_SITE_URL"] + "/embed/dashboard/" + token + "#bordered=false&titled=false" end end diff --git a/app/views/publisher_dashboards/show.html.erb b/app/views/publisher_dashboards/show.html.erb index 4d864d582..f912424d8 100644 --- a/app/views/publisher_dashboards/show.html.erb +++ b/app/views/publisher_dashboards/show.html.erb @@ -20,16 +20,18 @@ value: current_user.property_revenue(@start_date, @end_date).format %> - - data refreshes every 15 minutes. - - -
-
- <%= render partial: "/properties/overview_card", - collection: @properties, - locals: {start_date: @start_date, end_date: @end_date}, as: :property %> -
-
+ <%= card do %> + <%= card_body do %> + + ensure ad blockers are disabled to view the overview + + + <% end %> + <% end %> From be0504c447f002f831e43924a945936ea6df3bdf Mon Sep 17 00:00:00 2001 From: Andrew Mason Date: Wed, 22 Jan 2020 15:11:47 -0500 Subject: [PATCH 2/2] revert previous changes and remove screenshot from publisher dashboard --- .env-example | 1 - .../publisher_dashboards_controller.rb | 15 +----------- app/views/properties/_overview_card.html.erb | 4 ---- app/views/publisher_dashboards/show.html.erb | 24 +++++++++---------- 4 files changed, 12 insertions(+), 32 deletions(-) diff --git a/.env-example b/.env-example index 974c46c2e..d36a0600e 100644 --- a/.env-example +++ b/.env-example @@ -33,7 +33,6 @@ export LINKEDIN_SECRET= export MAILGUN_API_KEY= export MAILGUN_DOMAIN= export METABASE_CAMPAIGN_DASHBOARD_ID= -export METABASE_PUBLISHER_DASHBOARD_ID= export METABASE_PROPERTY_DASHBOARD_ID= export METABASE_SECRET_KEY= export METABASE_SITE_URL= diff --git a/app/controllers/publisher_dashboards_controller.rb b/app/controllers/publisher_dashboards_controller.rb index bd4ad35d8..f887d16ac 100644 --- a/app/controllers/publisher_dashboards_controller.rb +++ b/app/controllers/publisher_dashboards_controller.rb @@ -2,19 +2,6 @@ class PublisherDashboardsController < ApplicationController before_action :authenticate_user! def show - # @properties = current_user.properties.active.includes(:screenshot_attachment).order("status, name") - - payload = { - resource: { - dashboard: ENV["METABASE_PUBLISHER_DASHBOARD_ID"].to_i, - }, - params: { - "publisher_id" => current_user.id, - "date_filter" => "#{@start_date.strftime("%F")}~#{@end_date.strftime("%F")}", - }, - } - token = JWT.encode payload, ENV["METABASE_SECRET_KEY"] - - @iframe_url = ENV["METABASE_SITE_URL"] + "/embed/dashboard/" + token + "#bordered=false&titled=false" + @properties = current_user.properties.active.order("status, name") end end diff --git a/app/views/properties/_overview_card.html.erb b/app/views/properties/_overview_card.html.erb index 1ea73b4de..066a05f67 100644 --- a/app/views/properties/_overview_card.html.erb +++ b/app/views/properties/_overview_card.html.erb @@ -18,13 +18,9 @@ <% end %> <% end %> -
- <%= link_to image_tag(property.screenshot.attached? ? property.screenshot : "missing-screenshot.jpg", class: "embed-responsive-item"), property %> -
<%= card_body padding: "p-0" do %> <%= render_later async_property_card_footer_path(property_id: property.id) do %> <% end %> <% end %> - <% end %> diff --git a/app/views/publisher_dashboards/show.html.erb b/app/views/publisher_dashboards/show.html.erb index f912424d8..4d864d582 100644 --- a/app/views/publisher_dashboards/show.html.erb +++ b/app/views/publisher_dashboards/show.html.erb @@ -20,18 +20,16 @@ value: current_user.property_revenue(@start_date, @end_date).format %> - <%= card do %> - <%= card_body do %> - - ensure ad blockers are disabled to view the overview - - - <% end %> - <% end %> + + data refreshes every 15 minutes. + + +
+
+ <%= render partial: "/properties/overview_card", + collection: @properties, + locals: {start_date: @start_date, end_date: @end_date}, as: :property %> +
+