Exemplo n.º 1
0
def browse(request, name, is_mobile=False):
  engine = request.GET.get('engine', 'solr')
  collections = get_engine(request.user, engine).datasets()
  if not collections:
    return no_collections(request)

  collection = Collection2(user=request.user, name=name)
  query = {'qs': [{'q': ''}], 'fqs': [], 'start': 0}

  template = 'search.mako'
  if is_mobile:
    template = 'search_m.mako'

  return render(template, request, {
    'collection': collection,
    'query': query,
    'initial': json.dumps({
      'autoLoad': True,
      'collections': collections,
      'layout': [
          {"size":12,"rows":[{"widgets":[
              {"size":12,"name":"Grid Results","id":"52f07188-f30f-1296-2450-f77e02e1a5c0","widgetType":"resultset-widget",
               "properties":{},"offset":0,"isLoading":True,"klass":"card card-widget span12"}]}],
          "drops":["temp"],"klass":"card card-home card-column span10"}
      ],
      'is_latest': LATEST.get(),
      'engines': get_engines(request.user)
    }),
    'is_owner': True,
    'can_edit_index': can_edit_index(request.user),
    'mobile': is_mobile
  })
Exemplo n.º 2
0
def new_search(request, is_embeddable=False):
  collections = SearchController(request.user).get_all_indexes()
  if not collections:
    return no_collections(request)

  collection = Collection2(user=request.user, name=collections[0])
  query = {'qs': [{'q': ''}], 'fqs': [], 'start': 0}

  template = 'search.mako'
  if is_embeddable:
    template = 'search_embeddable.mako'

  return render(template, request, {
    'collection': collection,
    'query': query,
    'initial': json.dumps({
         'collections': collections,
         'layout': [
              {"size":2,"rows":[{"widgets":[]}],"drops":["temp"],"klass":"card card-home card-column span2"},
              {"size":10,"rows":[{"widgets":[
                  {"size":12,"name":"Filter Bar","widgetType":"filter-widget", "id":"99923aef-b233-9420-96c6-15d48293532b",
                   "properties":{},"offset":0,"isLoading":True,"klass":"card card-widget span12"}]},
                                 {"widgets":[
                  {"size":12,"name":"Grid Results","widgetType":"resultset-widget", "id":"14023aef-b233-9420-96c6-15d48293532b",
                   "properties":{},"offset":0,"isLoading":True,"klass":"card card-widget span12"}]}],
                 "drops":["temp"],"klass":"card card-home card-column span10"},
         ],
         'is_latest': LATEST.get(),
     }),
    'is_owner': True,
    'can_edit_index': can_edit_index(request.user)
  })
Exemplo n.º 3
0
Arquivo: views.py Projeto: QLGu/hue
def new_search(request):
  collections = SearchController(request.user).get_all_indexes()
  if not collections:
    return no_collections(request)

  collection = Collection2(user=request.user, name=collections[0])
  query = {'qs': [{'q': ''}], 'fqs': [], 'start': 0}

  return render('search.mako', request, {
    'collection': collection,
    'query': query,
    'initial': json.dumps({
         'collections': collections,
         'layout': [
              {"size":2,"rows":[{"widgets":[]}],"drops":["temp"],"klass":"card card-home card-column span2"},
              {"size":10,"rows":[{"widgets":[
                  {"size":12,"name":"Filter Bar","widgetType":"filter-widget", "id":"99923aef-b233-9420-96c6-15d48293532b",
                   "properties":{},"offset":0,"isLoading":True,"klass":"card card-widget span12"}]},
                                 {"widgets":[
                  {"size":12,"name":"Grid Results","widgetType":"resultset-widget", "id":"14023aef-b233-9420-96c6-15d48293532b",
                   "properties":{},"offset":0,"isLoading":True,"klass":"card card-widget span12"}]}],
                 "drops":["temp"],"klass":"card card-home card-column span10"},
         ],
         'is_latest': LATEST.get()
     }),
    'is_owner': True
  })
Exemplo n.º 4
0
Arquivo: views.py Projeto: qccash/hue
def browse(request, name):
  collections = SearchController(request.user).get_all_indexes()
  if not collections:
    return no_collections(request)

  collection = Collection2(user=request.user, name=name)
  query = {'qs': [{'q': ''}], 'fqs': [], 'start': 0}

  return render('search.mako', request, {
    'collection': collection,
    'query': query,
    'initial': json.dumps({
         'autoLoad': True,
         'collections': collections,
         'layout': [
              {"size":12,"rows":[{"widgets":[
                  {"size":12,"name":"Grid Results","id":"52f07188-f30f-1296-2450-f77e02e1a5c0","widgetType":"resultset-widget",
                   "properties":{},"offset":0,"isLoading":True,"klass":"card card-widget span12"}]}],
              "drops":["temp"],"klass":"card card-home card-column span10"}
         ],
         'is_latest': LATEST.get()
     }),
     'is_owner': True,
     'can_edit_index': can_edit_index(request.user)
  })
Exemplo n.º 5
0
def browse(request, name):
  collections = SearchController(request.user).get_all_indexes()
  if not collections:
    return no_collections(request)

  collection = Collection2(user=request.user, name=name)
  query = {'qs': [{'q': ''}], 'fqs': [], 'start': 0}

  return render('search.mako', request, {
    'collection': collection,
    'query': query,
    'initial': json.dumps({
         'autoLoad': True,
         'collections': collections,
         'layout': [
              {"size":12,"rows":[{"widgets":[
                  {"size":12,"name":"Grid Results","id":"52f07188-f30f-1296-2450-f77e02e1a5c0","widgetType":"resultset-widget",
                   "properties":{},"offset":0,"isLoading":True,"klass":"card card-widget span12"}]}],
              "drops":["temp"],"klass":"card card-home card-column span10"}
         ],
         'is_latest': LATEST.get()
     }),
     'is_owner': True,
     'can_edit_index': can_edit_index(request.user)
  })
Exemplo n.º 6
0
Arquivo: views.py Projeto: Edisnel/hue
def new_search(request):
    engine = request.GET.get('engine', 'solr')
    collections = get_engine(request.user, engine).datasets()
    if not collections:
        return no_collections(request)

    collection = Collection2(user=request.user,
                             name=collections[0],
                             engine=engine)
    query = {'qs': [{'q': ''}], 'fqs': [], 'start': 0}

    if request.GET.get('format', 'plain') == 'json':
        return JsonResponse({
            'collection': collection.get_props(request.user),
            'query': query,
            'initial': {
                'collections': collections,
                'layout': DEFAULT_LAYOUT,
                'is_latest': LATEST.get(),
                'engines': get_engines(request.user)
            }
        })
    else:
        return render(
            'search.mako', request, {
                'collection':
                collection,
                'query':
                query,
                'initial':
                json.dumps({
                    'collections': collections,
                    'layout': DEFAULT_LAYOUT,
                    'is_latest': LATEST.get(),
                    'engines': get_engines(request.user)
                }),
                'is_owner':
                True,
                'is_embeddable':
                request.GET.get('is_embeddable', False),
                'can_edit_index':
                can_edit_index(request.user)
            })
Exemplo n.º 7
0
def browse(request, name, is_mobile=False):
    collections = SearchController(request.user).get_all_indexes()
    if not collections:
        return no_collections(request)

    collection = Collection2(user=request.user, name=name)
    query = {"qs": [{"q": ""}], "fqs": [], "start": 0}

    template = "search.mako"
    if is_mobile:
        template = "search_m.mako"

    return render(
        template,
        request,
        {
            "collection": collection,
            "query": query,
            "initial": json.dumps(
                {
                    "autoLoad": True,
                    "collections": collections,
                    "layout": [
                        {
                            "size": 12,
                            "rows": [
                                {
                                    "widgets": [
                                        {
                                            "size": 12,
                                            "name": "Grid Results",
                                            "id": "52f07188-f30f-1296-2450-f77e02e1a5c0",
                                            "widgetType": "resultset-widget",
                                            "properties": {},
                                            "offset": 0,
                                            "isLoading": True,
                                            "klass": "card card-widget span12",
                                        }
                                    ]
                                }
                            ],
                            "drops": ["temp"],
                            "klass": "card card-home card-column span10",
                        }
                    ],
                    "is_latest": LATEST.get(),
                }
            ),
            "is_owner": True,
            "can_edit_index": can_edit_index(request.user),
            "mobile": is_mobile,
        },
    )
