rollout_admin 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
data/README.md
CHANGED
@@ -22,17 +22,24 @@ To mount the engine within your project add the following line to your routes.rb
|
|
22
22
|
|
23
23
|
mount RolloutAdmin::Engine => "/rollout_admin"
|
24
24
|
|
25
|
-
You will be asked for a username and password when accessing the page
|
25
|
+
You will be asked for a username and password when accessing the page. The default username, password is foo/bar. You can configure them to be anything you like with the intializer options:
|
26
|
+
|
27
|
+
RolloutAdmin.auth_name = "myuser"
|
28
|
+
RolloutAdmin.auth_password = "secret"
|
26
29
|
|
27
30
|
**Special hint when using an API**
|
28
31
|
|
29
32
|
It turned out that in one of our own projects we wrapped the users object to be accessed via an API. Within our main application controller the API calls got some additional headers for API Key which where not accessable within the rollout_admin engine. Therefor there is an option RolloutAdmin.user_url you can configure to provide the URL used for getting a users list within the RolloutAdmin interface.
|
30
33
|
|
34
|
+
Furthermore if you don't have the fields name and email present in your User Model or if they are named differently. You can override the User Model attributes rollout_admin should use to display user information.
|
35
|
+
|
31
36
|
Just define an initializer and paste the following:
|
32
37
|
|
33
38
|
# Rollout Admin configuration
|
34
39
|
#
|
35
40
|
RolloutAdmin.user_url = "/just/something/boring.json"
|
41
|
+
RolloutAdmin.user_name_attribute = "first_name"
|
42
|
+
RolloutAdmin.user_email_attribute = "email"
|
36
43
|
|
37
44
|
## TODO
|
38
45
|
|
@@ -76,7 +76,7 @@ $(function(){
|
|
76
76
|
$.getJSON('<%= user_url%>', function(json) {
|
77
77
|
userlist='<h5>Select users to add</h5><form id="userlist"><ul class="unstyled">';
|
78
78
|
$.each(json, function() {
|
79
|
-
userlist += '<li><input type="checkbox", value="'+this.id+'" data-username="'+this.
|
79
|
+
userlist += '<li><input type="checkbox", value="'+this.id+'" data-username="'+this.<%=RolloutAdmin.user_name_attribute%>+'"> '+this.<%=RolloutAdmin.user_name_attribute%>+', '+this.<%=RolloutAdmin.user_email_attribute%>+'</li>';
|
80
80
|
});
|
81
81
|
userlist +='</ul></form>';
|
82
82
|
|
@@ -59,7 +59,7 @@ module RolloutAdmin
|
|
59
59
|
|
60
60
|
def remove
|
61
61
|
if params[:object_type] == "user"
|
62
|
-
@user=User.where(
|
62
|
+
@user=User.where(RolloutAdmin.user_name_attribute.to_sym => params[:user]).first
|
63
63
|
if @user
|
64
64
|
$rollout.deactivate_user(params[:feature], @user)
|
65
65
|
end
|
@@ -86,7 +86,7 @@ module RolloutAdmin
|
|
86
86
|
|
87
87
|
def authenticate
|
88
88
|
authenticate_or_request_with_http_basic do |username, password|
|
89
|
-
username ==
|
89
|
+
username == RolloutAdmin.auth_name && password == RolloutAdmin.auth_password
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
@@ -11,11 +11,11 @@
|
|
11
11
|
<% if feature.users.count > 0 %>
|
12
12
|
<% feature.users.each {|user| %>
|
13
13
|
<li><i class="icon-minus delete_user"></i>
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
<% if User.find(user.to_i).nil? %>
|
15
|
+
<%= user %>
|
16
|
+
<% else %>
|
17
|
+
<%=User.find(user.to_i).send(RolloutAdmin.user_name_attribute) %>
|
18
|
+
<% end %>
|
19
19
|
</li>
|
20
20
|
<% } %>
|
21
21
|
<% else %>
|
data/lib/rollout_admin.rb
CHANGED
@@ -3,4 +3,15 @@ require "rollout_admin/engine"
|
|
3
3
|
module RolloutAdmin
|
4
4
|
mattr_accessor :user_url
|
5
5
|
|
6
|
+
mattr_accessor :user_name_attribute
|
7
|
+
@@user_name_attribute = "Name"
|
8
|
+
|
9
|
+
mattr_accessor :user_email_attribute
|
10
|
+
@@user_email_attribute = "email"
|
11
|
+
|
12
|
+
mattr_accessor :auth_name
|
13
|
+
@@auth_name = "foo"
|
14
|
+
|
15
|
+
mattr_accessor :auth_password
|
16
|
+
@@auth_password = "bar"
|
6
17
|
end
|