Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd517464

Browse files
authored
Merge pull request#35 from zhangchunlin/master
Sync
2 parents122bc1d +872eeeb commitd517464

File tree

5 files changed

+433
-198
lines changed

5 files changed

+433
-198
lines changed

‎demo/apps/apijson_demo/settings.ini

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ comment = 'apijson_demo.models.Comment'
44
moment ='apijson_demo.models.Moment'
55

66
[APIJSON_MODELS]
7+
user = {
8+
"user_id_field" :"id",
9+
"secret_fields" : ["password"],
10+
"GET" : {"roles" : ["LOGIN","ADMIN","OWNER"] },
11+
"HEAD" : {"roles" : ["LOGIN","ADMIN","OWNER"] },
12+
"POST" : {"roles" : ["ADMIN"] },
13+
"PUT" : {"roles" : ["ADMIN","OWNER"] },
14+
"DELETE" : {"roles" : ["ADMIN"] },
15+
}
716
moment = {
817
"user_id_field" :"user_id",
918
"GET" : {"roles" : ["OWNER","LOGIN","ADMIN"] },

‎demo/apps/apijson_demo/templates/index.html

Lines changed: 98 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -23,89 +23,110 @@
2323
<tab-panelabel="apijson put"name="tab_put"></tab-pane>
2424
<tab-panelabel="apijson delete"name="tab_delete"></tab-pane>
2525
</tabs>
26+
<layout>
27+
<siderhide-trigger:style="{height: '80vh', width:'360px', 'min-width': '360px', 'max-width': '380px', overflow: 'auto', background: '#fff'}">
28+
<i-menu:active-name="0"@on-select="on_select_get"width="360px"ref='menu_get'>
29+
<menu-grouptitle="apijson get examples"v-if="tab_current==='tab_get'">
30+
<menu-itemv-for="(item,index) in request_get":name="index":key="index">
31+
📋 {item.label}
32+
</menu-item>
33+
</menu-group>
34+
</i-menu>
35+
<i-menu:active-name="0"@on-select="on_select_head"width="360px">
36+
<menu-grouptitle="apijson head examples"v-if="tab_current==='tab_head'">
37+
<menu-itemv-for="(item,index) in request_head":name="index":key="index">
38+
📋 {item.label}
39+
</menu-item>
40+
</menu-group>
41+
</i-menu>
42+
<i-menu:active-name="0"@on-select="on_select_post"width="360px">
43+
<menu-grouptitle="apijson post examples"v-if="tab_current==='tab_post'">
44+
<menu-itemv-for="(item,index) in request_post":name="index":key="index">
45+
📋 {item.label}
46+
</menu-item>
47+
</menu-group>
48+
</i-menu>
49+
<i-menu:active-name="0"@on-select="on_select_put"width="360px">
50+
<menu-grouptitle="apijson put examples"v-if="tab_current==='tab_put'">
51+
<menu-itemv-for="(item,index) in request_put":name="index":key="index">
52+
📋 {item.label}
53+
</menu-item>
54+
</menu-group>
55+
</i-menu>
56+
<i-menu:active-name="0"@on-select="on_select_delete"width="360px">
57+
<menu-grouptitle="apijson delete examples"v-if="tab_current==='tab_delete'">
58+
<menu-itemv-for="(item,index) in request_delete":name="index":key="index">
59+
📋 {item.label}
60+
</menu-item>
61+
</menu-group>
62+
</i-menu>
63+
</sider>
64+
<i-content:style="{padding: '24px', minHeight: '280px', background: '#fff'}">
2665
<Row>
2766
<i-colspan="3"><divalign="center">login user</div></i-col>
28-
<i-colspan="8"><i-inputvalue="{{=user_info}}"readonly/></i-col>
67+
<i-colspan="18"><i-inputvalue="{{=user_info}}"readonly/></i-col>
2968
{{if request.user:}}
3069
<i-colspan="1"><divalign="center"><i-buttontype="warning"size="large"@click="logout">Logout</i-button></div></i-col>
3170
{{else:}}
3271
<i-colspan="1"><divalign="center"><i-buttontype="primary"size="large"@click="login">Login</i-button></div></i-col>
3372
{{pass}}
3473
</Row>
3574
<Rowv-if="tab_current==='tab_get'">
36-
<i-colspan="3"><divalign="center">HTTP POST URL</div></i-col>
37-
<i-colspan="8"><i-inputvalue="/apijson/get"readonly/></i-col>
75+
<i-colspan="3"><divalign="center">HTTP POST URL</div></i-col>
76+
<i-colspan="18"><i-inputvalue="/apijson/get"readonly/></i-col>
3877
</Row>
3978
<Rowv-if="tab_current==='tab_get'">
40-
<i-colspan="3"><divalign="center"><strong>apijson get</strong> request<spanclass="notice">{request_get.length}</span> examples</div></i-col>
41-
<i-colspan="8">
42-
<i-selectv-model="select_current">
43-
<i-optionv-for="(item,index) in request_get":value="item.value":key="item.value">{index+1}. {item.label}</i-option>
44-
</i-select>
45-
</i-col>
79+
<i-colspan="3"><divalign="center">example name</div></i-col>
80+
<i-colspan="18"><strong><i-input:value="request_get[cmenu_get].label"readonly/></strong></i-col>
4681
</Row>
4782

4883
<Rowv-if="tab_current==='tab_head'">
4984
<i-colspan="3"><divalign="center">HTTP HEAD URL</div></i-col>
50-
<i-colspan="8"><i-inputvalue="/apijson/head"readonly/></i-col>
85+
<i-colspan="18"><i-inputvalue="/apijson/head"readonly/></i-col>
5186
</Row>
5287
<Rowv-if="tab_current==='tab_head'">
53-
<i-colspan="3"><divalign="center"><strong>apijson head</strong> request<spanclass="notice">{request_head.length}</span> examples</div></i-col>
54-
<i-colspan="8">
55-
<i-selectv-model="select_current">
56-
<i-optionv-for="(item,index) in request_head":value="item.value":key="item.value">{index+1}. {item.label}</i-option>
57-
</i-select>
58-
</i-col>
88+
<i-colspan="3"><divalign="center">example name</div></i-col>
89+
<i-colspan="18"><strong><i-input:value="request_head[cmenu_head].label"readonly/></strong></i-col>
5990
</Row>
6091

6192
<Rowv-if="tab_current==='tab_post'">
62-
<i-colspan="3"><divalign="center">POST URL</div></i-col>
63-
<i-colspan="8"><i-inputvalue="/apijson/post"readonly/></i-col>
93+
<i-colspan="3"><divalign="center">POST URL</div></i-col>
94+
<i-colspan="18"><i-inputvalue="/apijson/post"readonly/></i-col>
6495
</Row>
6596
<Rowv-if="tab_current==='tab_post'">
66-
<i-colspan="3"><divalign="center"><strong>apijson post</strong> request<spanclass="notice">{request_post.length}</span> examples</div></i-col>
67-
<i-colspan="8">
68-
<i-selectv-model="select_current">
69-
<i-optionv-for="(item,index) in request_post":value="item.value":key="item.value">{index+1}. {item.label}</i-option>
70-
</i-select>
71-
</i-col>
97+
<i-colspan="3"><divalign="center">example name</div></i-col>
98+
<i-colspan="18"><strong><i-input:value="request_post[cmenu_post].label"readonly/></strong></i-col>
7299
</Row>
73100

74101
<Rowv-if="tab_current==='tab_put'">
75102
<i-colspan="3"><divalign="center">PUT URL</div></i-col>
76-
<i-colspan="8"><i-inputvalue="/apijson/put"readonly/></i-col>
103+
<i-colspan="18"><i-inputvalue="/apijson/put"readonly/></i-col>
77104
</Row>
78105
<Rowv-if="tab_current==='tab_put'">
79-
<i-colspan="3"><divalign="center"><strong>apijson put</strong> request<spanclass="notice">{request_put.length}</span> examples</div></i-col>
80-
<i-colspan="8">
81-
<i-selectv-model="select_current">
82-
<i-optionv-for="(item,index) in request_put":value="item.value":key="item.value">{index+1}. {item.label}</i-option>
83-
</i-select>
84-
</i-col>
106+
<i-colspan="3"><divalign="center">example name</div></i-col>
107+
<i-colspan="18"><strong><i-input:value="request_put[cmenu_put].label"readonly/></strong></i-col>
85108
</Row>
86109

87110
<Rowv-if="tab_current==='tab_delete'">
88111
<i-colspan="3"><divalign="center">DELETE URL</div></i-col>
89-
<i-colspan="8"><i-inputvalue="/apijson/delete"readonly/></i-col>
112+
<i-colspan="18"><i-inputvalue="/apijson/delete"readonly/></i-col>
90113
</Row>
91114
<Rowv-if="tab_current==='tab_delete'">
92-
<i-colspan="3"><divalign="center"><strong>apijson delete</strong> request<spanclass="notice">{request_delete.length}</span> examples</div></i-col>
93-
<i-colspan="8">
94-
<i-selectv-model="select_current">
95-
<i-optionv-for="(item,index) in request_delete":value="item.value":key="item.value">{index+1}. {item.label}</i-option>
96-
</i-select>
97-
</i-col>
115+
<i-colspan="3"><divalign="center">example name</div></i-col>
116+
<i-colspan="18"><strong><i-input:value="request_delete[cmenu_delete].label"readonly/></strong></i-col>
98117
</Row>
99118

100119
<Row>
101120
<i-colspan="3"><divalign="center">request data</div></i-col>
102-
<i-colspan="8"><i-inputv-model="request_data"type="textarea":autosize="{minRows: 3,maxRows: 15}"placeholder="request data"/></i-col>
121+
<i-colspan="18"><i-inputv-model="request_data"type="textarea":autosize="{minRows: 3,maxRows: 15}"placeholder="request data"/></i-col>
103122
<i-colspan="1"><divalign="center"><i-buttontype="primary"size="large"@click="post_request_data"v-bind:disabled="!can_post">Post</i-button></div></i-col>
104123
</Row>
105124
<Row>
106125
<i-colspan="3"><divalign="center">response data</div></i-col>
107-
<i-colspan="8"><i-inputv-model="response_data"type="textarea"readonly:autosize="{minRows: 5,maxRows: 30}"/></i-col>
126+
<i-colspan="18"><i-inputv-model="response_data"type="textarea"readonly:autosize="{minRows: 5,maxRows: 30}"/></i-col>
108127
</Row>
128+
</i-content>
129+
</layout>
109130
</div>
110131
</div>
111132
<script>
@@ -119,7 +140,13 @@
119140
request_put :{{<<request_put_json}},
120141
request_delete :{{<<request_delete_json}},
121142
request_data :"",
122-
select_current :"",
143+
144+
cmenu_get :0,
145+
cmenu_head :0,
146+
cmenu_post :0,
147+
cmenu_put :0,
148+
cmenu_delete :0,
149+
123150
can_post :true,
124151
response_data :"",
125152
tab_current :"tab_get",
@@ -134,7 +161,36 @@
134161
methods:{
135162
init_default:function(){
136163
vm.request_data=vm.request_get[0].value
137-
vm.select_current=vm.request_data
164+
},
165+
on_select_get:function(name){
166+
vm.cmenu_get=parseInt(name)
167+
vm.request_data=vm.request_get[vm.cmenu_get].value
168+
vm.response_data=""
169+
vm.can_post=true
170+
},
171+
on_select_head:function(name){
172+
vm.cmenu_head=parseInt(name)
173+
vm.request_data=vm.request_head[vm.cmenu_head].value
174+
vm.response_data=""
175+
vm.can_post=true
176+
},
177+
on_select_post:function(name){
178+
vm.cmenu_post=parseInt(name)
179+
vm.request_data=vm.request_post[vm.cmenu_post].value
180+
vm.response_data=""
181+
vm.can_post=true
182+
},
183+
on_select_put:function(name){
184+
vm.cmenu_put=parseInt(name)
185+
vm.request_data=vm.request_put[vm.cmenu_put].value
186+
vm.response_data=""
187+
vm.can_post=true
188+
},
189+
on_select_delete:function(name){
190+
vm.cmenu_delete=parseInt(name)
191+
vm.request_data=vm.request_delete[vm.cmenu_delete].value
192+
vm.response_data=""
193+
vm.can_post=true
138194
},
139195
post_request_data:function(){
140196
$.ajax({
@@ -171,16 +227,7 @@
171227
elseif(n=="tab_delete"){
172228
vm.request_data=vm.request_delete[0].value
173229
}
174-
vm.select_current=vm.request_data
175230
vm.response_data=""
176-
},
177-
select_current :function(n,o){
178-
if(n!=null&&n!=""&&n!==vm.request_data){
179-
vm.request_data=n
180-
}
181-
else{
182-
vm.select_current=vm.request_data
183-
}
184231
}
185232
}
186233
})

‎demo/apps/apijson_demo/views.py

Lines changed: 59 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,45 +11,49 @@ def index():
1111

1212
request_get= [
1313
{
14-
"label":"Singlerecordquery: self user",
14+
"label":"Single query: self user",
1515
"value":'''{
1616
"user":{
1717
"@role":"OWNER"
1818
}
1919
}''',
2020
},
21+
2122
{
22-
"label":"Singlerecordquery: with id as parameter",
23+
"label":"Single query: with id as parameter",
2324
"value":'''{
2425
"user":{
2526
"id":2,
2627
"@role":"ADMIN"
2728
}
2829
}''',
2930
},
31+
3032
{
31-
"label":"Singlerecordquery: @column",
33+
"label":"Single query: @column",
3234
"value":'''{
33-
"user":{
35+
"user":{
3436
"@column": "id,username,email",
3537
"@role":"OWNER"
36-
}
38+
}
3739
}''',
3840
},
41+
3942
{
4043
"label":"Array query: user",
4144
"value":'''{
42-
"[]":{
43-
"@count":2,
44-
"@page":0,
45-
"user":{
46-
"@column":"id,username,nickname,email",
47-
"@order":"id-",
48-
"@role":"ADMIN"
45+
"[]":{
46+
"@count":2,
47+
"@page":0,
48+
"user":{
49+
"@column":"id,username,nickname,email",
50+
"@order":"id-",
51+
"@role":"ADMIN"
52+
}
4953
}
50-
}
5154
}''',
5255
},
56+
5357
{
5458
"label":"Array query: moment",
5559
"value":'''{
@@ -64,6 +68,7 @@ def index():
6468
"total@":"/moment[]/total"
6569
}''',
6670
},
71+
6772
{
6873
"label":"Array query: like",
6974
"value":'''{
@@ -79,6 +84,7 @@ def index():
7984
}
8085
}''',
8186
},
87+
8288
{
8389
"label":"Array query: simple @expr",
8490
"value":'''{
@@ -96,6 +102,7 @@ def index():
96102
}
97103
}''',
98104
},
105+
99106
{
100107
"label":"Array query: complex @expr",
101108
"value":'''{
@@ -112,6 +119,45 @@ def index():
112119
"email$":"%local%"
113120
}
114121
}
122+
}''',
123+
},
124+
125+
{
126+
"label":"Association query: Two tables, one to one",
127+
"value":'''{
128+
"moment":{},
129+
"user":{
130+
"@column": "id,username,email",
131+
"id@": "moment/user_id"
132+
}
133+
}''',
134+
},
135+
136+
{
137+
"label":"Association query: Two tables, one to many",
138+
"value":'''{
139+
"moment": {},
140+
"[]": {
141+
"comment": {
142+
"moment_id@": "moment/id",
143+
"@order":"date-"
144+
}
145+
}
146+
}''',
147+
},
148+
149+
{
150+
"label":"Association query: Two tables in array",
151+
"value":'''{
152+
"[]": {
153+
"moment": {
154+
"@column": "id,date,user_id"
155+
},
156+
"user": {
157+
"id@": "/moment/user_id",
158+
"@column": "id,username"
159+
}
160+
}
115161
}''',
116162
},
117163
]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp