126 lines
4.0 KiB
Plaintext
126 lines
4.0 KiB
Plaintext
<h2>
|
|
<span style="display: inline-block; width: 16px; height: 16px; background: <%= @role_group.color %>; border-radius: 3px; margin-right: 10px; vertical-align: middle;"></span>
|
|
<%= @role_group.name %>
|
|
</h2>
|
|
|
|
<% if @role_group.description.present? %>
|
|
<p><%= @role_group.description %></p>
|
|
<% end %>
|
|
|
|
<hr />
|
|
|
|
<h3>멤버 (<%= @members.count %>명)</h3>
|
|
|
|
<% if @members.any? %>
|
|
<table class="list">
|
|
<thead>
|
|
<tr>
|
|
<th>이름</th>
|
|
<th>ID</th>
|
|
<th>이메일</th>
|
|
<th>비고</th>
|
|
<th>작업</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<% @members.each do |member| %>
|
|
<tr>
|
|
<td><%= link_to member.user.name, user_path(member.user) %></td>
|
|
<td><%= member.user.login %></td>
|
|
<td><%= member.user.mail %></td>
|
|
<td><%= member.note %></td>
|
|
<td>
|
|
<%= link_to '제거', remove_member_role_group_path(@role_group, user_id: member.user_id),
|
|
method: :delete, data: { confirm: '이 멤버를 제거하시겠습니까?' }, class: 'icon icon-del' %>
|
|
</td>
|
|
</tr>
|
|
<% end %>
|
|
</tbody>
|
|
</table>
|
|
<% else %>
|
|
<p class="nodata">멤버가 없습니다.</p>
|
|
<% end %>
|
|
|
|
<hr />
|
|
|
|
<h3>멤버 추가 (LDAP 검색)</h3>
|
|
|
|
<div class="box">
|
|
<p>
|
|
<label for="ldap_search">사용자 검색:</label>
|
|
<input type="text" id="ldap_search" size="30" placeholder="이름 또는 ID로 검색..." autocomplete="off" />
|
|
<span id="search_status" style="margin-left: 10px; color: #666;"></span>
|
|
</p>
|
|
<div id="search_results" style="margin-top: 10px;"></div>
|
|
</div>
|
|
|
|
<hr />
|
|
|
|
<p>
|
|
<%= link_to '목록으로', '/role_groups', class: 'icon icon-back' %>
|
|
<%= link_to '수정', edit_role_group_path(@role_group), class: 'icon icon-edit' %>
|
|
</p>
|
|
|
|
<%= javascript_tag do %>
|
|
var searchTimeout = null;
|
|
|
|
$('#ldap_search').on('keyup', function() {
|
|
var query = $(this).val();
|
|
|
|
if (searchTimeout) clearTimeout(searchTimeout);
|
|
|
|
if (query.length < 2) {
|
|
$('#search_results').html('');
|
|
$('#search_status').text('');
|
|
return;
|
|
}
|
|
|
|
$('#search_status').text('검색 중...');
|
|
|
|
searchTimeout = setTimeout(function() {
|
|
$.ajax({
|
|
url: '<%= search_ldap_role_groups_path %>',
|
|
data: { q: query },
|
|
dataType: 'json',
|
|
success: function(data) {
|
|
$('#search_status').text(data.length + '명 발견');
|
|
var html = '';
|
|
|
|
if (data.length === 0) {
|
|
html = '<p style="color: #999;">검색 결과가 없습니다.</p>';
|
|
} else {
|
|
html = '<table class="list" style="width: auto;"><thead><tr><th>ID</th><th>이름</th><th>이메일</th><th>상태</th><th></th></tr></thead><tbody>';
|
|
data.forEach(function(user) {
|
|
html += '<tr>';
|
|
html += '<td>' + user.uid + '</td>';
|
|
html += '<td>' + user.name + '</td>';
|
|
html += '<td>' + (user.email || '-') + '</td>';
|
|
html += '<td>' + (user.exists ? '<span style="color: green;">등록됨</span>' : '<span style="color: blue;">LDAP</span>') + '</td>';
|
|
html += '<td>';
|
|
html += '<form action="<%= add_member_role_group_path(@role_group) %>" method="post" style="display:inline;">';
|
|
html += '<input type="hidden" name="authenticity_token" value="' + $('meta[name="csrf-token"]').attr('content') + '">';
|
|
if (user.exists) {
|
|
html += '<input type="hidden" name="user_id" value="' + user.user_id + '">';
|
|
} else {
|
|
html += '<input type="hidden" name="ldap_uid" value="' + user.uid + '">';
|
|
html += '<input type="hidden" name="ldap_id" value="' + user.ldap_id + '">';
|
|
}
|
|
html += '<input type="submit" value="추가" class="button-positive" style="padding: 2px 10px;">';
|
|
html += '</form>';
|
|
html += '</td>';
|
|
html += '</tr>';
|
|
});
|
|
html += '</tbody></table>';
|
|
}
|
|
|
|
$('#search_results').html(html);
|
|
},
|
|
error: function() {
|
|
$('#search_status').text('검색 오류');
|
|
$('#search_results').html('<p style="color: red;">검색 중 오류가 발생했습니다.</p>');
|
|
}
|
|
});
|
|
}, 300);
|
|
});
|
|
<% end %>
|