def project_graph(request): if request.is_ajax(): boxList = request.GET.get('list') # Project Id(or Name) should be stored in SESSION projectName = request.session['projectName'] # projectName = request.GET.get('projectName') project = loadProject(request) provider = ProjectRunsTreeProvider(project) g = project.getRunsGraph() root = g.getRoot() root.w = 100 root.h = 40 root.item = WebNode('project', x=0, y=0) # Assign the width and height for box in boxList.split(','): id, w, h = box.split('-') node = g.getNode(id) if node is None: print "Get NONE node: i=%s" % id else: node.id = id node.w = float(w) node.h = float(h) lt = gg.LevelTree(g) lt.paint(createNode, createEdge) nodeList = [] for node in g.getNodes(): try: hx = node.w / 2 hy = node.h / 2 childs = [c.getName() for c in node.getChilds()] status, color = getNodeStateColor(node) info = "" if str(node.id) != "PROJECT": protocol = project.getProtocol(int(node.id)) info = provider.getObjectInfo(protocol)["values"][0] nodeList.append({ 'id': node.getName(), 'x': node.item.x - hx, 'y': node.item.y - hy, 'color': color, 'status': info, 'childs': childs }) except Exception: print "Error with node: ", node.getName() raise # print nodeList jsonStr = json.dumps(nodeList, ensure_ascii=False) return HttpResponse(jsonStr, mimetype='application/javascript')
def object_graph(request): if request.is_ajax(): boxList = request.GET.get('list') projectName = request.session['projectName'] project = loadProject(request) g = project.getSourceGraph() root = g.getRoot() root.w = 100 root.h = 40 root.item = WebNode('project', x=0, y=0) # Assign the width and height for box in boxList.split(','): id, w, h = box.split('-') node = g.getNode(id) if node is None: print "Get NONE node: i=%s" % id else: node.id = id node.w = float(w) node.h = float(h) lt = gg.LevelTree(g) lt.paint(createNode, createEdge) nodeList = [] for node in g.getNodes(): try: hx = node.w / 2 hy = node.h / 2 childs = [c.getName() for c in node.getChilds()] nodeList.append({ 'id': node.getName(), 'x': node.item.x - hx, 'y': node.item.y - hy, 'status': None, 'color': '#ADD8E6', # Lightblue 'childs': childs }) except Exception: print "Error with node: ", node.getName() raise jsonStr = json.dumps(nodeList, ensure_ascii=False) return HttpResponse(jsonStr, mimetype='application/javascript')