summaryrefslogtreecommitdiffstats
path: root/google-appengine/google/appengine/ext/admin/templates/datastore.html
blob: 3ae084d1cd12ffd50643d71cc1763b9eedacba9d (plain) (blame)
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
{% extends "base.html" %}

{% block title %}{{ application_name }} Development Console - Datastore Viewer{% endblock %}

{% block head %}
  <style type="text/css">{% include "css/datastore.css" %}</style>
  <style type="text/css">{% include "css/pager.css" %}</style>
  <script type="text/javascript">
  //<![CDATA[

  {% if in_production %}
  function manageCreateButton() {
    var input = document.getElementById("kind_input");
    var button = document.getElementById("create_button");
    if (input && button) {
      if (input.value.length == 0) {
        button.disabled = true;
      } else {
        button.disabled = false;
      }
    }
  }
  {% endif %}

  {% if entities %}
  function checkAllEntities() {
    var allCheckBox = document.getElementById("allkeys");
    var check = allCheckBox.checked;
    for (var i = 1; i <= {{ entities|length }}; i++) {
      var box = document.getElementById("key" + i);
      if (box)
        box.checked = check;
    }
    updateDeleteButtonAndCheckbox();
  }

  function updateDeleteButtonAndCheckbox() {
    var button = document.getElementById("delete_button");
    var uncheck = false;
    var disable = true;
    for (var i = 1; i <= {{ entities|length }}; i++) {
      var box = document.getElementById("key" + i);
      if (box) {
        if (box.checked) {
          disable = false;
        } else {
          uncheck = true;
        }
      }
    }
    button.disabled = disable;
    if (uncheck)
      document.getElementById("allkeys").checked = false;
  }
  {% endif %}

  //]]>
  </script>
{% endblock %}

{% block body %}
  <h3>Datastore Viewer</h3>

  {% if in_production %}
  <div id="hint">
    The <a href="http://appengine.google.com/datastore/explorer?&app_id={{ application_name }}">Admin Console Data Viewer</a>
    allows you to run GQL queries and much more!
  </div>
  {% endif %}

  {% if message %}
  <div id="message">
    {{ message }}
  </div>
  {% endif %}

  {% if entities %}
  <div id="pagetotal">
    Results <span class="count">{{ start|add:1 }}</span> - <span class="count">{{ entities|length|add:start }}</span> of <span class="count">{{ total }}</span>
  </div>
  {% endif %}

  {% if kinds or in_production %}
  <form action="{{ request.path }}" method="get">
    <div id="datastore_search">
      {% if namespace %}
      <div class="field">
        <span class="name">Namespace</span>
        <input name="namespace" type="text" size="20" value="{{ namespace|escape }}"/>
      </div>
      {% endif %}
      <span class="field">
        <span class="name">Entity Kind:</span>
        <span class="value">
          {% if in_production %}
          <input id="kind_input" name="kind" type="text" size="8" value="{{ kind|escape }}" onkeyup="manageCreateButton()" onkeydown="manageCreateButton()"/>
          {% else %}
          <select name="kind" id="kind_input">
            {% for a_kind in kinds %}
            <option value="{{ a_kind|escape }}"{% ifequal a_kind kind %} selected="selected"{% endifequal %}>{{ a_kind|escape }}</option>
            {% endfor %}
          </select>
          {% endif %}
        </span>
      </span>
      <span class="buttons">
        <input type="submit" value="List Entities"/>
        <input type="button" id="create_button"  onclick="location.href='{{ datastore_edit_path }}?namespace={{ namespace|escape }}&amp;kind=' + encodeURIComponent(document.getElementById('kind_input').value) + '&amp;next={{ request.uri|urlencode }}'" value="Create New Entity"/>
      </span>
    </div>
  </form>
  {% else %}
  <div id="datastore_empty">
    The datastore is empty.  You need to add data programatically before you can use this tool to view and edit it.
  </div>
  {% endif %}

  {% if entities %}
    <form action="{{ datastore_batch_edit_path }}" method="post">
      <input type="hidden" name="kind" value="{{ kind|escape }}"/>
      <input type="hidden" name="numkeys" value="{{ entities|length }}"/>
      <input type="hidden" name="next" value="{{ start_base_url }}"/>
      <input type="hidden" name="action" value="Delete"/>
      <table class="entities">
        <thead>
        <tr>
          <th><input id="allkeys" type="checkbox" onclick="checkAllEntities();"/></th>
          <th>Key</th>
          <th>ID</th>
          <th>Key Name</th>
          {% for header in headers %}
            <th style="cursor: pointer" onclick="document.location.href='{{ order_base_url }}&amp;order={% ifequal order header.name %}-{% endifequal %}{{ header.name|urlencode }}&amp;order_type={{ header.type|urlencode }}'"><a href="{{ order_base_url }}&amp;order={% ifequal order header.name %}-{% endifequal %}{{ header.name|urlencode }}&amp;order_type={{ header.type|urlencode }}" onclick="return false">{{ header.name }}</a></th>
          {% endfor %}
        </tr>
        {% for entity in entities %}
          <tr class="{% if forloop.counter|divisibleby:2 %}even{% else %}odd{% endif %}">
            <td><input id="key{{ forloop.counter }}" type="checkbox" name="key{{ forloop.counter }}" value="{{ entity.key|escape }}" onclick="updateDeleteButtonAndCheckbox();"/></td>
            <td onclick="location.href='{{ entity.edit_uri|escape }}'"><a href="{{ entity.edit_uri|escape }}" title="Edit entity #{{ entity.key|escape }}" onclick="return false">{{ entity.shortened_key|escape }}</a></td>
            <td>
              {% if entity.key_id %}
                {{entity.key_id}}
              {% endif %}
            </td>
            <td>
              {% if entity.key_name %}
                {{entity.key_name}}
              {% endif %}
            </td>
            {% for attribute in entity.attributes %}
              <td onclick="location.href='{{ entity.edit_uri|escape }}&amp;focus={{ attribute.name|urlencode }}'">{{ attribute.short_value|truncatewords:20|escape }}{{ attribute.additional_html|safe }}</td>
            {% endfor %}
          </tr>
        {% endfor %}
      </table>
       <div class="entities g-section g-tpl-50-50">
          <div class="g-unit g-first">
            <div id="entities-control"><input id="delete_button" type="submit" value="Delete" onclick="return confirm('Are you sure you wish to delete these entities?')" /></div>
          </div>
          <div class="g-unit">
            <div id="entities-pager">
            {% if pages %}
              {% include "pager.html" %}
            {% endif %}
            </div>
          </div>
        </div>
    </form>
  {% else %}
    {% if kind %}
      <p style="font-size: medium">Sorry, there are no entities of kind &quot;{{ kind|escape }}&quot; in your datastore.</p>
    {% endif %}
  {% endif %}
{% endblock %}

{% block final %}
  <script type="text/javascript">
  //<![CDATA[

  {% if in_production %}
  manageCreateButton();
  {% endif %}
  updateDeleteButtonAndCheckbox();
  document.getElementById("kind_input").focus();

  //]]>
  </script>
{% endblock %}