Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/views/appadmin.html
blob: cdd48f75aed5f91cfe29786e1191269f9bc11193 (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
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
190
191
192
193
194
195
196
197
198
{{extend 'layout.html'}}
<script><!--
jQuery(document).ready(function(){
  jQuery("table.sortable tbody tr").mouseover( function() {
     jQuery(this).addClass("highlight"); }).mouseout( function() { 
     jQuery(this).removeClass("highlight"); });
  jQuery('table.sortable tbody tr:odd').addClass('odd');
  jQuery('table.sortable tbody tr:even').addClass('even');
});
//--></script>

{{if request.function=='index':}}
  <h1>{{=T("Available databases and tables")}}</h1>
  {{if not databases:}}{{=T("No databases in this application")}}{{pass}}
  {{for db in sorted(databases):}}
    {{for table in databases[db].tables:}}
      {{qry='%s.%s.id>0'%(db,table)}}
      {{tbl=databases[db][table]}}
      {{if hasattr(tbl,'_primarykey'):}}
        {{if tbl._primarykey:}}
            {{firstkey=tbl[tbl._primarykey[0]]}}
            {{if firstkey.type in ['string','text']:}}
              {{qry='%s.%s.%s!=""'%(db,table,firstkey.name)}}
            {{else:}}
              {{qry='%s.%s.%s>0'%(db,table,firstkey.name)}}
            {{pass}}
        {{else:}}
             {{qry=''}}
             {{pass}}
      {{pass}}
      <h2>{{=A("%s.%s" % (db,table),_href=URL(r=request,f='select',args=[db],vars=dict(query=qry)))}}
</h2>
      [ {{=A(str(T('insert new'))+''+table,_href=URL(r=request,f='insert',args=[db,table]))}} ]
    <br /><br />
    {{pass}}
  {{pass}}

{{elif request.function=='select':}}
  <h1>{{=XML(str(T("database %s select"))%A(request.args[0],_href=URL(r=request,f='index'))) }}
  </h1>
   {{if table:}}
  [ {{=A(str(T('insert new %s'))%table,_href=URL(r=request,f='insert',args=[request.args[0],table]))}} ]<br/><br/>
    <h2>{{=T("Rows in table")}}</h2><br/>
   {{else:}}
    <h2>{{=T("Rows selected")}}</h2><br/>
   {{pass}}
   {{=form}}
   <p>{{=T('The "query" is a condition like "db.table1.field1==\'value\'". Something like "db.table1.field1==db.table2.field2" results in a SQL JOIN.')}}<br/>
      {{=T('Use (...)&(...) for AND, (...)|(...) for OR, and ~(...)  for NOT to build more complex queries.')}}<br/>
      {{=T('"update" is an optional expression like "field1=\'newvalue\'". You cannot update or delete the results of a JOIN')}}</p>
    <br/><br/>
    <h3>{{=nrows}} {{=T("selected")}}</h3>
    {{if start>0:}}[ {{=A(T('previous 100 rows'),_href=URL(r=request,f='select',args=request.args[0],vars=dict(start=start-100)))}} ]{{pass}}
    {{if stop<nrows:}}[ {{=A(T('next 100 rows'),_href=URL(r=request,f='select',args=request.args[0],vars=dict(start=start+100)))}} ]{{pass}}    
    {{if rows:}}
       <div style="overflow: auto;" width="80%">
       {{linkto=URL(r=request,f='update',args=request.args[0])}}
       {{upload=URL(r=request,f='download',args=request.args[0])}}    
       {{=SQLTABLE(rows,linkto,upload,orderby=True,_class='sortable')}}
       </div>
    {{pass}}
    <br/><br/><h2>{{=T("Import/Export")}}</h2><br/>
    [ <a href="{{=URL(r=request,f='csv',args=request.args[0],vars=dict(query=query))}}">{{=T("export as csv file")}}</a> ]
  {{if table:}}
    {{=FORM(str(T('or import from csv file'))+" ",INPUT(_type='file',_name='csvfile'),INPUT(_type='hidden',_value=table,_name='table'),INPUT(_type='submit',_value='import'))}}
  {{pass}}


{{elif request.function=='insert':}}  
  <h1>{{=T("database")}} {{=A(request.args[0],_href=URL(r=request,f='index'))}}
    {{if hasattr(table,'_primarykey'):}}
      {{fieldname=table._primarykey[0]}}
      {{dbname=request.args[0]}}
      {{tablename=request.args[1]}}
      {{cond = table[fieldname].type in ['string','text'] and '!=""' or '>0'}}
      {{=T("table")}} {{=A(tablename,_href=URL(r=request,f='select',args=dbname,vars=dict(query='%s.%s.%s%s'%(dbname,tablename,fieldname,cond))))}}
    {{else:}}  
      {{=T("table")}} {{=A(request.args[1],_href=URL(r=request,f='select',args=request.args[0],vars=dict(query='%s.%s.id>0'%tuple(request.args[:2]))))}}
    {{pass}}
  </h1>
  <h2>{{=T("New Record")}}</h2><br/>
  {{=form}}



{{elif request.function=='update':}}
  <h1>{{=T("database")}} {{=A(request.args[0],_href=URL(r=request,f='index'))}}
    {{if hasattr(table,'_primarykey'):}}
      {{fieldname=request.vars.keys()[0]}}
      {{dbname=request.args[0]}}
      {{tablename=request.args[1]}}
      {{cond = table[fieldname].type in ['string','text'] and '!=""' or '>0'}}      
      {{=T("table")}} {{=A(tablename,_href=URL(r=request,f='select',args=dbname,vars=dict(query='%s.%s.%s%s'%(dbname,tablename,fieldname,cond))))}}
      {{=T("record")}} {{=A('%s=%s'%request.vars.items()[0],_href=URL(r=request,f='update',args=request.args[:2],vars=request.vars))}}
    {{else:}}
      {{=T("table")}} {{=A(request.args[1],_href=URL(r=request,f='select',args=request.args[0],vars=dict(query='%s.%s.id>0'%tuple(request.args[:2]))))}}
      {{=T("record id")}} {{=A(request.args[2],_href=URL(r=request,f='update',args=request.args[:3]))}}
    {{pass}}
  </h1>
  <h2>{{=T("Edit current record")}}</h2><br/><br/>{{=form}}



{{elif request.function=='state':}}
  <h1>{{=T("Internal State")}}</h1>
  <h2>{{=T("Current request")}}</h2>
  {{=BEAUTIFY(request)}}
  <br/><h2>{{=T("Current response")}}</h2>
  {{=BEAUTIFY(response)}}
  <br/><h2>{{=T("Current session")}}</h2>
  {{=BEAUTIFY(session)}}


{{elif request.function == 'ccache':}}
<h2>Cache</h2>
<div class="wrapper">
<div class="list">
    <div class="list-header">
        Statistics
    </div>
    <div class="content">
        <h3>Overview</h3>
        <p>
            Hit Ratio: 
            <strong>{{=total['ratio']}}%</strong> 
            (<strong>{{=total['hits']}}</strong> hits 
            and <strong>{{=total['misses']}}</strong> misses)
        </p>
        <p>
            Size of cache: 
            <strong>{{=total['objects']}}</strong> items, 
            <strong>{{=total['bytes']}}</strong> bytes 
            {{if total['bytes'] > 524287:}}
                (<strong>{{="%.0d" % (total['bytes'] / 1048576)}} MB</strong>)
            {{pass}}
        </p>
        <p>
            Cache contains items up to 
            <strong>{{="%02d" % total['oldest'][0]}}</strong> hours 
            <strong>{{="%02d" % total['oldest'][1]}}</strong> minutes 
            <strong>{{="%02d" % total['oldest'][2]}}</strong> seconds old.
        </p>
        <h3>RAM</h3>
        <p>
            Hit Ratio: 
            <strong>{{=ram['ratio']}}%</strong> 
            (<strong>{{=ram['hits']}}</strong> hits 
            and <strong>{{=ram['misses']}}</strong> misses)
        </p>
        <p>
            Size of cache: 
            <strong>{{=ram['objects']}}</strong> items, 
            <strong>{{=ram['bytes']}}</strong> bytes 
            {{if ram['bytes'] > 524287:}}
                (<strong>{{=ram['bytes'] / 1048576}} MB</strong>)
            {{pass}}
        </p>
        <p>
            RAM contains items up to 
            <strong>{{="%02d" % ram['oldest'][0]}}</strong> hours 
            <strong>{{="%02d" % ram['oldest'][1]}}</strong> minutes 
            <strong>{{="%02d" % ram['oldest'][2]}}</strong> seconds old.
        </p>
        <h3>DISK</h3>
        <p>
            Hit Ratio: 
            <strong>{{=disk['ratio']}}%</strong> 
            (<strong>{{=disk['hits']}}</strong> hits 
            and <strong>{{=disk['misses']}}</strong> misses)
        </p>
        <p>
            Size of cache: 
            <strong>{{=disk['objects']}}</strong> items, 
            <strong>{{=disk['bytes']}}</strong> bytes 
            {{if disk['bytes'] > 524287:}}
                (<strong>{{=disk['bytes'] / 1048576}} MB</strong>)
            {{pass}}
        </p>
        <p>
            DISK contains items up to 
            <strong>{{="%02d" % disk['oldest'][0]}}</strong> hours 
            <strong>{{="%02d" % disk['oldest'][1]}}</strong> minutes 
            <strong>{{="%02d" % disk['oldest'][2]}}</strong> seconds old.
        </p>
    </div>
    
    <div class="list-header">
    Manage Cache
    </div>
    <div class="content">
    <p>
        {{=form}}
    </p>
    </div>
</div>
<div class="clear"></div>
</div>
{{pass}}