Exemplo n.º 8
0
def _get_latest():
    return hasattr(LATEST, 'get') and LATEST.get() or True
Exemplo n.º 9
0
    if 'qd' in request.GET:
      query['qd'] = request.GET.get('qd')

  template = 'search.mako'
  if is_mobile:
    template = 'search_m.mako'
  if is_embeddable:
    template = 'search_embeddable.mako'

  return render(template, request, {
    'collection': collection,
    'query': json.dumps(query),
    'initial': json.dumps({
        'collections': [],
        'layout': DEFAULT_LAYOUT,
        'is_latest': LATEST.get(),
        'engines': get_engines(request.user)
    }),
    'is_owner': collection_doc.doc.get().can_write(request.user),
    'can_edit_index': can_edit_index(request.user),
    'mobile': is_mobile,
  })

def index_m(request):
  return index(request, True)

def index_embeddable(request):
  return index(request, False, True)

def new_search(request, is_embeddable=False):
  engine = request.GET.get('engine', 'solr')
Exemplo n.º 10
0
  def get_json(self, user):
    props = self.data

    if self.document is not None:
      props['collection']['id'] = self.document.id
      props['collection']['label'] = self.document.name
      props['collection']['description'] = self.document.description

    # For backward compatibility
    if 'rows' not in props['collection']['template']:
      props['collection']['template']['rows'] = 25
    if 'showGrid' not in props['collection']['template']:
      props['collection']['template']['showGrid'] = True
    if 'showChart' not in props['collection']['template']:
      props['collection']['template']['showChart'] = False
    if 'chartSettings' not in props['collection']['template']:
      props['collection']['template']['chartSettings'] = {
        'chartType': 'bars',
        'chartSorting': 'none',
        'chartScatterGroup': None,
        'chartScatterSize': None,
        'chartScope': 'world',
        'chartX': None,
        'chartYSingle': None,
        'chartYMulti': [],
        'chartData': [],
        'chartMapLabel': None,
      }
    if 'enabled' not in props['collection']:
      props['collection']['enabled'] = True
    if 'leafletmap' not in props['collection']['template']:
      props['collection']['template']['leafletmap'] = {'latitudeField': None, 'longitudeField': None, 'labelField': None}
    if 'timeFilter' not in props['collection']:
      props['collection']['timeFilter'] = {
        'field': '',
        'type': 'rolling',
        'value': 'all',
        'from': '',
        'to': 'NOW',
        'truncate': True
      }
    if 'suggest' not in props['collection']:
      props['collection']['suggest'] = {'enabled': False, 'dictionary': ''}
    for field in props['collection']['template']['fieldsAttributes']:
      if 'type' not in field:
        field['type'] = 'string'
    if 'nested' not in props['collection'] and LATEST.get():
      props['collection']['nested'] = {
        'enabled': False,
        'schema': []
      }

    for facet in props['collection']['facets']:
      properties = facet['properties']
      if 'gap' in properties and not 'initial_gap' in properties:
        properties['initial_gap'] = properties['gap']
      if 'start' in properties and not 'initial_start' in properties:
        properties['initial_start'] = properties['start']
      if 'end' in properties and not 'initial_end' in properties:
        properties['initial_end'] = properties['end']
      if 'domain' not in properties:
        properties['domain'] = {'blockParent': [], 'blockChildren': []}

      if facet['widgetType'] == 'histogram-widget':
        if 'timelineChartType' not in properties:
          properties['timelineChartType'] = 'bar'
        if 'enableSelection' not in properties:
          properties['enableSelection'] = True
        if 'extraSeries' not in properties:
          properties['extraSeries'] = []

      if facet['widgetType'] == 'map-widget' and facet['type'] == 'field':
        facet['type'] = 'pivot'
        properties['facets'] = []
        properties['facets_form'] = {'field': '', 'mincount': 1, 'limit': 5}

    if 'qdefinitions' not in props['collection']:
      props['collection']['qdefinitions'] = []

    return json.dumps(props)
