Ejemplo n.º 1
0
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")
Ejemplo n.º 2
0
def contentContext(request, project):
    from pyworkflow.gui.tree import ProjectRunsTreeProvider

    projectName = project.getShortName()
    print "ProjectName: ", projectName
    project_settings = project.getSettings()
    request.session['projectPath'] = project.getPath()
    request.session['projectName'] = projectName

    provider = ProjectRunsTreeProvider(project)
    runs = formatProvider(provider, "runs")
    request.session['runs'] = runs

    # Get the selected runs stored in BD
    selectedRuns = project_settings.runSelection

    # Get the run mode view (0:list / 1:graph / 2:small graph) stored in BD
    runsView = project_settings.runsView.get()

    # load the protocol tree current active
    htmlTree = loadProtTree(project)

    # get the choices to load protocol trees
    choices = project.getProtocolViews()

    # get the choice current
    choiceSelected = choices.index(project.getCurrentProtocolView().text.get())

    # show the project name in the header.html
    projectNameHeader = 'Project ' + str(projectName)

    context = {
        'projectName': projectName,
        'view': 'protocols',
        'editTool': getResourceIcon('edit_toolbar'),
        'copyTool': getResourceIcon('copy_toolbar'),
        'deleteTool': getResourceIcon('delete_toolbar'),
        'browseTool': getResourceIcon('browse_toolbar'),
        'stopTool': getResourceIcon('stop_toolbar'),
        'analyzeTool': getResourceIcon('analyze_toolbar'),
        'treeTool': getResourceIcon('tree_toolbar'),
        'listTool': getResourceIcon('list_toolbar'),
        'graph_utils': getResourceJs('graph_utils'),
        'project_content_utils': getResourceJs('project_content_utils'),
        'jquery_cookie': getResourceJs('jquery_cookie'),
        'jquery_treeview': getResourceJs('jquery_treeview'),
        'project_content_css': getResourceCss('project_content'),
        'protTreeHtml': htmlTree,
        'choices': choices,
        'choiceSelected': choiceSelected,
        'runs': runs,
        'columns': provider.getColumns(),
        'projectNameHeader': projectNameHeader,
        'runsView': runsView,
        'selectedRuns': selectedRuns
    }

    context = base_flex(request, context)

    return context
Ejemplo n.º 3
0
def contentContext(request, project):
    from pyworkflow.gui.tree import ProjectRunsTreeProvider
    
    projectName = project.getShortName()
    print "ProjectName: ", projectName
    project_settings = project.getSettings()
    request.session['projectPath'] = project.getPath()
    request.session['projectName'] = projectName
    
    provider = ProjectRunsTreeProvider(project)
    runs = formatProvider(provider, "runs")
    request.session['runs'] = runs

    # Get the selected runs stored in BD    
    selectedRuns = project_settings.runSelection

    # Get the run mode view (0:list / 1:graph / 2:small graph) stored in BD
    runsView = project_settings.runsView.get()
        
    # load the protocol tree current active
    htmlTree = loadProtTree(project)
    
    # get the choices to load protocol trees
    choices = project.getProtocolViews()

    # get the choice current 
    choiceSelected =  choices.index(project.getCurrentProtocolView().text.get())
    
    # show the project name in the header.html
    projectNameHeader = 'Project '+ str(projectName)
    
    context = {'projectName': projectName,
               'view':'protocols',
               'editTool': getResourceIcon('edit_toolbar'),
               'copyTool': getResourceIcon('copy_toolbar'),
               'deleteTool': getResourceIcon('delete_toolbar'),
               'browseTool': getResourceIcon('browse_toolbar'),
               'stopTool': getResourceIcon('stop_toolbar'),
               'analyzeTool': getResourceIcon('analyze_toolbar'),
               'treeTool': getResourceIcon('tree_toolbar'),
               'listTool': getResourceIcon('list_toolbar'),
               'graph_utils': getResourceJs('graph_utils'),
               'project_content_utils': getResourceJs('project_content_utils'),
               'jquery_cookie': getResourceJs('jquery_cookie'),
               'jquery_treeview': getResourceJs('jquery_treeview'),
               'project_content_css':getResourceCss('project_content'),
               'protTreeHtml': htmlTree,
               'choices':choices,
               'choiceSelected': choiceSelected,
               'runs': runs,
               'columns': provider.getColumns(),
               'projectNameHeader': projectNameHeader, 
               'runsView': runsView,
               'selectedRuns': selectedRuns
               }

    context = base_flex(request, context)
    
    return context
