aboutsummaryrefslogtreecommitdiff
blob: f5b822460c60805a6dd9b28cdc6ba977d3a67581 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
{% extends "layout.html" %}
{% block title %}Your Account{% endblock %}
{% block script %}
{{ importer.load_js('jquery.min') }}
{{ importer.load_js('jquery-ui.min') }}
<script type="text/javascript">
$(document).ready(function() {
  function post_api_key_query(elem) {
    $.ajax({
      url: "{{ url_for('api_generate_api_key') }}",
      dataType: 'json',
      type: 'POST',
      error: function(req, xxx, error) {
        alert('Unknown error occurred.');
      },
      success: function(data) {
        $('#api_key').html('<strong>' + data.apikey + '</strong>');
      }
    });
  };

  $('#new_key_button').click(function() {
    elem = $('#api_key');
    if (elem.text() != 'unset') {
      $('#warn_dialog').dialog({
        title: "API key already exists!",
        modal: true,
        buttons: {
        "Cancel": function() { $(this).dialog("close"); },
        "Generate New": function() { post_api_key_query(elem); $(this).dialog("close"); }
      }
      });
    } else
      post_api_key_query(elem);
  });
});
</script>
{{ importer.load_css('ui-lightness/jquery-ui') }}
{% endblock %}
{% block body %}
<h2>Account overview</h2>
<dl>
  <dt>Developer email</dt>
  <dd>{{ g.user.email }}</dd>
  <dt>API token <button id="new_key_button">Generate</button></dt>
  <dd>Your API token is <span id="api_key">
  {%- if g.user.apitoken -%}
  <tt>{{ g.user.apitoken }}</tt><br>
  Please keep it safe.
  {% else -%}
  unset
  {%- endif -%}
  </span>
  </dd>
</dl>
<span id="warn_dialog" style="display: none;">FIXME: Need a nice description here ;)</span>
{% endblock %}