Exemplo n.º 11
0
Arquivo: views.py Projeto: QLGu/hue
  if not hue_collections or not collection_id:
    return admin_collections(request, True)

  try:
    collection_doc = Document2.objects.get(id=collection_id)
    collection_doc.doc.get().can_read_or_exception(request.user)
    collection = Collection2(request.user, document=collection_doc)
  except Exception, e:
    raise PopupException(e, title=_("Dashboard does not exist or you don't have the permission to access it."))

  query = {'qs': [{'q': ''}], 'fqs': [], 'start': 0}

  return render('search.mako', request, {
    'collection': collection,
    'query': query,
    'initial': json.dumps({'collections': [], 'layout': [], 'is_latest': LATEST.get()}),
    'is_owner': collection_doc.doc.get().can_write(request.user)
  })


def new_search(request):
  collections = SearchController(request.user).get_all_indexes()
  if not collections:
    return no_collections(request)

  collection = Collection2(user=request.user, name=collections[0])
  query = {'qs': [{'q': ''}], 'fqs': [], 'start': 0}

  return render('search.mako', request, {
    'collection': collection,
    'query': query,
Exemplo n.º 12
0
def new_search(request, is_embeddable=False):
    collections = SearchController(request.user).get_all_indexes()
    if not collections:
        return no_collections(request)

    collection = Collection2(user=request.user, name=collections[0])
    query = {"qs": [{"q": ""}], "fqs": [], "start": 0}

    template = "search.mako"
    if is_embeddable:
        template = "search_embeddable.mako"

    return render(
        template,
        request,
        {
            "collection": collection,
            "query": query,
            "initial": json.dumps(
                {
                    "collections": collections,
                    "layout": [
                        {
                            "size": 2,
                            "rows": [{"widgets": []}],
                            "drops": ["temp"],
                            "klass": "card card-home card-column span2",
                        },
                        {
                            "size": 10,
                            "rows": [
                                {
                                    "widgets": [
                                        {
                                            "size": 12,
                                            "name": "Filter Bar",
                                            "widgetType": "filter-widget",
                                            "id": "99923aef-b233-9420-96c6-15d48293532b",
                                            "properties": {},
                                            "offset": 0,
                                            "isLoading": True,
                                            "klass": "card card-widget span12",
                                        }
                                    ]
                                },
                                {
                                    "widgets": [
                                        {
                                            "size": 12,
                                            "name": "Grid Results",
                                            "widgetType": "resultset-widget",
                                            "id": "14023aef-b233-9420-96c6-15d48293532b",
                                            "properties": {},
                                            "offset": 0,
                                            "isLoading": True,
                                            "klass": "card card-widget span12",
                                        }
                                    ]
                                },
                            ],
                            "drops": ["temp"],
                            "klass": "card card-home card-column span10",
                        },
                    ],
                    "is_latest": LATEST.get(),
                }
            ),
            "is_owner": True,
            "can_edit_index": can_edit_index(request.user),
        },
    )
Exemplo n.º 13
0
        if "qd" in request.GET:
            query["qd"] = request.GET.get("qd")

    template = "search.mako"
    if is_mobile:
        template = "search_m.mako"
    if is_embeddable:
        template = "search_embeddable.mako"

    return render(
        template,
        request,
        {
            "collection": collection,
            "query": json.dumps(query),
            "initial": json.dumps({"collections": [], "layout": [], "is_latest": LATEST.get()}),
            "is_owner": collection_doc.doc.get().can_write(request.user),
            "can_edit_index": can_edit_index(request.user),
            "mobile": is_mobile,
        },
    )


def index_m(request):
    return index(request, True)


def index_embeddable(request):
    return index(request, False, True)

Exemplo n.º 14
0
  if request.method == 'GET':
    if 'q' in request.GET:
      query['qs'][0]['q'] = request.GET.get('q')
    if 'qd' in request.GET:
      query['qd'] = request.GET.get('qd')

  template = 'search.mako'
  if is_mobile:
    template = 'search_m.mako'
  if is_embeddable:
    template = 'search_embeddable.mako'

  return render(template, request, {
    'collection': collection,
    'query': json.dumps(query),
    'initial': json.dumps({'collections': [], 'layout': [], 'is_latest': LATEST.get()}),
    'is_owner': collection_doc.doc.get().can_write(request.user),
    'can_edit_index': can_edit_index(request.user),
    'mobile': is_mobile
  })

def index_m(request):
  return index(request, True)

def index_embeddable(request):
  return index(request, False, True)

def new_search(request, is_embeddable=False):
  collections = SearchController(request.user).get_all_indexes()
  if not collections:
    return no_collections(request)
Exemplo n.º 15
0
    def get_json(self, user):
        props = self.data

        if self.document is not None:
            props['collection']['id'] = self.document.id
            props['collection']['label'] = self.document.name
            props['collection']['description'] = self.document.description

        # For backward compatibility
        if 'rows' not in props['collection']['template']:
            props['collection']['template']['rows'] = 25
        if 'showGrid' not in props['collection']['template']:
            props['collection']['template']['showGrid'] = True
        if 'showChart' not in props['collection']['template']:
            props['collection']['template']['showChart'] = False
        if 'chartSettings' not in props['collection']['template']:
            props['collection']['template']['chartSettings'] = {
                'chartType': 'bars',
                'chartSorting': 'none',
                'chartScatterGroup': None,
                'chartScatterSize': None,
                'chartScope': 'world',
                'chartX': None,
                'chartYSingle': None,
                'chartYMulti': [],
                'chartData': [],
                'chartMapLabel': None,
            }
        if 'enabled' not in props['collection']:
            props['collection']['enabled'] = True
        if 'leafletmap' not in props['collection']['template']:
            props['collection']['template']['leafletmap'] = {
                'latitudeField': None,
                'longitudeField': None,
                'labelField': None
            }
        if 'timeFilter' not in props['collection']:
            props['collection']['timeFilter'] = {
                'field': '',
                'type': 'rolling',
                'value': 'all',
                'from': '',
                'to': 'NOW',
                'truncate': True
            }
        if 'suggest' not in props['collection']:
            props['collection']['suggest'] = {
                'enabled': False,
                'dictionary': ''
            }
        for field in props['collection']['template']['fieldsAttributes']:
            if 'type' not in field:
                field['type'] = 'string'
        if 'nested' not in props['collection'] and LATEST.get():
            props['collection']['nested'] = {'enabled': False, 'schema': []}

        for facet in props['collection']['facets']:
            properties = facet['properties']
            if 'gap' in properties and not 'initial_gap' in properties:
                properties['initial_gap'] = properties['gap']
            if 'start' in properties and not 'initial_start' in properties:
                properties['initial_start'] = properties['start']
            if 'end' in properties and not 'initial_end' in properties:
                properties['initial_end'] = properties['end']
            if 'domain' not in properties:
                properties['domain'] = {'blockParent': [], 'blockChildren': []}

            if facet['widgetType'] == 'histogram-widget':
                if 'timelineChartType' not in properties:
                    properties['timelineChartType'] = 'bar'
                if 'enableSelection' not in properties:
                    properties['enableSelection'] = True
                if 'extraSeries' not in properties:
                    properties['extraSeries'] = []

            if facet['widgetType'] == 'map-widget' and facet['type'] == 'field':
                facet['type'] = 'pivot'
                properties['facets'] = []
                properties['facets_form'] = {
                    'field': '',
                    'mincount': 1,
                    'limit': 5
                }

        if 'qdefinitions' not in props['collection']:
            props['collection']['qdefinitions'] = []

        return json.dumps(props)