Add basic dashboard to admin section

This commit is contained in:
Rob H
2014-05-09 15:48:58 +10:00
parent 169d5669f1
commit 01c5822fcc
7 changed files with 221 additions and 44 deletions

View File

@@ -0,0 +1,113 @@
div.dashboard_item
margin-bottom: 30px
.centered
text-align: center
div.header
border: solid
border-color: #5498da
border-width: 1px
border-radius: 6px 6px 0px 0px
position: relative
a.with-tip
position: absolute
right: 5px
bottom: 5px
&.red
border-color: #DA5354
border-width: 3px
h3
color: #DA5354
&.orange
border-color: #DA7F52
border-width: 3px
h3
color: #DA7F52
h3
padding: 5px 5px 5px 3%
.list-title
border: solid #5498da
border-width: 0px 1px 0px 1px
span
font-size: 105%
padding: 10px 0px
font-weight: bold
span.alpha
padding: 10px 2px 10px 5%
.list-item
border: solid
border-width: 0px 1px 0px 1px
span.alpha
font-weight: bold
margin-left: -3px
padding: 10px 2px 10px 5%
span.omega
padding-right: 13px
margin-right: -3px
text-align: right
.icon-arrow-right
padding-top: 6px
font-size: 20px
.icon-warning-sign
color: #DA7F52
font-size: 30px
.icon-remove-sign
color: #DA5354
font-size: 30px
.icon-ok-sign
color: #9fc820
font-size: 30px
&.orange
color: #DA7F52
border: solid #DA7F52
&.red
color: #DA5354
border: solid #DA5354
&.orange, &.red
border-width: 0px 3px 0px 3px
&.even
background-color: #fff
&.odd
background-color: #eff5fc
&.even, &.odd
&:hover
color: #ffffff
background-color: #9fc820
.icon-arrow-right
color: #fff
.icon-remove-sign
color: #fff
.icon-warning-sign
color: #fff
.icon-ok-sign
color: #fff
a.button
color: #fff
padding: 15px 15px
font-size: 110%
font-weight: bold
text-align: center
&.orange
background-color: #DA7F52
&.blue
background-color: #5498da
&.red
background-color: #DA5354
&:hover
background-color: #9fc820
&.top
border-radius: 6px 6px 0px 0px
&.bottom
border-radius: 0px 0px 6px 6px
&.top-right
border-radius: 0px 6px 0px 0px
&.top-left
border-radius: 6px 0px 0px 0px

View File

@@ -2,11 +2,9 @@ module Spree
module Admin
class OverviewController < Spree::Admin::BaseController
def index
if current_spree_user.admin? || current_spree_user.enterprises.any?{ |e| e.is_distributor? }
redirect_to admin_orders_path
elsif current_spree_user.enterprises.any?{ |e| e.is_primary_producer? }
redirect_to bulk_edit_admin_products_path
end
@enterprises = Enterprise.managed_by(spree_current_user).order('is_distributor DESC, is_primary_producer ASC, name').limit(4)
@product_count = Spree::Product.active.managed_by(spree_current_user).count
@order_cycle_count = OrderCycle.active.managed_by(spree_current_user).count
end
end
end

View File

@@ -0,0 +1,43 @@
%div.dashboard_item.sixteen.columns.alpha
%div.header.sixteen.columns.alpha{ :class => "#{@enterprises.count > 0 ? "" : "red"}"}
%h3.five.columns.alpha My Enterprises
%a.with-tip{ title: "Enterprises are Producers and/or Hubs and are the basic unit of organisation within the Open Food Network." } What's this?
%div.sixteen.columns.alpha.list
- if @enterprises.empty?
%div.sixteen.columns.alpha.list-item.red
%span.text.fifteen.columns.alpha You have no enterprises.
%span.one.columns.omega
%span.icon-remove-sign
%a.sixteen.columns.alpha.button.bottom.red{ href: "#{main_app.new_admin_enterprise_path}" }
CREATE NEW ENTERPRISE
%span.icon-arrow-right
- else
%div.sixteen.columns.alpha.list-title
%span.five.columns.alpha Name
%span.centered.three.columns Payment Methods
%span.centered.three.columns Shipping Methods
%span.centered.three.columns Enterprise Fees
- @enterprises.each do |enterprise|
%a.sixteen.columns.alpha.list-item{ class: "#{cycle('odd','even')}", href: "#{main_app.edit_admin_enterprise_path(enterprise)}" }
%span.five.columns.alpha
= enterprise.name
%span.symbol.three.columns.centered
- if enterprise.payment_methods.count > 0
%span.icon-ok-sign
- else
%span.icon-remove-sign
%span.symbol.three.columns.centered
- if enterprise.shipping_methods.count > 0
%span.icon-ok-sign
- else
%span.icon-remove-sign
%span.symbol.three.columns.centered
- if enterprise.enterprise_fees.count > 0
%span.icon-ok-sign
- else
%span.icon-warning-sign
%span.two.columns.omega.right
%span.icon-arrow-right
%a.sixteen.columns.alpha.button.bottom.blue{ href: "#{main_app.admin_enterprises_path}" }
MANAGE MY ENTERPRISES
%span.icon-arrow-right

