api refactoring

parent 8ebf8811
......@@ -16,7 +16,7 @@ from flask.ext.restful import reqparse, Resource
from flask.ext.login import current_user, login_required
from flask import jsonify
@api.resource('/api/client-tree.json/<name>/<int:backup>', '/api/<server>/client-tree.json/<name>/<int:backup>')
@api.resource('/api/client-tree.json/<name>/<int:backup>', '/api/<server>/client-tree.json/<name>/<int:backup>', endpoint='api.client_tree')
class ClientTree(Resource):
"""
The :class:`burpui.api.client.ClientTree` resource allows you to
......@@ -91,7 +91,7 @@ class ClientTree(Resource):
return jsonify(notif=err)
return jsonify(results=j)
@api.resource('/api/client-stat.json/<name>', '/api/<server>/client-stat.json/<name>', '/api/client-stat.json/<name>/<int:backup>', '/api/<server>/client-stat.json/<name>/<int:backup>')
@api.resource('/api/client-stat.json/<name>', '/api/<server>/client-stat.json/<name>', '/api/client-stat.json/<name>/<int:backup>', '/api/<server>/client-stat.json/<name>/<int:backup>', endpoint='api.client_stats')
class ClientStats(Resource):
"""
The :class:`burpui.api.client.ClientStats` resource allows you to
......@@ -288,7 +288,7 @@ class ClientStats(Resource):
return jsonify(notif=err)
return jsonify(results=j)
@api.resource('/api/client.json/<name>', '/api/<server>/client.json/<name>')
@api.resource('/api/client.json/<name>', '/api/<server>/client.json/<name>', endpoint='api.client_report')
class ClientReport(Resource):
"""
The :class:`burpui.api.client.ClientReport` resource allows you to
......
......@@ -16,7 +16,6 @@ from burpui.misc.backend.interface import BUIserverException
from burpui.api import api
from burpui.api.restore import Restore
from burpui.api.settings import ServerSettings, ClientSettings
from burpui.api.client import ClientTree, ClientStats, ClientReport
from burpui.api.servers import ServersStats, Live
@login_manager.user_loader
......@@ -56,9 +55,6 @@ The API has been split-out into several files and now uses Flask-Restful
app.jinja_env.globals.update(Restore=Restore)
app.jinja_env.globals.update(ServerSettings=ServerSettings)
app.jinja_env.globals.update(ClientSettings=ClientSettings)
app.jinja_env.globals.update(ClientTree=ClientTree)
app.jinja_env.globals.update(ClientStats=ClientStats)
app.jinja_env.globals.update(ClientReport=ClientReport)
app.jinja_env.globals.update(ServersStats=ServersStats)
app.jinja_env.globals.update(Live=Live)
......
......@@ -34,7 +34,7 @@ var _client = function() {
chart_unified.yAxis.tickFormat(d3.format(',.0f'));
}
url = '{{ api.url_for(ClientStats, name=cname, backup=nbackup, server=server) }}';
url = '{{ url_for("api.client_stats", name=cname, backup=nbackup, server=server) }}';
$.getJSON(url, function(d) {
j = d.results;
var _fields = [];
......
......@@ -56,7 +56,7 @@
},
source: function() {
r = [];
$.getJSON('{{ api.url_for(ClientTree, name=cname, backup=nbackup, server=server) }}', function(data) {
$.getJSON('{{ url_for("api.client_tree", name=cname, backup=nbackup, server=server) }}', function(data) {
if (!data.results) {
if (data.notif) {
$.each(data.notif, function(i, n) {
......@@ -84,7 +84,7 @@
r = [];
p = node.key;
if (p !== "/") p += '/';
$.getJSON('{{ api.url_for(ClientTree, name=cname, backup=nbackup, server=server) }}?root='+p, function(data) {
$.getJSON('{{ url_for("api.client_tree", name=cname, backup=nbackup, server=server) }}?root='+p, function(data) {
if (!data.results) {
if (data.notif) {
$.each(data.notif, function(i, n) {
......
......@@ -73,7 +73,7 @@ var _client = function() {
_chart_stats.bars.forceY([0]);
}
url = '{{ api.url_for(ClientStats, name=cname, server=server) }}';
url = '{{ url_for("api.client_stats", name=cname, server=server) }}';
$.getJSON(url, function(d) {
var _fields = [ 'dir', 'files', 'hardlink', 'softlink', 'files_enc', 'meta', 'meta_enc', 'special', 'efs', 'vssheader', 'vssheader_enc', 'vssfooter', 'vssfooter_enc' ];
var stats = true;
......
......@@ -25,7 +25,7 @@
var _client_table = $('#table-client').dataTable( {
responsive: true,
ajax: {
url: '{{ api.url_for(ClientReport, name=cname, server=server) }}',
url: '{{ url_for("api.client_report", name=cname, server=server) }}',
dataSrc: function (data) {
if (!data.results) {
$('#table-client').hide();
......
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