# Path: server_client/server/models/room.py
# class Room(BaseComponent):
#     """Defines room display in system"""
#     table_name = 'rooms'
#     column_headers_and_types = BaseComponent.column_headers_and_types + [['els', 'text'], ['regs', 'text']]
#     
#     COL_REGS = 4
#     COL_ELS = 3                                     
#     ID = 0
#     items = {}
#     groups_per_row = 4
# 
#     def __init__(self, *args):
#         super().__init__(args[0], Rt(args[1]), args[2]) # inicjalizuj id type, name
#         Room.items[self.id] = self
#         self.elements = args[Room.COL_ELS]
#         self.regulations = args[Room.COL_REGS]
#         self.groups = OrderedDict() # Thanks to ordered dict groups always apear in the same order
# 
#     def add_element(self, *elements):
#         for element in elements:
#             self.elements.append(element)
# 
#     def get_display_data(self,):
#         """Returns data organized in bootstrap rows and columns. There are Room.groups_per_row columns per row"""
#         rows = []
#         row = []
#         for group_num, group in enumerate(self.groups.values()):
#             row.append(group)
#             if group_num == Room.groups_per_row-1:
#                 rows.append(row)
#                 row = []
#         if row:
#             rows.append(row) # dla ostatniego niepelnego rzedu
# 
#         return rows
# 
#     def get_html(self, ):
#         """Generates room html"""
#         rows = self.get_display_data()
# 
#         room_container = div(cls = "well", id='room' + str(self.id))
#         room_name = h3(self.name, cls="text-center")
#         room_container.add(room_name)
#         for row in rows:            
#             r = div(cls='row')
#             with r:
#                 for group in row:
#                     div(cls="col-sm-3 group").add(group.get_html())
#             room_container.add(r)
#         return room_container.render()
# 
# 
#     def __str__(self, ):
#         return "".join([super().__str__(), '\tELEMENTS: ',  ",".join([str(el.id) for el in self.elements])])


import tornado.web
from server_client.server.models.room import Room


class UiHandler(tornado.web.RequestHandler):
    def get(self):
        if self.request.path == '/ui/navigation_bar':
            self.render('navigation_bar.html', rooms=Room.items.values())
                    
        elif self.request.path == '/ui/system':

# Path: server_client/server/models/room.py
# class Room(BaseComponent):
#     """Defines room display in system"""
#     table_name = 'rooms'
#     column_headers_and_types = BaseComponent.column_headers_and_types + [['els', 'text'], ['regs', 'text']]
#     
#     COL_REGS = 4
#     COL_ELS = 3                                     
#     ID = 0
#     items = {}
#     groups_per_row = 4
# 
#     def __init__(self, *args):
#         super().__init__(args[0], Rt(args[1]), args[2]) # inicjalizuj id type, name
#         Room.items[self.id] = self
#         self.elements = args[Room.COL_ELS]
#         self.regulations = args[Room.COL_REGS]
#         self.groups = OrderedDict() # Thanks to ordered dict groups always apear in the same order
# 
#     def add_element(self, *elements):
#         for element in elements:
#             self.elements.append(element)
# 
#     def get_display_data(self,):
#         """Returns data organized in bootstrap rows and columns. There are Room.groups_per_row columns per row"""
#         rows = []
#         row = []
#         for group_num, group in enumerate(self.groups.values()):
#             row.append(group)
#             if group_num == Room.groups_per_row-1:
#                 rows.append(row)
#                 row = []
#         if row:
#             rows.append(row) # dla ostatniego niepelnego rzedu
# 
#         return rows
# 
#     def get_html(self, ):
#         """Generates room html"""
#         rows = self.get_display_data()
# 
#         room_container = div(cls = "well", id='room' + str(self.id))
#         room_name = h3(self.name, cls="text-center")
#         room_container.add(room_name)
#         for row in rows:            
#             r = div(cls='row')
#             with r:
#                 for group in row:
#                     div(cls="col-sm-3 group").add(group.get_html())
#             room_container.add(r)
#         return room_container.render()
# 
# 
#     def __str__(self, ):
#         return "".join([super().__str__(), '\tELEMENTS: ',  ",".join([str(el.id) for el in self.elements])])


# Path: server_client/server/handlers/ui_handler.py
import tornado.web
from server_client.server.models.room import Room



class UiHandler(tornado.web.RequestHandler):
    def get(self):
        if self.request.path == '/ui/navigation_bar':
            self.render('navigation_bar.html', rooms=Room.items.values())
                    
        elif self.request.path == '/ui/system':

            for room in Room.items.values():