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

Sync#35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
TommyLemon merged 4 commits intoAPIJSON:masterfromzhangchunlin:master
Sep 11, 2019
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletionsdemo/apps/apijson_demo/settings.ini
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,15 @@ comment = 'apijson_demo.models.Comment'
moment = 'apijson_demo.models.Moment'

[APIJSON_MODELS]
user = {
"user_id_field" : "id",
"secret_fields" : ["password"],
"GET" : { "roles" : ["LOGIN","ADMIN","OWNER"] },
"HEAD" : { "roles" : ["LOGIN","ADMIN","OWNER"] },
"POST" : { "roles" : ["ADMIN"] },
"PUT" : { "roles" : ["ADMIN","OWNER"] },
"DELETE" : { "roles" : ["ADMIN"] },
}
moment = {
"user_id_field" : "user_id",
"GET" : { "roles" : ["OWNER","LOGIN","ADMIN"] },
Expand Down
149 changes: 98 additions & 51 deletionsdemo/apps/apijson_demo/templates/index.html
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,89 +23,110 @@
<tab-pane label="apijson put" name="tab_put"></tab-pane>
<tab-pane label="apijson delete" name="tab_delete"></tab-pane>
</tabs>
<layout>
<sider hide-trigger :style="{height: '80vh', width:'360px', 'min-width': '360px', 'max-width': '380px', overflow: 'auto', background: '#fff'}">
<i-menu :active-name="0" @on-select="on_select_get" width="360px" ref='menu_get'>
<menu-group title="apijson get examples" v-if="tab_current==='tab_get'">
<menu-item v-for="(item,index) in request_get" :name="index" :key="index">
📋 {item.label}
</menu-item>
</menu-group>
</i-menu>
<i-menu :active-name="0" @on-select="on_select_head" width="360px">
<menu-group title="apijson head examples" v-if="tab_current==='tab_head'">
<menu-item v-for="(item,index) in request_head" :name="index" :key="index">
📋 {item.label}
</menu-item>
</menu-group>
</i-menu>
<i-menu :active-name="0" @on-select="on_select_post" width="360px">
<menu-group title="apijson post examples" v-if="tab_current==='tab_post'">
<menu-item v-for="(item,index) in request_post" :name="index" :key="index">
📋 {item.label}
</menu-item>
</menu-group>
</i-menu>
<i-menu :active-name="0" @on-select="on_select_put" width="360px">
<menu-group title="apijson put examples" v-if="tab_current==='tab_put'">
<menu-item v-for="(item,index) in request_put" :name="index" :key="index">
📋 {item.label}
</menu-item>
</menu-group>
</i-menu>
<i-menu :active-name="0" @on-select="on_select_delete" width="360px">
<menu-group title="apijson delete examples" v-if="tab_current==='tab_delete'">
<menu-item v-for="(item,index) in request_delete" :name="index" :key="index">
📋 {item.label}
</menu-item>
</menu-group>
</i-menu>
</sider>
<i-content :style="{padding: '24px', minHeight: '280px', background: '#fff'}">
<Row>
<i-col span="3"><div align="center">login user</div></i-col>
<i-col span="8"><i-input value="{{=user_info}}" readonly/></i-col>
<i-col span="18"><i-input value="{{=user_info}}" readonly/></i-col>
{{if request.user:}}
<i-col span="1"><div align="center"><i-button type="warning" size="large" @click="logout">Logout</i-button></div></i-col>
{{else:}}
<i-col span="1"><div align="center"><i-button type="primary" size="large" @click="login">Login</i-button></div></i-col>
{{pass}}
</Row>
<Row v-if="tab_current==='tab_get'">
<i-col span="3"><div align="center">HTTP POST URL</div></i-col>
<i-col span="8"><i-input value="/apijson/get" readonly/></i-col>
<i-col span="3"><div align="center">HTTP POST URL</div></i-col>
<i-col span="18"><i-input value="/apijson/get" readonly/></i-col>
</Row>
<Row v-if="tab_current==='tab_get'">
<i-col span="3"><div align="center"><strong>apijson get</strong> request <span class="notice">{request_get.length}</span> examples</div></i-col>
<i-col span="8">
<i-select v-model="select_current">
<i-option v-for="(item,index) in request_get" :value="item.value" :key="item.value">{index+1}. {item.label}</i-option>
</i-select>
</i-col>
<i-col span="3"><div align="center">example name</div></i-col>
<i-col span="18"><strong><i-input :value="request_get[cmenu_get].label" readonly/></strong></i-col>
</Row>

<Row v-if="tab_current==='tab_head'">
<i-col span="3"><div align="center">HTTP HEAD URL</div></i-col>
<i-col span="8"><i-input value="/apijson/head" readonly/></i-col>
<i-col span="18"><i-input value="/apijson/head" readonly/></i-col>
</Row>
<Row v-if="tab_current==='tab_head'">
<i-col span="3"><div align="center"><strong>apijson head</strong> request <span class="notice">{request_head.length}</span> examples</div></i-col>
<i-col span="8">
<i-select v-model="select_current">
<i-option v-for="(item,index) in request_head" :value="item.value" :key="item.value">{index+1}. {item.label}</i-option>
</i-select>
</i-col>
<i-col span="3"><div align="center">example name</div></i-col>
<i-col span="18"><strong><i-input :value="request_head[cmenu_head].label" readonly/></strong></i-col>
</Row>

<Row v-if="tab_current==='tab_post'">
<i-col span="3"><div align="center">POST URL</div></i-col>
<i-col span="8"><i-input value="/apijson/post" readonly/></i-col>
<i-col span="3"><div align="center">POST URL</div></i-col>
<i-col span="18"><i-input value="/apijson/post" readonly/></i-col>
</Row>
<Row v-if="tab_current==='tab_post'">
<i-col span="3"><div align="center"><strong>apijson post</strong> request <span class="notice">{request_post.length}</span> examples</div></i-col>
<i-col span="8">
<i-select v-model="select_current">
<i-option v-for="(item,index) in request_post" :value="item.value" :key="item.value">{index+1}. {item.label}</i-option>
</i-select>
</i-col>
<i-col span="3"><div align="center">example name</div></i-col>
<i-col span="18"><strong><i-input :value="request_post[cmenu_post].label" readonly/></strong></i-col>
</Row>

<Row v-if="tab_current==='tab_put'">
<i-col span="3"><div align="center">PUT URL</div></i-col>
<i-col span="8"><i-input value="/apijson/put" readonly/></i-col>
<i-col span="18"><i-input value="/apijson/put" readonly/></i-col>
</Row>
<Row v-if="tab_current==='tab_put'">
<i-col span="3"><div align="center"><strong>apijson put</strong> request <span class="notice">{request_put.length}</span> examples</div></i-col>
<i-col span="8">
<i-select v-model="select_current">
<i-option v-for="(item,index) in request_put" :value="item.value" :key="item.value">{index+1}. {item.label}</i-option>
</i-select>
</i-col>
<i-col span="3"><div align="center">example name</div></i-col>
<i-col span="18"><strong><i-input :value="request_put[cmenu_put].label" readonly/></strong></i-col>
</Row>

<Row v-if="tab_current==='tab_delete'">
<i-col span="3"><div align="center">DELETE URL</div></i-col>
<i-col span="8"><i-input value="/apijson/delete" readonly/></i-col>
<i-col span="18"><i-input value="/apijson/delete" readonly/></i-col>
</Row>
<Row v-if="tab_current==='tab_delete'">
<i-col span="3"><div align="center"><strong>apijson delete</strong> request <span class="notice">{request_delete.length}</span> examples</div></i-col>
<i-col span="8">
<i-select v-model="select_current">
<i-option v-for="(item,index) in request_delete" :value="item.value" :key="item.value">{index+1}. {item.label}</i-option>
</i-select>
</i-col>
<i-col span="3"><div align="center">example name</div></i-col>
<i-col span="18"><strong><i-input :value="request_delete[cmenu_delete].label" readonly/></strong></i-col>
</Row>

<Row>
<i-col span="3"><div align="center">request data</div></i-col>
<i-col span="8"><i-input v-model="request_data" type="textarea" :autosize="{minRows: 3,maxRows: 15}" placeholder="request data" /></i-col>
<i-col span="18"><i-input v-model="request_data" type="textarea" :autosize="{minRows: 3,maxRows: 15}" placeholder="request data" /></i-col>
<i-col span="1"><div align="center"><i-button type="primary" size="large" @click="post_request_data" v-bind:disabled="!can_post">Post</i-button></div></i-col>
</Row>
<Row>
<i-col span="3"><div align="center">response data</div></i-col>
<i-col span="8"><i-input v-model="response_data" type="textarea" readonly :autosize="{minRows: 5,maxRows: 30}" /></i-col>
<i-col span="18"><i-input v-model="response_data" type="textarea" readonly :autosize="{minRows: 5,maxRows: 30}" /></i-col>
</Row>
</i-content>
</layout>
</div>
</div>
<script>
Expand All@@ -119,7 +140,13 @@
request_put : {{<<request_put_json}},
request_delete : {{<<request_delete_json}},
request_data : "",
select_current : "",

cmenu_get : 0,
cmenu_head : 0,
cmenu_post : 0,
cmenu_put : 0,
cmenu_delete : 0,

can_post : true,
response_data : "",
tab_current : "tab_get",
Expand All@@ -134,7 +161,36 @@
methods: {
init_default: function(){
vm.request_data = vm.request_get[0].value
vm.select_current = vm.request_data
},
on_select_get: function(name){
vm.cmenu_get = parseInt(name)
vm.request_data = vm.request_get[vm.cmenu_get].value
vm.response_data = ""
vm.can_post = true
},
on_select_head: function(name){
vm.cmenu_head = parseInt(name)
vm.request_data = vm.request_head[vm.cmenu_head].value
vm.response_data = ""
vm.can_post = true
},
on_select_post: function(name){
vm.cmenu_post = parseInt(name)
vm.request_data = vm.request_post[vm.cmenu_post].value
vm.response_data = ""
vm.can_post = true
},
on_select_put: function(name){
vm.cmenu_put = parseInt(name)
vm.request_data = vm.request_put[vm.cmenu_put].value
vm.response_data = ""
vm.can_post = true
},
on_select_delete: function(name){
vm.cmenu_delete = parseInt(name)
vm.request_data = vm.request_delete[vm.cmenu_delete].value
vm.response_data = ""
vm.can_post = true
},
post_request_data: function(){
$.ajax({
Expand DownExpand Up@@ -171,16 +227,7 @@
else if (n=="tab_delete") {
vm.request_data = vm.request_delete[0].value
}
vm.select_current = vm.request_data
vm.response_data = ""
},
select_current : function(n,o){
if (n!=null && n!="" && n!==vm.request_data) {
vm.request_data = n
}
else {
vm.select_current = vm.request_data
}
}
}
})
Expand Down
72 changes: 59 additions & 13 deletionsdemo/apps/apijson_demo/views.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,45 +11,49 @@ def index():

request_get = [
{
"label":"Singlerecordquery: self user",
"label":"Single query: self user",
"value":'''{
"user":{
"@role":"OWNER"
}
}''',
},

{
"label":"Singlerecordquery: with id as parameter",
"label":"Single query: with id as parameter",
"value":'''{
"user":{
"id":2,
"@role":"ADMIN"
}
}''',
},

{
"label":"Singlerecordquery: @column",
"label":"Single query: @column",
"value":'''{
"user":{
"user":{
"@column": "id,username,email",
"@role":"OWNER"
}
}
}''',
},

{
"label":"Array query: user",
"value":'''{
"[]":{
"@count":2,
"@page":0,
"user":{
"@column":"id,username,nickname,email",
"@order":"id-",
"@role":"ADMIN"
"[]":{
"@count":2,
"@page":0,
"user":{
"@column":"id,username,nickname,email",
"@order":"id-",
"@role":"ADMIN"
}
}
}
}''',
},

{
"label":"Array query: moment",
"value":'''{
Expand All@@ -64,6 +68,7 @@ def index():
"total@":"/moment[]/total"
}''',
},

{
"label":"Array query: like",
"value":'''{
Expand All@@ -79,6 +84,7 @@ def index():
}
}''',
},

{
"label":"Array query: simple @expr",
"value":'''{
Expand All@@ -96,6 +102,7 @@ def index():
}
}''',
},

{
"label":"Array query: complex @expr",
"value":'''{
Expand All@@ -112,6 +119,45 @@ def index():
"email$":"%local%"
}
}
}''',
},

{
"label":"Association query: Two tables, one to one",
"value":'''{
"moment":{},
"user":{
"@column": "id,username,email",
"id@": "moment/user_id"
}
}''',
},

{
"label":"Association query: Two tables, one to many",
"value":'''{
"moment": {},
"[]": {
"comment": {
"moment_id@": "moment/id",
"@order":"date-"
}
}
}''',
},

{
"label":"Association query: Two tables in array",
"value":'''{
"[]": {
"moment": {
"@column": "id,date,user_id"
},
"user": {
"id@": "/moment/user_id",
"@column": "id,username"
}
}
}''',
},
]
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp