Commit 8b37e3cb authored by ibuler's avatar ibuler

[Fixture] 添加api

parent 01dd6b8b
1c6d3755b3377017f38fe4afcdf76e543d8e2978
[
{
"title": "localhost",
"id": "1",
"folder": false,
"hostname": "localhost",
"system_users": [
{
"id": 3,
"name": "测试环境web",
"username": "web"
},
{
"id": 6,
"name": "测试环境sa",
"username": "sa"
}
]
},
{
"title": "JAVA",
"id": "2",
"folder": true,
"children": [
{
"title": "java-test-1",
"id": "3",
"ip":"192.168.1.1",
"system_users": [
{
"id": 3,
"name": "测试环境web",
"username": "web"
}
]
},
{
"title": "java-test-2",
"id": "4",
"ip":"192.168.1.2",
"system_users": [
{
"id": 3,
"name": "测试环境web",
"username": "web"
}
]
}
]
},
{
"title": "MySQL",
"id": "2",
"folder": true,
"children": [
{
"title": "mysql-1",
"id": "3",
"ip": "192.168.3.1"
},
{
"title": "msyql-master",
"id": "4",
"ip": "192.168.2.3"
}
]
}
]
\ No newline at end of file
[
{
"title": "Cut",
"cmd": "cut",
"uiIcon": "fa fa-cut fa-size-1p3em"
},
{
"title": "Copy",
"cmd": "copy",
"uiIcon": "fa fa-copy fa-size-1p3em"
},
{
"title": "Paste",
"cmd": "paste",
"uiIcon": "fa fa-paste fa-size-1p3em",
"disabled": false
},
{
"title": "----"
},
{
"title": "Edit",
"cmd": "edit",
"uiIcon": "fa fa-edit fa-size-1p3em",
"disabled": true
},
{
"title": "Delete",
"cmd": "delete",
"uiIcon": "fa fa-trash fa-size-1p3em",
"disabled": true
},
{
"title": "More",
"uiIcon": "fa fa-caret-right fa-size-1p3em",
"children": [
{
"title": "Sub 1",
"cmd": "sub1"
},
{
"title": "Sub 2",
"cmd": "sub1"
}
]
}
]
\ No newline at end of file
[
{"id": "File", "name": "File", "children": [
{"id": "NewConnection", "href": "Aaaa", "name": "New connection","disable":true},
{"id": "Connect", "href": "Aaaa", "name": "Connect","disable":true},
{"id": "Disconnect", "click": "Disconnect", "name": "Disconnect"},
{"id": "DisconnectAll", "click": "DisconnectAll", "name": "Disconnect all"},
{"id": "Duplicate", "href": "Aaaa", "name": "Duplicate","disable":true},
{"id": "Upload", "href": "Aaaa", "name": "Upload","disable":true},
{"id": "Download", "href": "Aaaa", "name": "Download","disable":true},
{"id": "Reload", "click": "ReloadLeftbar", "name": "Reload"}
]},
{"id": "Edit", "name": "Edit", "children": [
{"id": "Copy", "href": "Aaaa", "name": "Copy","disable":true},
{"id": "Paste", "href": "Aaaa", "name": "Paste","disable":true},
{"id": "SelectAll", "href": "Aaaa", "name": "Select all","disable":true},
{"id": "Search", "href": "Aaaa", "name": "Search","disable":true}
]},
{"id": "View","name": "View", "children": [
{"id": "HindLeftManager", "click": "HideLeft", "name": "Hind left manager"},
{"id": "SplitVertical", "href": "Aaaa", "name": "Split vertical","disable":true},
{"id": "SplitHirizontal", "href": "Aaaa", "name": "Split hirizontal","disable":true},
{"id": "CommandBar", "href": "Aaaa", "name": "Command bar","disable":true},
{"id": "ShareSession", "href": "Aaaa", "name": "Share session (read/write)","disable":true},
{"id": "Language", "href": "Aaaa", "name": "Language","disable":true}
]},
{"id": "Help", "name": "Help", "children": [
{"id": "EnterLicense", "click": "EnterLicense", "name": "Enter License"},
{"id": "Website", "click": "Website", "name": "Website"},
{"id": "BBS", "click": "BBS", "name": "BBS"}
]}
]
0.1
\ No newline at end of file
# ~*~ coding: utf-8 ~*~ # ~*~ coding: utf-8 ~*~
import os
from .. import app from .. import app
from ..authentication import login_required from ..authentication import login_required
from flask import render_template, send_from_directory, make_response from flask import render_template, send_from_directory, make_response, jsonify
import json
API_MOCK_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'api')
__all__ = ['index', 'luna', 'send_dist'] __all__ = ['index', 'luna', 'send_dist']
@app.route('/test/')
@login_required
def test():
return make_response('Hello')
@app.route('/') @app.route('/')
@login_required @login_required
def index(): def index():
...@@ -33,3 +30,65 @@ def luna(): ...@@ -33,3 +30,65 @@ def luna():
def send_dist(path): def send_dist(path):
return send_from_directory('dist', path) return send_from_directory('dist', path)
@app.route('/api/version')
def version():
with open(os.path.join(API_MOCK_DIR, 'version')) as f:
response = json.load(f)
return jsonify(response)
@app.route('/api/nav')
def nav():
with open(os.path.join(API_MOCK_DIR, 'nav')) as f:
response = json.load(f)
return jsonify(response)
@app.route('/api/leftbar')
def leftbar():
with open(os.path.join(API_MOCK_DIR, 'leftbar')) as f:
response = json.load(f)
return jsonify(response)
@app.route('/api/leftbarrightclick')
def leftbarrightclick():
with open(os.path.join(API_MOCK_DIR, 'leftbarrightclick')) as f:
response = json.load(f)
return jsonify(response)
@app.route('/api/checklogin')
def checklogin():
return jsonify({
'logined': True,
'user': {
'id': 1,
'username': 'admin',
'name': 'Administrator',
'role': 'Admin',
'email': 'admin@jumpserver.org',
'is_active': True,
'date_joined': '2016-01-01 12:12:12',
'groups': ['admin', 'sa']
}
})
@app.route('/api/userprofile')
def profile():
return jsonify({
'id': 1,
'username': 'admin',
'name': 'Administrator',
'role': 'Admin',
'email': 'admin@jumpserver.org',
'is_active': True,
'date_joined': '2016-01-01 12:12:12',
'groups': ['admin', 'sa']
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment