Ejemplo n.º 1
0
def renderDashboardHtmlUniqueDashboard(request, layout_name='default_config', isFlipboard=False):
    """
        Render Html page for all the tiles needed in layout_name(dashboard .yml)
        with CSS/JS dependency if isFlipboard is false
    """
    config = parseXmlLayout(layout_name)
    if config is not None:  # file is present
        title = layout_name
        color_mode = "black"
        if 'details' in config:
            title = config['details']['page_title'] if 'page_title' in config['details'] else title
            color_mode = config['details']['color_mode'] if 'color_mode' in config['details'] else color_mode
        # TODO: handle when layout is not present inside the .yml (will throw error when config['layout'] not found)
        data = dict(layout=config['layout'],
                    layout_name=layout_name,
                    tipboard_css=list() if isFlipboard else TIPBOARD_CSS_STYLES,
                    tipboard_js=list() if isFlipboard else TIPBOARD_JAVASCRIPT_FILES,
                    color_mode=color_mode,
                    page_title=title)
        return render(request, 'dashboard.html' if isFlipboard else 'flipboard.html', data)
    if LOG:
        print(f'{getTimeStr()}: (+)Config file:{layout_name} not found', flush=True)
    msg = f'<br> <div style="color: red"> ' \
        f'No config file found for dashboard: {layout_name} ' \
        f'Make sure that file: "{layout_name}" exists. </div>'
    return HttpResponse(msg, status=404)
Ejemplo n.º 2
0
def renderDashboardHtmlUniqueDashboard(request,
                                       layout_name='default_config',
                                       isFlipboard=False):
    """
        Render Html page for all the tiles needed in layout_name(dashboard .yml)
        with CSS/JS dependency if isFlipboard is false
    """
    config = parseXmlLayout(layout_name)
    if config is not None:
        color_mode = "black"
        title = layout_name
        if 'details' in config:
            title = config['details']['page_title'] if 'page_title' in config[
                'details'] else layout_name
            color_mode = config['details'][
                'color_mode'] if 'color_mode' in config[
                    'details'] else color_mode
        if 'layout' in config:
            data = dict(
                layout=config['layout'],
                layout_name=layout_name,
                page_title=title,
                tipboard_css=list() if isFlipboard else TIPBOARD_CSS_STYLES,
                tipboard_js=list()
                if isFlipboard else TIPBOARD_JAVASCRIPT_FILES,
                color_mode=color_mode)
            return render(
                request, 'dashboard.html' if isFlipboard else 'flipboard.html',
                data)
    msg = f'''
    <br> <div style="color: red">
        No config file found for dashboard: {layout_name}
    Make sure that file: "{layout_name}" exists. </div> '''
    return HttpResponse(msg, status=404)
Ejemplo n.º 3
0
def listOfTilesFromLayout(layout_name='layout_config'):
    rcx = 0
    listOfTiles = list()
    config = parseXmlLayout(layout_name)
    for tile in config['tiles_keys']:
        listOfTiles.append(dict(tile_id=tile, tile_template=config['tiles_names'][rcx]))
        rcx += 1
    return listOfTiles
Ejemplo n.º 4
0
def getTilesDependency(layout_name):
    """ Build CSS / JS tiles dependency from the tile referenced in layout.yaml """
    config = parseXmlLayout(layout_name)
    tiles_template = replaceNameTiles(config['tiles_names'])
    data = dict(details=config['details'],
                layout=config['layout'],
                tipboard_css=TIPBOARD_CSS_STYLES,
                tipboard_js=TIPBOARD_JAVASCRIPTS,
                tiles_css=[
                    'tiles/' + '.'.join((name, 'css'))
                    for name in tiles_template
                ],
                tiles_js=[
                    'tiles/' + '.'.join((name, 'js'))
                    for name in tiles_template
                ])
    tiles_css = list(
    )  # TODO i think this need to be deleted, no css anymore for specific tile
    for tile_css in data['tiles_css']:
        if finders.find(tile_css):
            tiles_css.append(tile_css)
    data['tiles_css'] = tiles_css
    return data
Ejemplo n.º 5
0
 def test_0003_parser(self):
     """ Test XmlParser for layout """
     config = parseXmlLayout()
     title = config['details']['page_title']
     self.assertTrue(title is not None)
Ejemplo n.º 6
0
def listOfTilesFromLayout(layout_name='default_config'):
    """ List all tiles for a specific layout in Config/*.yml """
    return parseXmlLayout(layout_name)['tiles_conf']
Ejemplo n.º 7
0
 def test_0006_parser_getTilesIdFromXml(self):
     """ Test XmlParser able to get tiles Id of tiles from /config/default_config.yml """
     tiles_conf = parseXmlLayout(layout_name=self.layout)['tiles_conf']
     self.assertTrue((tiles_conf[next(iter(tiles_conf))]['tile_id']) is not None)
Ejemplo n.º 8
0
 def test_0005_parser_getTilesNameFromXml(self):  # test if able to parse tiles template
     """ Test XmlParser able to get tiles name of /config/default_config.yml """
     tiles_conf = parseXmlLayout(layout_name=self.layout)['tiles_conf']
     self.assertTrue(tiles_conf[next(iter(tiles_conf))]['title'] is not None)
Ejemplo n.º 9
0
 def test_0004_parser_getDashboardColsFromXml(self):  # test if able to parse row
     """ Test XmlParser able to get cols dashboard of /config/default_config.yml """
     self.assertTrue(len(parseXmlLayout(layout_name=self.layout)['layout']) > 0)
Ejemplo n.º 10
0
 def test_0003_parser_getTitleOfDashboard(self):
     """ Test XmlParser is able to get title of /config/default_config.yml """
     config = parseXmlLayout(layout_name=self.layout)
     title = config['details']['page_title']
     self.assertTrue(title is not None)
Ejemplo n.º 11
0
 def test_0001_parse_dashboardXml(self):
     """ Test Parse all tiles, cols, rows from a specific .yaml """
     config = parseXmlLayout(layout_name=self.layout)
     self.assertTrue(config is not None)