Ejemplo n.º 1
0
def create_dashboard(drop=False):
    from cripts.dashboards.dashboard import SavedSearch, Dashboard
    if drop:
        Dashboard.drop_collection()
        SavedSearch.drop_collection()
    defaultDashboard = Dashboard.objects(name="Default",
                                         analystId__not__exists=1,
                                         isPublic=True).first()
    if not defaultDashboard:
        defaultDashboard = Dashboard()
        defaultDashboard.name = "Default"
        defaultDashboard.isPublic = True
        defaultDashboard.save()
        for title in [
                "Counts",
        ]:
            savedSearch = SavedSearch()
            savedSearch.name = title
            savedSearch.dashboard = defaultDashboard.id
            savedSearch.isDefaultOnDashboard = True
            savedSearch.tableColumns = getColumnsForTable(title)
            if title == "Counts":
                savedSearch.sizex = 10

            savedSearch.save()
        print "Default Dashboard Created."
    else:
        print "Default Dashboard already exists."
Ejemplo n.º 2
0
def createNewDashboard(userId, name):
    """
    Creates a new dashboard for the user
    """
    if Dashboard.objects(analystId=userId,name=name):
        return
    newDash = Dashboard()
    newDash.name = name
    newDash.analystId = userId
    newDash.save()
    return newDash
Ejemplo n.º 3
0
def cloneDashboard(userId, dashboard, cloneSearches=False, skip=None):
    """
    Clones a public dashboard to a user-modified version of if.
    cloneSearches will clone all affiliated searches with the dashboard.
    Skip will skip a specific table if cloning searches
    """
    if Dashboard.objects(analystId=userId,name=dashboard.name):
        return
    newDash = Dashboard()
    newDash.name = dashboard.name
    newDash.theme = dashboard.theme
    newDash.analystId = userId
    newDash.parent = dashboard.id
    newDash.save()
    if cloneSearches:
        for search in SavedSearch.objects(dashboard = dashboard.id):
            if skip != str(search.id):
                cloneSavedSearch(search, newDash.id)
    return newDash
Ejemplo n.º 4
0
def create_dashboard(drop=False):
    from cripts.dashboards.dashboard import SavedSearch, Dashboard
    if drop:
        Dashboard.drop_collection()
        SavedSearch.drop_collection()
    defaultDashboard = Dashboard.objects(name="Default", analystId__not__exists=1 , isPublic=True).first()
    if not defaultDashboard:
        defaultDashboard = Dashboard()
        defaultDashboard.name = "Default"
        defaultDashboard.isPublic = True
        defaultDashboard.save()
        for title in ["Counts", ]:
            savedSearch = SavedSearch()
            savedSearch.name = title
            savedSearch.dashboard = defaultDashboard.id
            savedSearch.isDefaultOnDashboard = True
            savedSearch.tableColumns = getColumnsForTable(title)
            if title == "Counts":
                savedSearch.sizex = 10
                
            savedSearch.save()
        print "Default Dashboard Created."
    else:
        print "Default Dashboard already exists."