-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 0bd6df4
Showing
18 changed files
with
417 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 2 | ||
trim_trailing_whitespace = true | ||
|
||
[*.key] | ||
insert_final_newline = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: Reset cache | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
run-updater: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Reset cache | ||
run: | | ||
curl -X GET "https://v3.avohq.io/templates/reset?secret=${{secrets.GH_API_SECRET}}&repo=$GITHUB_REPOSITORY" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Avo 3 to Jumpstart Pro template | ||
|
||
## Happening | ||
|
||
1. Add to the `Gemfile`. Possibly to show a choice for `avo`, `pro` or `advanced`. `gem "avo", ">= 3.0.1.beta4", source: "https://packager.dev/avo-hq"` | ||
1. Run `bundle install` | ||
1. Add the route `mount Avo::Engine, at: Avo.configuration.root_path` | ||
1. Copy the `template` files | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Insert templates here | ||
|
||
if ARGV.include? "--community-edition" | ||
edition = "community" | ||
elsif ARGV.include? "--pro-edition" | ||
edition = "pro" | ||
elsif ARGV.include? "--advanced-edition" | ||
edition = "advanced" | ||
end | ||
|
||
unless edition | ||
# === Fetch the Avo edition === | ||
question = <<~QUESTION | ||
What version of Avo would you like to install? | ||
1. Avo Community (default) | ||
2. Avo Pro | ||
3. Avo Advanced | ||
QUESTION | ||
|
||
answer = ask(question, default: "1", limited_to: ["1", "2", "3"]) | ||
|
||
edition = case answer | ||
when "1" | ||
"community" | ||
when "2" | ||
"pro" | ||
when "3" | ||
"advanced" | ||
end | ||
end | ||
|
||
# === Add gem to Gemfile === | ||
case edition | ||
when "community" | ||
gem "avo", ">= 3.0.1.beta4", source: "https://packager.dev/avo-hq" | ||
when "pro" | ||
gem "avo-pro", source: "https://packager.dev/avo-hq" | ||
when "advanced" | ||
gem "avo-advanced", source: "https://packager.dev/avo-hq" | ||
end | ||
|
||
# === Run bundle install === | ||
Bundler.with_unbundled_env { run "bundle install" } | ||
|
||
# === Add route === | ||
route_contents = <<-ROUTES | ||
# Avo admin panel | ||
if defined?(Avo::Engine) | ||
authenticated :user, lambda { |u| u.admin? } do | ||
mount Avo::Engine, at: Avo.configuration.root_path | ||
end | ||
end | ||
ROUTES | ||
route route_contents | ||
|
||
# === Copy template files === | ||
files.each do |path, contents| | ||
file path, contents | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class Avo::Cards::ActiveSubscriptions < Avo::Dashboards::MetricCard | ||
self.id = "active_subscriptions" | ||
self.label = "Active subscriptions" | ||
self.description = "Total number of active subscriptions" | ||
|
||
def query | ||
result ::Pay::Subscription.active.count | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
class Avo::Cards::TotalRevenue < Avo::Dashboards::MetricCard | ||
self.id = "total_revenue" | ||
self.label = "Total revenue" | ||
self.prefix = "$" | ||
|
||
def query | ||
case arguments[:period] | ||
when :last_12_months | ||
result last_12_months | ||
when :last_month | ||
result last_month | ||
when :this_month | ||
result this_month | ||
else | ||
result total_revenue | ||
end | ||
end | ||
|
||
def total_revenue | ||
revenue_in_cents = ::Pay::Charge.sum(:amount) | ||
refunds_in_cents = ::Pay::Charge.sum(:amount_refunded) | ||
(revenue_in_cents - refunds_in_cents) / 100.0 | ||
end | ||
|
||
def last_12_months | ||
revenue_for_range 12.months.ago..Time.current | ||
end | ||
|
||
def last_month | ||
month = Time.current.prev_month | ||
revenue_for_range month.beginning_of_month..month.end_of_month | ||
end | ||
|
||
def this_month | ||
month = Time.current | ||
revenue_for_range month.beginning_of_month..month.end_of_month | ||
end | ||
|
||
def revenue_for_range(range) | ||
revenue_in_cents = ::Pay::Charge.where(created_at: range).sum(:amount) | ||
refunds_in_cents = ::Pay::Charge.where(created_at: range).sum(:amount_refunded) | ||
(revenue_in_cents - refunds_in_cents) / 100.0 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class Avo::Cards::UsersCount < Avo::Dashboards::MetricCard | ||
self.id = "users_count" | ||
self.label = "Users count" | ||
self.description = "Total number of users registered" | ||
|
||
def query | ||
result ::User.all.count | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
class Avo::Dashboards::Overview < Avo::Dashboards::BaseDashboard | ||
self.id = "overview" | ||
self.name = "Overview" | ||
self.grid_cols = 4 | ||
|
||
def cards | ||
divider label: "Revenue" | ||
card Avo::Cards::TotalRevenue, | ||
arguments: { | ||
period: :this_month | ||
}, | ||
label: "This month" | ||
card Avo::Cards::TotalRevenue, | ||
arguments: { | ||
period: :last_month | ||
}, | ||
label: "Last month" | ||
card Avo::Cards::TotalRevenue, | ||
arguments: { | ||
period: :last_12_months | ||
}, | ||
label: "Last 12 months" | ||
card Avo::Cards::TotalRevenue | ||
|
||
divider | ||
|
||
card Avo::Cards::UsersCount | ||
card Avo::Cards::ActiveSubscriptions | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
class InvitationResource < Avo::BaseResource | ||
self.title = :email | ||
self.includes = [] | ||
# self.search = { | ||
# query: -> { query.ransack(id_eq: params[:q], email_cont: params[:q], m: "or").result(distinct: false) }, | ||
# item: -> { | ||
# { | ||
# title: record.title | ||
# } | ||
# } | ||
# } | ||
|
||
def fields | ||
field :id, as: :id | ||
field :email, as: :text | ||
field :uuid, as: :text | ||
field :team, as: :belongs_to | ||
field :from_membership, as: :belongs_to | ||
field :membership, as: :has_one | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
class MembershipResource < Avo::BaseResource | ||
self.title = :name | ||
self.includes = [] | ||
# self.search = { | ||
# query: -> { query.ransack(id_eq: params[:q], name_cont: params[:q], user_email_cont: params[:q], role_cont: params[:q], m: "or").result(distinct: false) }, | ||
# item: -> { | ||
# { | ||
# title: record.name | ||
# } | ||
# } | ||
# } | ||
|
||
field :id, as: :id | ||
field :name, as: :text, hide_on: :forms | ||
field :user_profile_photo_id, as: :text | ||
field :user_email, as: :text | ||
field :added_by_id, as: :number | ||
field :role_ids, as: :tags | ||
field :user, as: :belongs_to | ||
field :team, as: :belongs_to | ||
field :invitation, as: :belongs_to | ||
field :added_by, as: :belongs_to | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
class Avo::Resources::Team < Avo::BaseResource | ||
self.title = :name | ||
self.includes = [] | ||
self.search = { | ||
query: -> { query.ransack(id_eq: params[:q], name_cont: params[:q], slug_cont: params[:q], m: "or").result(distinct: false) }, | ||
item: -> { | ||
{ | ||
title: record.name | ||
} | ||
} | ||
} | ||
|
||
def fields | ||
field :id, as: :id | ||
field :name, as: :text | ||
field :slug, as: :text | ||
field :being_destroyed, as: :boolean, hide_on: :forms | ||
field :time_zone, as: :text | ||
field :locale, as: :text | ||
field :users, as: :has_many, through: :memberships | ||
field :memberships, as: :has_many | ||
field :invitations, as: :has_many | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
class UserResource < Avo::BaseResource | ||
self.title = :full_name | ||
self.includes = [:teams, :memberships] | ||
self.search = { | ||
query: -> { query.ransack(id_eq: params[:q], first_name_cont: params[:q], last_name_cont: params[:q], email_cont: params[:q], m: "or").result(distinct: false) }, | ||
item: -> { | ||
{ | ||
title: record.name, | ||
} | ||
} | ||
} | ||
|
||
def fields | ||
field :id, as: :id | ||
field :email, as: :text | ||
field :first_name, as: :text | ||
field :last_name, as: :text | ||
field :time_zone, as: :text | ||
field :current_team, as: :belongs_to | ||
|
||
field :teams, as: :has_many, through: :teams | ||
field :memberships, as: :has_many | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# This controller has been generated to enable Rails' resource routes. | ||
# More information on https://docs.avohq.io/3.0/controllers.html | ||
class Avo::InvitationsController < Avo::ResourcesController | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# This controller has been generated to enable Rails' resource routes. | ||
# More information on https://docs.avohq.io/3.0/controllers.html | ||
class Avo::MembershipsController < Avo::ResourcesController | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# This controller has been generated to enable Rails' resource routes. | ||
# More information on https://docs.avohq.io/3.0/controllers.html | ||
class Avo::TeamsController < Avo::ResourcesController | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# This controller has been generated to enable Rails' resource routes. | ||
# More information on https://docs.avohq.io/3.0/controllers.html | ||
class Avo::UsersController < Avo::ResourcesController | ||
end |
Oops, something went wrong.