Example #1
0
def editor(request):
  editor_id = request.GET.get('editor')

  if editor_id:
    editor = Notebook(document=Document2.objects.get(id=editor_id))
  else:
    editor = Notebook()
    data = editor.get_data()
    data['name'] = 'Hive SQL Editor'
    data['snippets'] = json.loads('[{"id":"c111cbb4-f475-4050-c5a1-02df6c31e3d8","name":"","type":"hive","editorMode":"text/x-hiveql","statement_raw":"Example: SELECT * FROM tablename, or press CTRL + space","codemirrorSize":100,"status":"ready","properties":{"settings":[],"files":[]},"variables":[],"variableNames":[],"statement":"Example: SELECT * FROM tablename, or press CTRL + space","result":{"id":"149347d9-3ae7-8d06-4cc8-d4bce5e72dc8","type":"table","hasResultset":true,"handle":{},"meta":[],"cleanedMeta":[],"fetchedOnce":false,"startTime":"2015-07-17T20:38:21.970Z","endTime":"2015-07-17T20:38:21.970Z","executionTime":0,"cleanedNumericMeta":[],"cleanedStringMeta":[],"cleanedDateTimeMeta":[],"data":[],"logs":"","logLines":0,"errors":"","hasSomeResults":false},"showGrid":true,"showChart":false,"showLogs":false,"progress":0,"size":12,"offset":0,"isLoading":false,"klass":"snippet card card-widget","editorKlass":"editor span12","resultsKlass":"results hive","errorsKlass":"results hive alert alert-error","chartType":"bars","chartSorting":"none","chartYMulti":[],"chartData":[],"tempChartOptions":{},"isLeftPanelVisible":false,"codeVisible":true,"settingsVisible":false,"checkStatusTimeout":null}]')
    editor.data = json.dumps(data)

  autocomplete_base_url = ''
  try:
    autocomplete_base_url = reverse('beeswax:api_autocomplete_databases', kwargs={})
  except:
    LOG.exception('failed to get autocomplete base url')

  return render('editor.mako', request, {
      'notebooks_json': json.dumps([editor.get_data()]),
      'options_json': json.dumps({
          'languages': [{"name": "Hive SQL", "type": "hive"}],
          'snippet_placeholders' : {
              'scala': _('Example: 1 + 1, or press CTRL + space'),
              'python': _('Example: 1 + 1, or press CTRL + space'),
              'impala': _('Example: SELECT * FROM tablename, or press CTRL + space'),
              'hive': _('Example: SELECT * FROM tablename, or press CTRL + space'),
              'text': _('<h2>This is a text snippet</h2>Type your text here')
          }
      }),
      'autocomplete_base_url': autocomplete_base_url,
  })
Example #2
0
def editor(request):
    editor_id = request.GET.get('editor')

    if editor_id:
        editor = Notebook(document=Document2.objects.get(id=editor_id))
    else:
        editor = Notebook()
        data = editor.get_data()
        data['name'] = 'Hive SQL Editor'
        data['snippets'] = json.loads(
            '[{"id":"c111cbb4-f475-4050-c5a1-02df6c31e3d8","name":"","type":"hive","editorMode":"text/x-hiveql","statement_raw":"Example: SELECT * FROM tablename, or press CTRL + space","codemirrorSize":100,"status":"ready","properties":{"settings":[],"files":[]},"variables":[],"variableNames":[],"statement":"Example: SELECT * FROM tablename, or press CTRL + space","result":{"id":"149347d9-3ae7-8d06-4cc8-d4bce5e72dc8","type":"table","hasResultset":true,"handle":{},"meta":[],"cleanedMeta":[],"fetchedOnce":false,"startTime":"2015-07-17T20:38:21.970Z","endTime":"2015-07-17T20:38:21.970Z","executionTime":0,"cleanedNumericMeta":[],"cleanedStringMeta":[],"cleanedDateTimeMeta":[],"data":[],"logs":"","logLines":0,"errors":"","hasSomeResults":false},"showGrid":true,"showChart":false,"showLogs":false,"progress":0,"size":12,"offset":0,"isLoading":false,"klass":"snippet card card-widget","editorKlass":"editor span12","resultsKlass":"results hive","errorsKlass":"results hive alert alert-error","chartType":"bars","chartSorting":"none","chartYMulti":[],"chartData":[],"tempChartOptions":{},"isLeftPanelVisible":false,"codeVisible":true,"settingsVisible":false,"checkStatusTimeout":null}]'
        )
        editor.data = json.dumps(data)

    autocomplete_base_url = ''
    try:
        autocomplete_base_url = reverse('beeswax:api_autocomplete_databases',
                                        kwargs={})
    except:
        LOG.exception('failed to get autocomplete base url')

    return render(
        'editor.mako', request, {
            'notebooks_json':
            json.dumps([editor.get_data()]),
            'options_json':
            json.dumps({
                'languages': [{
                    "name": "Hive SQL",
                    "type": "hive"
                }],
                'snippet_placeholders': {
                    'scala':
                    _('Example: 1 + 1, or press CTRL + space'),
                    'python':
                    _('Example: 1 + 1, or press CTRL + space'),
                    'impala':
                    _('Example: SELECT * FROM tablename, or press CTRL + space'
                      ),
                    'hive':
                    _('Example: SELECT * FROM tablename, or press CTRL + space'
                      ),
                    'text':
                    _('<h2>This is a text snippet</h2>Type your text here')
                }
            }),
            'autocomplete_base_url':
            autocomplete_base_url,
        })
Example #3
0
def editor(request):
  notebook_id = request.GET.get('notebook')

  if notebook_id:
    notebook = Notebook(document=Document2.objects.get(id=notebook_id))
  else:
    notebook = Notebook()

  autocomplete_base_url = ''
  try:
    autocomplete_base_url = reverse('beeswax:api_autocomplete_databases', kwargs={})
  except:
    LOG.exception('failed to get autocomplete base url')

  return render('editor.mako', request, {
      'notebooks_json': json.dumps([notebook.get_data()]),
      'options_json': json.dumps({
          'languages': LANGUAGES.get(),
          'snippet_placeholders' : {
              'scala': _('Example: 1 + 1, or press CTRL + space'),
              'python': _('Example: 1 + 1, or press CTRL + space'),
              'impala': _('Example: SELECT * FROM tablename, or press CTRL + space'),
              'hive': _('Example: SELECT * FROM tablename, or press CTRL + space'),
              'text': _('<h2>This is a text snippet</h2>Type your text here')
          }
      }),
      'autocomplete_base_url': autocomplete_base_url,
  })
Example #4
0
File: views.py Project: hwl-py/hue
def notebook(request):
  notebook_id = request.GET.get('notebook')

  if notebook_id:
    notebook = Notebook(document=Document2.objects.get(id=notebook_id))
  else:
    notebook = Notebook()

  autocomplete_base_url = ''
  try:
    autocomplete_base_url = reverse('beeswax:api_autocomplete_databases', kwargs={})
  except:
    LOG.exception('failed to get autocomplete base url')

  return render('notebook.mako', request, {
      'notebooks_json': json.dumps([notebook.get_data()]),
      'options_json': json.dumps({
          'languages': LANGUAGES.get(),
          'snippet_placeholders' : {
              'scala': _('/** Example: 1 + 1, or press CTRL + space */'),
              'python': _('# Example: 1 + 1, or press CTRL + space'),
              'impala': _('-- Example: SELECT * FROM tablename, or press CTRL + space'),
              'hive': _('-- Example: SELECT * FROM tablename, or press CTRL + space'),
              'text': _('<h2>This is a text snippet</h2>Type your text here')
          },
          'session_properties': SparkApi.PROPERTIES
      }),
      'autocomplete_base_url': autocomplete_base_url,
      'is_yarn_mode': LIVY_SERVER_SESSION_KIND.get()
  })
Example #5
0
def notebook(request):
    notebook_id = request.GET.get('notebook')

    if notebook_id:
        notebook = Notebook(document=Document2.objects.get(id=notebook_id))
    else:
        notebook = Notebook()

    autocomplete_base_url = ''
    try:
        autocomplete_base_url = reverse('beeswax:api_autocomplete_databases',
                                        kwargs={})
    except:
        LOG.exception('failed to get autocomplete base url')

    return render(
        'notebook.mako', request, {
            'notebooks_json':
            json.dumps([notebook.get_data()]),
            'options_json':
            json.dumps({
                'languages': LANGUAGES.get(),
                'snippet_placeholders': {
                    'scala':
                    _('/** Example: 1 + 1, or press CTRL + space */'),
                    'python':
                    _('# Example: 1 + 1, or press CTRL + space'),
                    'impala':
                    _('-- Example: SELECT * FROM tablename, or press CTRL + space'
                      ),
                    'hive':
                    _('-- Example: SELECT * FROM tablename, or press CTRL + space'
                      ),
                    'text':
                    _('<h2>This is a text snippet</h2>Type your text here'),
                    'r':
                    _('# Example: 1 + 1, or press CTRL + space')
                },
                'session_properties': SparkApi.PROPERTIES
            }),
            'autocomplete_base_url':
            autocomplete_base_url,
            'is_yarn_mode':
            LIVY_SERVER_SESSION_KIND.get()
        })
Example #6
0
def editor(request):
    notebook_id = request.GET.get('notebook')

    if notebook_id:
        notebook = Notebook(
            document=Document2.objects.get(id=notebook_id))  # Todo perms
    else:
        notebook = Notebook()

    autocomplete_base_url = ''
    try:
        autocomplete_base_url = reverse('beeswax:api_autocomplete_databases',
                                        kwargs={})
    except:
        pass

    return render(
        'editor.mako', request, {
            'notebooks_json':
            json.dumps([notebook.get_data()]),
            'options_json':
            json.dumps({
                'languages': LANGUAGES.get(),
                'snippet_placeholders': {
                    'scala':
                    _('Example: 1 + 1, or press CTRL + space'),
                    'python':
                    _('Example: 1 + 1, or press CTRL + space'),
                    'impala':
                    _('Example: SELECT * FROM tablename, or press CTRL + space'
                      ),
                    'hive':
                    _('Example: SELECT * FROM tablename, or press CTRL + space'
                      ),
                    'text':
                    _('<h2>This is a text snippet</h2>Type your text here')
                }
            }),
            'autocomplete_base_url':
            autocomplete_base_url,
        })
Example #7
0
def editor(request):
  notebook_id = request.GET.get('notebook')
  
  if notebook_id:
    notebook = Notebook(document=Document2.objects.get(id=notebook_id)) # Todo perms
  else:
    notebook = Notebook()
    
  return render('editor.mako', request, {
      'notebooks_json': json.dumps([notebook.get_data()]),
      'options_json': json.dumps({
          'languages': LANGUAGES.get(),
          'snippet_placeholders' : {
              'scala': _('Example: 1 + 1, or press CTRL + space'),
              'python': _('Example: 1 + 1, or press CTRL + space'),
              'impala': _('Example: SELECT * FROM tablename, or press CTRL + space'),
              'hive': _('Example: SELECT * FROM tablename, or press CTRL + space'),
              'text': _('<h2>This is a text snippet</h2>Type your text here')
          }
      })
  })