Beispiel #1
0
    def graph_tasks(team_id=None, channel=None, params=None):
        load_dependencies(['syncer', 'requests'])
        graph_name = params.pop(0)
        table_width = "1200px"
        headers = [
            'Key', 'Summary', 'Latest_Information', 'Status', 'Issue Type'
        ]  # without issue links
        columns_defs = [
            {
                "targets": [1],
                "width": "70px"
            },  # Key
            {
                "targets": [1],
                "width": "300px"
            },  # Summary
            {
                "targets": [2],
                "width": "300px"
            },  # Latest_Information
            #{"targets": [3], "width": "100px"},  # Status
            #{"targets": [5], "width": "100px"},  # Rating
        ]

        return DataTable_Js_Views._create_table_with_headers(
            team_id, channel, graph_name, headers, columns_defs, table_width)
    def default(team_id=None, channel=None, params=None, no_render=False):

        load_dependencies(['syncer', 'requests']);
        from view_helpers.VivaGraph_Js import VivaGraph_Js

        graph_name = params.pop(0)
        vivagraph_js = VivaGraph_Js(headless=False)  # will start browser

        graph_data = vivagraph_js.get_graph_data(graph_name)
        #
        vivagraph_js.load_page(False)
        if graph_data:
            edges = graph_data.get('edges')
            nodes = []
            for key,issue in graph_data.get('nodes').items():
                node = {
                            'key'   : key ,
                            'label' : key,
                            'img'   : vivagraph_js.resolve_icon_from_issue_type(issue, key)
                        }
                nodes.append(node)
            slack_message(":point_right: Rendering `{0}` using VivaGraph JS engine (`{1}` nodes and `{2}` edges)"
                          .format(graph_name, len(nodes), len(edges)), [], channel,team_id)



            if no_render is True:
                return graph_name, nodes, edges, graph_data, vivagraph_js

            options = {}
            vivagraph_js.create_graph_and_send_screenshot_to_slack(nodes, edges, options, team_id, channel)
    def default(team_id=None, channel=None, params=None, no_render=False):

        load_dependencies(['syncer', 'requests'])
        from view_helpers.Vis_Js import Vis_Js

        graph_name = params.pop(0)
        vis_js = Vis_Js(headless=True)  # will start browser
        graph_data = vis_js.get_graph_data(graph_name)

        nodes = []
        edges = []
        vis_js.load_page(False)
        if graph_data:
            graph_name = graph_data.get('graph_name')
            for key, issue in graph_data.get('nodes').items():
                nodes.append({'id': key, 'label': key})
                # Dev.pprint(issue)

            for edge in graph_data.get('edges'):
                from_node = edge[0]
                link_type = edge[1]
                to_node = edge[2]
                edges.append({
                    'from': from_node,
                    'to': to_node,
                    'label': link_type
                })

            if no_render is False:
                vis_js.create_graph(nodes, edges, {}, graph_name)

        if no_render is True:
            return (graph_name, nodes, edges, graph_data, vis_js)

        return vis_js.send_screenshot_to_slack(team_id, channel)
Beispiel #4
0
    def _get_graph_data(params,layout=None, headless=True):
        load_dependencies(['syncer', 'requests']);
        from view_helpers.Go_Js import Go_Js

        graph_name = params.pop(0)

        go_js = Go_Js(headless=headless,layout=layout)
        graph_data = go_js.get_graph_data(graph_name)
        return go_js, graph_data
Beispiel #5
0
    def _get_graph_data(params, layout=None, headless=True):
        load_dependencies(['syncer', 'requests'])
        from view_helpers.Am_Charts import Am_Charts

        am_charts = Am_Charts(headless=headless, layout=layout)
        graph_name = Misc.array_pop(params, 0)
        if graph_name:
            graph_data = am_charts.get_graph_data(graph_name)
            return am_charts, graph_data
        return am_charts, None
Beispiel #6
0
    def test_data(team_id=None, channel=None, params=None):

        load_dependencies(['syncer', 'requests'])

        from view_helpers.DataTable_Js import DataTable_Js
        headers = ['Header AAA', 'Header BBB']
        rows = [['value 1', 'value 2'], ['value 3', 'value 4'], ['value 5'],
                [], ['value 6', 'value 7'], [None], [None, 'value 8', 'AB'],
                ['value 9', 'value 10']]
        return DataTable_Js().create_table(headers,
                                           rows).send_screenshot_to_slack(
                                               team_id, channel)
