pvl/verkko/hosts.py
changeset 10 513eb70e54f2
parent 9 3334d8ddf2f1
child 11 d1e17bd498e7
equal deleted inserted replaced
9:3334d8ddf2f1 10:513eb70e54f2
   108         # k
   108         # k
   109         return hosts
   109         return hosts
   110     
   110     
   111     def render_hosts (self, hosts, title=None, filters=False) :
   111     def render_hosts (self, hosts, title=None, filters=False) :
   112         COLS = (
   112         COLS = (
   113             #title          sort        filter
   113             #title          sort        filter      class
   114             ('IP',          'ip',       'ip'    ),
   114             ('IP',          'ip',       'ip',       'ip'    ),
   115             ('MAC',         'mac',      'mac'   ),
   115             ('MAC',         'mac',      'mac',      'mac'   ),
   116             ('Hostname',    'name',     False   ),
   116             ('Hostname',    'name',     False,      False   ),
   117             ('Seen',        'seen',     False   ),
   117             ('Seen',        'seen',     False,      False   ),
   118         )
   118         )
   119 
   119 
   120         def url (**opts) :
   120         def url (**opts) :
   121             args = dict(filters)
   121             args = dict(filters)
   122             args.update(opts)
   122             args.update(opts)
   129                 html.tr(
   129                 html.tr(
   130                     html.th('#'),
   130                     html.th('#'),
   131                     (
   131                     (
   132                         html.th(
   132                         html.th(
   133                             html.a(href=url(sort=sort))(title) if sort else (title)
   133                             html.a(href=url(sort=sort))(title) if sort else (title)
   134                         ) for title, sort, filter in COLS
   134                         ) for title, sort, filter, class_ in COLS
   135                     )
   135                     )
   136                 ),
   136                 ),
   137                 html.tr(class_='filter')(
   137                 html.tr(class_='filter')(
   138                     html.td(
   138                     html.td(
   139                         html.input(type='submit', value=u'\u00BF'),
   139                         html.input(type='submit', value=u'\u00BF'),
   140                     ),
   140                     ),
   141                     (
   141                     (
   142                         html.td(
   142                         html.td(class_=class_)(
   143                             html.input(type='text', name=filter, value=filters.get(filter)) if filter else None
   143                             html.input(type='text', name=filter, value=filters.get(filter)) if filter else None
   144                         ) for title, sort, filter in COLS
   144                         ) for title, sort, filter, class_ in COLS
   145                     )
   145                     )
   146                 ) if filters is not False else None
   146                 ) if filters is not False else None
   147             ),
   147             ),
   148             html.tbody(
   148             html.tbody(
   149                 html.tr(class_=('alternate' if i % 2 else None), id=host.id)(
   149                 html.tr(class_=('alternate' if i % 2 else None), id=host.id)(