def Index(params=None): """ Renders the index page which displays some generic connections information and links to all the activated modules. """ handle_params(params) p = Page() # Header p.add_page(Header(title='Index')) p.add_page(Navigation(page='index')) with p.div({'class': 'container-fluid'}): # Connection information data, params = [], defaultdict(str) param_keys = ('server_version', 'server_encoding', 'client_encoding', 'is_superuser', 'TimeZone') with pg_connection(*current_user.get_config()) as (con, cur, err): for k in param_keys: params[k] = con.get_parameter_status(k) with pg_log_err('list databases'): cur.execute(query('list-databases')) data = cur.fetchall() with p.div({'class': 'row'}): with p.div({'class': 'col-md-2'}): with p.div({'class': 'btn-group'}): with p.button({'class': 'btn btn-default dropdown-toggle', 'data-toggle': 'dropdown', 'aria-expanded': 'false'}): p.content('Switch database <span class="caret"></span>') with p.ul({'class': 'dropdown-menu', 'role': 'menu'}): for n, d in enumerate(data): with p.li(): with p.a({'href': 'index?database=%s' % d[0]}): p.content(d[0]) if n < len(data) - 1: with p.li({'class': 'divider'}): pass with p.div({'class': 'col-md-4 small'}): p.content('<strong>%s</strong>' % current_user.database) p.content('<br>%s@%s:%s' % (current_user.name, current_user.host, current_user.port)) with p.div({'class': 'col-md-6 small'}): with p.ul({'class': 'list-inline'}): for k, v in sorted(params.items()): with p.li(): p.content('%s: %s' % (k, v)) with p.hr(): pass # Modules cols = 12 col_size = 4 col = 0 for page in PAGES[1:]: if col == 0: with p.div({'class': 'row'}, close=False): pass with p.div({'class': 'col-md-%s' % col_size}): with p.a({'href': '/%s' % page['name']}): with p.div({'class': 'page-link'}): with p.span({'class': 'page-icon glyphicon glyphicon-%s' % page['icon']}): pass with p.h3(): p.content(page['caption']) p.content(page['desc']) col = (col + col_size) % cols if col == 0: p.close('div') p.add_page(Footer()) return p
def Footer(params=None): p = Page() p.close('body').close('html') return p
def Index(params=None): """ Renders the index page which displays some generic connections information and links to all the activated modules. """ handle_params(params) p = Page() # Header p.add_page(Header(title='Index')) p.add_page(Navigation(page='index')) with p.div({'class': 'container-fluid'}): # Connection information data, params = [], defaultdict(str) param_keys = ('server_version', 'server_encoding', 'client_encoding', 'is_superuser', 'TimeZone') with pg_connection(*current_user.get_config()) as (con, cur, err): for k in param_keys: params[k] = con.get_parameter_status(k) with pg_log_err('list databases'): cur.execute(query('list-databases')) data = cur.fetchall() with p.div({'class': 'row'}): with p.div({'class': 'col-md-2'}): with p.div({'class': 'btn-group'}): with p.button({ 'class': 'btn btn-default dropdown-toggle', 'data-toggle': 'dropdown', 'aria-expanded': 'false' }): p.content( 'Switch database <span class="caret"></span>') with p.ul({'class': 'dropdown-menu', 'role': 'menu'}): for n, d in enumerate(data): with p.li(): with p.a({'href': 'index?database=%s' % d[0]}): p.content(d[0]) if n < len(data) - 1: with p.li({'class': 'divider'}): pass with p.div({'class': 'col-md-4 small'}): p.content('<strong>%s</strong>' % current_user.database) p.content( '<br>%s@%s:%s' % (current_user.name, current_user.host, current_user.port)) with p.div({'class': 'col-md-6 small'}): with p.ul({'class': 'list-inline'}): for k, v in sorted(params.items()): with p.li(): p.content('%s: %s' % (k, v)) with p.hr(): pass # Modules cols = 12 col_size = 4 col = 0 for page in PAGES[1:]: if col == 0: with p.div({'class': 'row'}, close=False): pass with p.div({'class': 'col-md-%s' % col_size}): with p.a({'href': '/%s' % page['name']}): with p.div({'class': 'page-link'}): with p.span({ 'class': 'page-icon glyphicon glyphicon-%s' % page['icon'] }): pass with p.h3(): p.content(page['caption']) p.content(page['desc']) col = (col + col_size) % cols if col == 0: p.close('div') p.add_page(Footer()) return p