View File

@@ -0,0 +1,22 @@
%div.dashboard_item.seven.columns.omega
%div.header.seven.columns.alpha{ :class => "#{@order_cycle_count > 0 ? "" : "orange"}"}
%h3.five.columns.alpha Order Cycles
%a.with-tip{ title: "Order cycles determine when and where your products are available to customers." } What's this?
%div.seven.columns.alpha.list
- if @order_cycle_count > 0
%div.seven.columns.alpha.list-item
%span.six.columns.alpha
= "You have #{@order_cycle_count} active order cycle#{@order_cycle_count > 1 ? "s" : ""}."
%span.one.column.omega
%span.icon-ok-sign
%a.seven.columns.alpha.button.bottom.blue{ href: "#{main_app.admin_order_cycles_path}" }
MANAGE ORDER CYCLES
%span.icon-arrow-right
- else
%div.seven.columns.alpha.list-item.orange
%span.six.columns.alpha You don't have any active order cycles.
%span.one.column.omega
%span.icon-warning-sign
%a.seven.columns.alpha.button.bottom.orange{ href: "#{main_app.admin_order_cycles_path}" }
MANAGE ORDER CYCLES
%span.icon-arrow-right

View File

@@ -0,0 +1,25 @@
%div.dashboard_item.seven.columns.alpha
%div.header.seven.columns.alpha{ :class => "#{@product_count > 0 ? "" : "red"}"}
%h3.four.columns.alpha Products
-# %a.three.columns.omega.button.top-right.blue{ href: "#{new_admin_product_path}" }
-# ADD NEW
-# %span.icon-plus
%a.with-tip{ title: "The products that you sell through the Open Food Network." } What's this?
%div.seven.columns.alpha.list
- if @product_count > 0
%div.seven.columns.alpha.list-item
%span.six.columns.alpha
= "You have #{@product_count} active product#{@product_count > 1 ? "s" : ""}."
%span.one.column.omega
%span.icon-ok-sign
%a.seven.columns.alpha.button.bottom.blue{ href: "#{bulk_edit_admin_products_path}" }
MANAGE PRODUCTS
%span.icon-arrow-right
- else
%div.seven.columns.alpha.list-item.red
%span.six.columns.alpha You don't have any products yet.
%span.one.column.omega
%span.icon-remove-sign
%a.seven.columns.alpha.button.bottom.red{ href: "#{new_admin_product_path}" }
CREATE A NEW PRODUCT
%span.icon-arrow-right

View File

@@ -1,39 +0,0 @@
<% content_for :head do %>
<% if Rails.env.production? %>
<%= stylesheet_link_tag 'https://api.jirafe.com/dashboard/css/spree_ui.css', :media => 'all' %>
<%= javascript_include_tag 'https://jirafe.com/dashboard/js/spree_namespaced_ui.js' %>
<% end %>
<% end %>
<% if Rails.env.production? %>
<% if Spree::Dash::Config.configured? %>
<h1><%= t(:overview) %></h1>
<div id="jirafe"></div>
<%= javascript_tag :defer => 'defer' do %>
jirafe.jQuery('#jirafe').jirafe({
api_url: 'https://api.jirafe.com/v1',
api_token: '<%= Spree::Dash::Config.token %>',
app_id: '<%= Spree::Dash::Config.app_id %>',
version: 'spree-v0.1.0',
locale: '<%= Spree::Dash::Config.locale %>' });
setTimeout(function() {
if ($('mod-jirafe') == undefined) {
$('messages').insert ("<ul class=\"messages\"><li class=\"error-msg\">We're unable to connect with the Jirafe service for the moment. Please wait a few minutes and refresh this page later.</li></ul>");
}
}, 10000);
<% end %>
<div id="jirafe_locales">
<%= raw jirafe_locale_links.join(' | ') %>
</div>
<% else %>
<div class="analytics_splash">
<%= image_tag 'analytics_dashboard_preview.png', :alt => 'Spree Analytics' %>
</div>
<br/>
<div class="preview-buttons">
<%= link_to content_tag(:span, t(:activate)), admin_analytics_sign_up_path, :class => 'button green' %>
<%= t(:or) %> &nbsp;
<%= link_to content_tag(:span, t(:learn_more)), "http://spreecommerce.com/blog/2012/01/31/introducing-spree-analytics/", :class => 'button', :target => '_blank' %>
</div>
<% end %>
<% end %>

View File

@@ -0,0 +1,15 @@
%h1{ :style => 'margin-bottom: 30px'} Dashboard
- if @enterprises.empty?
= render partial: "spree/admin/overview/enterprises"
- else
= render partial: "spree/admin/overview/products"
%div.two.columns
&nbsp;
= render partial: "spree/admin/overview/order_cycles"
= render partial: "spree/admin/overview/enterprises"