Skip to content

Commit ec9fa07

Browse files
authored
Add madmin initial implementation (#295)
* Add madmin initial implementation * Update attributes for user based on @toppa's feedback
1 parent 8aeb1bc commit ec9fa07

21 files changed

Lines changed: 432 additions & 0 deletions

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,5 @@ gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby]
111111
gem "coffee-script"
112112

113113
gem "pundit", "~> 2.2"
114+
115+
gem "madmin", "~> 1.2"

Gemfile.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@ GEM
168168
loofah (2.19.1)
169169
crass (~> 1.0.2)
170170
nokogiri (>= 1.5.9)
171+
madmin (1.2.7)
172+
pagy (>= 3.5, < 6.0)
173+
rails (>= 6.0.3)
171174
mail (2.8.1)
172175
mini_mime (>= 0.1.1)
173176
net-imap
@@ -220,6 +223,8 @@ GEM
220223
actionpack (>= 4.2)
221224
omniauth (~> 2.0)
222225
orm_adapter (0.5.0)
226+
pagy (5.10.1)
227+
activesupport
223228
parallel (1.22.1)
224229
parser (3.2.1.1)
225230
ast (~> 2.4.1)
@@ -409,6 +414,7 @@ DEPENDENCIES
409414
jquery-rails
410415
jquery-ui-rails (~> 5.0, >= 5.0.5)
411416
listen (~> 3.7)
417+
madmin (~> 1.2)
412418
matrix
413419
mimemagic (~> 0.3.8)
414420
newrelic_rpm
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module Madmin
2+
class ApplicationController < Madmin::BaseController
3+
before_action :ensure_admin
4+
5+
def ensure_admin
6+
redirect_to "/" if current_user.nil? || !current_user.admin
7+
end
8+
end
9+
end
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module Madmin
2+
class EstimatesController < Madmin::ResourceController
3+
end
4+
end
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module Madmin
2+
class ProjectsController < Madmin::ResourceController
3+
end
4+
end
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module Madmin
2+
class StoriesController < Madmin::ResourceController
3+
end
4+
end
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module Madmin
2+
class UsersController < Madmin::ResourceController
3+
end
4+
end
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
class EstimateResource < Madmin::Resource
2+
# Attributes
3+
attribute :id, form: false
4+
attribute :best_case_points
5+
attribute :worst_case_points
6+
7+
# Associations
8+
attribute :story
9+
attribute :user
10+
11+
# Uncomment this to customize the display name of records in the admin area.
12+
# def self.display_name(record)
13+
# record.name
14+
# end
15+
16+
# Uncomment this to customize the default sort column and direction.
17+
# def self.default_sort_column
18+
# "created_at"
19+
# end
20+
#
21+
# def self.default_sort_direction
22+
# "desc"
23+
# end
24+
end
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
class ProjectResource < Madmin::Resource
2+
# Attributes
3+
attribute :id, form: false
4+
attribute :title
5+
attribute :status
6+
7+
# Associations
8+
attribute :stories
9+
attribute :estimates
10+
attribute :users
11+
attribute :parent
12+
attribute :projects
13+
14+
def self.display_name(record)
15+
record.title.truncate(20)
16+
end
17+
18+
# Uncomment this to customize the default sort column and direction.
19+
# def self.default_sort_column
20+
# "created_at"
21+
# end
22+
#
23+
# def self.default_sort_direction
24+
# "desc"
25+
# end
26+
end
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
class StoryResource < Madmin::Resource
2+
# Attributes
3+
attribute :id, form: false
4+
attribute :title
5+
attribute :description
6+
attribute :real_score
7+
attribute :extra_info
8+
9+
# Associations
10+
attribute :project
11+
attribute :estimates
12+
attribute :users
13+
14+
def self.display_name(record)
15+
record.title.truncate(30)
16+
end
17+
18+
# Uncomment this to customize the default sort column and direction.
19+
# def self.default_sort_column
20+
# "created_at"
21+
# end
22+
#
23+
# def self.default_sort_direction
24+
# "desc"
25+
# end
26+
end

0 commit comments

Comments
 (0)