Beispiel #7
0
 def graph(team_id=None, channel=None, params=None):
     load_dependencies(['syncer', 'requests'])
     graph_name = params.pop(0)
     headers = [
         'Issue Type', 'Summary', 'Description', 'Status', 'Rating', 'Key'
     ]  # without issue links
     table_width = "1500px"
     columns_defs = [
         {
             "targets": [1],
             "width": "60px"
         },  # Key
         {
             "targets": [2],
             "width": "600px"
         },  # Summary
     ]
     return DataTable_Js_Views._create_table_with_headers(
         team_id, channel, graph_name, headers, columns_defs, table_width)
Beispiel #8
0
    def graph_all_fields(team_id=None, channel=None, params=None):
        load_dependencies(['syncer', 'requests'])
        graph_data = DataTable_Js_Views._get_data(params.pop(0))

        if graph_data:
            nodes = graph_data.get('nodes')
            headers = sorted(list(set(list(nodes.values()).pop())))
            rows = []
            for index, node in enumerate(nodes.values()):
                row = [index + 1]
                for header in headers:
                    value = node.get(header)
                    if type(value).__name__ == 'dict':
                        value = json.dumps(value)
                    row.append(value)
                rows.append(row)
            headers.insert(0, '#')
            return DataTable_Js_Views._create_table(headers, rows, team_id,
                                                    channel)
Beispiel #9
0
    def issue(team_id=None, channel=None, params=None):
        load_dependencies(['syncer', 'requests'])

        graph_data = DataTable_Js_Views._get_data(params.pop(0))
        if graph_data:
            nodes = graph_data.get('nodes')
            node = list(nodes.values()).pop()
            fields = sorted(list(set(node)))
            rows = []
            for field in fields:
                row = ['<b>{0}</b>'.format(field)]
                value = node.get(field)
                if value:
                    if type(value).__name__ == 'dict':
                        value = json.dumps(value)
                    row.append(value)
                    rows.append(row)

            return DataTable_Js_Views._create_table(['name', 'value'], rows,
                                                    team_id, channel)
Beispiel #10
0
    def chord(team_id=None, channel=None, params=None, headless=True):
        load_dependencies(['syncer', 'requests'])
        from view_helpers.Am_Charts import Am_Charts
        (am_charts,
         graph_data) = Am_Charts_Views._get_graph_data(params,
                                                       headless=headless)

        am_charts.load_page(True)
        js_code = """
var chart = am4core.create("chartdiv", am4charts.ChordDiagram);
chart.hiddenState.properties.opacity = 0;

chart.dataFields.fromName = "from";
chart.dataFields.toName = "to";
chart.dataFields.value = "value";

// make nodes draggable
var nodeTemplate = chart.nodes.template;
nodeTemplate.readerTitle = "Click to show/hide or drag to rearrange";
nodeTemplate.showSystemTooltip = true;
nodeTemplate.cursorOverStyle = am4core.MouseCursorStyle.pointer
"""
        am_charts.exec_js(js_code)

        data = [{
            "from": "A",
            "to": "D",
            "value": 1
        }, {
            "from": "B",
            "to": "D",
            "value": 1
        }, {
            "from": "B",
            "to": "E",
            "value": 1
        }, {
            "from": "B",
            "to": "C",
            "value": 1
        }, {
            "from": "C",
            "to": "E",
            "value": 1
        }, {
            "from": "E",
            "to": "D",
            "value": 1
        }, {
            "from": "C",
            "to": "A",
            "value": 1
        }, {
            "from": "G",
            "to": "A",
            "value": 1
        }, {
            "from": "D",
            "to": "B",
            "value": 1
        }]

        data = []
        for edge in graph_data.get('edges'):
            data.append({"from": edge[0], "to": edge[2], "value": 1})

        am_charts.assign_variable_js('window.chart.data', data)

        return am_charts.send_screenshot_to_slack(team_id, channel)