Ejemplo n.º 4
0
def contentContext(request, project, serviceName=None):
    from pyworkflow.gui.tree import ProjectRunsTreeProvider

    projectName = project.getShortName()
    if serviceName is None:
        serviceName = getVarFromRequest(request, SERVICE_NAME)

    project_settings = project.getSettings()
    request.session[CTX_PROJECT_PATH] = project.getPath()
    request.session[PROJECT_NAME] = projectName

    provider = ProjectRunsTreeProvider(project)
    runs = formatProvider(provider, "runs")
    request.session['runs'] = runs

    # Get the selected runs stored in BD
    selectedRuns = project_settings.runSelection

    # Get the run mode view (0:list / 1:graph / 2:small graph) stored in BD
    runsView = project_settings.runsView.get()

    # load the protocol tree current active
    htmlTree = loadProtTree(project, serviceName)

    # get the choices to load protocol trees
    choices = project.getProtocolViews()

    # get the choice current
    choiceSelected = choices.index(project.getCurrentProtocolView().text.get())

    context = {
        CTX_PROJECT_NAME: projectName,
        'view': 'protocols',
        'editTool': getResourceIcon('edit_toolbar'),
        'copyTool': getResourceIcon('copy_toolbar'),
        'deleteTool': getResourceIcon('delete_toolbar'),
        'browseTool': getResourceIcon('browse_toolbar'),
        'stopTool': getResourceIcon('stop_toolbar'),
        'analyzeTool': getResourceIcon('analyze_toolbar'),
        'treeTool': getResourceIcon('tree_toolbar'),
        'listTool': getResourceIcon('list_toolbar'),
        'graph_utils': getResourceJs('graph_utils'),
        'project_content_utils': getResourceJs('project_content_utils'),
        'jquery_cookie': getResourceJs('jquery_cookie'),
        'jquery_treeview': getResourceJs('jquery_treeview'),
        'project_content_css': getResourceCss('project_content'),
        'protTreeHtml': htmlTree,
        'choices': choices,
        'choiceSelected': choiceSelected,
        'runs': runs,
        'columns': provider.getColumns(),
        'runsView': runsView,
        'selectedRuns': selectedRuns,
        SERVICE_NAME: serviceName
    }

    context = base_flex(request, context)

    return context
Ejemplo n.º 5
0
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')
Ejemplo n.º 6
0
def run_table_graph(request):
    from pyworkflow.gui.tree import ProjectRunsTreeProvider

    try:
        projectName = request.session['projectName']
        project = loadProject(request)
        project_settings = project.getSettings()
        provider = ProjectRunsTreeProvider(project)

        runs = request.session['runs']
        runsNew = formatProvider(provider, "runs")

        refresh = False
        listNewElm = []

        if len(runs) != len(runsNew):
            print 'Change detected, different size'
            refresh = True
        else:
            for kx, vx in runs:
                for ky, vy in runsNew:
                    if kx == ky and vx != vy:
                        print 'Change detected', vx, vy
                        #                   refresh = True
                        listNewElm.append(vy)
        if refresh:
            request.session['runs'] = runsNew

            # Get the selected runs stored in BD
            selectedRuns = project_settings.runSelection

            # Get the run mode view (0:list / 1:graph / 2:small graph) stored in BD
            runsView = project_settings.runsView.get()

            context = {
                'runs': runsNew,
                'columns': provider.getColumns(),
                'runsView': runsView,
                'selectedRuns': selectedRuns
            }

            return render_to_response('project_content/run_table_graph.html',
                                      context)

        elif listNewElm:
            request.session['runs'] = runsNew
            jsonStr = json.dumps(listNewElm, ensure_ascii=False)
            return HttpResponse(jsonStr, mimetype='application/json')

        else:
            print "No changes detected"
            return HttpResponse("ok", mimetype='text/plain')

    except Exception:
        print "Stopped script"
        return HttpResponse("stop", mimetype='text/plain')
Ejemplo n.º 7
0
def run_table_graph(request):
    from pyworkflow.gui.tree import ProjectRunsTreeProvider
    
    try:
        projectName = request.session['projectName']
        project = loadProject(request)
        project_settings = project.getSettings()
        provider = ProjectRunsTreeProvider(project)
        
        runs = request.session['runs']
        runsNew = formatProvider(provider, "runs")
        
        refresh = False
        listNewElm = []
        
        if len(runs) != len(runsNew):
            print 'Change detected, different size'
            refresh = True
        else:
            for kx, vx in runs:
                for ky, vy in runsNew:
                    if kx == ky and vx != vy:
                        print 'Change detected', vx, vy
    #                   refresh = True
                        listNewElm.append(vy)
        if refresh:
            request.session['runs'] = runsNew
            
            # Get the selected runs stored in BD    
            selectedRuns = project_settings.runSelection
            
            # Get the run mode view (0:list / 1:graph / 2:small graph) stored in BD
            runsView = project_settings.runsView.get()
            
            context = {'runs': runsNew,
                       'columns': provider.getColumns(),
                       'runsView': runsView,
                       'selectedRuns' : selectedRuns}
            
            return render_to_response('project_content/run_table_graph.html', context)
        
        elif listNewElm:
            request.session['runs'] = runsNew
            jsonStr = json.dumps(listNewElm, ensure_ascii=False)
            return HttpResponse(jsonStr, mimetype='application/json')
        
        else:
            print "No changes detected"
            return HttpResponse("ok", mimetype='text/plain')
        
    except Exception:
        print "Stopped script"
        return HttpResponse("stop", mimetype='text/plain')