Added search by user in virtualhosts
This commit is contained in:
parent
8da559b6ec
commit
2ae159623f
2 changed files with 38 additions and 8 deletions
30
admin/app.py
30
admin/app.py
|
|
@ -40,6 +40,8 @@ system_path='./ssh/'
|
|||
if hasattr(config, 'pastafari_system_path'):
|
||||
system_path=config.pastafari_system_path
|
||||
|
||||
config_task.pastafari_paths.append('modules/apache/tasks')
|
||||
|
||||
@admin_app.route('/webservers/servers/')
|
||||
def webservers():
|
||||
|
||||
|
|
@ -278,8 +280,13 @@ def virtualhost(webserver_id):
|
|||
arr_webserver=cursor.fetchone()
|
||||
|
||||
if arr_webserver:
|
||||
|
||||
usernames=[]
|
||||
|
||||
with db.query('select DISTINCT username from virtualhost WHERE webserver_id=%s', [webserver_id]) as cursor:
|
||||
usernames=cursor.fetchall()
|
||||
|
||||
return t.load_template('virtualhosts.phtml', title=_('Virtual Hosts'), path_module='admin_app.webservers', webserver_id=webserver_id, hostname=arr_webserver['hostname'])
|
||||
return t.load_template('virtualhosts.phtml', title=_('Virtual Hosts'), path_module='admin_app.webservers', webserver_id=webserver_id, hostname=arr_webserver['hostname'], usernames=usernames)
|
||||
|
||||
else:
|
||||
|
||||
|
|
@ -305,25 +312,34 @@ def get_virtualhosts():
|
|||
|
||||
db=g.connection
|
||||
|
||||
user_id=request.args.get('webserver_id', '0')
|
||||
webserver_id=request.args.get('webserver_id', '0')
|
||||
|
||||
username=request.args.get('username', '').strip()
|
||||
|
||||
group_sql=''
|
||||
|
||||
count_data=[]
|
||||
sql_data=[user_id]
|
||||
count_data=[webserver_id]
|
||||
sql_data=[webserver_id]
|
||||
|
||||
extra_sql=''
|
||||
|
||||
if username!='':
|
||||
count_data.append(username)
|
||||
sql_data.append(username)
|
||||
extra_sql=' AND username=%s'
|
||||
|
||||
fields=[[_('Domain'), True], [_('User'), True], [_('Options'), False]]
|
||||
arr_order_fields=['domain']
|
||||
|
||||
count_query=['select count(virtualhost.id) as num_elements from virtualhost', count_data]
|
||||
count_query=['select count(virtualhost.id) as num_elements from virtualhost WHERE webserver_id=%s'+extra_sql, count_data]
|
||||
|
||||
# server.id as select_id,
|
||||
|
||||
# select hostname, ip, date, num_updates, id from serverofuser where user_id=%s;
|
||||
# select hostname, ip, date, num_updates, id from serverofuser where webserver_id=%s;
|
||||
|
||||
#str_query=['select webserver.hostname, webserver.ip, webserver.id from webserver,serverdbtask', sql_data]
|
||||
|
||||
str_query=['select domain, username, id from virtualhost WHERE webserver_id=%s', sql_data]
|
||||
str_query=['select domain, username, id from virtualhost WHERE webserver_id=%s'+extra_sql, sql_data]
|
||||
|
||||
ajax=AjaxList(db, fields, arr_order_fields, count_query, str_query)
|
||||
|
||||
|
|
|
|||
|
|
@ -6,8 +6,13 @@
|
|||
<%block name="content">
|
||||
<h3>${hostname}</h3>
|
||||
<p>${_('Filter by user')}:
|
||||
<select name="user_vhost">
|
||||
<select name="user_vhost" id="user_vhost">
|
||||
<option value=""></option>
|
||||
% for username in usernames:
|
||||
|
||||
<option value="${username['username']}">${username['username']}</option>
|
||||
|
||||
% endfor
|
||||
</select>
|
||||
</p>
|
||||
<p><a href="${url_for('admin_app.webservers')}">${_('Webservers list')}</a> >> ${_('Websites')}</p>
|
||||
|
|
@ -70,6 +75,15 @@ $('#form_change_password').sendPost(options_post);
|
|||
|
||||
//$.fn.popUp = function (popup, width, pre_callback, post_callback, options)
|
||||
|
||||
$('#user_vhost').change( function (e) {
|
||||
|
||||
options.url="${url_for('.get_virtualhosts', webserver_id=webserver_id)}&username="+$('#user_vhost').val();
|
||||
|
||||
alist.updateAjax('table_list', options, 0);
|
||||
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
</%block>
|
||||
</%block>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue