def mindmap(team_id=None, channel=None, params=None): (go_js, graph_data) = Go_Js_Views._get_graph_data(params, "mindmap",headless=True) go_js.load_page(False) (nodes, edges) = Go_Js_Views._get_nodes_and_edges(graph_data,text_field='Summary') data = { "class": "go.TreeModel", "nodeDataArray": []} width = Misc.to_int(Misc.array_pop(params, 0)) height = Misc.to_int(Misc.array_pop(params, 0)) if width and height: go_js.browser().sync__browser_width(width,height) else: go_js.set_browser_width_based_on_nodes(nodes) nodes_indexed = {} for index, node in enumerate(nodes): key = node.get('key') text = "{1} | {0}".format(key,node.get('text')) nodes_indexed[key] = {'index':index, 'text': text } root_node_text = "{1} | {0}".format(nodes[0].get('key'), nodes[0].get('text')) data['nodeDataArray'].append({"key": 0, "text": root_node_text }) # add root node first for edge in edges: from_key = edge['from'] to_key = edge['to'] from_issue = nodes_indexed.get(from_key) to_issue = nodes_indexed.get(to_key) if from_issue: parent = nodes_indexed.get(edge['from']).get('index') else: parent = from_key if to_issue: key = nodes_indexed.get(edge['to' ]).get('index') text = nodes_indexed.get(edge['to' ]).get('text') else: key = to_key text = to_key item = {"key": key, "parent": parent, "text": text, "brush": Misc.get_random_color()} data['nodeDataArray'].append(item) go_js.invoke_js("create_graph_from_json", data) js_code = 'layoutAll()' go_js.api_browser.sync__await_for_element('#animationFinished') Dev.pprint(go_js.exec_js(js_code)) return go_js.send_screenshot_to_slack(team_id=team_id, channel=channel)
def screenshot(team_id=None, channel=None, params=[]): url = params.pop(0).replace('<', '').replace( '>', '') # fix extra chars added by Slack delay = Misc.to_int(Misc.array_pop(params, 0)) slack_message( ":point_right: taking screenshot of url: {0}".format(url), [], channel, team_id) browser_helper = Browser_Lamdba_Helper().setup() png_data = browser_helper.get_screenshot_png(url, full_page=True, delay=delay) return browser_helper.send_png_data_to_slack(team_id, channel, url, png_data)
def render(team_id, channel, params): if params: target = params.pop(0) delay = Misc.to_int(Misc.array_pop(params, 0)) if len(params) == 4: clip = { 'x': int(params[0]), 'y': int(params[1]), 'width': int(params[2]), 'height': int(params[3]) } else: clip = None else: return None slack_message(":point_right: rendering file `{0}`".format(target), [], channel, team_id) return Browser_Lamdba_Helper().setup().render_file(team_id, channel, target, clip=clip, delay=delay)