Ejemplo n.º 1
0
def multicloud():
    """
    Handles the functionality on the multicloud pages.
    Note: Returns a response object (often a render_template call) to flask and eventually
    to the browser.
    """

    fileManager = session_functions.loadFileManager()

    if 'cloudoption' not in session:
        session['cloudoption'] = constants.DEFAULT_CLOUD_OPTIONS
    if 'multicloudoptions' not in session:
        session['multicloudoptions'] = constants.DEFAULT_MULTICLOUD_OPTIONS

    if request.method == 'GET':
        # 'GET' request occurs when the page is first loaded.

        labels = fileManager.getActiveLabels()

        return render_template('multicloud.html', jsonStr="", labels=labels)

    if request.method == "POST":
        # 'POST' request occur when html form is submitted (i.e. 'Get Graphs', 'Download...')

        labels = fileManager.getActiveLabels()
        JSONObj = utility.generateMCJSONObj(fileManager)

        session_functions.cacheCloudOption()
        session_functions.cacheMultiCloudOptions()
        return render_template('multicloud.html', JSONObj=JSONObj, labels=labels, loading='loading')
Ejemplo n.º 2
0
def viz():
    """
    Handles the functionality on the alternate bubbleViz page with performance improvements.
    Note: Returns a response object (often a render_template call) to flask and eventually
    to the browser.
    """
    fileManager = session_functions.loadFileManager()
    if 'cloudoption' not in session:
        session['cloudoption'] = constants.DEFAULT_CLOUD_OPTIONS
    if 'bubblevisoption' not in session:
        session['bubblevisoption'] = constants.DEFAULT_BUBBLEVIZ_OPTIONS

    if request.method == "GET":
        # "GET" request occurs when the page is first loaded.
        labels = fileManager.getActiveLabels()

        return render_template('viz.html', JSONObj="", labels=labels)

    if request.method == "POST":
        # "POST" request occur when html form is submitted (i.e. 'Get Dendrogram', 'Download...')
        labels = fileManager.getActiveLabels()
        JSONObj = utility.generateJSONForD3(fileManager, mergedSet=True)

        session_functions.cacheCloudOption()
        session_functions.cacheBubbleVizOption()
        return render_template('viz.html', JSONObj=JSONObj, labels=labels, loading='loading')
Ejemplo n.º 3
0
def wordcloud():
    """
    Handles the functionality on the visualisation page -- a prototype for displaying
    single word cloud graphs.
    Note: Returns a response object (often a render_template call) to flask and eventually
    to the browser.
    """
    fileManager = session_functions.loadFileManager()
    if 'cloudoption' not in session:
        session['cloudoption'] = constants.DEFAULT_CLOUD_OPTIONS

    if request.method == "GET":
        # "GET" request occurs when the page is first loaded.
        labels = fileManager.getActiveLabels()
        # there is no wordcloud option so we don't initialize that

        return render_template('wordcloud.html', labels=labels)

    if request.method == "POST":
        # "POST" request occur when html form is submitted (i.e. 'Get Dendrogram', 'Download...')
        labels = fileManager.getActiveLabels()
        JSONObj = utility.generateJSONForD3(fileManager, mergedSet=True)

        # Create a list of column values for the word count table
        from operator import itemgetter

        terms = sorted(JSONObj["children"], key=itemgetter('size'), reverse=True)
        columnValues = []
        for term in terms:
            rows = [term["name"], term["size"]]
            columnValues.append(rows)

        session_functions.cacheCloudOption()
        return render_template('wordcloud.html', labels=labels, JSONObj=JSONObj, columnValues=columnValues)